![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
ladsidfs
Fork of 0NicksCoursework_copywithserialtime by
Revision 10:c9c1522957b2, committed 2018-01-10
- Comitter:
- liam_grazier
- Date:
- Wed Jan 10 14:10:05 2018 +0000
- Parent:
- 9:e27b3f34de24
- Commit message:
- workin;
Changed in this revision
Components/components.cpp | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r e27b3f34de24 -r c9c1522957b2 Components/components.cpp --- a/Components/components.cpp Tue Jan 09 06:14:41 2018 +0000 +++ b/Components/components.cpp Wed Jan 10 14:10:05 2018 +0000 @@ -108,19 +108,20 @@ { Lock2.lock(); time_t seconds = time(NULL); +char prefix[4]; +char jdate2[32]; +strcpy(prefix,"/sd/"); strftime(jdate1, 32, "%F", localtime(&seconds)); strftime(jdate, 32, "%F\n\r", localtime(&seconds)); strftime(jtime, 32, "%X\n\r", localtime(&seconds)); +sprintf(jdate2,"%s%s",prefix,jdate1); FATFileSystem fs("sd", &sd); -char filename[32]; -char suffix[4]; -char prefix[4]; -strcpy(prefix,"/sd/"); -strcpy(suffix,".txt"); Lock1.lock(); double P = sensor.getPressure(); double L = adcIn; double t = sensor.getTemperature(); +char filename[32]; +char suffix[4]; char tem[6]; char pre[5]; char light[6]; @@ -129,8 +130,13 @@ sprintf(pre,"%.2f", P); sprintf(tem,"%.2f",t); sprintf(light,"%.2f\n\r", L); -sprintf(filename,"%s%s%s",prefix,jdate1,suffix); + +strcpy(suffix,".txt"); Lock1.unlock(); +Lock1.lock(); +sprintf(filename,"%s%s",jdate2,suffix); +Lock1.unlock(); +//FILE* fp = fopen("/sd/test.txt","a"); FILE* fp = fopen(filename,"a"); if (fp == NULL) { errorCode(FATAL); @@ -142,15 +148,18 @@ if (fp != NULL){ //printf("SD Success\n\r"); // fprintf(fp,"%s\n\r", "*C, mbar, light level 0-1 scale"); - fprintf(fp,"%s",jdate);//date - fprintf(fp,"%s",com); - fprintf(fp,"%s",jtime);//time - fprintf(fp,"%s",com); - fprintf(fp,"%s",pre); - fprintf(fp,"%s",com); - fprintf(fp,"%s",tem); - fprintf(fp,"%s",com); - fprintf(fp,"%s\n\r",light); + char sdbuf[64]; + sprintf(sdbuf,"%s%s%s%s%s%s%s%s%s\n\r",jdate,com,jtime,com,pre,com,tem,com,light); + fprintf(fp,"%s",sdbuf); + // fprintf(fp,"%s",jdate);//date +// fprintf(fp,"%s",com); +// fprintf(fp,"%s",jtime);//time +// fprintf(fp,"%s",com); +// fprintf(fp,"%s",pre); +// fprintf(fp,"%s",com); +// fprintf(fp,"%s",tem); +// fprintf(fp,"%s",com); +// fprintf(fp,"%s\n\r",light); wait(0.01); } fclose(fp); @@ -245,18 +254,8 @@ /*Initialising the time for our program to easy edit*/ time ( &rawtime ); timeinfo = localtime ( &rawtime ); - - /*Setting the time to the deadline time*/ - /*Same as button Code*/ - //Set the initialisation time to: Tuesday 9th January 2018, 16:00:00. - //set_time(1515513600); - //Initialisation of the times. time ( &rawtime ); - timeinfo = localtime ( &rawtime ); - //Displays the initialisation time - DispTime(); - /*End the initialisation */ - + timeinfo = localtime ( &rawtime ); } void runtime(void){
diff -r e27b3f34de24 -r c9c1522957b2 main.cpp --- a/main.cpp Tue Jan 09 06:14:41 2018 +0000 +++ b/main.cpp Wed Jan 10 14:10:05 2018 +0000 @@ -15,14 +15,12 @@ void inter3(); void inter4(); void inter5(); -void inter6(); Ticker samples; Ticker remov; InterruptIn sdex(USER_BUTTON); Ticker storage; Ticker netTick; Ticker serielTick; -Ticker buttonTick; int T = 5; void inter1(){ sdcheck(); @@ -44,13 +42,9 @@ void inter5(){ stxThread.signal_set(SIG_SX); } -//void inter6(){ -// timebuttonThread.signal_set(SIG_button); -//} int main(){ lglcd mylcd(D7,D6,D5,D4,D3,D2); setuptime(); -printf("NEWIT"); sdrun(); lcdstart(); welcomemsg(); @@ -64,6 +58,5 @@ netTick.attach(&inter4,0.01); stxThread.start(useseriel); serielTick.attach(&inter5,0.1); -//timebuttonThread.start(//insertnamehere); -//buttonTick.attach(&inter6,0.3); + } \ No newline at end of file