ECE 4180 Fitbit Project / Mbed 2 deprecated 4180_Fitness_Tracker

Dependencies:   mbed PulseSensor2 SCP1000 mbed-rtos 4DGL-uLCD-SE LSM9DS1_Library_cal PinDetect FatFileSystemCpp GP-20U7

main.cpp

Committer:
Richard_Xiong
Date:
2020-03-25
Revision:
7:fb47593628be
Parent:
6:29ccbdd09706
Child:
20:adb9e6e1ad22

File content as of revision 7:fb47593628be:

#include "mbed.h"
#include "LSM9DS1.h"
#include "uLCD_4DGL.h"

uLCD_4DGL uLCD(p28, p27, p30);
LSM9DS1 my_imu(p9, p10, 0xD6, 0x3C);

int Steps;

int main() {
    // set up the display
    uLCD.display_control(PORTRAIT);
    uLCD.baudrate(BAUD_3000000);
    uLCD.background_color(BLACK);
    uLCD.cls();
    wait(0.5);
    
    //set up the imu 
    my_imu.begin();
    if (!my_imu.begin()) {
        uLCD.printf("Failed to communicate with LSM9DS1.\n");
    }
    my_imu.calibrate();

    while (1) { 
    //reading the acceleration/Mag/Gyro data information from the imu
    my_imu.readAccel();
    my_imu.readMag();
    my_imu.readGyro();
    
    // print the information to the LCD display
    uLCD.printf("Your steps right now is %d",steps);
    uLCD.printf("gyro: %d %d %d\n\r", my_imu.gx, my_imu.gy, my_imu.gz);
    uLCD.printf("accel: %d %d %d\n\r", my_imu.ax, my_imu.ay, my_imu.az);
    uLCD.printf("mag: %d %d %d\n\n\r", my_imu.mx, my_imu.my, my_imu.mz);
    }
    
}