A system to help you ride your bike better than you do right now.
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed LSM9DS1_Library_cal
main.cpp
- Committer:
- kswanson31
- Date:
- 2016-12-02
- Revision:
- 0:134f49df01f8
- Child:
- 1:9d3f2e86392e
File content as of revision 0:134f49df01f8:
#include "mbed.h" #include "SDFileSystem.h" #include "uLCD_4GDL.h" DigitalOut myled(LED1); SDFileSystem sd(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name); //mosi -> DI, miso <- DO, slck -> sclck, CS -> CS uLCD_4DGL lcd(PinName tx, PinName rx, PinName rst); float distance; float speed; float maxSpeed; int main() { // open the file for reading and appending records FILE *fp = fopen("/sd/records/best-of.txt", "a+"); // recall last trip recall_trip(&fp); wait(10); lcd.cls(); // normal operation loop here // check current speed // check curret distance // check time so far // display this on the screen // check if braking, turning left or right // show that on the screen // store this trip lcd.cls(); store_trip(&fp); // close the file at the end of the program fclose(fp); // end everything } void store_trip(FILE * fp) { // write trip results to the SD card } void recall_trip(FILE * fp) { // display the most recent trip made on the screen // display the most impressive trip (longest distance, best speed, least time) int lineCount; std::ifstream file("/sd/records/best-of.txt"); char str[12]; char split; if(fp == NULL) { lcd.locate(0, 1); lcd.printf("Could not open file for write\n"); } else { lcd.locate(0, 1); while (std::getline(file, str)) { } } }