Skip to content

Commit

Permalink
tramp/sa: ensure a valid power level is returned
Browse files Browse the repository at this point in the history
  • Loading branch information
bkleiner committed Mar 14, 2022
1 parent e16ac34 commit f03864a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/drivers/drv_serial_vtx_sa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/drivers/drv_serial_vtx_sa.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
uint8_t smart_audio_dac_power_level_index(uint8_t dac);
4 changes: 2 additions & 2 deletions src/main/vtx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit f03864a

Please sign in to comment.