Skip to content

Commit

Permalink
Update TX and RX info indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
gdyuldin committed Sep 30, 2024
1 parent 6a40ba3 commit 71f8418
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 25 deletions.
10 changes: 3 additions & 7 deletions src/meter.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ static void meter_draw_cb(lv_event_t * e) {

rect_dsc.bg_opa = LV_OPA_80;

// uint32_t count = slice_db * slice * (meter_db - min_db) / (max_db - min_db);
uint32_t count = (meter_db - min_db) / slice_db;
uint32_t count = (meter_db - min_db + slice_db) / slice_db;
count = LV_MIN(count, slices_total);

area.y1 = y1 - 5;
Expand Down Expand Up @@ -113,15 +112,12 @@ static void meter_draw_cb(lv_event_t * e) {
label_dsc.font = &sony_22;

area.x1 = x1;
area.y1 = y1;
area.x2 = x1 + 20;
area.y2 = y1 + 32;

lv_point_t label_size;

area.y1 = y1 + 5;
area.y2 = area.y1 + 18;

lv_point_t label_size;

for (uint8_t i = 0; i < NUM_ITEMS; i++) {
char *label = s_items[i].label;
int16_t db = s_items[i].db;
Expand Down
45 changes: 27 additions & 18 deletions src/tx_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,33 +69,37 @@ static void tx_info_draw_cb(lv_event_t * e) {
lv_area_t area;
lv_point_t label_size;
uint32_t count;
uint8_t slices_total;
uint8_t slice_spacing = 2;

lv_coord_t x1 = obj->coords.x1 + 7;
lv_coord_t y1 = obj->coords.y1 + 17;

lv_coord_t w = lv_obj_get_width(obj);
lv_coord_t w = lv_obj_get_width(obj) - 60;
lv_coord_t h = lv_obj_get_height(obj) - 1;

uint8_t slice = 10;
lv_coord_t len = 300;

/* PWR rects */

lv_draw_rect_dsc_init(&rect_dsc);

rect_dsc.bg_opa = LV_OPA_80;

count = len * (pwr - min_pwr) / (max_pwr - min_pwr) / slice;
float slice_pwr_step = 0.25f;
slices_total = (max_pwr - min_pwr) / slice_pwr_step;
uint8_t slice_pwr_width = w / slices_total;

count = (pwr - min_pwr + slice_pwr_step) / slice_pwr_step;
count = LV_MIN(count, slices_total);

area.y1 = y1 - slice / 2;
area.y1 = y1 - 5;
area.y2 = y1 + 32;

rect_dsc.bg_color = lv_color_hex(0xAAAAAA);

for (uint16_t i = 0; i < count; i++) {

area.x1 = x1 + 30 + i * slice;
area.x2 = area.x1 + slice - 3;
area.x1 = x1 + 30 + i * slice_pwr_width - slice_pwr_width / 2 + slice_spacing / 2;
area.x2 = area.x1 + slice_pwr_width - slice_spacing;

lv_draw_rect(draw_ctx, &rect_dsc, &area);
}
Expand All @@ -106,26 +110,31 @@ static void tx_info_draw_cb(lv_event_t * e) {

rect_dsc.bg_opa = LV_OPA_80;

count = len * (vswr - min_swr) / (max_swr - min_swr) / slice;
float slice_swr_step = 0.1f;
slices_total = (max_swr - min_swr) / slice_swr_step;
uint8_t slice_swr_width = w / slices_total;

count = (vswr - min_swr + slice_swr_step) / slice_swr_step;

area.y1 = y1 - slice / 2 + 54;
area.y1 = y1 - 5 + 54;
area.y2 = y1 + 32 + 54;

for (uint16_t i = 0; i < count; i++) {
float s = i * (max_swr - min_swr) / (len / slice) + min_swr;
float swr_val = vswr_items[0].val;

if (s <= 2.0f) {
for (uint16_t i = 0; i < count; i++) {
if (swr_val <= 2.0f) {
rect_dsc.bg_color = lv_color_hex(0xAAAAAA);
} else if (s <= 3.0f) {
} else if (swr_val <= 3.0f) {
rect_dsc.bg_color = lv_color_hex(0xAAAA00);
} else {
rect_dsc.bg_color = lv_color_hex(0xAA0000);
}

area.x1 = x1 + 30 + i * slice;
area.x2 = area.x1 + slice - 3;
area.x1 = x1 + 30 + i * slice_swr_width - slice_swr_width / 2 + slice_spacing / 2;
area.x2 = area.x1 + slice_swr_width - slice_spacing;

lv_draw_rect(draw_ctx, &rect_dsc, &area);
swr_val += slice_swr_step;
}

/* PWR Labels */
Expand All @@ -147,7 +156,7 @@ static void tx_info_draw_cb(lv_event_t * e) {

lv_txt_get_size(&label_size, label, label_dsc.font, 0, 0, LV_COORD_MAX, 0);

area.x1 = x1 + 30 + len * (val - min_pwr) / (max_pwr - min_pwr) - (label_size.x / 2);
area.x1 = x1 + 30 + slice_pwr_width * ((val - min_pwr) / slice_pwr_step) - label_size.x / 2;
area.x2 = area.x1 + label_size.x;

lv_draw_label(draw_ctx, &label_dsc, &area, label, NULL);
Expand All @@ -167,7 +176,7 @@ static void tx_info_draw_cb(lv_event_t * e) {

lv_txt_get_size(&label_size, label, label_dsc.font, 0, 0, LV_COORD_MAX, 0);

area.x1 = x1 + 30 + len * (val - min_swr) / (max_swr - min_swr) - (label_size.x / 2);
area.x1 = x1 + 30 + slice_swr_width * ((val - min_swr) / slice_swr_step) - label_size.x / 2;
area.x2 = area.x1 + label_size.x;

lv_draw_label(draw_ctx, &label_dsc, &area, label, NULL);
Expand Down

0 comments on commit 71f8418

Please sign in to comment.