Printing gyro measurement results on LCD screen
Dependencies: LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI GYRO_DISCO_F429ZI
main.cpp@4:3e78c8cfba95, 2019-10-20 (annotated)
- Committer:
- ratsrex
- Date:
- Sun Oct 20 00:30:52 2019 +0000
- Revision:
- 4:3e78c8cfba95
- Parent:
- 0:44f624c5501e
LCD Printout
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bcostm | 0:44f624c5501e | 1 | #include "mbed.h" |
bcostm | 0:44f624c5501e | 2 | #include "GYRO_DISCO_F429ZI.h" |
ratsrex | 4:3e78c8cfba95 | 3 | #include "LCD_DISCO_F429ZI.h" |
ratsrex | 4:3e78c8cfba95 | 4 | |
ratsrex | 4:3e78c8cfba95 | 5 | LCD_DISCO_F429ZI lcd; |
bcostm | 0:44f624c5501e | 6 | |
bcostm | 0:44f624c5501e | 7 | GYRO_DISCO_F429ZI gyro; |
bcostm | 0:44f624c5501e | 8 | |
bcostm | 0:44f624c5501e | 9 | DigitalOut led1(LED1); |
bcostm | 0:44f624c5501e | 10 | |
bcostm | 0:44f624c5501e | 11 | int main() |
bcostm | 0:44f624c5501e | 12 | { |
bcostm | 0:44f624c5501e | 13 | float GyroBuffer[3]; |
bcostm | 0:44f624c5501e | 14 | |
bcostm | 0:44f624c5501e | 15 | printf("Gyroscope started\n"); |
bcostm | 0:44f624c5501e | 16 | |
ratsrex | 4:3e78c8cfba95 | 17 | BSP_LCD_SetFont(&Font20); |
ratsrex | 4:3e78c8cfba95 | 18 | |
ratsrex | 4:3e78c8cfba95 | 19 | lcd.Clear(LCD_COLOR_BLUE); |
ratsrex | 4:3e78c8cfba95 | 20 | lcd.SetBackColor(LCD_COLOR_BLUE); |
ratsrex | 4:3e78c8cfba95 | 21 | lcd.SetTextColor(LCD_COLOR_WHITE); |
ratsrex | 4:3e78c8cfba95 | 22 | |
ratsrex | 4:3e78c8cfba95 | 23 | |
bcostm | 0:44f624c5501e | 24 | while(1) { |
bcostm | 0:44f624c5501e | 25 | // Read Gyroscope values |
bcostm | 0:44f624c5501e | 26 | gyro.GetXYZ(GyroBuffer); |
bcostm | 0:44f624c5501e | 27 | // Display values |
ratsrex | 4:3e78c8cfba95 | 28 | |
ratsrex | 4:3e78c8cfba95 | 29 | // wait(0.3); |
ratsrex | 4:3e78c8cfba95 | 30 | |
ratsrex | 4:3e78c8cfba95 | 31 | |
ratsrex | 4:3e78c8cfba95 | 32 | char xPos[18]; |
ratsrex | 4:3e78c8cfba95 | 33 | char yPos[18]; |
ratsrex | 4:3e78c8cfba95 | 34 | char zPos[128]; |
ratsrex | 4:3e78c8cfba95 | 35 | |
ratsrex | 4:3e78c8cfba95 | 36 | int spRes = snprintf(xPos, 14,"X = %f\n", GyroBuffer[0] ); |
ratsrex | 4:3e78c8cfba95 | 37 | spRes = snprintf(yPos, 14,"Y = %f\n", GyroBuffer[1] ); |
ratsrex | 4:3e78c8cfba95 | 38 | spRes = snprintf(zPos, 14,"Z = %f\n", GyroBuffer[2] ); |
ratsrex | 4:3e78c8cfba95 | 39 | |
ratsrex | 4:3e78c8cfba95 | 40 | lcd.DisplayStringAt(20, LINE(4), (uint8_t *)xPos, LEFT_MODE); |
ratsrex | 4:3e78c8cfba95 | 41 | lcd.DisplayStringAt(20, LINE(5), (uint8_t *)yPos, LEFT_MODE); |
ratsrex | 4:3e78c8cfba95 | 42 | lcd.DisplayStringAt(20, LINE(6), (uint8_t *)zPos, LEFT_MODE); |
ratsrex | 4:3e78c8cfba95 | 43 | |
ratsrex | 4:3e78c8cfba95 | 44 | wait_ms(250); |
bcostm | 0:44f624c5501e | 45 | led1 = !led1; |
ratsrex | 4:3e78c8cfba95 | 46 | |
bcostm | 0:44f624c5501e | 47 | } |
bcostm | 0:44f624c5501e | 48 | } |