簡體   English   中英

如何使用 DisplayStringAtLine 函數在 STM32 上正確顯示 uint32 變量

[英]How to display uint32 variable on STM32 correctly with DisplayStringAtLine function

我試圖在連接到 STM32F407 評估板的 LCD 顯示器(Waveshare 3.2 英寸 TFT)上顯示 uint32_t 值。 Waveshare 提供的庫包括一個函數 BSP_LCD_DisplayStringAtLine。 我已經讓這個字符串輸出工作正常,但是當我嘗試向它發送一個 uint32_t 值時,它只會在 LCD 上應該打印值的行上顯示損壞的數據。

我試過使用

BSP_LCD_DisplayStringAtLine (3, (uint8_t*) Difference);

並且

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

但產生廢話。 我想我可能錯誤地將變量傳遞給函數,但制造商提供的文檔並不全面,我在 Google 上找不到太多幫助。

您需要先將 uint32_t 轉換為字符串。

偽代碼:

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);

這個問題可能有有用的答案。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM