From 84f39c4c66f28d48d71358d94a637856f8ca3e70 Mon Sep 17 00:00:00 2001 From: p-i-engineer Date: Mon, 20 May 2024 11:00:44 +0100 Subject: [PATCH] Add model_id parameter and CRSF reuse option --- src/main/cli/settings.c | 6 ++++-- src/main/config/config.c | 1 + src/main/config/config.h | 1 + src/main/telemetry/crsf.c | 2 ++ src/main/telemetry/crsf.h | 1 + 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/cli/settings.c b/src/main/cli/settings.c index 22893ab8d1..d2e311e452 100644 --- a/src/main/cli/settings.c +++ b/src/main/cli/settings.c @@ -497,7 +497,7 @@ const char * const lookupTableCrsfGpsReuse[] = { }; const char * const lookupTableCrsfGpsSatsReuse[] = { - "NONE", "ESC_TEMP", "MCU_TEMP", "PROFILE", "RATE_PROFILE", "LED_PROFILE", + "NONE", "ESC_TEMP", "MCU_TEMP", "PROFILE", "RATE_PROFILE", "LED_PROFILE", "MODEL_ID", }; const char * const lookupTableDtermMode[] = { @@ -969,7 +969,6 @@ const clivalue_t valueTable[] = { { "auto_disarm_delay", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 60 }, PG_ARMING_CONFIG, offsetof(armingConfig_t, auto_disarm_delay) }, { PARAM_NAME_GYRO_CAL_ON_FIRST_ARM, VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_ARMING_CONFIG, offsetof(armingConfig_t, gyro_cal_on_first_arm) }, - // PG_GPS_CONFIG #ifdef USE_GPS { "gps_provider", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_GPS_PROVIDER }, PG_GPS_CONFIG, offsetof(gpsConfig_t, provider) }, @@ -1675,10 +1674,13 @@ const clivalue_t valueTable[] = { { "stats_total_time_s", VAR_UINT32 | MASTER_VALUE, .config.u32Max = UINT32_MAX, PG_STATS_CONFIG, offsetof(statsConfig_t, stats_total_time_s) }, { "stats_total_dist_m", VAR_UINT32 | MASTER_VALUE, .config.u32Max = UINT32_MAX, PG_STATS_CONFIG, offsetof(statsConfig_t, stats_total_dist_m) }, #endif + +// PG_PILOT_CONFIG { "name", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_NAME_LENGTH, STRING_FLAGS_NONE }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, name) }, #ifdef USE_OSD { "display_name", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_NAME_LENGTH, STRING_FLAGS_NONE }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, displayName) }, #endif + { "model_id", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 99 }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, modelId) }, // PG_POSITION { "position_alt_source", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_POSITION_ALT_SOURCE }, PG_POSITION, offsetof(positionConfig_t, alt_source) }, diff --git a/src/main/config/config.c b/src/main/config/config.c index cd1a2fee66..86ae121d1a 100644 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -112,6 +112,7 @@ PG_REGISTER_WITH_RESET_TEMPLATE(pilotConfig_t, pilotConfig, PG_PILOT_CONFIG, 1); PG_RESET_TEMPLATE(pilotConfig_t, pilotConfig, .name = { 0 }, .displayName = { 0 }, + .modelId = 0, ); PG_REGISTER_WITH_RESET_TEMPLATE(systemConfig_t, systemConfig, PG_SYSTEM_CONFIG, 3); diff --git a/src/main/config/config.h b/src/main/config/config.h index 74198c66a1..a82da853ee 100644 --- a/src/main/config/config.h +++ b/src/main/config/config.h @@ -36,6 +36,7 @@ typedef enum { typedef struct pilotConfig_s { char name[MAX_NAME_LENGTH + 1]; char displayName[MAX_NAME_LENGTH + 1]; + uint8_t modelId; } pilotConfig_t; PG_DECLARE(pilotConfig_t, pilotConfig); diff --git a/src/main/telemetry/crsf.c b/src/main/telemetry/crsf.c index 52360d1503..b26f72230c 100644 --- a/src/main/telemetry/crsf.c +++ b/src/main/telemetry/crsf.c @@ -346,6 +346,8 @@ static int8_t crsfGpsSatsReuse(uint8_t reuse, int8_t value) return getCurrentPidProfileIndex() + 1; case CRSF_GPS_SATS_REUSE_RATE_PROFILE: return getCurrentControlRateProfileIndex() + 1; + case CRSF_GPS_SATS_REUSE_MODEL_ID: + return pilotConfig()->modelId; case CRSF_GPS_SATS_REUSE_LED_PROFILE: #ifdef USE_LED_STRIP return getLedProfile() + 1; diff --git a/src/main/telemetry/crsf.h b/src/main/telemetry/crsf.h index ceaab554ff..5710e3a440 100644 --- a/src/main/telemetry/crsf.h +++ b/src/main/telemetry/crsf.h @@ -92,6 +92,7 @@ enum { CRSF_GPS_SATS_REUSE_PROFILE, CRSF_GPS_SATS_REUSE_RATE_PROFILE, CRSF_GPS_SATS_REUSE_LED_PROFILE, + CRSF_GPS_SATS_REUSE_MODEL_ID, }; void initCrsfTelemetry(void);