![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Projet d'interfaçage - LSM6DS3 : Test de Stabilité Quentin NOIRET LP MECSE 2020 -------------------------------------------------- L’application réalisée permet de tester la stabilité d’un système (ex : drone) en affichant différents seuils d’inclinaison en fonction des valeurs de l’accéléromètre.
Dependencies: Interfacage_MECSE_LSM6DS3 mbed LSM6DS3
main.cpp
- Committer:
- raketitch
- Date:
- 2020-06-04
- Revision:
- 6:16ba206a4253
- Parent:
- 3:c450734baa8b
- Child:
- 7:e5f8936d11af
File content as of revision 6:16ba206a4253:
// LSM6DS3 Demo #include "mbed.h" #include "LSM6DS3.h" //sensor #include "LCD_DISCO_F746NG.h" //LCD Screen #include "TS_DISCO_F746NG.h" //Touch Screen // refresh time. set to 500 for part 2 and 50 for part 4 #define REFRESH_TIME_MS 500 // Verify that the pin assignments below match your breadboard LSM6DS3 sensor(PB_9, PB_8); //SCL, SDA LCD_DISCO_F746NG lcd; TS_DISCO_F746NG ts; Serial pc(USBTX, USBRX); // tx, rx //prototypes void setup(); void lcd_print(uint16_t x, uint16_t y, char* text); void lcd_print(uint16_t x, uint16_t y, char* text, float data); //Global Data char text[30]; using namespace std; int main() { //Init Serial port and LSM6DS3 chip setup(); pc.printf("\r\n------ LSM6DS3 Demo -----------\r\n"); TS_StateTypeDef TS_State; uint16_t i; while (true) { i = 0; //lcd.Clear(LCD_COLOR_BLACK); sensor.readTemp(); lcd_print(0, i, "temperature : %0.3f", sensor.temperature_c); i++; sensor.readAccel(); lcd_print(0, i, "acc X : %0.3f", sensor.ax); i++; lcd_print(0, i, "acc Y : %0.3f", sensor.ay); i++; lcd_print(0, i, "acc Z : %0.3f", sensor.az); i++; sensor.readGyro(); lcd_print(0, i, "gyro X : %0.3f", sensor.gx); i++; lcd_print(0, i, "gyro Y : %0.3f", sensor.gy); i++; lcd_print(0, i, "gyro Z : %0.3f", sensor.gz); ts.GetState(&TS_State); if(TS_State.touchDetected) { pc.printf("touched"); } wait_ms(REFRESH_TIME_MS); } } void setup() { // HIGHEST uint16_t status = sensor.begin(sensor.G_SCALE_2000DPS, sensor.A_SCALE_8G, sensor.G_ODR_1660, sensor.A_ODR_6660); //Make sure communication is working pc.printf("LSM6DS3 WHO_AM_I's returned: 0x%X\r\n", status); pc.printf("Should be 0x69\r\n"); lcd.SetBackColor(LCD_COLOR_BLACK); lcd.SetTextColor(LCD_COLOR_WHITE); lcd.SetFont(&Font12); pc.printf("LDSM6DS3 Init\r\n"); lcd_print(0, 0, "Init LSM6DS3"); pc.printf("LCD Init\r\n"); lcd_print(0, 1, "LCD init"); } void lcd_print(uint16_t x, uint16_t y, char* toto) { char txt[30]; sprintf((char*)txt, (const char*) toto); lcd.DisplayStringAt(x, LINE(y), (uint8_t *)&txt, LEFT_MODE); } void lcd_print(uint16_t x, uint16_t y, char* toto, float data) { char txt[30]; sprintf((char*)txt, (const char*) toto, data); lcd.DisplayStringAt(x, LINE(y), (uint8_t *)&txt, LEFT_MODE); }