Line data Source code
1 : /* 2 : This program is free software: you can redistribute it and/or modify 3 : it under the terms of the GNU General Public License as published by 4 : the Free Software Foundation, either version 3 of the License, or 5 : (at your option) any later version. 6 : 7 : This program is distributed in the hope that it will be useful, 8 : but WITHOUT ANY WARRANTY; without even the implied warranty of 9 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 : GNU General Public License for more details. 11 : 12 : You should have received a copy of the GNU General Public License 13 : along with this program. If not, see <http://www.gnu.org/licenses/>. 14 : */ 15 : #pragma once 16 : 17 : #include "AP_TemperatureSensor.h" 18 : 19 : #if AP_TEMPERATURE_SENSOR_ENABLED 20 : #include <AP_HAL/Semaphores.h> 21 : #include <AP_ESC_Telem/AP_ESC_Telem.h> 22 : 23 : class AP_TemperatureSensor_Backend 24 : #if HAL_WITH_ESC_TELEM 25 : : public AP_ESC_Telem_Backend 26 : #endif 27 : { 28 : public: 29 : // constructor. This incorporates initialisation as well. 30 : AP_TemperatureSensor_Backend(AP_TemperatureSensor &front, AP_TemperatureSensor::TemperatureSensor_State &state, AP_TemperatureSensor_Params ¶ms); 31 : 32 : // initialise 33 0 : __INITFUNC__ virtual void init() {}; 34 : 35 : // update the latest temperature 36 : virtual void update() = 0; 37 : 38 : // do we have a valid temperature reading? 39 : virtual bool healthy(void) const; 40 : 41 : // logging functions 42 : void Log_Write_TEMP() const; 43 : 44 : AP_HAL::Device *_dev; 45 : 46 : 47 : protected: 48 : 49 : void set_temperature(const float temperature); 50 : void update_external_libraries(const float temperature); 51 : 52 : AP_TemperatureSensor &_front; // reference to front-end 53 : AP_TemperatureSensor::TemperatureSensor_State &_state; // reference to this instance's state (held in the front-end) 54 : AP_TemperatureSensor_Params &_params; // reference to this instance's parameters (held in the front-end) 55 : 56 : private: 57 : HAL_Semaphore _sem; // used to copy from backend to frontend 58 : }; 59 : 60 : #endif // AP_TEMPERATURE_SENSOR_ENABLED