2022-09-12 16:48:05 -03:00
|
|
|
/*
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "AP_TemperatureSensor.h"
|
|
|
|
|
|
|
|
#if AP_TEMPERATURE_SENSOR_ENABLED
|
2022-09-26 20:23:48 -03:00
|
|
|
#include <AP_HAL/Semaphores.h>
|
2022-09-02 18:26:15 -03:00
|
|
|
#include <AP_ESC_Telem/AP_ESC_Telem.h>
|
2022-09-12 16:48:05 -03:00
|
|
|
|
|
|
|
class AP_TemperatureSensor_Backend
|
2022-09-02 18:26:15 -03:00
|
|
|
#if HAL_WITH_ESC_TELEM
|
|
|
|
: public AP_ESC_Telem_Backend
|
|
|
|
#endif
|
2022-09-12 16:48:05 -03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// constructor. This incorporates initialisation as well.
|
|
|
|
AP_TemperatureSensor_Backend(AP_TemperatureSensor &front, AP_TemperatureSensor::TemperatureSensor_State &state, AP_TemperatureSensor_Params ¶ms);
|
|
|
|
|
|
|
|
// initialise
|
|
|
|
virtual void init() {};
|
|
|
|
|
|
|
|
// update the latest temperature
|
|
|
|
virtual void update() = 0;
|
|
|
|
|
|
|
|
// do we have a valid temperature reading?
|
2022-09-26 20:23:48 -03:00
|
|
|
virtual bool healthy(void) const;
|
2022-09-12 16:48:05 -03:00
|
|
|
|
|
|
|
// logging functions
|
2022-09-26 20:23:48 -03:00
|
|
|
void Log_Write_TEMP() const;
|
|
|
|
|
|
|
|
AP_HAL::OwnPtr<AP_HAL::Device> _dev;
|
|
|
|
|
2022-09-12 16:48:05 -03:00
|
|
|
|
|
|
|
protected:
|
2022-09-26 20:23:48 -03:00
|
|
|
|
|
|
|
void set_temperature(const float temperature);
|
2022-09-02 18:26:15 -03:00
|
|
|
void update_external_libraries(const float temperature);
|
2022-09-26 20:23:48 -03:00
|
|
|
|
2022-09-12 16:48:05 -03:00
|
|
|
AP_TemperatureSensor &_front; // reference to front-end
|
|
|
|
AP_TemperatureSensor::TemperatureSensor_State &_state; // reference to this instance's state (held in the front-end)
|
|
|
|
AP_TemperatureSensor_Params &_params; // reference to this instance's parameters (held in the front-end)
|
2022-09-26 20:23:48 -03:00
|
|
|
|
|
|
|
private:
|
|
|
|
HAL_Semaphore _sem; // used to copy from backend to frontend
|
2022-09-12 16:48:05 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // AP_TEMPERATURE_SENSOR_ENABLED
|