This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

string to canvas widget

Other Parts Discussed in Thread: TIDM-TM4C129POEAUDIO

Hello All,

I am working on a project using tiva c launchpad with kentec booster pack using Grlib for a graphic application development.

I am using "canvas" in one of my screen where I want to assign text converted from integer (such as "123"). I am using following code:

uint32_t Number = 1234;      (This is Variable changes b/w 0 to 2^32 in run time)

char result[15];

ltoa(Number,result);                (stdlib function to convert long to string)

CanvasTextSet(&Num_Cycles,result);    (to assign result string to canvas)

 WidgetPaint((tWidget*)&Num_Cycles);

When I do this I am getting garbage text on canvas instead of "1234". The converted string is proper with null termination.

Can any one let me know why this is happening.

(FYI: If I do CanvasTextSet(&Num_Cycles,"1234"); It is proper but I can't do as string is not constant)

Thank you.

-Nagendra.

  • Hello Nagaendra,

    Please check the TIDM-TM4C129POEAUDIO example as it has a graphics library interface where dynamic text can be displayed.

    The same is also available in the DK-TM4C129x examples on booster packs where dynamic values of the sensors is displayed.
  • Hi Amit,
    Thanks for your reply.I had look at the example you provided.I also used similar code as in the example. After going through your code and testing my code I found some weird thing which doesn't make sense at all to me. When I define the canvas in main.c, It is changing text perfectly, But in my code I have a different c file "screens.c" where I defined all the screens and their attributes. When I place the same canvas and same code of canvas text set in "screens.c" , It is setting some garbage text on screen.
    Do you have any Idea why the behavior is like this?

    Thanks,
    Nagendra.
  • Hello Nagendra

    No, I haven't used the graphics library in such a manner. However I would check the value of the variable being used to hold the text.