Skip to content

Commit

Permalink
vtx: increase power level count, increase label length
Browse files Browse the repository at this point in the history
  • Loading branch information
bkleiner committed Aug 10, 2024
1 parent 9f5f718 commit 3755f60
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 34 deletions.
3 changes: 3 additions & 0 deletions src/driver/vtx/sa.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ const uint8_t default_dac_power_levels[VTX_POWER_LEVEL_MAX] = {
25,
40,
40,
40,
40,
40,
};

static void serial_smart_audio_reconfigure() {
Expand Down
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
2 changes: 1 addition & 1 deletion src/io/quic.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define QUIC_MAGIC '#'
#define QUIC_HEADER_LEN 4

#define QUIC_PROTOCOL_VERSION MAKE_SEMVER(0, 2, 2)
#define QUIC_PROTOCOL_VERSION MAKE_SEMVER(0, 2, 3)

typedef enum {
QUIC_CMD_INVALID,
Expand Down
12 changes: 8 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 @@ -42,6 +43,9 @@ typedef enum {
VTX_POWER_LEVEL_3,
VTX_POWER_LEVEL_4,
VTX_POWER_LEVEL_5,
VTX_POWER_LEVEL_6,
VTX_POWER_LEVEL_7,
VTX_POWER_LEVEL_8,

VTX_POWER_LEVEL_MAX,
} vtx_power_level_t;
Expand All @@ -65,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
15 changes: 9 additions & 6 deletions src/io/vtx_smartaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +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
15 changes: 9 additions & 6 deletions src/io/vtx_tramp.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +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
17 changes: 5 additions & 12 deletions src/osd/render.c
Original file line number Diff line number Diff line change
Expand Up @@ -927,12 +927,14 @@ 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 const char *power_level_labels[VTX_POWER_LEVEL_MAX];
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;
power_level_labels[i] = power_level_labels_terminated[i];
}
vtx_buffer_populated = 1;
}
Expand All @@ -945,15 +947,6 @@ 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);

// this ugly AF
const char *power_level_labels[] = {
power_level_labels_terminated[0],
power_level_labels_terminated[1],
power_level_labels_terminated[2],
power_level_labels_terminated[3],
power_level_labels_terminated[4],
};
osd_menu_select_enum_adjust(4, 6, "POWER LEVEL", 20, &vtx_settings_copy.power_level, power_level_labels, VTX_POWER_LEVEL_1, VTX_POWER_LEVEL_MAX - 1);

const char *pit_mode_labels[] = {"OFF", "ON ", "N/A"};
Expand Down

0 comments on commit 3755f60

Please sign in to comment.