Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SB1602E SDFileSystem mbed
Diff: main.cpp
- Revision:
- 2:78ba5d3f0ac9
- Parent:
- 1:758a4ce77b97
- Child:
- 3:7bc0db64fa61
--- a/main.cpp Fri May 15 05:40:12 2015 +0000 +++ b/main.cpp Sun May 17 06:31:47 2015 +0000 @@ -1,22 +1,46 @@ #include "mbed.h" #include "SB1602E.h" +#include "SDFileSystem.h" + +#define LOG_MAX 120 AnalogIn sensor(dp13); -Serial pc(USBTX, USBRX); SB1602E lcd( dp5, dp27 ); +SDFileSystem sd(dp2, dp1, dp6, dp4, "sd"); int main() { + int counter = 0; + int16_t TmpLog[LOG_MAX]; + lcd.contrast(0x30); while(1) { float Temperature; Temperature = (sensor * 3.3 - 0.6) / 0.01; - pc.printf("Temperature = %f\r\n",Temperature); - lcd.clear(); lcd.printf(0,0,"%.2f",Temperature); - - wait(1.0); + + if( counter < LOG_MAX ) + { + TmpLog[counter] = (int16_t)(Temperature*100.0); + counter++; + } + else if( counter == LOG_MAX ) + { + FILE *fp = fopen("/sd/TempLog.csv", "w"); + for(int i=0;i<counter;i++) + { + fprintf(fp,"%d,%.2f\r\n",i,(float)TmpLog[i]/100.0); + } + fclose(fp); + lcd.printf(0,1,"RecEnd"); + counter++; + } + else + { + lcd.printf(0,1,"RecEnd"); + } + wait(60.0); } }