-
Notifications
You must be signed in to change notification settings - Fork 3
/
FrSkySportSensorEsc.h
executable file
·58 lines (50 loc) · 1.6 KB
/
FrSkySportSensorEsc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
FrSky ESC sensor class for Teensy 3.x/4.0/LC, ESP8266, ATmega2560 (Mega) and ATmega328P based boards (e.g. Pro Mini, Nano, Uno)
(c) Pawelsky 202000503
Not for commercial use
*/
#ifndef _FRSKY_SPORT_SENSOR_ESC_H_
#define _FRSKY_SPORT_SENSOR_ESC_H_
#include "FrSkySportSensor.h"
#define ESC_DEFAULT_ID ID17
#define ESC_DATA_COUNT 4
#define ESC_POWER_DATA_ID 0x0B50
#define ESC_RPM_CONS_DATA_ID 0x0B60
#define ESC_TEMP_DATA_ID 0x0B70
#define ESC_SBEC_DATA_ID 0x0E50
#define ESC_POWER_DATA_PERIOD 300
#define ESC_RPM_CONS_DATA_PERIOD 300
#define ESC_TEMP_DATA_PERIOD 300
#define ESC_SBEC_DATA_PERIOD 300
class FrSkySportSensorEsc : public FrSkySportSensor
{
public:
FrSkySportSensorEsc(SensorId id = ESC_DEFAULT_ID);
void setData(float volt, float curr, uint32_t rpm, uint16_t cons, float temp, float sbecVolt = 0.0, float sbecCurr = 0.0);
virtual uint16_t send(FrSkySportSingleWireSerial& serial, uint8_t id, uint32_t now);
virtual uint16_t decodeData(uint8_t id, uint16_t appId, uint32_t data);
float getVoltage();
float getCurrent();
uint32_t getRpm();
uint16_t getConsumption();
int32_t getTemp();
float getSbecVoltage();
float getSbecCurrent();
private:
uint32_t powerData;
int32_t rpmConsData;
int32_t tempData;
uint32_t sbecData;
uint32_t powerTime;
uint32_t rpmConsTime;
uint32_t tempTime;
uint32_t sbecTime;
float volt;
float curr;
uint32_t rpm;
uint16_t cons;
int32_t temp;
float sbecVolt;
float sbecCurr;
};
#endif // _FRSKY_SPORT_SENSOR_ESC_H_