Skip to content

Commit

Permalink
vtx: increase power level count, inrease label length
Browse files Browse the repository at this point in the history
  • Loading branch information
bkleiner committed Aug 10, 2024
1 parent c32e667 commit c2cfb6f
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/driver/vtx/sa.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/io/msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions src/io/vtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
18 changes: 9 additions & 9 deletions src/io/vtx_smartaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
18 changes: 9 additions & 9 deletions src/io/vtx_tramp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/osd/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit c2cfb6f

Please sign in to comment.