Add Ghost pack telemetry (#8110)

This commit is contained in:
3djc
2020-11-22 08:23:55 +01:00
committed by 3djc
parent 462ed53f9a
commit b0e85ab288
2 changed files with 26 additions and 0 deletions
+25
View File
@@ -46,6 +46,9 @@ enum
GHOST_ID_VTX_CHAN = 0x000a, // Vtx Channel
GHOST_ID_VTX_BAND = 0x000b, // Vtx Band
GHOST_ID_PACK_VOLTS = 0x000c, // Battery Pack Voltage
GHOST_ID_PACK_AMPS = 0x000d, // Battery Pack Current
GHOST_ID_PACK_MAH = 0x000e, // Battery Pack mAh consumed
};
const GhostSensor ghostSensors[] = {
@@ -63,6 +66,10 @@ const GhostSensor ghostSensors[] = {
{GHOST_ID_VTX_CHAN, ZSTR_VTX_CHAN, UNIT_RAW, 0},
{GHOST_ID_VTX_BAND, ZSTR_VTX_BAND, UNIT_TEXT, 0},
{GHOST_ID_PACK_VOLTS, ZSTR_BATT, UNIT_VOLTS, 2},
{GHOST_ID_PACK_AMPS, ZSTR_CURR, UNIT_AMPS, 2},
{GHOST_ID_PACK_MAH, ZSTR_CAPACITY, UNIT_MAH, 0},
{0x00, NULL, UNIT_RAW, 0},
};
@@ -103,6 +110,11 @@ uint16_t getTelemetryValue_u16(uint8_t index)
return (telemetryRxBuffer[index] << 8) | telemetryRxBuffer[index + 1];
}
uint16_t getTelemetryValue_u16le(uint8_t index)
{
return (telemetryRxBuffer[index + 1] << 8) | telemetryRxBuffer[index];
}
uint32_t getTelemetryValue_s32(uint8_t index)
{
uint32_t val = 0;
@@ -200,6 +212,19 @@ void processGhostTelemetryFrame()
lineData->menuUpdateNeeded = true;
break;
}
case GHST_DL_PACK_STAT: {
#if defined(BLUETOOTH)
if (g_eeGeneral.bluetoothMode == BLUETOOTH_TELEMETRY && bluetooth.state == BLUETOOTH_STATE_CONNECTED) {
bluetooth.write(telemetryRxBuffer, telemetryRxBufferCount);
}
#endif
processGhostTelemetryValue(GHOST_ID_PACK_VOLTS, getTelemetryValue_u16le(3));
processGhostTelemetryValue(GHOST_ID_PACK_AMPS, getTelemetryValue_u16le(5));
processGhostTelemetryValue(GHOST_ID_PACK_MAH, getTelemetryValue_u16le(7) * 10);
break;
}
}
}
+1
View File
@@ -42,6 +42,7 @@
#define GHST_DL_OPENTX_SYNC 0x20
#define GHST_DL_LINK_STAT 0x21
#define GHST_DL_VTX_STAT 0x22
#define GHST_DL_PACK_STAT 0x23
#define GHST_DL_MENU_DESC 0x24
#define GHST_RC_CTR_VAL_12BIT 0x7C0 // 0x3e0 << 1