2015-08-07 00:37:06 -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/>.
|
|
|
|
*/
|
2016-02-17 21:25:46 -04:00
|
|
|
#pragma once
|
2015-08-07 00:37:06 -03:00
|
|
|
|
|
|
|
#include "AP_RPM.h"
|
|
|
|
|
2022-07-15 08:53:41 -03:00
|
|
|
#if AP_RPM_ENABLED
|
|
|
|
|
2015-08-07 00:37:06 -03:00
|
|
|
class AP_RPM_Backend
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// constructor. This incorporates initialisation as well.
|
2021-08-09 18:34:28 -03:00
|
|
|
AP_RPM_Backend(AP_RPM &_ap_rpm, uint8_t instance, AP_RPM::RPM_State &_state);
|
2015-08-07 00:37:06 -03:00
|
|
|
|
|
|
|
// we declare a virtual destructor so that RPM drivers can
|
|
|
|
// override with a custom destructor if need be
|
|
|
|
virtual ~AP_RPM_Backend(void) {}
|
|
|
|
|
|
|
|
// update the state structure. All backends must implement this.
|
|
|
|
virtual void update() = 0;
|
|
|
|
|
2017-04-02 00:57:59 -03:00
|
|
|
int8_t get_pin(void) const {
|
2019-02-07 03:00:36 -04:00
|
|
|
if (state.instance >= RPM_MAX_INSTANCES) {
|
2017-04-02 00:57:59 -03:00
|
|
|
return -1;
|
|
|
|
}
|
2021-08-09 08:21:52 -03:00
|
|
|
return ap_rpm._params[state.instance].pin.get();
|
2017-04-02 00:57:59 -03:00
|
|
|
}
|
2021-08-09 18:34:28 -03:00
|
|
|
|
2015-08-07 00:37:06 -03:00
|
|
|
protected:
|
|
|
|
|
|
|
|
AP_RPM &ap_rpm;
|
|
|
|
AP_RPM::RPM_State &state;
|
|
|
|
};
|
2022-07-15 08:53:41 -03:00
|
|
|
|
|
|
|
#endif // AP_RPM_ENABLED
|