Skip to content

Commit 0363368

Browse files
committed
make only one setting for custom telemetry
1 parent 646bf7e commit 0363368

File tree

7 files changed

+39
-71
lines changed

7 files changed

+39
-71
lines changed

docs/Settings.md

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -602,16 +602,6 @@ CRSF telemetry link ratio
602602

603603
---
604604

605-
### crsf_telemetry_mode
606-
607-
Use extended custom or native telemetry sensors for CRSF
608-
609-
| Default | Min | Max |
610-
| --- | --- | --- |
611-
| NATIVE | | |
612-
613-
---
614-
615605
### cruise_power
616606

617607
Power draw at cruise throttle used for remaining flight time/distance estimation in 0.01W unit
@@ -6222,16 +6212,6 @@ _// TODO_
62226212

62236213
---
62246214

6225-
### smartport_telemetry_mode
6226-
6227-
Use legacy or standard telemetry sensors for SmartPort
6228-
6229-
| Default | Min | Max |
6230-
| --- | --- | --- |
6231-
| LEGACY | | |
6232-
6233-
---
6234-
62356215
### smith_predictor_delay
62366216

62376217
Expected delay of the gyro signal. In milliseconds
@@ -6382,6 +6362,16 @@ Determines if the telemetry protocol default signal inversion is reversed. This
63826362

63836363
---
63846364

6365+
### telemetry_mode
6366+
6367+
Use extended custom or native telemetry sensors for CRSF or SmartPort
6368+
6369+
| Default | Min | Max |
6370+
| --- | --- | --- |
6371+
| LEGACY | | |
6372+
6373+
---
6374+
63856375
### telemetry_switch
63866376

63876377
Which aux channel to use to change serial output & baud rate (MSP / Telemetry). It disables automatic switching to Telemetry when armed.

src/main/fc/settings.yaml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,9 @@ tables:
103103
- name: bat_voltage_source
104104
values: ["RAW", "SAG_COMP"]
105105
enum: batVoltageSource_e
106-
- name: crsf_telemetry_modes
107-
values: [ "OFF", "NATIVE", "CUSTOM" ]
108-
enum: crsfTelemetryMode_e
109-
- name: smartport_telemetry_modes
110-
values: [ "LEGACY", "STANDARD" ]
111-
enum: smartportTelemetryMode_e
106+
- name: telemetry_modes
107+
values: [ "LEGACY", "CUSTOM" ]
108+
enum: telemetryMode_e
112109
- name: smartport_fuel_unit
113110
values: ["PERCENT", "MAH", "MWH"]
114111
enum: smartportFuelUnit_e
@@ -3123,17 +3120,11 @@ groups:
31233120
description: "S.Port telemetry: Send pitch and roll degrees*10 instead of raw accelerometer data"
31243121
default_value: OFF
31253122
type: bool
3126-
- name: crsf_telemetry_mode
3127-
description: "Use extended custom or native telemetry sensors for CRSF"
3128-
default_value: NATIVE
3129-
condition: USE_CUSTOM_TELEMETRY
3130-
table: crsf_telemetry_modes
3131-
type: uint8_t
3132-
- name: smartport_telemetry_mode
3133-
description: "Use legacy or standard telemetry sensors for SmartPort"
3123+
- name: telemetry_mode
3124+
description: "Use extended custom or native telemetry sensors for CRSF or SmartPort"
31343125
default_value: LEGACY
31353126
condition: USE_CUSTOM_TELEMETRY
3136-
table: smartport_telemetry_modes
3127+
table: telemetry_modes
31373128
type: uint8_t
31383129
- name: crsf_telemetry_link_rate
31393130
description: "CRSF telemetry link rate"

src/main/target/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
#define USE_TELEMETRY_JETIEXBUS
156156

157157
#if defined(USE_TELEMETRY_SMARTPORT) || defined(USE_TELEMETRY_CRSF)
158-
#define USE_CUSTOM_TELEMETRY
158+
//#define USE_CUSTOM_TELEMETRY
159159
#endif
160160

161161
// These are rather exotic serial protocols

src/main/telemetry/crsf.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ void crsfSendMspResponse(uint8_t *payload, const uint8_t payloadSize)
739739

