SEDO subject project
Dependencies: ds3231 mbed-rtos mbed DHT
Diff: main.cpp
- Revision:
- 10:f14f47225091
- Parent:
- 9:5e9c4277151d
- Child:
- 11:a9f41d6489c9
--- a/main.cpp Mon May 08 07:20:54 2017 +0000 +++ b/main.cpp Mon May 08 17:13:57 2017 +0000 @@ -4,6 +4,7 @@ #include "main.h" #include "real_time_clock.h" #include "temp_hum_sensor.h" +#include "motor_cnt.h" #define TASKS_NUMBER (sizeof(taskList)/sizeof(taskList[0])) @@ -26,8 +27,11 @@ pc.printf("MAIN: init\n"); mutexPCComm.unlock(); // Init RTC - time_t epoch_time; + time_t epoch_time, elapsed_time; epoch_time = rtc.get_epoch(); + mutexPCComm.lock(); + pc.printf("MAIN: time %s\n", ctime(&epoch_time)); + mutexPCComm.unlock(); // Reset all data status mutexData.lock(); data.DHTError = -128; @@ -35,19 +39,25 @@ // Init all tasks initTasks(); while(true) { + epoch_time = rtc.get_epoch(); // Start all threads sensors_running = true; for (int i = 0; i < TASKS_NUMBER; i++) { if (taskList[i].retVal == 1) { taskList[i].thread->signal_set(0x1); - Thread::wait(taskList[i].delay); - taskList[i].thread->signal_clr(0x1); } } publishSensorData(); // Stop all remain tasks sensors_running = false; - Thread::wait(10000); + elapsed_time = rtc.get_epoch()-epoch_time; + + mutexPCComm.lock(); + pc.printf("MAIN: elapsed %ld\n",(long)elapsed_time); + mutexPCComm.unlock(); + if(30-elapsed_time>0){ + Thread::wait((30-elapsed_time)*1000); + } } }