Skip to content

Commit

Permalink
REUSE - added BEC, BUS, MPU voltage sources to GPS sensor options
Browse files Browse the repository at this point in the history
  • Loading branch information
bob01 committed Mar 31, 2024
1 parent d9785ff commit 0b64ce8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/main/cli/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ const char * const lookupTableCrsfAttReuse[] = {
};

const char * const lookupTableCrsfGpsReuse[] = {
"NONE", "HEADSPEED", "THROTTLE", "ESC_TEMP", "ESC_PWM", "ESC_BEC_VOLTAGE", "ESC_BEC_CURRENT", "ESC_BEC_TEMP", "ESC_STATUS", "ESC_STATUS2", "MCU_TEMP", "MCU_LOAD", "SYS_LOAD", "RT_LOAD",
"NONE", "HEADSPEED", "THROTTLE", "ESC_TEMP", "ESC_PWM", "ESC_BEC_VOLTAGE", "ESC_BEC_CURRENT", "ESC_BEC_TEMP", "ESC_STATUS", "ESC_STATUS2", "MCU_TEMP", "MCU_LOAD", "SYS_LOAD", "RT_LOAD", "BEC_VOLTAGE", "BUS_VOLTAGE", "MCU_VOLTAGE",
};

const char * const lookupTableCrsfGpsSatsReuse[] = {
Expand Down
28 changes: 17 additions & 11 deletions src/main/telemetry/crsf.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,17 @@ uint16 Altitude ( meter ­1000m offset )
uint8_t Satellites in use ( counter )
*/

static int getVoltageMeter(voltageMeterId_e id)
{
voltageMeter_t meter;

voltageMeterRead(id, &meter);

// Use ratio 200 in EdgeTx 2.9.3 and 20 in earlier versions
// Max voltage 25.5V
return meter.voltage * 255 / 200;
}

static int16_t crsfGpsReuse(uint8_t reuse, int16_t value)
{
escSensorData_t *escData;
Expand Down Expand Up @@ -278,6 +289,12 @@ static int16_t crsfGpsReuse(uint8_t reuse, int16_t value)
return getAverageSystemLoad();
case CRSF_GPS_REUSE_RT_LOAD:
return getMaxRealTimeLoad();
case CRSF_GPS_REUSE_BEC_VOLTAGE:
return getVoltageMeter(VOLTAGE_METER_ID_BEC);
case CRSF_GPS_REUSE_BUS_VOLTAGE:
return getVoltageMeter(VOLTAGE_METER_ID_BUS);
case CRSF_GPS_REUSE_MCU_VOLTAGE:
return getVoltageMeter(VOLTAGE_METER_ID_MCU);
}

return 0;
Expand Down Expand Up @@ -435,17 +452,6 @@ static int16_t decidegrees2Radians10000(int16_t angle_decidegree)
return (int16_t)(RAD * 1000.0f * angle_decidegree);
}

static int getVoltageMeter(voltageMeterId_e id)
{
voltageMeter_t meter;

voltageMeterRead(id, &meter);

// Use ratio 200 in EdgeTx 2.9.3 and 20 in earlier versions
// Max voltage 25.5V
return meter.voltage * 255 / 200;
}

static int16_t crsfAttitudeReuse(uint8_t reuse, int attitude)
{
escSensorData_t *escData;
Expand Down
3 changes: 3 additions & 0 deletions src/main/telemetry/crsf.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ enum {
CRSF_GPS_REUSE_MCU_LOAD,
CRSF_GPS_REUSE_SYS_LOAD,
CRSF_GPS_REUSE_RT_LOAD,
CRSF_GPS_REUSE_BEC_VOLTAGE,
CRSF_GPS_REUSE_BUS_VOLTAGE,
CRSF_GPS_REUSE_MCU_VOLTAGE,
};

enum {
Expand Down

0 comments on commit 0b64ce8

Please sign in to comment.