From c2cfb6f613d43f44c7b0cbadf24e7ece6a39b5e8 Mon Sep 17 00:00:00 2001 From: bkleiner Date: Sat, 10 Aug 2024 11:22:05 +0200 Subject: [PATCH] vtx: increase power level count, inrease label length --- src/driver/vtx/sa.h | 2 +- src/io/msp.c | 6 +++--- src/io/vtx.h | 9 +++++---- src/io/vtx_smartaudio.c | 18 +++++++++--------- src/io/vtx_tramp.c | 18 +++++++++--------- src/osd/render.c | 6 +++--- 6 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/driver/vtx/sa.h b/src/driver/vtx/sa.h index c8102c459..0ba68fc29 100644 --- a/src/driver/vtx/sa.h +++ b/src/driver/vtx/sa.h @@ -28,7 +28,7 @@ typedef struct { uint8_t power; uint8_t mode; uint16_t frequency; - uint16_t dac_power_levels[5]; + uint16_t dac_power_levels[8]; } smart_audio_settings_t; void serial_smart_audio_init(); diff --git a/src/io/msp.c b/src/io/msp.c index 92e694ace..2b5630fce 100644 --- a/src/io/msp.c +++ b/src/io/msp.c @@ -477,8 +477,8 @@ static void msp_process_serial_cmd(msp_t *msp, msp_magic_t magic, uint16_t cmd, buf[0] = level; buf[1] = power & 0xFF; buf[2] = power >> 8; - buf[3] = 3; - memcpy(buf + 4, vtx_actual.power_table.labels[level - 1], 3); + buf[3] = VTX_POWER_LABEL_LEN; + memcpy(buf + 4, vtx_actual.power_table.labels[level - 1], VTX_POWER_LABEL_LEN); msp_send_reply(msp, magic, cmd, buf, 7); break; @@ -495,7 +495,7 @@ static void msp_process_serial_cmd(msp_t *msp, msp_magic_t magic, uint16_t cmd, vtx_actual.power_table.values[level - 1] = payload[2] << 8 | payload[1]; const uint8_t label_len = payload[3]; - for (uint8_t i = 0; i < 3; i++) { + for (uint8_t i = 0; i < VTX_POWER_LABEL_LEN; i++) { vtx_actual.power_table.labels[level - 1][i] = i >= label_len ? 0 : payload[4 + i]; } msp_send_reply(msp, magic, cmd, NULL, 0); diff --git a/src/io/vtx.h b/src/io/vtx.h index 48201698d..84263a583 100644 --- a/src/io/vtx.h +++ b/src/io/vtx.h @@ -4,6 +4,7 @@ #define VTX_SETTINGS_MAGIC 0xdeed #define VTX_APPLY_TRIES 50 +#define VTX_POWER_LABEL_LEN 5 typedef enum { VTX_DETECT_WAIT, @@ -68,13 +69,13 @@ typedef enum { typedef struct { uint8_t levels; - char labels[VTX_POWER_LEVEL_MAX][3]; + char labels[VTX_POWER_LEVEL_MAX][VTX_POWER_LABEL_LEN]; uint16_t values[VTX_POWER_LEVEL_MAX]; } vtx_power_table_t; -#define VTX_POWER_TABLE_MEMBERS \ - MEMBER(levels, uint8_t) \ - TSTR_ARRAY_MEMBER(labels, VTX_POWER_LEVEL_MAX, 3) \ +#define VTX_POWER_TABLE_MEMBERS \ + MEMBER(levels, uint8_t) \ + TSTR_ARRAY_MEMBER(labels, VTX_POWER_LEVEL_MAX, VTX_POWER_LABEL_LEN) \ ARRAY_MEMBER(values, VTX_POWER_LEVEL_MAX, uint16_t) typedef struct { diff --git a/src/io/vtx_smartaudio.c b/src/io/vtx_smartaudio.c index ede229326..31bea9e06 100644 --- a/src/io/vtx_smartaudio.c +++ b/src/io/vtx_smartaudio.c @@ -17,15 +17,15 @@ extern smart_audio_settings_t smart_audio_settings; static bool smart_audio_needs_update = false; -static const char smart_audio_power_level_labels[VTX_POWER_LEVEL_MAX][3] = { - "25 ", - "100", - "200", - "300", - "400", - " ", - " ", - " ", +static const char smart_audio_power_level_labels[VTX_POWER_LEVEL_MAX][VTX_POWER_LABEL_LEN] = { + "25 ", + "100 ", + "200 ", + "300 ", + "400 ", + " ", + " ", + " ", }; vtx_detect_status_t vtx_smart_audio_update(vtx_settings_t *actual) { diff --git a/src/io/vtx_tramp.c b/src/io/vtx_tramp.c index 3582ca20c..21ccb59a2 100644 --- a/src/io/vtx_tramp.c +++ b/src/io/vtx_tramp.c @@ -23,15 +23,15 @@ static const uint16_t tramp_power_level_values[VTX_POWER_LEVEL_MAX] = { 400, }; -static const char tramp_power_level_labels[VTX_POWER_LEVEL_MAX][3] = { - "25 ", - "100", - "200", - "300", - "400", - " ", - " ", - " ", +static const char tramp_power_level_labels[VTX_POWER_LEVEL_MAX][VTX_POWER_LABEL_LEN] = { + "25 ", + "100 ", + "200 ", + "300 ", + "400 ", + " ", + " ", + " ", }; vtx_detect_status_t vtx_tramp_update(vtx_settings_t *actual) { diff --git a/src/osd/render.c b/src/osd/render.c index 2032d2c49..6433ec13b 100644 --- a/src/osd/render.c +++ b/src/osd/render.c @@ -927,12 +927,12 @@ void osd_display() { case OSD_SCREEN_VTX: #ifdef USE_VTX if (vtx_settings.detected) { - static char power_level_labels_terminated[VTX_POWER_LEVEL_MAX][4]; + static char power_level_labels_terminated[VTX_POWER_LEVEL_MAX][VTX_POWER_LABEL_LEN + 1]; if (!vtx_buffer_populated) { vtx_settings_copy = vtx_settings; for (uint8_t i = 0; i < VTX_POWER_LEVEL_MAX; i++) { - memcpy(power_level_labels_terminated[i], vtx_settings.power_table.labels[i], 3); - power_level_labels_terminated[i][3] = 0; + memcpy(power_level_labels_terminated[i], vtx_settings.power_table.labels[i], VTX_POWER_LABEL_LEN); + power_level_labels_terminated[i][VTX_POWER_LABEL_LEN] = 0; } vtx_buffer_populated = 1; }