cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to display continuous data on scroll wheel container?

Krautermann
Senior II

I have been trying to display continuous data on Scroll wheel container for the past 2 months but have been very unsuccessful. Could someone help or tell me if it's even possible to do that?? The example in the documentation does not help in that regard.

I would like to display a counter that goes from 0 to 255 on a scroll wheel but what I get is the exact same value on each row of the scroll updating in real time. What I want is each counter value displayed on each row, e.g

Krautermann_0-1694341254885.png

This is my customContainer setup:

void CustomContainer2::RX_UART(char* data)
{
	TX_BufferArea.setWideTextAction(touchgfx::WIDE_TEXT_WORDWRAP);
	sprintf(USART_Array, "%d", data);
	Unicode::strncpy(TX_BufferAreaBuffer, USART_Array, TX_BUFFERAREA_SIZE);
	TX_BufferArea.invalidate();
}

This is displayed via the View:

void Screen2View::scrollWheel2UpdateItem(CustomContainer2& item, int16_t itemIndex)
{
	item.RX_UART((char*)CounterTimer); //I feel itemIndex should be somehow added to this line here but I don't know how to do that codewise...Please help!!

	int indexOfitemAtTopOfTheList = scrollWheel2.getSelectedItem();
	scrollWheel2.animateToItem(indexOfitemAtTopOfTheList + 1);
}

In the main:

volatile uint8_t CounterTimer = 0;

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
	if(htim->Instance == TIM2)
	{
		CounterTimer++; //Incremented every 1 second
        }
}
  
1 ACCEPTED SOLUTION

Accepted Solutions
Osman SOYKURT
ST Employee

Hello @Krautermann ,

I created a small example you can get inspiration from. I started from the "Scroll Wheel and List example" from TouchGFX Designer and I removed the "List" part. Then I added a handleTickEvent for the counter and made the wheel animate each 60 ticks. You'll find my project in attachment. 

Hope it helps 😉

Osman SOYKURT
ST Software Developer | TouchGFX

View solution in original post

2 REPLIES 2
Osman SOYKURT
ST Employee

Hello @Krautermann ,

I created a small example you can get inspiration from. I started from the "Scroll Wheel and List example" from TouchGFX Designer and I removed the "List" part. Then I added a handleTickEvent for the counter and made the wheel animate each 60 ticks. You'll find my project in attachment. 

Hope it helps 😉

Osman SOYKURT
ST Software Developer | TouchGFX
Krautermann
Senior II

Solution provided accepted after several days of testing.

Although user needs to modify it according to his application. Here is my modified code if anyone is interested:

void Screen2View::handleTickEvent()
{
	if(tick%1==0)
	{
		snprintf(ActualBuffer, sizeof(ActualBuffer), "%s", (char*)currentBuffer);
		if (strcmp(ActualBuffer, PreviousBuffer)!=0)
		{
			snprintf(temporaryBuffer, sizeof(temporaryBuffer), "%s", (char*)currentBuffer);
			scrollWheel1.animateToItem(scrollWheel1.getSelectedItem()-1);
			flag2Scroll1 = 1;
			snprintf(PreviousBuffer, sizeof(PreviousBuffer), "%s", ActualBuffer);
		}

		int currentCounterTimer = CounterTimer;
		if (currentCounterTimer != previousCounterTimer)
		{
			flag2Scroll2 = 1;
			scrollWheel2.animateToItem(scrollWheel2.getSelectedItem()-1);
			previousCounterTimer = currentCounterTimer;
		}
	}
}

void Screen2View::scrollWheel1UpdateItem(CustomContainer1& item, int16_t itemIndex)
{
	if(flag2Scroll1==1)
	{
	item.RX_SPI((char*)temporaryBuffer);
	flag2Scroll1 = 0;
	}
}


void Screen2View::scrollWheel2UpdateItem(CustomContainer2& item, int16_t itemIndex)
{
	if(flag2Scroll2==1)
	{
	item.RX_UART((char*)TX_Buffer4);
	flag2Scroll2 = 0;
	}
}