1

I am trying to display a uint32_t value on an LCD display (Waveshare 3.2inch TFT) connected to a STM32F407 evaluation board. The library provided by Waveshare includes a function BSP_LCD_DisplayStringAtLine. I have got this working fine for string output but when I try to send it a uint32_t value it just displays corrupt data on the LCD on the line where the value should print.

I have tried using

BSP_LCD_DisplayStringAtLine (3, (uint8_t*) Difference);

and also

BSP_LCD_DisplayStringAtLine (3, (uint8_t*) &Difference);

but generate nonsense. I think I am probably passing the variable to the function incorrectly but the documentation provided by the manufacturer is not exactly comprehensive and I'm not finding much help on Google.

Joe P
  • 79
  • 4

1 Answers1

1

You need to convert the uint32_t to a string first.

Pseudocode:

uint32_t value = 7;
uint8_t buf[16]; // pick a large enough size
u32_to_u8str(value, buf); // assuming this null terminates the string
BSP_LCD_DisplayStringAtLine(3, &buf);

This question may have useful answers.

agh2k
  • 11
  • 2
  • Thanks, I did think of that just after posting the question and found the below idea https://stackoverflow.com/questions/8257714/how-to-convert-an-int-to-string-in-c so I'll try that and see how it goes – Joe P Sep 27 '20 at 08:06