fix(tele): DSM LIPO 6S sensor endian order (#6014)
This commit is contained in:
@@ -272,13 +272,13 @@ const SpektrumSensor spektrumSensors[] = {
|
|||||||
//SS(0x38, 0, uint16, STR_SENSOR_PRESSSURE, UNIT_PSI, 1),
|
//SS(0x38, 0, uint16, STR_SENSOR_PRESSSURE, UNIT_PSI, 1),
|
||||||
|
|
||||||
// 0x3A Lipo 6s Monitor Cells
|
// 0x3A Lipo 6s Monitor Cells
|
||||||
SS(I2C_CELLS, 0, uint16, STR_SENSOR_CL01, UNIT_VOLTS, 2), // Voltage across cell 1, .01V steps
|
SS(I2C_CELLS, 0, uint16le, STR_SENSOR_CL01, UNIT_VOLTS, 2), // Voltage across cell 1, .01V steps
|
||||||
SS(I2C_CELLS, 2, uint16, STR_SENSOR_CL02, UNIT_VOLTS, 2),
|
SS(I2C_CELLS, 2, uint16le, STR_SENSOR_CL02, UNIT_VOLTS, 2),
|
||||||
SS(I2C_CELLS, 4, uint16, STR_SENSOR_CL03, UNIT_VOLTS, 2),
|
SS(I2C_CELLS, 4, uint16le, STR_SENSOR_CL03, UNIT_VOLTS, 2),
|
||||||
SS(I2C_CELLS, 6, uint16, STR_SENSOR_CL04, UNIT_VOLTS, 2),
|
SS(I2C_CELLS, 6, uint16le, STR_SENSOR_CL04, UNIT_VOLTS, 2),
|
||||||
SS(I2C_CELLS, 8, uint16, STR_SENSOR_CL05, UNIT_VOLTS, 2),
|
SS(I2C_CELLS, 8, uint16le, STR_SENSOR_CL05, UNIT_VOLTS, 2),
|
||||||
SS(I2C_CELLS, 10, uint16, STR_SENSOR_CL06, UNIT_VOLTS, 2),
|
SS(I2C_CELLS, 10, uint16le, STR_SENSOR_CL06, UNIT_VOLTS, 2),
|
||||||
SS(I2C_CELLS, 12, uint16, STR_SENSOR_TEMP2, UNIT_CELSIUS, 1), // Temperature, 0.1C (0-655.34C)
|
SS(I2C_CELLS, 12, uint16le, STR_SENSOR_TEMP2, UNIT_CELSIUS, 1), // Temperature, 0.1C (0-655.34C)
|
||||||
|
|
||||||
// 0x40 Vario-S
|
// 0x40 Vario-S
|
||||||
SS(I2C_VARIO, 0, int16, STR_SENSOR_ALT, UNIT_METERS, 1),
|
SS(I2C_VARIO, 0, int16, STR_SENSOR_ALT, UNIT_METERS, 1),
|
||||||
@@ -677,6 +677,12 @@ void processSpektrumPacket(const uint8_t *packet)
|
|||||||
continue; // discard unavailable sensors (farzu: i think might not be needed.. previous validation)
|
continue; // discard unavailable sensors (farzu: i think might not be needed.. previous validation)
|
||||||
} else {
|
} else {
|
||||||
value = value / 10;
|
value = value / 10;
|
||||||
|
if (i2cAddress == I2C_SMART_BAT_CELLS_1_6) {
|
||||||
|
// Map to FrSky style cell values (All Cells in a single Sensor)
|
||||||
|
int cellIndex = ((sensor->startByte-2) / 2) << 16; // First cell is at StartByte 2
|
||||||
|
uint32_t valueCells = cellIndex | value;
|
||||||
|
setTelemetryValue(PROTOCOL_TELEMETRY_SPEKTRUM, I2C_PSEUDO_TX_CELLS, 0, instance, valueCells, UNIT_CELLS, 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // I2C_SMART_BAT_REALTIME
|
} // I2C_SMART_BAT_REALTIME
|
||||||
|
|
||||||
@@ -695,14 +701,14 @@ void processSpektrumPacket(const uint8_t *packet)
|
|||||||
}
|
}
|
||||||
} // I2C_ESC
|
} // I2C_ESC
|
||||||
|
|
||||||
else if (i2cAddress == I2C_CELLS && sensor->unit == UNIT_VOLTS) {
|
else if (i2cAddress == I2C_CELLS) {
|
||||||
if (value == 0x7FFF) continue; // ignore NO-DATA
|
if (value == 0x7FFF) continue; // ignore NO-DATA for Voltage and Temp
|
||||||
|
if (sensor->unit == UNIT_VOLTS) {
|
||||||
// Map to FrSky style cell values (All Cells in a single Sensor)
|
// Map to FrSky style cell values (All Cells in a single Sensor)
|
||||||
int cellIndex = (sensor->startByte / 2) << 16;
|
int cellIndex = (sensor->startByte / 2) << 16; // First Cell is at startByte 0
|
||||||
uint32_t valueCells = cellIndex | value;
|
uint32_t valueCells = cellIndex | value;
|
||||||
setTelemetryValue(PROTOCOL_TELEMETRY_SPEKTRUM, I2C_PSEUDO_TX_CELLS, 0, instance, valueCells, UNIT_CELLS, 2);
|
setTelemetryValue(PROTOCOL_TELEMETRY_SPEKTRUM, I2C_PSEUDO_TX_CELLS, 0, instance, valueCells, UNIT_CELLS, 2);
|
||||||
|
}
|
||||||
// Continue to process regular Single Cell value
|
// Continue to process regular Single Cell value
|
||||||
} // I2C_CELLS
|
} // I2C_CELLS
|
||||||
|
|
||||||
@@ -1145,13 +1151,13 @@ static char test17data[] = {0x17, 0x00, 0x25, 0x00, 0x00,
|
|||||||
static char test34data[] = {0x34, 0x00, 0x2F, 0x00, 0x30, 0x09, 0x85, 0x01,
|
static char test34data[] = {0x34, 0x00, 0x2F, 0x00, 0x30, 0x09, 0x85, 0x01,
|
||||||
0x2B, 0x00, 0x07, 0x0A, 0x81, 0x01 };
|
0x2B, 0x00, 0x07, 0x0A, 0x81, 0x01 };
|
||||||
|
|
||||||
// *********** Lipo monitor (Big-Endian)***************
|
// *********** Lipo monitor (Little-Endian)***************
|
||||||
// Example 0x3A: 0 1 2 3 4 5 6 7 8 9 10 11 12 13
|
// Example 0x3A: 0 1 2 3 4 5 6 7 8 9 10 11 12 13
|
||||||
// 3A 00 | 01 9A | 01 9B | 01 9C | 01 9D | 7F FF | 7F FF | 0F AC
|
// 3A 00 | 01 9A | 01 9B | 01 9C | 01 9D | 7F FF | 7F FF | 0F AC
|
||||||
// 4.10V 4.11V 4.12V 4.12v -- -- 40.1C
|
// 4.10V 4.11V 4.12V 4.12v -- -- 40.1C
|
||||||
static char test3Adata[] = {0x3A, 0x00, 0x01, 0x9A, 0x01, 0x9B, 0x01, 0x9C,
|
static char test3Adata[] = {0x3A, 0x00, 0x9A, 0x01, 0x9B, 0x01, 0x9C, 0x01,
|
||||||
0x01, 0x9D, 0x7F, 0xFF, 0x7F, 0xFF,
|
0x9D, 0x01, 0x7F, 0xFF, 0x7F, 0xFF,
|
||||||
0x01, 0x91 };
|
0x91, 0x01 };
|
||||||
|
|
||||||
|
|
||||||
// RemoteID (0x27), embeds Gps data in its frames, but by puting the real I2C frame
|
// RemoteID (0x27), embeds Gps data in its frames, but by puting the real I2C frame
|
||||||
|
|||||||
Reference in New Issue
Block a user