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 d16e32d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 31 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
8 changes: 4 additions & 4 deletions src/io/msp.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,12 @@ static void msp_process_serial_cmd(msp_t *msp, msp_magic_t magic, uint16_t cmd,

const uint16_t power = vtx_actual.power_table.values[level - 1];

uint8_t buf[7];
uint8_t buf[4 + VTX_POWER_LABEL_LEN];
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
8 changes: 4 additions & 4 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 All @@ -945,7 +945,7 @@ void osd_display() {

const char *channel_labels[] = {"1", "2", "3", "4", "5", "6", "7", "8"};
osd_menu_select_enum_adjust(4, 5, "CHANNEL", 20, &vtx_settings_copy.channel, channel_labels, VTX_CHANNEL_1, VTX_CHANNEL_8);
osd_menu_select_enum_adjust(4, 6, "POWER LEVEL", 20, &vtx_settings_copy.power_level, power_level_labels_terminated, VTX_POWER_LEVEL_1, VTX_POWER_LEVEL_MAX - 1);
osd_menu_select_enum_adjust(4, 6, "POWER LEVEL", 20, &vtx_settings_copy.power_level, (const char **)power_level_labels_terminated, VTX_POWER_LEVEL_1, VTX_POWER_LEVEL_MAX - 1);

const char *pit_mode_labels[] = {"OFF", "ON ", "N/A"};
osd_menu_select(4, 7, "PITMODE");
Expand Down

0 comments on commit d16e32d

Please sign in to comment.