740740
static bool crsfSendNativeTelemetry(void)
741741
{
742-
if (crsfTelemetryState != CRSFR_TELEMETRY_STATE_NATIVE)
742+
if (crsfTelemetryState != TELEMETRY_STATE_LEGACY)
743743
{
744744
return false;
745745
}
@@ -799,7 +799,7 @@ static bool crsfSendNativeTelemetry(void)
799799
#ifdef USE_CUSTOM_TELEMETRY
800800
static bool crsfSendCustomTelemetry(void)
801801
{
802-
if (crsfTelemetryState == CRSFR_TELEMETRY_STATE_CUSTOM)
802+
if (crsfTelemetryState == TELEMETRY_STATE_CUSTOM)
803803
{
804804
size_t sensor_count = 0;
805805
sbuf_t *dst = crsfInitializeSbuf(); // prepare buffer
@@ -841,7 +841,7 @@ static bool crsfSendCustomTelemetry(void)
841841
#ifdef USE_CUSTOM_TELEMETRY
842842
static bool crsfPopulateCustomTelemetry(void)
843843
{
844-
if (crsfTelemetryState == CRSFR_TELEMETRY_STATE_POPULATE)
844+
if (crsfTelemetryState == TELEMETRY_STATE_POPULATE)
845845
{
846846
static int slot = -10;
847847

@@ -883,7 +883,7 @@ static bool crsfPopulateCustomTelemetry(void)
883883
}
884884
}
885885

886-
crsfTelemetryState = CRSFR_TELEMETRY_STATE_CUSTOM;
886+
crsfTelemetryState = TELEMETRY_STATE_CUSTOM;
887887
}
888888

889889
return false;
@@ -985,9 +985,9 @@ void initCrsfTelemetry(void)
985985
// and feature is enabled, if so, set CRSF telemetry enabled
986986

987987
#ifdef USE_CUSTOM_TELEMETRY
988-
crsfTelemetryState = !crsfRxIsActive() ? CRSFR_TELEMETRY_STATE_OFF : (telemetryConfig()->crsf_telemetry_mode == CRSFR_TELEMETRY_STATE_NATIVE ? CRSFR_TELEMETRY_STATE_NATIVE : CRSFR_TELEMETRY_STATE_POPULATE);
988+
crsfTelemetryState = !crsfRxIsActive() ? TELEMETRY_STATE_OFF : (telemetryConfig()->telemetry_mode == TELEMETRY_MODE_LEGACY ? TELEMETRY_STATE_LEGACY : TELEMETRY_STATE_POPULATE);
989989
#else
990-
crsfTelemetryState = !crsfRxIsActive() ? CRSFR_TELEMETRY_STATE_OFF : CRSFR_TELEMETRY_STATE_NATIVE;
990+
crsfTelemetryState = !crsfRxIsActive() ? TELEMETRY_STATE_OFF : TELEMETRY_STATE_LEGACY;
991991
#endif
992992

993993
if(crsfTelemetryState) {
@@ -1004,7 +1004,7 @@ void initCrsfTelemetry(void)
10041004
mspReplyPending = false;
10051005
#endif
10061006
#ifdef USE_CUSTOM_TELEMETRY
1007-
if (crsfTelemetryState == CRSFR_TELEMETRY_STATE_NATIVE) {
1007+
if (crsfTelemetryState == TELEMETRY_STATE_LEGACY) {
10081008
initCrsfNativeSensors();
10091009
} else {
10101010
initCrsfCustomSensors();

src/main/telemetry/smartport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ static void smartPortWriteFrameInternal(const smartPortPayload_t *payload)
287287
static void initSmartPortSensors(void)
288288
{
289289
#ifdef USE_CUSTOM_TELEMETRY
290-
if(telemetryConfig()->smartport_telemetry_mode == SMARTPORT_TELEMETRY_STATE_LEGACY) {
290+
if(telemetryConfig()->telemetry_mode == TELEMETRY_MODE_LEGACY) {
291291
initSmartPortSensorsLegacy();
292292
} else {
293293
telemetryScheduleInit(smartportTelemetrySensors, ARRAYLEN(smartportTelemetrySensors));

src/main/telemetry/telemetry.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,13 @@ PG_RESET_TEMPLATE(telemetryConfig_t, telemetryConfig,
103103
#ifdef USE_TELEMETRY_CRSF
104104
.crsf_telemetry_link_rate = SETTING_CRSF_TELEMETRY_LINK_RATE_DEFAULT,
105105
.crsf_telemetry_link_ratio = SETTING_CRSF_TELEMETRY_LINK_RATIO_DEFAULT,
106-
#ifdef USE_CUSTOM_TELEMETRY
107-
.crsf_telemetry_mode = SETTING_CRSF_TELEMETRY_MODE_DEFAULT,
108-
#endif //USE_CUSTOM_TELEMETRY
109106
#endif //USE_TELEMETRY_CRSF
110107

111-
#if defined(USE_TELEMETRY_SMARTPORT) && defined(USE_CUSTOM_TELEMETRY)
112-
#if !defined(SETTING_SMARTPORT_TELEMETRY_MODE_DEFAULT) // SITL
113-
.smartport_telemetry_mode = 0,
114-
#else
115-
.smartport_telemetry_mode = SETTING_SMARTPORT_TELEMETRY_MODE_DEFAULT,
116-
#endif
117-
#endif // USE_TELEMETRY_SMARTPORT USE_CUSTOM_TELEMETRY
118-
#ifdef USE_CUSTOM_TELEMETRY
108+
#if defined(USE_CUSTOM_TELEMETRY)
109+
.telemetry_mode = SETTING_TELEMETRY_MODE_DEFAULT,
119110
.telemetry_sensors = { 0x0, }, // all sensors enabled by default
120111
#endif
112+
121113
);
122114

123115
void telemetryInit(void)

src/main/telemetry/telemetry.h

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,16 @@ typedef enum {
5555
} smartportFuelUnit_e;
5656

5757
typedef enum {
58-
CRSFR_TELEMETRY_STATE_OFF = 0,
59-
CRSFR_TELEMETRY_STATE_NATIVE,
60-
CRSFR_TELEMETRY_STATE_CUSTOM,
61-
CRSFR_TELEMETRY_STATE_POPULATE,
62-
} crsfTelemetryMode_e;
58+
TELEMETRY_STATE_OFF = 0,
59+
TELEMETRY_STATE_LEGACY,
60+
TELEMETRY_STATE_CUSTOM,
61+
TELEMETRY_STATE_POPULATE,
62+
} telemetryState_e;
6363

6464
typedef enum {
65-
SMARTPORT_TELEMETRY_STATE_LEGACY = 0,
66-
SMARTPORT_CRSFR_TELEMETRY_STATE_STANDARD,
67-
} smartportTelemetryMode_e;
65+
TELEMETRY_MODE_LEGACY,
66+
TELEMETRY_MODE_CUSTOM,
67+
} telemetryMode_e;
6868

6969
typedef struct telemetryConfig_s {
7070
uint8_t telemetry_switch; // Use aux channel to change serial output & baudrate( MSP / Telemetry ). It disables automatic switching to Telemetry when armed.
@@ -104,18 +104,13 @@ typedef struct telemetryConfig_s {
104104
#ifdef USE_TELEMETRY_CRSF
105105
uint16_t crsf_telemetry_link_rate;
106106
uint16_t crsf_telemetry_link_ratio;
107-
#ifdef USE_CUSTOM_TELEMETRY
108-
uint8_t crsf_telemetry_mode;
109-
#endif
110-
#endif
111-
112-
#if defined(USE_TELEMETRY_SMARTPORT) && defined(USE_CUSTOM_TELEMETRY)
113-
uint8_t smartport_telemetry_mode;
114107
#endif
115108

116-
#ifdef USE_CUSTOM_TELEMETRY
109+
#if defined(USE_CUSTOM_TELEMETRY)
110+
uint8_t telemetry_mode;
117111
uint16_t telemetry_sensors[TELEM_SENSOR_SLOT_COUNT];
118112
#endif
113+
119114
} telemetryConfig_t;
120115

121116
typedef struct {

0 commit comments

Comments
 (0)