Printing gyro measurement results on LCD screen
Dependencies: LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI GYRO_DISCO_F429ZI
Revision 4:3e78c8cfba95, committed 2019-10-20
- Comitter:
- ratsrex
- Date:
- Sun Oct 20 00:30:52 2019 +0000
- Parent:
- 3:119a7b64165c
- Commit message:
- LCD Printout
Changed in this revision
LCD_DISCO_F429ZI.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 119a7b64165c -r 3e78c8cfba95 LCD_DISCO_F429ZI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LCD_DISCO_F429ZI.lib Sun Oct 20 00:30:52 2019 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/LCD_DISCO_F429ZI/#dc55a068bc1a
diff -r 119a7b64165c -r 3e78c8cfba95 main.cpp --- a/main.cpp Tue Jul 04 15:49:49 2017 +0000 +++ b/main.cpp Sun Oct 20 00:30:52 2019 +0000 @@ -1,5 +1,8 @@ #include "mbed.h" #include "GYRO_DISCO_F429ZI.h" +#include "LCD_DISCO_F429ZI.h" + +LCD_DISCO_F429ZI lcd; GYRO_DISCO_F429ZI gyro; @@ -11,15 +14,35 @@ printf("Gyroscope started\n"); + BSP_LCD_SetFont(&Font20); + + lcd.Clear(LCD_COLOR_BLUE); + lcd.SetBackColor(LCD_COLOR_BLUE); + lcd.SetTextColor(LCD_COLOR_WHITE); + + while(1) { // Read Gyroscope values gyro.GetXYZ(GyroBuffer); // Display values - printf("X = %f\n", GyroBuffer[0]); - printf("Y = %f\n", GyroBuffer[1]); - printf("Z = %f\n", GyroBuffer[2]); - printf("\033[3A"); // Moves cursor up x lines (x value is between [ and A) + + // wait(0.3); + + + char xPos[18]; + char yPos[18]; + char zPos[128]; + + int spRes = snprintf(xPos, 14,"X = %f\n", GyroBuffer[0] ); + spRes = snprintf(yPos, 14,"Y = %f\n", GyroBuffer[1] ); + spRes = snprintf(zPos, 14,"Z = %f\n", GyroBuffer[2] ); + + lcd.DisplayStringAt(20, LINE(4), (uint8_t *)xPos, LEFT_MODE); + lcd.DisplayStringAt(20, LINE(5), (uint8_t *)yPos, LEFT_MODE); + lcd.DisplayStringAt(20, LINE(6), (uint8_t *)zPos, LEFT_MODE); + + wait_ms(250); led1 = !led1; - wait(1); + } }