fixes
This commit is contained in:
parent
7ddf906c8e
commit
f09142fa2f
89
ETCPLPP.cpp
89
ETCPLPP.cpp
@ -112,20 +112,7 @@ uint8_t ETCPLPP::addLuminosity(uint8_t channel, uint16_t lux)
|
|||||||
return cursor;
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t CayenneLPP::addPresence(uint8_t channel, uint8_t value)
|
uint8_t ETCPLPP::addTemperature(uint8_t channel, float celsius)
|
||||||
{
|
|
||||||
if ((cursor + LPP_PRESENCE_SIZE) > maxsize)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
buffer[cursor++] = channel;
|
|
||||||
buffer[cursor++] = LPP_PRESENCE;
|
|
||||||
buffer[cursor++] = value;
|
|
||||||
|
|
||||||
return cursor;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t CayenneLPP::addTemperature(uint8_t channel, float celsius)
|
|
||||||
{
|
{
|
||||||
if ((cursor + LPP_TEMPERATURE_SIZE) > maxsize)
|
if ((cursor + LPP_TEMPERATURE_SIZE) > maxsize)
|
||||||
{
|
{
|
||||||
@ -140,7 +127,7 @@ uint8_t CayenneLPP::addTemperature(uint8_t channel, float celsius)
|
|||||||
return cursor;
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t CayenneLPP::addRelativeHumidity(uint8_t channel, float rh)
|
uint8_t ETCPLPP::addRelativeHumidity(uint8_t channel, float rh)
|
||||||
{
|
{
|
||||||
if ((cursor + LPP_RELATIVE_HUMIDITY_SIZE) > maxsize)
|
if ((cursor + LPP_RELATIVE_HUMIDITY_SIZE) > maxsize)
|
||||||
{
|
{
|
||||||
@ -153,29 +140,7 @@ uint8_t CayenneLPP::addRelativeHumidity(uint8_t channel, float rh)
|
|||||||
return cursor;
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t CayenneLPP::addAccelerometer(uint8_t channel, float x, float y, float z)
|
uint8_t ETCPLPP::addBarometricPressure(uint8_t channel, float hpa)
|
||||||
{
|
|
||||||
if ((cursor + LPP_ACCELEROMETER_SIZE) > maxsize)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int16_t vx = x * 1000;
|
|
||||||
int16_t vy = y * 1000;
|
|
||||||
int16_t vz = z * 1000;
|
|
||||||
|
|
||||||
buffer[cursor++] = channel;
|
|
||||||
buffer[cursor++] = LPP_ACCELEROMETER;
|
|
||||||
buffer[cursor++] = vx >> 8;
|
|
||||||
buffer[cursor++] = vx;
|
|
||||||
buffer[cursor++] = vy >> 8;
|
|
||||||
buffer[cursor++] = vy;
|
|
||||||
buffer[cursor++] = vz >> 8;
|
|
||||||
buffer[cursor++] = vz;
|
|
||||||
|
|
||||||
return cursor;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t CayenneLPP::addBarometricPressure(uint8_t channel, float hpa)
|
|
||||||
{
|
{
|
||||||
if ((cursor + LPP_BAROMETRIC_PRESSURE_SIZE) > maxsize)
|
if ((cursor + LPP_BAROMETRIC_PRESSURE_SIZE) > maxsize)
|
||||||
{
|
{
|
||||||
@ -190,51 +155,3 @@ uint8_t CayenneLPP::addBarometricPressure(uint8_t channel, float hpa)
|
|||||||
|
|
||||||
return cursor;
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t CayenneLPP::addGyrometer(uint8_t channel, float x, float y, float z)
|
|
||||||
{
|
|
||||||
if ((cursor + LPP_GYROMETER_SIZE) > maxsize)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int16_t vx = x * 100;
|
|
||||||
int16_t vy = y * 100;
|
|
||||||
int16_t vz = z * 100;
|
|
||||||
|
|
||||||
buffer[cursor++] = channel;
|
|
||||||
buffer[cursor++] = LPP_GYROMETER;
|
|
||||||
buffer[cursor++] = vx >> 8;
|
|
||||||
buffer[cursor++] = vx;
|
|
||||||
buffer[cursor++] = vy >> 8;
|
|
||||||
buffer[cursor++] = vy;
|
|
||||||
buffer[cursor++] = vz >> 8;
|
|
||||||
buffer[cursor++] = vz;
|
|
||||||
|
|
||||||
return cursor;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t CayenneLPP::addGPS(uint8_t channel, float latitude, float longitude, float meters)
|
|
||||||
{
|
|
||||||
if ((cursor + LPP_GPS_SIZE) > maxsize)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int32_t lat = latitude * 10000;
|
|
||||||
int32_t lon = longitude * 10000;
|
|
||||||
int32_t alt = meters * 100;
|
|
||||||
|
|
||||||
buffer[cursor++] = channel;
|
|
||||||
buffer[cursor++] = LPP_GPS;
|
|
||||||
|
|
||||||
buffer[cursor++] = lat >> 16;
|
|
||||||
buffer[cursor++] = lat >> 8;
|
|
||||||
buffer[cursor++] = lat;
|
|
||||||
buffer[cursor++] = lon >> 16;
|
|
||||||
buffer[cursor++] = lon >> 8;
|
|
||||||
buffer[cursor++] = lon;
|
|
||||||
buffer[cursor++] = alt >> 16;
|
|
||||||
buffer[cursor++] = alt >> 8;
|
|
||||||
buffer[cursor++] = alt;
|
|
||||||
|
|
||||||
return cursor;
|
|
||||||
}
|
|
||||||
|
@ -29,8 +29,8 @@
|
|||||||
#define LPP_TEMPERATURE_SIZE 4 // input, 2 bytes, 0.1°C signed
|
#define LPP_TEMPERATURE_SIZE 4 // input, 2 bytes, 0.1°C signed
|
||||||
#define LPP_RELATIVE_HUMIDITY_SIZE 3 // input, 1 byte, 0.5% unsigned
|
#define LPP_RELATIVE_HUMIDITY_SIZE 3 // input, 1 byte, 0.5% unsigned
|
||||||
#define LPP_ACCELERATION_SIZE 4 // input, 2 bytes, 0.001G
|
#define LPP_ACCELERATION_SIZE 4 // input, 2 bytes, 0.001G
|
||||||
#define LPP_BAROMETRIC_PRESSURE 4 // input, 2 bytes 0.1 hPa unsigned
|
#define LPP_BAROMETRIC_PRESSURE_SIZE 4 // input, 2 bytes 0.1 hPa unsigned
|
||||||
#define LPP_ANGLE_VELOCITY 4 // input, 2 bytes, 0.01 °/s
|
#define LPP_ANGLE_VELOCITY_SIZE 4 // input, 2 bytes, 0.01 °/s
|
||||||
#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%
|
||||||
@ -53,13 +53,9 @@ public:
|
|||||||
uint8_t addAnalogOutput(uint8_t channel, float value);
|
uint8_t addAnalogOutput(uint8_t channel, float value);
|
||||||
|
|
||||||
uint8_t addLuminosity(uint8_t channel, uint16_t lux);
|
uint8_t addLuminosity(uint8_t channel, uint16_t lux);
|
||||||
uint8_t addPresence(uint8_t channel, uint8_t value);
|
|
||||||
uint8_t addTemperature(uint8_t channel, float celsius);
|
uint8_t addTemperature(uint8_t channel, float celsius);
|
||||||
uint8_t addRelativeHumidity(uint8_t channel, float rh);
|
uint8_t addRelativeHumidity(uint8_t channel, float rh);
|
||||||
uint8_t addAccelerometer(uint8_t channel, float x, float y, float z);
|
|
||||||
uint8_t addBarometricPressure(uint8_t channel, float hpa);
|
uint8_t addBarometricPressure(uint8_t channel, float hpa);
|
||||||
uint8_t addGyrometer(uint8_t channel, float x, float y, float z);
|
|
||||||
uint8_t addGPS(uint8_t channel, float latitude, float longitude, float meters);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t *buffer;
|
uint8_t *buffer;
|
||||||
|
Loading…
Reference in New Issue
Block a user