2019-05-19 06:22 AM
Hi ,
I'm using 4.10 library version , I've downloaded the Graph widget from https://github.com/touchgfx/touchgfx-open-repository/tree/master/widgets/Graph .
Updated Graph::Setup function as recommended in repository .
I've created custom container named baseContainer which contains some common, to whole application ,values .So I'm also wanted to add Graph representation from ADC readings (ADC readings works , because I've added another field to container which displays the ADC readings once per second)
I've placed the Graph widget source code to "\gui\src\common" and headers to "gui\include\gui\common" ,I'v added instance of Graph to my container and initialized as follows :
void baseContainer::initialize()
{
baseContainerBase::initialize();
graph.setXY(46,201);
graph.setup(220,250,Color::getColorFrom24BitRGB(111, 156, 233));
graph.setRange(0, 220, 0, 250);
graph.setLineWidth(5);
graph_insert_index = 0;
graph_insert_period = graph.getRangeRight() / 22 ; // debugging
add(graph);
}
The aim is to display the graph in bottom left corner on 800x480 screen .
The background color of the screen is RGB(16, 20, 40) ;
The update of the graph is as follows :
void baseContainer::periodicRefresh(CONT_DATA_STRUCT adc_data)
{
Unicode::snprintf(txtCurrPressBuffer, TXTCURRPRESS_SIZE, "%d", adc_data.internal_pressure);
// Unicode::snprintf(txtCurrPressBuffer, TXTCURRPRESS_SIZE, "%d", 0);
txtCurrPress.invalidate();
boxBatProg.setValue(adc_data.bettery_percentage);
boxBatProg.invalidate();
if((graph_insert_index % graph_insert_period) == 0)
{
graph.addValue(graph_insert_index,adc_data.bettery_percentage);
}
graph_insert_index = ((graph_insert_index + 1) % graph.getRangeRight());
graph.invalidate();
}
the other values : boxBatProg and txtCurrentPressure updated good . The debugger showed that periodicRefresh function is reached .
The problem is that graph is not showed at all :no dots ,no lines ,nothing . Just background.
The Graph::NUMBER_OF_POINTS is set to 25 . Also , my IAR compiler , complained about line 325 of AbstractGraph.cpp file (void AbstractGraph::invalidateLineFromIndex(int index)) ,that numPointsUsed variable is undefined ,so I've fixed it to numPoints .
Best Regards ,
2019-06-13 06:32 AM
Hi @Community member,
Just going through old posts and found this. Very sorry i missed it.
Did you get anywhere on your own in the meantime?
/Martin
2019-06-14 04:23 AM
Did you also add a GraphLine to your Graph? This could be what's missing. Where did you get your sample code?
2019-06-17 11:50 PM
2020-03-05 11:27 PM
Hello Martin
I have used your graph code to display waveform in applications. i have a issue:
Code works fine when using single screen application.
It also works fine if display graph in startup screen , in application with multiple screens.
But dosn't display anything when you use multi screen application and want to display graph in second or third screen. Means suppose i have two screen application first screen with show graph button when button is clicked it moves to second screen which have same code as given by to display graph but it dos't works. It just show background nothing else.
So where is the error? i think its an error of canvas buffer. Is canvas buffer changes with screen change?
waiting for your response.
Thanks
2020-03-06 04:46 AM
The canvas buffer is global but you can reconfigure it from screen to screen.
Are you debugging this? Is the application running when you're not seeing the graph?
/Martin
2020-03-06 05:40 AM
yes application is running without any issues but no graph is displayed.
I tried to debug the canvas buffer but enable to do so.
How to declare canvas buffer for screen to screen?
Any other way to check it?
i have tried one more thing just build you code for 746disco it works fine but if add one more screen to your code and make graph screen 2nd one, then it stop working.
2020-03-06 06:06 AM
You don't have to set the buffer size for each screen, you can have one global setting. And its the same if you were to do it inside one of your view classes:
static uint8_t canvasBuffer[CANVAS_BUFFER_SIZE];
CanvasWidgetRenderer::setupBuffer(canvasBuffer, CANVAS_BUFFER_SIZE);
I think you'll have to share the project - Does it fail in both simulator and on target? I can't really guess as to what's wrong.
Could be task stack size or CSTACK if you're not using an OS since you're allocating a buffer on top of your View+Presenter+Model.
/Martin
2020-03-06 06:57 AM
ok i will try by changing stack size , and let you know the results.if it will not work i will share the code.
thanks
2020-03-08 10:27 PM