Skip to content

Commit

Permalink
Add more CRSF FM reuse options
Browse files Browse the repository at this point in the history
  • Loading branch information
pmattila committed Oct 16, 2023
1 parent aca3256 commit 05ac008
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/main/cli/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ const char * const lookupTableSwashType[] = {
};

const char * const lookupTableCrsfFmReuse[] = {
"NONE", "RPM", "TEMP", "ADJFUNC",
"NONE", "HEADSPEED", "MCU_TEMP", "ESC_TEMP", "THROTTLE", "ADJFUNC",
};

const char * const lookupTableDtermMode[] = {
Expand Down
48 changes: 34 additions & 14 deletions src/main/telemetry/crsf.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include "flight/imu.h"
#include "flight/motors.h"
#include "flight/position.h"
#include "flight/governor.h"

#include "io/displayport_crsf.h"
#include "io/gps.h"
Expand All @@ -66,6 +67,7 @@
#include "sensors/battery.h"
#include "sensors/sensors.h"
#include "sensors/adcinternal.h"
#include "sensors/esc_sensor.h"

#include "telemetry/telemetry.h"
#include "telemetry/msp_shared.h"
Expand Down Expand Up @@ -377,40 +379,58 @@ static void crsfFlightModeInfo(char *buf)
tfp_sprintf(buf, "%s%c", flightMode, armChar);
}

static void crsfRpmInfo(char *buf)
static void crsfHeadspeedInfo(char *buf)
{
int val = lrintf(getHeadSpeed());
tfp_sprintf(buf, "RPM: %d", val);
int val = getHeadSpeed();
tfp_sprintf(buf, "%d", val);
}

static void crsfTempInfo(char *buf)
static void crsfMCUTempInfo(char *buf)
{
int val = getCoreTemperatureCelsius();
tfp_sprintf(buf, "Temp: %dC", val);
tfp_sprintf(buf, "%d", val);
}

static void crsfESCTempInfo(char *buf)
{
escSensorData_t *escData = getEscSensorData(ESC_SENSOR_COMBINED);
if (escData) {
int val = escData->temperature;
tfp_sprintf(buf, "%d", val);
}
}

static void crsfThrottleInfo(char *buf)
{
int val = lrintf(getGovernorOutput() * 100);
tfp_sprintf(buf, "%d", val);
}

static void crsfAdjFuncInfo(char *buf)
{
if (getAdjustmentsRangeName()) {
int fun = getAdjustmentsRangeFunc();
int val = getAdjustmentsRangeValue();
tfp_sprintf(buf, "ADJ %d:%d", fun, val);
}
else {
buf[0] = 0;
tfp_sprintf(buf, "%d:%d", fun, val);
}
}

void crsfFrameFlightMode(sbuf_t *dst)
{
char buff[32];
char buff[32] = { 0, };

switch (rxConfig()->crsf_flight_mode_reuse) {
case CRSF_FM_REUSE_RPM:
crsfRpmInfo(buff);
case CRSF_FM_REUSE_HEADSPEED:
crsfHeadspeedInfo(buff);
break;
case CRSF_FM_REUSE_MCU_TEMP:
crsfMCUTempInfo(buff);
break;
case CRSF_FM_REUSE_ESC_TEMP:
crsfESCTempInfo(buff);
break;
case CRSF_FM_REUSE_TEMP:
crsfTempInfo(buff);
case CRSF_FM_REUSE_THROTTLE:
crsfThrottleInfo(buff);
break;
case CRSF_FM_REUSE_ADJFUNC:
crsfAdjFuncInfo(buff);
Expand Down
6 changes: 4 additions & 2 deletions src/main/telemetry/crsf.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@

enum {
CRSF_FM_REUSE_NONE = 0,
CRSF_FM_REUSE_RPM,
CRSF_FM_REUSE_TEMP,
CRSF_FM_REUSE_HEADSPEED,
CRSF_FM_REUSE_MCU_TEMP,
CRSF_FM_REUSE_ESC_TEMP,
CRSF_FM_REUSE_THROTTLE,
CRSF_FM_REUSE_ADJFUNC,
};

Expand Down

0 comments on commit 05ac008

Please sign in to comment.