kopia lustrzana https://github.com/OpenRTX/OpenRTX
UI: Add MEM channel filtering per zone
rodzic
81461669fe
commit
438540290b
|
@ -52,6 +52,8 @@ typedef struct
|
|||
uint16_t channel_index;
|
||||
channel_t channel;
|
||||
channel_t vfo_channel;
|
||||
bool zone_enabled;
|
||||
zone_t zone;
|
||||
uint8_t rtxStatus;
|
||||
// Squelch steps from 0 to 15
|
||||
uint8_t sqlLevel;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
***************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <state.h>
|
||||
#include <battery.h>
|
||||
#include <hwconfig.h>
|
||||
|
@ -39,7 +40,8 @@ void state_init()
|
|||
state.v_bat = platform_getVbat();
|
||||
state.charge = battery_getCharge(state.v_bat);
|
||||
state.rssi = rtx_getRssi();
|
||||
|
||||
|
||||
// Set VFO channel default settings
|
||||
state.channelInfoUpdated = true;
|
||||
state.channel.mode = FM;
|
||||
state.channel.bandwidth = BW_25;
|
||||
|
@ -50,7 +52,7 @@ void state_init()
|
|||
state.channel.fm.rxTone = 2; // 71.9Hz
|
||||
state.channel.fm.txToneEn = 1;
|
||||
state.channel.fm.txTone = 2; // 71.9Hz
|
||||
|
||||
state.zone_enabled = false;
|
||||
state.rtxStatus = RTX_OFF;
|
||||
#ifdef HAS_ABSOLUTE_KNOB // If the radio has an absolute position knob
|
||||
state.sqlLevel = platform_getChSelector() - 1;
|
||||
|
|
|
@ -436,8 +436,17 @@ bool _ui_drawDarkOverlay() {
|
|||
}
|
||||
|
||||
int _ui_fsm_loadChannel(uint16_t index, bool *sync_rtx) {
|
||||
// Try to load selected channel
|
||||
channel_t channel;
|
||||
// If a zone is active, get index from current zone
|
||||
if(state.zone_enabled)
|
||||
{
|
||||
// Calculate zone size
|
||||
const uint8_t zone_size = sizeof(state.zone.member)/sizeof(state.zone.member[0]);
|
||||
if(index >= zone_size)
|
||||
return -1;
|
||||
else
|
||||
index = state.zone.member[index];
|
||||
}
|
||||
int result = nvm_readChannelData(&channel, index);
|
||||
// Read successful and channel is valid
|
||||
if(result != -1 && _ui_channel_valid(&channel))
|
||||
|
@ -830,7 +839,8 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
|
|||
if(state.ui_screen == MENU_ZONE)
|
||||
{
|
||||
zone_t zone;
|
||||
if(nvm_readZoneData(&zone, ui_state.menu_selected + 1) != -1)
|
||||
// The index is -1 because the first zone "All channels" is not read from flash
|
||||
if(nvm_readZoneData(&zone, ui_state.menu_selected) != -1)
|
||||
ui_state.menu_selected += 1;
|
||||
}
|
||||
else if(state.ui_screen == MENU_CHANNEL)
|
||||
|
@ -848,6 +858,31 @@ void ui_updateFSM(event_t event, bool *sync_rtx)
|
|||
}
|
||||
else if(msg.keys & KEY_ENTER)
|
||||
{
|
||||
if(state.ui_screen == MENU_ZONE)
|
||||
{
|
||||
zone_t newzone;
|
||||
int result = 0;
|
||||
// If "All channels" is selected, load default zone
|
||||
if(ui_state.menu_selected == 0)
|
||||
state.zone_enabled = false;
|
||||
else
|
||||
{
|
||||
state.zone_enabled = true;
|
||||
// The index is -1 because the first zone "All channels" is not read from flash
|
||||
result = nvm_readZoneData(&newzone, ui_state.menu_selected - 1);
|
||||
}
|
||||
if(result != -1)
|
||||
{
|
||||
state.zone = newzone;
|
||||
// If we were in VFO mode, save VFO channel
|
||||
if(ui_state.last_main_state == MAIN_VFO)
|
||||
state.vfo_channel = state.channel;
|
||||
// Load zone first channel
|
||||
_ui_fsm_loadChannel(0, sync_rtx);
|
||||
// Switch to MEM screen
|
||||
state.ui_screen = MAIN_MEM;
|
||||
}
|
||||
}
|
||||
if(state.ui_screen == MENU_CHANNEL)
|
||||
{
|
||||
// If we were in VFO mode, save VFO channel
|
||||
|
|
|
@ -64,18 +64,18 @@ void _ui_drawMainTop()
|
|||
color_white);
|
||||
}
|
||||
|
||||
void _ui_drawZoneChannel(bool print_zone)
|
||||
void _ui_drawZoneChannel()
|
||||
{
|
||||
if(print_zone)
|
||||
{
|
||||
char zone_buf[20] = "";
|
||||
snprintf(zone_buf, sizeof(zone_buf), "zone: %.13s", "Test Zone");
|
||||
// Print Zone name
|
||||
gfx_print(layout.line1_pos, zone_buf, layout.line1_font, TEXT_ALIGN_LEFT, color_white);
|
||||
}
|
||||
char zone_buf[20] = "";
|
||||
char channel_buf[20] = "";
|
||||
if(!last_state.zone_enabled)
|
||||
snprintf(zone_buf, sizeof(zone_buf), "zone: %.13s", "All channels");
|
||||
else
|
||||
snprintf(zone_buf, sizeof(zone_buf), "zone: %.13s", last_state.zone.name);
|
||||
snprintf(channel_buf, sizeof(channel_buf), " %03d: %.12s", last_state.channel_index,
|
||||
last_state.channel.name);
|
||||
// Print Zone name
|
||||
gfx_print(layout.line1_pos, zone_buf, layout.line1_font, TEXT_ALIGN_LEFT, color_white);
|
||||
// Print Channel name
|
||||
gfx_print(layout.line2_pos, channel_buf, layout.line2_font, TEXT_ALIGN_LEFT, color_white);
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ void _ui_drawMainMEM()
|
|||
{
|
||||
gfx_clearScreen();
|
||||
_ui_drawMainTop();
|
||||
_ui_drawZoneChannel(false);
|
||||
_ui_drawZoneChannel();
|
||||
_ui_drawFrequency();
|
||||
_ui_drawBottom();
|
||||
}
|
||||
|
|
|
@ -147,10 +147,19 @@ int _ui_getInfoValueName(char *buf, uint8_t max_len, uint8_t index)
|
|||
}
|
||||
int _ui_getZoneName(char *buf, uint8_t max_len, uint8_t index)
|
||||
{
|
||||
zone_t zone;
|
||||
int result = nvm_readZoneData(&zone, index);
|
||||
if(result != -1)
|
||||
snprintf(buf, max_len, "%s", zone.name);
|
||||
int result = 0;
|
||||
// First zone "All channels" is not read from flash
|
||||
if(index == 0)
|
||||
{
|
||||
snprintf(buf, max_len, "All channels");
|
||||
}
|
||||
else
|
||||
{
|
||||
zone_t zone;
|
||||
int result = nvm_readZoneData(&zone, index - 1);
|
||||
if(result != -1)
|
||||
snprintf(buf, max_len, "%s", zone.name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue