![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Comments added and commented out outdated code
Dependencies: Peripherals SD_Lib Time_Lib_v2 Year3_Version5 BMP280 LCDFunctions TextLCD BME280 Serial_Lib
Diff: main.cpp
- Revision:
- 6:2ef9c06ce506
- Parent:
- 5:60e116a1e913
- Child:
- 7:981670f59caf
--- a/main.cpp Mon Nov 19 20:54:41 2018 +0000 +++ b/main.cpp Fri Nov 23 12:40:27 2018 +0000 @@ -37,6 +37,36 @@ Thread t2; +//Main thread +int main() { + + lcd.printf("Select Time Option\n\n"); + + post(); + + //Initialise the SD card + if ( sd.init() != 0) { + printf("Init failed \n"); + errorCode(FATAL); + } + + //Create a filing system for SD Card + FATFileSystem fs("sd", &sd); + + //Open to WRITE + FILE* fp = fopen("/sd/test.csv","a"); + if (fp == NULL) { + error("Could not open file for write\n"); + errorCode(FATAL); + } + + // run threads + t1.start(FunctionSensor); + t2.start(FunctionTime); + +} + + void displayOnLcd() { date_mutex.lock(); @@ -154,7 +184,7 @@ day = day + 1; lcd.cls(); lcd.locate(0,0); - lcd.printf("Day = %d\n\r", day); + lcd.printf("Day = %d\n", day); } if (SW2 == 1) { setting = Month; @@ -168,7 +198,7 @@ month = month + 1; lcd.cls(); lcd.locate(0,0); - lcd.printf("Month = %d\n\r", month); + lcd.printf("Month = %d\n", month); } if (SW2 == 1) { setting = Year; @@ -182,7 +212,7 @@ year = year + 1; lcd.cls(); lcd.locate(0,0); - lcd.printf("Year = %d\n\r", year); + lcd.printf("Year = %d\n", year); } if (SW2 == 1) { setting = Hour; @@ -196,7 +226,7 @@ hour = hour + 1; lcd.cls(); lcd.locate(0,0); - lcd.printf("Hour = %d\n\r", hour); + lcd.printf("Hour = %d\n", hour); } if (SW2 == 1) { setting = Minute; @@ -210,7 +240,7 @@ min = min + 1; lcd.cls(); lcd.locate(0,0); - lcd.printf("Minute = %d\n\r", min); + lcd.printf("Minute = %d\n", min); } if (SW2 == 1) { setting = Second; @@ -224,7 +254,7 @@ sec = sec + 1; lcd.cls(); lcd.locate(0,0); - lcd.printf("Second = %d\n\r", sec); + lcd.printf("Second = %d\n", sec); } if (SW2 == 1) { wait(0.5); @@ -297,34 +327,4 @@ } } -} - -//Main thread -int main() { - - lcd.printf("Select Time Option\n\n"); - - post(); - - //Initialise the SD card - if ( sd.init() != 0) { - printf("Init failed \n"); - errorCode(FATAL); - } - - //Create a filing system for SD Card - FATFileSystem fs("sd", &sd); - - //Open to WRITE - FILE* fp = fopen("/sd/test.csv","a"); - if (fp == NULL) { - error("Could not open file for write\n"); - errorCode(FATAL); - } - - // run threads - t1.start(FunctionSensor); - t2.start(FunctionTime); - -} - +} \ No newline at end of file