Dalsi polozky - napeti baterie, obecny status

This commit is contained in:
Pavel Brychta 2018-08-01 07:48:32 +02:00
parent f09142fa2f
commit 480314e8d4
2 changed files with 54 additions and 0 deletions

View File

@ -155,3 +155,51 @@ uint8_t ETCPLPP::addBarometricPressure(uint8_t channel, float hpa)
return cursor; 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;
}

View File

@ -20,6 +20,7 @@
#define LPP_LUMINOSITY 0x09 // input, 2 bytes, 1 lux unsigned #define LPP_LUMINOSITY 0x09 // input, 2 bytes, 1 lux unsigned
#define LPP_BATTERY_VOLTAGE 0x0A // input, 2 bytes, 1mV unsigned #define LPP_BATTERY_VOLTAGE 0x0A // input, 2 bytes, 1mV unsigned
#define LPP_BATTERY_STATUS 0x0B // input, 1 byte 1%, 255 == unknown #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 // Data ID + Data Type + Data Size
#define LPP_DIGITAL_INPUT_SIZE 3 // 1 byte #define LPP_DIGITAL_INPUT_SIZE 3 // 1 byte
@ -34,6 +35,7 @@
#define LPP_LUMINOSITY_SIZE 4 // 2 bytes, 1 lux unsigned #define LPP_LUMINOSITY_SIZE 4 // 2 bytes, 1 lux unsigned
#define LPP_BATTERY_VOLTAGE_SIZE 4 // 2 bytes, 1mV unsigned #define LPP_BATTERY_VOLTAGE_SIZE 4 // 2 bytes, 1mV unsigned
#define LPP_BATTERY_STATUS_SIZE 3 // 1 byte 1% #define LPP_BATTERY_STATUS_SIZE 3 // 1 byte 1%
#define LPP_STATUS_SIZE 4 // 2 bytes unsigned
class ETCPLPP class ETCPLPP
{ {
@ -57,6 +59,10 @@ public:
uint8_t addRelativeHumidity(uint8_t channel, float rh); uint8_t addRelativeHumidity(uint8_t channel, float rh);
uint8_t addBarometricPressure(uint8_t channel, float hpa); 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: private:
uint8_t *buffer; uint8_t *buffer;
uint8_t maxsize; uint8_t maxsize;