Skip to main content
Michael N
Associate
May 19, 2019
Question

TouchGFX Graph widget inside custom container

  • May 19, 2019
  • 12 replies
  • 2581 views

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 ,

This topic has been closed for replies.

12 replies

Martin KJELDSEN
Principal III
June 13, 2019

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

Martin KJELDSEN
Principal III
June 14, 2019

Did you also add a GraphLine to your Graph? This could be what's missing. Where did you get your sample code?

Martin KJELDSEN
Principal III
June 18, 2019

You can check out this example to have a look at how to set up a working graph.

/Martin

Harwinder Singh
Associate III
March 6, 2020

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

Martin KJELDSEN
Principal III
March 6, 2020

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

Harwinder Singh
Associate III
March 6, 2020

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.​

Martin KJELDSEN
Principal III
March 6, 2020

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

Harwinder Singh
Associate III
March 9, 2020

Hi Martin,

I have tried by changing stack size but nothing is changed. I have shared the code.Please check and let me know my problem.

Thanks.

Harwinder Singh
Associate III
March 11, 2020

Hello Martin,

waiting for your reply.

Martin KJELDSEN
Principal III
March 11, 2020

Hi @Community member​,

I'll get around to your issue asap.

/Martin

Harwinder Singh
Associate III
April 3, 2020

Hello Martin,

I have done some testing

if i declare canvas buffer inside view base class then graph works fine even in any (second third) screen.like below

GraphscreenViewBase.hpp
 
private:
 
 /*
 * Canvas Buffer Size
 */
 static const uint16_t CANVAS_BUFFER_SIZE = 12000;
 uint8_t canvasBuffer[CANVAS_BUFFER_SIZE];
GraphscreenViewBase.cpp
 
 
Graph_ScreenViewBase::Graph_ScreenViewBase() 
{ 
 
 touchgfx::CanvasWidgetRenderer::setupBuffer(canvasBuffer, CANVAS_BUFFER_SIZE); 
 

But if we declare in GraphsreenView class then it is not working. i don't know why?

Why its working only in view base class?

if we declare canvas buffer in main.cpp then it will work only in startup screen.

Thanks