2025-03-24 11:29 AM
I have my own TouchGFX App running on STM32H747I-DISCO board. It reads data from popular BME280 sensor chip via I2C interface. Now I need to show the "history" of measured temperature, pressure and humidity on a graph underneath the RTC date, day of week and time of day display (Clock).
I picked Dynamic Graph first because it can show the last (say) 400 measured data and scrolls it automatically when I add a new data point. Then I realized that Dynamic Graph does not support custom X/Y data.: I can add the Y data only: graph.addDataPoint(float yValue). Too bad. I also noticed that everything is stored as integer, not as float type number )For performance I guess). And last but not least I cannot access (read/modify) the added values stored in graph. What is good for such a graph?
Then I switched to Static Graph. It was a big surprise, but static graph can add X/Y values graph.addDataPoint(float xValue, float yValue). Great. They are still stored as integers but that's okay. Using Scaling and Precision I could simulate float number on the graph.
I set the capacity of the static graph to 400. And here comes the question: what I should do if the graph is full, (it contains 400 X/Y data points) and the 401st sample should be shown. I think it is obvious: I should delete the "oldest X/Y data point" (Index = 0) and I will have 399 X/Y data points in graph. Now I can append then 401st data point to the graph. This way the user still will see 400 data points but from 1 to 401 sample range. This works nice.
As I mentioned earlier that I cannot read X/Y data from the graph so the time (X Axis), the temperature (Y1 axis), the pressure (Y2 axis) and the humidity (Y3 axis) should be stored in own array. (4 x 400 entry float numbers). In addition, the arrays must be reordered: when deleting the first element every element must be moved to the previous address, to have a room for the new element. It's not nice feature but I solved it.
Of course, none of the graphs have multi-Y axes, they can store a single Y axis data only. So when the user wants to look at the pressure instead of the temperature, then I have to clear the graph, reload X/Y value from pressure array into the graph. It is clear but it does not work. Once the graph is full (It has 400 samples), clearing it and adding 400 pressures data only a couple of data is added. Instead of 400 pressure data I see 90-100 data. The graph.addDataPoint(float xValue, float yValue) normally returns the index of the new data store in graph's internal array, or -1 if there was error. When the data is not added the method always return index = 0.
Anyway, I am disappointed. TouchGFX is a good platform, but the graph support is a shame.
Or, of course, I am doing something wrong...
Sorry about the long post!
Louis
2025-03-24 11:54 PM
Suggestions (Instead of the above long story):
It would be nice:
I think these suggested changed would make the Graph control much better and at least usable for most of us.
Thanks,
Louis