cancel
Showing results for 
Search instead for 
Did you mean: 

Graph data not showing

Thomas8607
Senior

Hello.

I would use a static graph to display data. In the handletickevent function, I update the addDataPoint(x data, y data) function for the given page, but nothing appears on the graph, the scale is fine, but no line or change in the x direction can be seen on the display. I am currently using the tickcounter++ variable value for X data, which also increases in debug. For X data, I entered 0min, 200max data in the touchgfx program. I also tried the dynamic graph.

Thanks if anyone can help.

1 ACCEPTED SOLUTION

Accepted Solutions

Good, Please note that just clearing the static graph doesnt reset the horizontal plotting. You must also reset X coordinate value and start increasing it again from 0 to 200 (if your X range is 0-200).

If you need constantly scrolling curve, then dynamic graph is right choice. Select scroll as dynamic behavior:

JTP1_0-1717845201692.png

then just simply add points like

 

	dynamicGraph1.addDataPoint(some_value);
	

 

 

and graph-widget will place it to first free position (and also scrolls the curve if it is full).

So with dynamic graph you dont have to worry about X values. Naturally using dynamicGraph requires that the x interval of the data points is constant, otherwise the graph will be distorted in the direction of the X-axis.

Br JTP

View solution in original post

26 REPLIES 26
LouisB
ST Employee

Hello @Thomas8607 and welcome to the TouchGFX community !

Can you post your code ?

Regards,

Louis BOUDO
ST Software Developer | TouchGFX

Hello LouisB,

Here is my screen cpp(tickCounter declared in hpp protect) :

LiveDataScreenView::LiveDataScreenView()
{

}

void LiveDataScreenView::setupScreen()
{
    LiveDataScreenViewBase::setupScreen();
    DisplayValues.ActiveScreenNumber = 3;
    tickCounter = 0;
	graph1.clear();
	if(SettingsValues.RadioButtonSelectedItem == 1)
	{
		graph1.setGraphRangeY(0, 300);
		graph1.setScaleY(1);
		graph1MajorYAxisGrid.setInterval(10);
		graph1MajorYAxisGrid.setScale(1);
		graph1MajorYAxisLabel.setInterval(20);
		graph1MajorYAxisLabel.setLabelDecimals(0);
		graph1MajorYAxisLabel.setScale(1);
	}
	else if(SettingsValues.RadioButtonSelectedItem == 2)
	{
		graph1.setGraphRangeY(0, 6000);
		graph1.setScaleY(1);
		graph1MajorYAxisGrid.setInterval(200);
		graph1MajorYAxisGrid.setScale(1);
		graph1MajorYAxisLabel.setInterval(1000);
		graph1MajorYAxisLabel.setLabelDecimals(0);
		graph1MajorYAxisLabel.setScale(1);
	}
	else if(SettingsValues.RadioButtonSelectedItem == 3)
	{
		graph1.setGraphRangeY(-4, 4);
		graph1.setScaleY(10);
		graph1MajorYAxisGrid.setInterval(1);
		graph1MajorYAxisGrid.setScale(10);
		graph1MajorYAxisLabel.setInterval(2);
		graph1MajorYAxisLabel.setLabelDecimals(1);
		graph1MajorYAxisLabel.setScale(10);
	}
	else if(SettingsValues.RadioButtonSelectedItem == 4)
	{
		graph1.setGraphRangeY(0, 9000);
		graph1.setScaleY(1);
		graph1MajorYAxisGrid.setInterval(100);
		graph1MajorYAxisGrid.setScale(1);
		graph1MajorYAxisLabel.setInterval(1000);
		graph1MajorYAxisLabel.setLabelDecimals(0);
		graph1MajorYAxisLabel.setScale(1);
	}
	else if(SettingsValues.RadioButtonSelectedItem == 5)
	{
		graph1.setGraphRangeY(0, 4);
		graph1.setScaleY(10);
		graph1MajorYAxisGrid.setInterval(1);
		graph1MajorYAxisGrid.setScale(10);
		graph1MajorYAxisLabel.setInterval(1);
		graph1MajorYAxisLabel.setLabelDecimals(1);
		graph1MajorYAxisLabel.setScale(10);
	}
	else if(SettingsValues.RadioButtonSelectedItem == 6)
	{
		graph1.setGraphRangeY(0, 4);
		graph1.setScaleY(10);
		graph1MajorYAxisGrid.setInterval(1);
		graph1MajorYAxisGrid.setScale(10);
		graph1MajorYAxisLabel.setInterval(1);
		graph1MajorYAxisLabel.setLabelDecimals(1);
		graph1MajorYAxisLabel.setScale(10);
	}
	else if(SettingsValues.RadioButtonSelectedItem == 7)
	{
		graph1.setGraphRangeY(0, 250);
		graph1.setScaleY(1);
		graph1MajorYAxisGrid.setInterval(5);
		graph1MajorYAxisGrid.setScale(1);
		graph1MajorYAxisLabel.setInterval(25);
		graph1MajorYAxisLabel.setLabelDecimals(0);
		graph1MajorYAxisLabel.setScale(1);
	}
	else if(SettingsValues.RadioButtonSelectedItem == 8)
	{
		graph1.setGraphRangeY(0, 250);
		graph1.setScaleY(1);
		graph1MajorYAxisGrid.setInterval(5);
		graph1MajorYAxisGrid.setScale(1);
		graph1MajorYAxisLabel.setInterval(25);
		graph1MajorYAxisLabel.setLabelDecimals(0);
		graph1MajorYAxisLabel.setScale(1);
	}
}

