Dalsi polozky - napeti baterie, obecny status
This commit is contained in:
parent
f09142fa2f
commit
480314e8d4
48
ETCPLPP.cpp
48
ETCPLPP.cpp
@ -155,3 +155,51 @@ uint8_t ETCPLPP::addBarometricPressure(uint8_t channel, float hpa)
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
uint8_t ETCLPP::addBatteryVoltage(uint8_t channel, float voltage)
|
||||
{
|
||||
|
||||
if ((cursor + LPP_BATTERY_VOLTAGE_SIZE) > maxsize)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int16_t val = voltage * 1000;
|
||||
|
||||
buffer[cursor++] = channel;
|
||||
buffer[cursor++] = LPP_BATTERY_VOLTAGE;
|
||||
buffer[cursor++] = val >> 8;
|
||||
buffer[cursor++] = val;
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
uint8_t ETCLPP::addBatteryStatus(uint8_t channel, uint8_t percent)
|
||||
{
|
||||
|
||||
if ((cursor + LPP_BATTERY_STATUS_SIZE) > maxsize)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
buffer[cursor++] = channel;
|
||||
buffer[cursor++] = LPP_BATTERY_STATUS;
|
||||
buffer[cursor++] = percent;
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
||||
uint8_t ETCLPP::addStatus(uint8_t channel, uint16_t status)
|
||||
{
|
||||
|
||||
if ((cursor + LPP_STATUS_SIZE) > maxsize)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
buffer[cursor++] = channel;
|
||||
buffer[cursor++] = LPP_STATUS;
|
||||
buffer[cursor++] = status >> 8;
|
||||
buffer[cursor++] = status;
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define LPP_LUMINOSITY 0x09 // input, 2 bytes, 1 lux unsigned
|
||||
#define LPP_BATTERY_VOLTAGE 0x0A // input, 2 bytes, 1mV unsigned
|
||||
#define LPP_BATTERY_STATUS 0x0B // input, 1 byte 1%, 255 == unknown
|
||||
#define LPP_STATUS 0x0C // input, 2 bytes unsigned
|
||||
|
||||
// Data ID + Data Type + Data Size
|
||||
#define LPP_DIGITAL_INPUT_SIZE 3 // 1 byte
|
||||
@ -34,6 +35,7 @@
|
||||
#define LPP_LUMINOSITY_SIZE 4 // 2 bytes, 1 lux unsigned
|
||||
#define LPP_BATTERY_VOLTAGE_SIZE 4 // 2 bytes, 1mV unsigned
|
||||
#define LPP_BATTERY_STATUS_SIZE 3 // 1 byte 1%
|
||||
#define LPP_STATUS_SIZE 4 // 2 bytes unsigned
|
||||
|
||||
class ETCPLPP
|
||||
{
|
||||
@ -57,6 +59,10 @@ public:
|
||||
uint8_t addRelativeHumidity(uint8_t channel, float rh);
|
||||
uint8_t addBarometricPressure(uint8_t channel, float hpa);
|
||||
|
||||
uint8_t addBatteryVoltage(uint8_t channel, float voltage);
|
||||
uint8_t addBatteryStatus(uint8_t channel, uint8_t percent);
|
||||
|
||||
uint8_t addStatus(uint8_t channel, uint16_t status);
|
||||
private:
|
||||
uint8_t *buffer;
|
||||
uint8_t maxsize;
|
||||
|
Loading…
Reference in New Issue
Block a user