diff --git a/src/frsky.cpp b/src/frsky.cpp index 1a8604842..52688d5dc 100644 --- a/src/frsky.cpp +++ b/src/frsky.cpp @@ -264,6 +264,12 @@ void parseTelemHubByte(uint8_t byte) frskyData.hub.maxCurrent = frskyData.hub.current; break; + case offsetof(FrskyHubData, volts_ap): + frskyData.hub.vfas = ((frskyData.hub.volts_bp * 100 + frskyData.hub.volts_bp) * 21) / 11; + /* TODO later if (!frskyData.hub.minVfas || frskyData.hub.minVfas > frskyData.hub.vfas) + frskyData.hub.minVfas = frskyData.hub.vfas; */ + break; + case offsetof(FrskyHubData, baroAltitude_bp): // First received barometer altitude => Altitude offset if (!frskyData.hub.baroAltitudeOffset) @@ -625,24 +631,25 @@ void check_frsky() } #endif + uint16_t voltage = 0; + for (uint8_t i=0; i= FRSKY_SOURCE_A1) { + uint8_t channel = g_model.frsky.voltsSource - FRSKY_SOURCE_A1; + voltage = applyChannelRatio(channel, frskyData.analog[channel].value); + } + uint16_t current = frskyData.hub.current; if (g_model.frsky.currentSource >= FRSKY_SOURCE_A1) { uint8_t channel = g_model.frsky.currentSource - FRSKY_SOURCE_A1; current = applyChannelRatio(channel, frskyData.analog[channel].value); } - frskyData.currentPrescale += current; - uint16_t voltage = 0; - if (g_model.frsky.voltsSource >= FRSKY_SOURCE_A1) { - uint8_t channel = g_model.frsky.voltsSource - FRSKY_SOURCE_A1; - voltage = applyChannelRatio(channel, frskyData.analog[channel].value); - } - else { - for (uint8_t i=0; i= currentConsumptionBoundary) { frskyData.currentConsumption += 1; frskyData.currentPrescale -= currentConsumptionBoundary; @@ -956,10 +963,11 @@ void putsTelemetryChannel(uint8_t x, uint8_t y, uint8_t channel, int16_t val, ui } case TELEM_CELL-1: + case TELEM_VFAS-1: putsTelemetryValue(x, y, val, UNIT_VOLTS, att|PREC2); break; - case TELEM_VOLTAGE-1: + case TELEM_CELLS_SUM-1: putsTelemetryValue(x, y, val, UNIT_VOLTS, att|PREC1); break; diff --git a/src/frsky.h b/src/frsky.h index 19271a2a4..f1ccb3880 100644 --- a/src/frsky.h +++ b/src/frsky.h @@ -139,6 +139,9 @@ PACK(struct FrskyHubData { int16_t varioSpeed; uint8_t varioAltitudeQueuePointer; // circular-buffer pointer uint8_t minCellIdx; + uint16_t cellsSum; + uint16_t vfas; + // TODO later uint16_t minVfas; }); #elif defined(WS_HOW_HIGH) @@ -158,7 +161,6 @@ struct FrskyData { #endif uint16_t currentConsumption; uint16_t currentPrescale; - uint16_t voltage; uint16_t power; }; diff --git a/src/myeeprom.h b/src/myeeprom.h index adf93ae9e..7f22b2286 100644 --- a/src/myeeprom.h +++ b/src/myeeprom.h @@ -382,7 +382,8 @@ enum TelemetrySource { TELEM_DIST, TELEM_GPSALT, TELEM_CELL, - TELEM_VOLTAGE, + TELEM_CELLS_SUM, + TELEM_VFAS, TELEM_CURRENT, TELEM_CONSUMPTION, TELEM_POWER, diff --git a/src/open9x.cpp b/src/open9x.cpp index 67bc13e53..01cddef15 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -487,7 +487,8 @@ int16_t getValue(uint8_t i) else if(i