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:
1:9d3f2e86392e
Parent:
0:134f49df01f8
Child:
2:d08643ff3c62

File content as of revision 1:9d3f2e86392e:

#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
    
    
    // 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
    if (fp == NULL) {
        
    }
}

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;
    char str[12];
    char split;
    
    // read out the most recent trip
    FILE *fp = fopen("/sd/records/recent.txt", "r");
    
    if (fp == NULL) {
        lcd.locate(0, 1);
        lcd.printf("Could not open file for write\n");
    } else {
        std::getline(file, str);
        lcd.locate(0, 1);
        lcd.printf("Most recent trip\n%s", str);
    }
    
    // read out the most impressive trip so far
    FILE *fp = fopen("/sd/records/best_of.txt", "r");

    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)) {
        
        }
    }
}