Increased GPS altitude resolution, further fixes

This commit is contained in:
cyberman54 2019-07-27 13:35:12 +02:00
parent 8fdd83edf9
commit 1f9e93cf39
4 changed files with 15 additions and 18 deletions

View File

@ -18,8 +18,6 @@
#define LPP_BAROMETER_CHANNEL 30
#define LPP_AIR_CHANNEL 31
#endif
// MyDevices CayenneLPP 2.0 types for Packed Sensor Payload, not using channels,
// but different FPorts
#define LPP_GPS 136 // 3 byte lon/lat 0.0001 °, 3 bytes alt 0.01m
@ -32,6 +30,8 @@
#define LPP_HUMIDITY 104 // 1 byte, 0.5 % unsigned
#define LPP_BAROMETER 115 // 2 bytes, hPa unsigned MSB
#endif
class PayloadConvert {
public:
@ -54,13 +54,13 @@ public:
void addSensor(uint8_t[]);
void addTime(time_t value);
#if PAYLOAD_ENCODER == 1 // format plain
#if (PAYLOAD_ENCODER == 1) // format plain
private:
uint8_t *buffer;
uint8_t cursor;
#elif PAYLOAD_ENCODER == 2 // format packed
#elif (PAYLOAD_ENCODER == 2) // format packed
private:
uint8_t *buffer;
@ -78,7 +78,7 @@ private:
void writeBitmap(bool a, bool b, bool c, bool d, bool e, bool f, bool g,
bool h);
#elif (PAYLOAD_ENCODER == 3 || PAYLOAD_ENCODER == 4) // format cayenne lpp
#elif ((PAYLOAD_ENCODER == 3) || (PAYLOAD_ENCODER == 4)) // format cayenne lpp
private:
uint8_t *buffer;

View File

@ -143,7 +143,7 @@ var hdop = function (bytes) {
if (bytes.length !== hdop.BYTES) {
throw new Error('hdop must have exactly 2 bytes');
}
return bytesToInt(bytes) / 100;
return +(bytesToInt(bytes) / 100).toFixed(1);
};
hdop.BYTES = 2;
@ -151,8 +151,7 @@ var altitude = function (bytes) {
if (bytes.length !== altitude.BYTES) {
throw new Error('Altitude must have exactly 2 bytes');
}
var alt = bytesToInt(bytes) / 4 - 1000;
return +alt.toFixed(1);
return +(bytesToInt(bytes) / 4 - 1000).toFixed(1);
};
altitude.BYTES = 2;

View File

@ -71,7 +71,7 @@ void gps_storelocation(gpsStatus_t &gps_store) {
gps_store.longitude = (int32_t)(gps.location.lng() * 1e6);
gps_store.satellites = (uint8_t)gps.satellites.value();
gps_store.hdop = (uint16_t)gps.hdop.value();
gps_store.altitude = (int16_t)((gps.altitude.meters() + 1000) * 4);
gps_store.altitude = (int16_t)gps.altitude.meters();
}
// store current GPS timedate in struct

View File

@ -16,7 +16,7 @@ uint8_t *PayloadConvert::getBuffer(void) { return buffer; }
/* ---------------- plain format without special encoding ---------- */
#if PAYLOAD_ENCODER == 1
#if (PAYLOAD_ENCODER == 1)
void PayloadConvert::addByte(uint8_t value) { buffer[cursor++] = (value); }
@ -92,8 +92,8 @@ void PayloadConvert::addGPS(gpsStatus_t value) {
buffer[cursor++] = value.satellites;
buffer[cursor++] = highByte(value.hdop);
buffer[cursor++] = lowByte(value.hdop);
buffer[cursor++] = highByte(value.altitude);
buffer[cursor++] = lowByte(value.altitude);
buffer[cursor++] = highByte((value.altitude + 1000) * 4);
buffer[cursor++] = lowByte((value.altitude + 1000) * 4);
#endif
}
@ -141,7 +141,7 @@ void PayloadConvert::addTime(time_t value) {
// derived from
// https://github.com/thesolarnomad/lora-serialization/blob/master/src/LoraEncoder.cpp
#elif PAYLOAD_ENCODER == 2
#elif (PAYLOAD_ENCODER == 2)
void PayloadConvert::addByte(uint8_t value) { writeUint8(value); }
@ -195,7 +195,7 @@ void PayloadConvert::addGPS(gpsStatus_t value) {
writeLatLng(value.latitude, value.longitude);
writeUint8(value.satellites);
writeUint16(value.hdop);
writeUint16(value.altitude);
writeUint16((value.altitude + 1000) * 4);
#endif
}
@ -301,7 +301,7 @@ void PayloadConvert::writeBitmap(bool a, bool b, bool c, bool d, bool e, bool f,
// FPort 1 PAYLOAD_ENCODER == 4 -> Packed Sensor Payload, not using channels ->
// FPort 2
#elif (PAYLOAD_ENCODER == 3 || PAYLOAD_ENCODER == 4)
#elif ((PAYLOAD_ENCODER == 3) || (PAYLOAD_ENCODER == 4))
void PayloadConvert::addByte(uint8_t value) {
/*
@ -412,7 +412,7 @@ void PayloadConvert::addSensor(uint8_t buf[]) {
memcpy(buffer, buf+1, length);
cursor += length; // length of buffer
*/
#endif
#endif // HAS_SENSORS
}
void PayloadConvert::addBME(bmeStatus_t value) {
@ -481,6 +481,4 @@ void PayloadConvert::addTime(time_t value) {
#endif
}
#else
#error No valid payload converter defined!
#endif