From f03864a42b7f3b43274033d19f3032ba840facf8 Mon Sep 17 00:00:00 2001 From: bkleiner Date: Mon, 14 Mar 2022 22:56:40 +0100 Subject: [PATCH] tramp/sa: ensure a valid power level is returned --- src/drivers/drv_serial_vtx_sa.c | 4 ++-- src/drivers/drv_serial_vtx_sa.h | 2 +- src/main/vtx.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/drivers/drv_serial_vtx_sa.c b/src/drivers/drv_serial_vtx_sa.c index 51731001b..388283644 100644 --- a/src/drivers/drv_serial_vtx_sa.c +++ b/src/drivers/drv_serial_vtx_sa.c @@ -380,13 +380,13 @@ void serial_smart_audio_send_payload(uint8_t cmd, const uint8_t *payload, const vtx_last_valid_read = time_millis(); } -int8_t smart_audio_dac_power_level_index(uint8_t dac) { +uint8_t smart_audio_dac_power_level_index(uint8_t dac) { for (uint8_t level = 0; level < 4; level++) { if (dac == smart_audio_settings.dac_power_levels[level]) { return level; } } - return -1; + return 0; } #endif diff --git a/src/drivers/drv_serial_vtx_sa.h b/src/drivers/drv_serial_vtx_sa.h index aa99c8c98..e7695d323 100644 --- a/src/drivers/drv_serial_vtx_sa.h +++ b/src/drivers/drv_serial_vtx_sa.h @@ -34,4 +34,4 @@ typedef struct { void serial_smart_audio_init(); vtx_update_result_t serial_smart_audio_update(); void serial_smart_audio_send_payload(uint8_t cmd, const uint8_t *payload, const uint32_t size); -int8_t smart_audio_dac_power_level_index(uint8_t dac); \ No newline at end of file +uint8_t smart_audio_dac_power_level_index(uint8_t dac); \ No newline at end of file diff --git a/src/main/vtx.c b/src/main/vtx.c index d14a8e747..fb62dedde 100644 --- a/src/main/vtx.c +++ b/src/main/vtx.c @@ -191,13 +191,13 @@ const uint16_t tramp_power_level[4] = { 400, }; -int8_t tramp_power_level_index(uint16_t power) { +vtx_power_level_t tramp_power_level_index(uint16_t power) { for (uint8_t level = 0; level < VTX_POWER_LEVEL_MAX; level++) { if (power >= tramp_power_level[level] && power <= tramp_power_level[level]) { return level; } } - return -1; + return VTX_POWER_LEVEL_1; } vtx_detect_status_t vtx_tramp_update(vtx_settings_t *actual) {