Time: 17:33 Date: 10/12/2017 Description: Task 1,7,8 Currently Functioning

Dependencies:   BME280 BMP280 TextLCD

Working Repository

Committer:
thomasmorris
Date:
Mon Jan 08 21:53:40 2018 +0000
Revision:
47:6d128e500875
Child:
48:244d6d81bb52
FINAL working copy

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thomasmorris 47:6d128e500875 1 #include "SD_CARD.hpp"
thomasmorris 47:6d128e500875 2 void SD_Init()//Initialised the SD CARD
thomasmorris 47:6d128e500875 3 {
thomasmorris 47:6d128e500875 4
thomasmorris 47:6d128e500875 5 }
thomasmorris 47:6d128e500875 6 void SD_Card_Write()
thomasmorris 47:6d128e500875 7 {
thomasmorris 47:6d128e500875 8 if(Write_Pointer == mailsize - 1)
thomasmorris 47:6d128e500875 9 {
thomasmorris 47:6d128e500875 10 if(Log_Value==1){pc.printf("In SD_Card Thread\n");}
thomasmorris 47:6d128e500875 11
thomasmorris 47:6d128e500875 12 //Open to WRITE
thomasmorris 47:6d128e500875 13 FILE* fp = fopen("/sd/test.csv","a");
thomasmorris 47:6d128e500875 14 if(Log_Value==1){pc.printf("File Opened\n");}
thomasmorris 47:6d128e500875 15
thomasmorris 47:6d128e500875 16 for(int SD_Card_Data_Pointer = 0; SD_Card_Data_Pointer != mailsize; SD_Card_Data_Pointer++)
thomasmorris 47:6d128e500875 17 {
thomasmorris 47:6d128e500875 18 time_t Time = Data_Buffer[SD_Card_Data_Pointer].get_time();
thomasmorris 47:6d128e500875 19 tm* Time_Pointer = localtime(&Time);
thomasmorris 47:6d128e500875 20 int temp_day = Time_Pointer->tm_mday;
thomasmorris 47:6d128e500875 21 int temp_month = (Time_Pointer->tm_mon+1);//Set to current month
thomasmorris 47:6d128e500875 22 int temp_year = (Time_Pointer->tm_year+1900);//Set to current year
thomasmorris 47:6d128e500875 23
thomasmorris 47:6d128e500875 24 int temp_hours = Time_Pointer->tm_hour;
thomasmorris 47:6d128e500875 25 int temp_minute = Time_Pointer->tm_min;
thomasmorris 47:6d128e500875 26 int temp_seconds = Time_Pointer->tm_sec;
thomasmorris 47:6d128e500875 27
thomasmorris 47:6d128e500875 28 float temp_temperature = Data_Buffer[SD_Card_Data_Pointer].get_temperature();
thomasmorris 47:6d128e500875 29 float temp_pressure = Data_Buffer[SD_Card_Data_Pointer].get_pressure();
thomasmorris 47:6d128e500875 30 float temp_light = Data_Buffer[SD_Card_Data_Pointer].get_light();
thomasmorris 47:6d128e500875 31
thomasmorris 47:6d128e500875 32 fprintf(fp, "Date: %02d/%02d/%d,",temp_day,temp_month,temp_year);//Date
thomasmorris 47:6d128e500875 33 fprintf(fp, "Time: %02d:%02d:%02d,",temp_hours,temp_minute, temp_seconds);//Time
thomasmorris 47:6d128e500875 34 fprintf(fp, "Temperature: %1.1f,",temp_temperature);//Temperature
thomasmorris 47:6d128e500875 35 fprintf(fp, "Pressure: %1.1f,",temp_pressure);//Pressure
thomasmorris 47:6d128e500875 36 fprintf(fp, "Light: %5.3f,",temp_light);//Light
thomasmorris 47:6d128e500875 37 fprintf(fp, "End of Data \n");//End of data
thomasmorris 47:6d128e500875 38 }
thomasmorris 47:6d128e500875 39 if(Log_Value==1){pc.printf("Dumped data to SD Card\n");}
thomasmorris 47:6d128e500875 40 //Close File
thomasmorris 47:6d128e500875 41 fclose(fp);
thomasmorris 47:6d128e500875 42 }
thomasmorris 47:6d128e500875 43 }