void LiveDataScreenView::tearDownScreen()
{
    LiveDataScreenViewBase::tearDownScreen();
}
void LiveDataScreenView::handleTickEvent()
{
	tickCounter++;
	HardwareValues.TickCounter = tickCounter; // for debugging
	if (tickCounter % 2 == 0)	// Insert each second tick
	{
		if(SettingsValues.RadioButtonSelectedItem == 1)
		{
			graph1.addDataPoint(tickCounter, 20/*DisplayValues.Speed*/);
		}
		else if(SettingsValues.RadioButtonSelectedItem == 2)
		{
			graph1.addDataPoint(tickCounter, DisplayValues.Rpm);
		}
		else if(SettingsValues.RadioButtonSelectedItem == 3)
		{
			graph1.addDataPoint((float)tickCounter, DisplayValues.Acceleration);
		}
		else if(SettingsValues.RadioButtonSelectedItem == 4)
		{
			graph1.addDataPoint(tickCounter, (uint16_t)DisplayValues.TravelledMeter);
		}
		else if(SettingsValues.RadioButtonSelectedItem == 5)
		{
			graph1.addDataPoint((float)tickCounter, DisplayValues.ImapPressure);
		}
		else if(SettingsValues.RadioButtonSelectedItem == 6)
		{
			graph1.addDataPoint((float)tickCounter, DisplayValues.EmapPressure);
		}
		else if(SettingsValues.RadioButtonSelectedItem == 7)
		{
			graph1.addDataPoint(tickCounter, DisplayValues.IntakeTemp);
		}
		else if(SettingsValues.RadioButtonSelectedItem == 8)
		{
			graph1.addDataPoint(tickCounter, DisplayValues.CoolantTemp);
		}
		graph1.invalidate();
	}
	if(DisplayValues.BootScreenActivate == 1   && DisplayValues.ActiveScreenNumber != 0) {
		static_cast<FrontendApplication*>(Application::getInstance())->gotoBootScreenScreenSlideTransitionEast();
	}
}
void LiveDataScreenView::RadioButtonSet(uint16_t itemSel)
{
	switch(itemSel)
	{
	case 1: radioButtonGroup1.setSelected(radioButton1);
	break;
	case 2: radioButtonGroup1.setSelected(radioButton2);
	break;
	case 3: radioButtonGroup1.setSelected(radioButton3);
	break;
	case 4: radioButtonGroup1.setSelected(radioButton4);
	break;
	case 5: radioButtonGroup1.setSelected(radioButton5);
	break;
	case 6: radioButtonGroup1.setSelected(radioButton6);
	break;
	case 7: radioButtonGroup1.setSelected(radioButton7);
	break;
	case 8: radioButtonGroup1.setSelected(radioButton8);
	break;
	}
}
void LiveDataScreenView::radioButton1Selected()
{
	SettingsValues.RadioButtonSelectedItem = 1;
	ExtEEPROM.writeToEEPROM(RadioButtonSelectedItem_EEPROMADDRESS, SettingsValues.RadioButtonSelectedItem);
	graph1.clear();
	graph1.setGraphRangeY(0, 300);
	graph1.setScaleY(1);
	graph1MajorYAxisGrid.setInterval(10);
	graph1MajorYAxisGrid.setScale(1);
	graph1MajorYAxisLabel.setInterval(20);
	graph1MajorYAxisLabel.setLabelDecimals(0);
	graph1MajorYAxisLabel.setScale(1);
}
void LiveDataScreenView::radioButton2Selected()
{
	SettingsValues.RadioButtonSelectedItem = 2;
	ExtEEPROM.writeToEEPROM(RadioButtonSelectedItem_EEPROMADDRESS, SettingsValues.RadioButtonSelectedItem);
	graph1.clear();
	graph1.setGraphRangeY(0, 6000);
	graph1.setScaleY(1);
	graph1MajorYAxisGrid.setInterval(200);
	graph1MajorYAxisGrid.setScale(1);
	graph1MajorYAxisLabel.setInterval(1000);
	graph1MajorYAxisLabel.setLabelDecimals(0);
	graph1MajorYAxisLabel.setScale(1);
}
void LiveDataScreenView::radioButton3Selected()
{
	SettingsValues.RadioButtonSelectedItem = 3;
	ExtEEPROM.writeToEEPROM(RadioButtonSelectedItem_EEPROMADDRESS, SettingsValues.RadioButtonSelectedItem);
	graph1.clear();
	graph1.setGraphRangeY(-4, 4);
	graph1.setScaleY(10);
	graph1MajorYAxisGrid.setInterval(1);
	graph1MajorYAxisGrid.setScale(10);
	graph1MajorYAxisLabel.setInterval(2);
	graph1MajorYAxisLabel.setLabelDecimals(1);
	graph1MajorYAxisLabel.setScale(10);
}
void LiveDataScreenView::radioButton4Selected()
{
	SettingsValues.RadioButtonSelectedItem = 4;
	ExtEEPROM.writeToEEPROM(RadioButtonSelectedItem_EEPROMADDRESS, SettingsValues.RadioButtonSelectedItem);
	graph1.clear();
	graph1.setGraphRangeY(0, 9000);
	graph1.setScaleY(1);
	graph1MajorYAxisGrid.setInterval(100);
	graph1MajorYAxisGrid.setScale(1);
	graph1MajorYAxisLabel.setInterval(1000);
	graph1MajorYAxisLabel.setLabelDecimals(0);
	graph1MajorYAxisLabel.setScale(1);
}
void LiveDataScreenView::radioButton5Selected()
{
	SettingsValues.RadioButtonSelectedItem = 5;
	ExtEEPROM.writeToEEPROM(RadioButtonSelectedItem_EEPROMADDRESS, SettingsValues.RadioButtonSelectedItem);
	graph1.clear();
	graph1.setGraphRangeY(0, 4);
	graph1.setScaleY(10);
	graph1MajorYAxisGrid.setInterval(1);
	graph1MajorYAxisGrid.setScale(10);
	graph1MajorYAxisLabel.setInterval(1);
	graph1MajorYAxisLabel.setLabelDecimals(1);
	graph1MajorYAxisLabel.setScale(10);
}
void LiveDataScreenView::radioButton6Selected()
{
	SettingsValues.RadioButtonSelectedItem = 6;
	ExtEEPROM.writeToEEPROM(RadioButtonSelectedItem_EEPROMADDRESS, SettingsValues.RadioButtonSelectedItem);
	graph1.clear();
	graph1.setGraphRangeY(0, 4);
	graph1.setScaleY(10);
	graph1MajorYAxisGrid.setInterval(1);
	graph1MajorYAxisGrid.setScale(10);
	graph1MajorYAxisLabel.setInterval(1);
	graph1MajorYAxisLabel.setLabelDecimals(1);
	graph1MajorYAxisLabel.setScale(10);
}
void LiveDataScreenView::radioButton7Selected()
{
	SettingsValues.RadioButtonSelectedItem = 7;
	ExtEEPROM.writeToEEPROM(RadioButtonSelectedItem_EEPROMADDRESS, SettingsValues.RadioButtonSelectedItem);
	graph1.clear();
	graph1.setGraphRangeY(0, 250);
	graph1.setScaleY(1);
	graph1MajorYAxisGrid.setInterval(5);
	graph1MajorYAxisGrid.setScale(1);
	graph1MajorYAxisLabel.setInterval(25);
	graph1MajorYAxisLabel.setLabelDecimals(0);
	graph1MajorYAxisLabel.setScale(1);
}
void LiveDataScreenView::radioButton8Selected()
{
	SettingsValues.RadioButtonSelectedItem = 8;
	ExtEEPROM.writeToEEPROM(RadioButtonSelectedItem_EEPROMADDRESS, SettingsValues.RadioButtonSelectedItem);
	graph1.clear();
	graph1.setGraphRangeY(0, 250);
	graph1.setScaleY(1);
	graph1MajorYAxisGrid.setInterval(5);
	graph1MajorYAxisGrid.setScale(1);
	graph1MajorYAxisLabel.setInterval(25);
	graph1MajorYAxisLabel.setLabelDecimals(0);
	graph1MajorYAxisLabel.setScale(1);
}

 

Thank you!

I recorded the issue. I don't see the line and the x axis doesn't move. 

Dashboard graph

 

Thank you! 

 

 

Check in debuger if your handletick func is called ...

I tried it. The tickcounter increments

Try break on next ifs or change

if ((tickCounter % 2) == 0)

This is working

Hello Thomas

Maybe slow down process bit, now its adding points maybe 30 times / sec. Also divide counter when using as x coordinate, in your version x- value is running out of screen in few seconds, I guess.

tickCounter++;
HardwareValues.TickCounter = tickCounter; // for debugging
if (tickCounter % 60 == 0)	// Insert each second tick
{
	if(SettingsValues.RadioButtonSelectedItem == 1)
	{
		graph1.addDataPoint(tickCounter/60, 20/*DisplayValues.Speed*/);
	}
		

And also clear tickCounter when radiobutton is pressed.

Basically your simplified tickHandler- code seems to work in 4.23.2 simulator and also STM32U5DK2 target.

Br JTP

 

I will try it with == 60, if i change radiobutton then i clrear the graph (is is good)

 

Thank you!