diff --git a/source/shoh/src/threads/temperature/Temperature.cpp b/source/shoh/src/threads/temperature/Temperature.cpp index 210f9d8..941dfdf 100644 --- a/source/shoh/src/threads/temperature/Temperature.cpp +++ b/source/shoh/src/threads/temperature/Temperature.cpp @@ -6,6 +6,7 @@ #include "Temperature.h" #include "SensorTempTC74.h" +#include "Event.h" #include "Log.h" Temperature::Temperature(ThreadCommon::QueueManager* qm, I2C* pi2c) : _qm(qm), _pi2c(pi2c) {} @@ -15,18 +16,22 @@ Temperature::~Temperature() {} void Temperature::taskFunction() { SensorTempTC74 ext_temp_sensor(this->_pi2c, 0x4a); + Event t (Event::ExternalTemp, -10); int8_t temp_value = 0; for (;;) { if (ext_temp_sensor.is_up()) temp_value = ext_temp_sensor.getTemperature(); - + + if(temp_value == -10) + { + LOG_ERROR("Failed to get temperature."); + continue; + } + LOG_DEBUG("External temperature is: %d", temp_value); - - //Send temperature on queue. As event. :( - - - vTaskDelay(5000); + t.setDataOf(Event::ExternalTemp, temp_value); + _qm->send(ThreadCommon::QueueManager::master_event_all, &t, 5000); } }