Add squelch visualization and control from macro menu

This commit is contained in:
Niccolò Izzo 2021-01-28 12:51:22 +01:00
parent 5156783495
commit 364f8d4e46
3 changed files with 24 additions and 1 deletions

View File

@ -54,6 +54,7 @@ typedef struct
channel_t channel;
channel_t vfo_channel;
uint8_t rtxStatus;
// Squelch steps from 0 to 15
uint8_t sqlLevel;
uint8_t voxLevel;

View File

@ -72,6 +72,7 @@
#include <string.h>
#include <battery.h>
#include <input.h>
#include <hwconfig.h>
/* UI main screen functions, their implementation is in "ui_main.c" */
extern void _ui_drawMainBackground();
@ -534,6 +535,20 @@ void _ui_fsm_menuMacro(kbd_msg_t msg, bool *sync_rtx) {
platform_setBacklightLevel(state.backlight_level);
break;
}
#ifdef HAS_ABSOLUTE_KNOB // If the radio has an absolute position knob
state.sqlLevel = platform_getChSelector();
printf("New squelch value: %d\n\r", state.sqlLevel);
#else // Use left and right buttons or relative position knob
if(msg.keys && KEY_LEFT) {
state.sqlLevel++;
state.sqlLevel = (state.sqlLevel > 15) 15 : state.sqlLevel;
}
else if(msg.keys && KEY_RIGHT) {
state.sqlLevel--;
state.sqlLevel = (state.sqlLevel < 0) 0 : state.sqlLevel;
}
#endif
}
void ui_updateFSM(event_t event, bool *sync_rtx)

View File

@ -304,5 +304,12 @@ bool _ui_drawMacroMenu(state_t* last_state) {
yellow_fab413);
gfx_print(layout.line3_right, "Sav", layout.top_font, TEXT_ALIGN_RIGHT,
color_white);
return true;
// Squelch bar
uint16_t squelch_width = SCREEN_WIDTH / 16 * last_state->sqlLevel;
point_t squelch_pos = { layout.bottom_left.x, layout.bottom_left.y +
layout.status_v_pad +
layout.text_v_offset -
layout.bottom_h };
gfx_drawRect(squelch_pos, squelch_width, layout.bottom_h, color_white, true);
return true;
}