Printing gyro measurement results on LCD screen

Dependencies:   LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI GYRO_DISCO_F429ZI

main.cpp

Committer:
ratsrex
Date:
2019-10-20
Revision:
4:3e78c8cfba95
Parent:
0:44f624c5501e

File content as of revision 4:3e78c8cfba95:

#include "mbed.h"
#include "GYRO_DISCO_F429ZI.h"
#include "LCD_DISCO_F429ZI.h"

LCD_DISCO_F429ZI lcd;

GYRO_DISCO_F429ZI gyro;

DigitalOut led1(LED1);

int main()
{
    float GyroBuffer[3];
  
    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      
        
      // 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;
        
    }
}