![](/media/cache/profiles/acab0116c354964a558e65bdd07ff047.jpg.50x50_q85.jpg)
Syggestions
Dependencies: CheckRTC LPS25H hts221
Fork of ELEC350-extended-referral2 by
Diff: main.cpp
- Revision:
- 45:fac0d195fc65
- Parent:
- 44:ca34a376a17c
- Child:
- 46:794973f66ef6
diff -r ca34a376a17c -r fac0d195fc65 main.cpp --- a/main.cpp Wed Nov 22 13:09:15 2017 +0000 +++ b/main.cpp Wed Nov 22 13:34:16 2017 +0000 @@ -39,7 +39,7 @@ Thread t1; - +Thread tSample; osThreadId idMain; osThreadId id1; @@ -47,7 +47,7 @@ osThreadId id3; osThreadId id4; - +Ticker ticker; void function1() {//begin function @@ -88,11 +88,16 @@ //Thread::signal_wait(SETTIME_OFF); if(buffer_str=="SETT") // begin if buffer sett + { for (count = 0; count < 5; count++) { - sz = snprintf(NULL, 0,"%s, %s, %4.2fC , %3.1f%%, %6.1f, %4.1f\n\r", time, date, tempCelsius, humi, barometer.pressure(), barometer.temperature()); + float temp = barometer.temperature(); + float pressure = barometer.pressure(); + + sz = snprintf(NULL, 0,"%s, %s, %4.2fC , %3.1f%%, %6.1f, %4.1f\n\r", time, date, tempCelsius, humi, pressure, temp); buf = (char *)malloc(sz + 1); - snprintf(buf, sz + 1, "%s, %s, %4.2fC , %3.1f%%, %6.1f, %4.1f\n\r", time, date, tempCelsius, humi, barometer.pressure(), barometer.temperature()); + snprintf(buf, sz + 1, "%s, %s, %4.2fC , %3.1f%%, %6.1f, %4.1f\n\r", time, date, tempCelsius, humi, pressure, temp); printf("%s\n\r",buf); + free(buf); printf("written to memory\n\r"); myled = 1; Thread::wait(200); @@ -100,7 +105,7 @@ t1.signal_set(SETT_OFF); } //end if buffer sett Thread::wait(200); - + } //Thread::signal_wait(SETT_OFF); @@ -113,13 +118,28 @@ osSignalSet(idMain, ALL_OFF); }//end if buffer read Thread::wait(200); - }//end while true - }//end function + }//end while true +}//end function + void getSampleThread() { + while (true) { + Thread::signal_wait(99); + //Get samples + + //Put in buffer + } + } + + void getSample() { + tSample.signal_set(99); + } int main() { pc.baud(9600); //sets baud rate to 9600 + ticker.attach(getSample, 15); + tSample.start(getSampleThread); + time_t seconds = time(NULL); idMain = osThreadGetId(); t1.start(function1);