2021-12-01 06:51 PM
I have two questions regarding TouchGFX graphs:
1) I have a scroll graph:
touchgfx::GraphWrapAndOverwrite<100> graph;
The API documentation for GraphWrapAndOverwrite includes a section titled "Protected Functions inherited from AbstractDataGraph", which lists the function invalidateGraphArea(). However, in STM32CubeIDE, autocomplete offers only invalidate() and invalidateRect().
If I type in invalidateGraphArea(), I get an error when compiling:
AbstractDataGraph.hpp:650:10: note: declared protected here
Since all subclasses from AbstractDataGraph down to GraphScroll declare public inheritance:
class DataGraphScroll : public AbstractDataGraphWithY ... etc.
why am I unable to access invalidateGraphArea()? And, if invalidateRect() is to be the only method available to me, how to I get the coordinates of the graph area?
2) The number of data points in the graph is set to 100, and "Use custom visible data point range" is not checked in the Designer, and X-Axis Labels / Major Labels is checked. So, the designer initially labels the x axis ticks as 0 to 90, with 100 not shown on the right limit.
What I really want to do is repopulate the graph with 100 new values every 5 seconds (this is a test only):
void MainView::handleTickEvent()
{
// New graph every 5 seconds
if ((tickCounter % 300) == 0) {
graph.clear();
graph.invalidate(); // note: this affects _everything_, not just the graph area
for (int i = 0; i < 100; i++) {
graph.addDataPoint(presenter->getHeapUsage(100));
}
}
tickCounter++;
}
But, after clearing the graph, each time a new set of 100 points is displayed, the x axis labels continue to increment (0-90, 100-190, 200-290, etc.).
The API documentation for clear() says: "Clears the graph to its blank/initial state", which would seem to indicate that the x index of the next point added would revert to 0. But, instead, it continues to increment ad infinitum.
So, how can I reset the x axis index after clearing the graph?
2021-12-01 06:52 PM
Correction to first line: not a scroll graph; a wrap and overwrite graph.