Time: 17:33 Date: 10/12/2017 Description: Task 1,7,8 Currently Functioning
Dependencies: BME280 BMP280 TextLCD
Working Repository
Diff: sample_hardware.cpp
- Revision:
- 49:d51f96a46cc3
- Parent:
- 48:244d6d81bb52
--- a/sample_hardware.cpp Tue Jan 09 00:37:01 2018 +0000 +++ b/sample_hardware.cpp Tue Jan 09 11:41:07 2018 +0000 @@ -1,6 +1,7 @@ #include "mbed.h" #include "sample_hardware.hpp" #include "LCD.hpp" + #define RED_DONE 1 #define YELLOW_DONE 2 @@ -86,10 +87,11 @@ errorCode(FATAL); } //Create a filing system for SD Card - FATFileSystem fs("sd", &sd); + FATFileSystem fs("sd", &sd); //Open to WRITE - FILE* fp = fopen("/sd/test.csv","a");//test.csv is created in the SD Card + + FILE* fp = fopen("/sd/test.csv","w"); if (fp == NULL) { error("Could not open file for write\n"); LCD.Display_Clear(); @@ -98,6 +100,7 @@ } //Close File fclose(fp); + int network_temp; network_temp = Network_Init(); if(network_temp == 1)//Sets up the network and checks if the network cable is not pluged in @@ -127,17 +130,35 @@ return; case NETWORK_FATAL: while(1) { - redLED = 1; - wait(0.1); - redLED = 0; + pc.printf("NETWOK FATAL\n"); + } + case SD_CARD_REMOVED: wait(0.1); - } - case FATAL: + LCD.Display_Clear(); + LCD.DDRAM_Address(0x00); + LCD.Write_String("SD CARD"); + LCD.DDRAM_Address(0x40); + LCD.Write_String("Removed"); + + wait(5); + pc.printf("SD CARD REMOVED\n"); + while(1) + { + if(SD_CARD_DETECT.read() == 0) + { + LCD.Display_Clear(); + LCD.DDRAM_Address(0x00); + LCD.Write_String("SD CARD"); + LCD.DDRAM_Address(0x40); + LCD.Write_String("Inserted"); + pc.printf("SD CARD INSERTED\n"); + SD_Write = 1; + return; + } + } + case FATAL: while(1) { - redLED = 1; - wait(0.1); - redLED = 0; - wait(0.1); + pc.printf("FATAL\n"); } }; } \ No newline at end of file