kopia lustrzana https://github.com/OpenRTX/OpenRTX
Module17 UI: cleaned up dead code
rodzic
94b9cd46b6
commit
bf97bcb011
|
@ -133,38 +133,6 @@ const char *authors[] =
|
|||
"Fred IU2NRO",
|
||||
};
|
||||
|
||||
static const char *symbols_ITU_T_E161[] =
|
||||
{
|
||||
" 0",
|
||||
",.?1",
|
||||
"abc2ABC",
|
||||
"def3DEF",
|
||||
"ghi4GHI",
|
||||
"jkl5JKL",
|
||||
"mno6MNO",
|
||||
"pqrs7PQRS",
|
||||
"tuv8TUV",
|
||||
"wxyz9WXYZ",
|
||||
"-/*",
|
||||
"#"
|
||||
};
|
||||
|
||||
static const char *symbols_ITU_T_E161_callsign[] =
|
||||
{
|
||||
"0 ",
|
||||
"1",
|
||||
"ABC2",
|
||||
"DEF3",
|
||||
"GHI4",
|
||||
"JKL5",
|
||||
"MNO6",
|
||||
"PQRS7",
|
||||
"TUV8",
|
||||
"WXYZ9",
|
||||
"-/",
|
||||
""
|
||||
};
|
||||
|
||||
static const char symbols_callsign[] = "_ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890/-.";
|
||||
|
||||
// Calculate number of menu entries
|
||||
|
@ -315,16 +283,6 @@ void ui_drawSplashScreen()
|
|||
gfx_print(origin, FONT_SIZE_12PT, TEXT_ALIGN_CENTER, yellow_fab413, "O P N\nR T X");
|
||||
}
|
||||
|
||||
freq_t _ui_freq_add_digit(freq_t freq, uint8_t pos, uint8_t number)
|
||||
{
|
||||
freq_t coefficient = 100;
|
||||
for(uint8_t i=0; i < FREQ_DIGITS - pos; i++)
|
||||
{
|
||||
coefficient *= 10;
|
||||
}
|
||||
return freq += number * coefficient;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_RTC
|
||||
void _ui_timedate_add_digit(datetime_t *timedate, uint8_t pos, uint8_t number)
|
||||
{
|
||||
|
@ -369,132 +327,6 @@ void _ui_timedate_add_digit(datetime_t *timedate, uint8_t pos, uint8_t number)
|
|||
}
|
||||
#endif
|
||||
|
||||
bool _ui_freq_check_limits(freq_t freq)
|
||||
{
|
||||
bool valid = false;
|
||||
const hwInfo_t* hwinfo = platform_getHwInfo();
|
||||
if(hwinfo->vhf_band)
|
||||
{
|
||||
// hwInfo_t frequencies are in MHz
|
||||
if(freq >= (hwinfo->vhf_minFreq * 1000000) &&
|
||||
freq <= (hwinfo->vhf_maxFreq * 1000000))
|
||||
valid = true;
|
||||
}
|
||||
if(hwinfo->uhf_band)
|
||||
{
|
||||
// hwInfo_t frequencies are in MHz
|
||||
if(freq >= (hwinfo->uhf_minFreq * 1000000) &&
|
||||
freq <= (hwinfo->uhf_maxFreq * 1000000))
|
||||
valid = true;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
bool _ui_channel_valid(channel_t* channel)
|
||||
{
|
||||
return _ui_freq_check_limits(channel->rx_frequency) &&
|
||||
_ui_freq_check_limits(channel->tx_frequency);
|
||||
}
|
||||
|
||||
int _ui_fsm_loadChannel(int16_t channel_index, bool *sync_rtx) {
|
||||
channel_t channel;
|
||||
int32_t selected_channel = channel_index;
|
||||
// If a bank is active, get index from current bank
|
||||
if(state.bank_enabled)
|
||||
{
|
||||
bankHdr_t bank = { 0 };
|
||||
cps_readBankHeader(&bank, state.bank);
|
||||
if((channel_index < 0) || (channel_index >= bank.ch_count))
|
||||
return -1;
|
||||
channel_index = cps_readBankData(state.bank, channel_index);
|
||||
}
|
||||
int result = cps_readChannel(&channel, channel_index);
|
||||
// Read successful and channel is valid
|
||||
if(result != -1 && _ui_channel_valid(&channel))
|
||||
{
|
||||
// Set new channel index
|
||||
state.channel_index = selected_channel;
|
||||
// Copy channel read to state
|
||||
state.channel = channel;
|
||||
*sync_rtx = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void _ui_fsm_confirmVFOInput(bool *sync_rtx)
|
||||
{
|
||||
// Switch to TX input
|
||||
if(ui_state.input_set == SET_RX)
|
||||
{
|
||||
ui_state.input_set = SET_TX;
|
||||
// Reset input position
|
||||
ui_state.input_position = 0;
|
||||
}
|
||||
else if(ui_state.input_set == SET_TX)
|
||||
{
|
||||
// Save new frequency setting
|
||||
// If TX frequency was not set, TX = RX
|
||||
if(ui_state.new_tx_frequency == 0)
|
||||
{
|
||||
ui_state.new_tx_frequency = ui_state.new_rx_frequency;
|
||||
}
|
||||
// Apply new frequencies if they are valid
|
||||
if(_ui_freq_check_limits(ui_state.new_rx_frequency) &&
|
||||
_ui_freq_check_limits(ui_state.new_tx_frequency))
|
||||
{
|
||||
state.channel.rx_frequency = ui_state.new_rx_frequency;
|
||||
state.channel.tx_frequency = ui_state.new_tx_frequency;
|
||||
*sync_rtx = true;
|
||||
}
|
||||
state.ui_screen = MAIN_VFO;
|
||||
}
|
||||
}
|
||||
|
||||
void _ui_fsm_insertVFONumber(kbd_msg_t msg, bool *sync_rtx)
|
||||
{
|
||||
// Advance input position
|
||||
ui_state.input_position += 1;
|
||||
// Save pressed number to calculate frequency and show in GUI
|
||||
ui_state.input_number = input_getPressedNumber(msg);
|
||||
if(ui_state.input_set == SET_RX)
|
||||
{
|
||||
if(ui_state.input_position == 1)
|
||||
ui_state.new_rx_frequency = 0;
|
||||
// Calculate portion of the new RX frequency
|
||||
ui_state.new_rx_frequency = _ui_freq_add_digit(ui_state.new_rx_frequency,
|
||||
ui_state.input_position, ui_state.input_number);
|
||||
if(ui_state.input_position >= FREQ_DIGITS)
|
||||
{
|
||||
// Switch to TX input
|
||||
ui_state.input_set = SET_TX;
|
||||
// Reset input position
|
||||
ui_state.input_position = 0;
|
||||
// Reset TX frequency
|
||||
ui_state.new_tx_frequency = 0;
|
||||
}
|
||||
}
|
||||
else if(ui_state.input_set == SET_TX)
|
||||
{
|
||||
if(ui_state.input_position == 1)
|
||||
ui_state.new_tx_frequency = 0;
|
||||
// Calculate portion of the new TX frequency
|
||||
ui_state.new_tx_frequency = _ui_freq_add_digit(ui_state.new_tx_frequency,
|
||||
ui_state.input_position, ui_state.input_number);
|
||||
if(ui_state.input_position >= FREQ_DIGITS)
|
||||
{
|
||||
// Save both inserted frequencies
|
||||
if(_ui_freq_check_limits(ui_state.new_rx_frequency) &&
|
||||
_ui_freq_check_limits(ui_state.new_tx_frequency))
|
||||
{
|
||||
state.channel.rx_frequency = ui_state.new_rx_frequency;
|
||||
state.channel.tx_frequency = ui_state.new_tx_frequency;
|
||||
*sync_rtx = true;
|
||||
}
|
||||
state.ui_screen = MAIN_VFO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void _ui_changeBrightness(int variation)
|
||||
{
|
||||
// Avoid rollover if current value is zero.
|
||||
|
@ -605,45 +437,6 @@ static void _ui_textInputReset(char *buf)
|
|||
memset(buf, 0, 9);
|
||||
}
|
||||
|
||||
static void _ui_textInputKeypad(char *buf, uint8_t max_len, kbd_msg_t msg, bool callsign)
|
||||
{
|
||||
if(ui_state.input_position >= max_len)
|
||||
return;
|
||||
long long now = getTick();
|
||||
// Get currently pressed number key
|
||||
uint8_t num_key = input_getPressedNumber(msg);
|
||||
// Get number of symbols related to currently pressed key
|
||||
uint8_t num_symbols = 0;
|
||||
if(callsign)
|
||||
num_symbols = strlen(symbols_ITU_T_E161_callsign[num_key]);
|
||||
else
|
||||
num_symbols = strlen(symbols_ITU_T_E161[num_key]);
|
||||
|
||||
// Skip keypad logic for first keypress
|
||||
if(ui_state.last_keypress != 0)
|
||||
{
|
||||
// Same key pressed and timeout not expired: cycle over chars of current key
|
||||
if((ui_state.input_number == num_key) && ((now - ui_state.last_keypress) < input_longPressTimeout))
|
||||
{
|
||||
ui_state.input_set = (ui_state.input_set + 1) % num_symbols;
|
||||
}
|
||||
// Differnt key pressed: save current char and change key
|
||||
else
|
||||
{
|
||||
ui_state.input_position += 1;
|
||||
ui_state.input_set = 0;
|
||||
}
|
||||
}
|
||||
// Show current character on buffer
|
||||
if(callsign)
|
||||
buf[ui_state.input_position] = symbols_ITU_T_E161_callsign[num_key][ui_state.input_set];
|
||||
else
|
||||
buf[ui_state.input_position] = symbols_ITU_T_E161[num_key][ui_state.input_set];
|
||||
// Update reference values
|
||||
ui_state.input_number = num_key;
|
||||
ui_state.last_keypress = now;
|
||||
}
|
||||
|
||||
static void _ui_textInputArrows(char *buf, uint8_t max_len, kbd_msg_t msg)
|
||||
{
|
||||
if(ui_state.input_position >= max_len)
|
||||
|
@ -684,18 +477,6 @@ static void _ui_textInputConfirm(char *buf)
|
|||
buf[ui_state.input_position + 1] = '\0';
|
||||
}
|
||||
|
||||
static void _ui_textInputDel(char *buf)
|
||||
{
|
||||
buf[ui_state.input_position] = '\0';
|
||||
// Move back input cursor
|
||||
if(ui_state.input_position > 0)
|
||||
ui_state.input_position--;
|
||||
// If we deleted the initial character, reset starting condition
|
||||
else
|
||||
ui_state.last_keypress = 0;
|
||||
ui_state.input_set = 0;
|
||||
}
|
||||
|
||||
void ui_saveState()
|
||||
{
|
||||
last_state = state;
|
||||
|
|
|
@ -49,52 +49,10 @@ void _ui_drawMainTop()
|
|||
color_white, state.settings.callsign);
|
||||
}
|
||||
|
||||
void _ui_drawBankChannel()
|
||||
static void _ui_drawModeInfo(ui_state_t* ui_state)
|
||||
{
|
||||
// Print Bank number, channel number and Channel name
|
||||
uint16_t b = (last_state.bank_enabled) ? last_state.bank : 0;
|
||||
gfx_print(layout.line1_pos, layout.line1_font, TEXT_ALIGN_CENTER,
|
||||
color_white, "%01d-%03d: %.12s",
|
||||
b, last_state.channel_index + 1, last_state.channel.name);
|
||||
}
|
||||
|
||||
void _ui_drawModeInfo(ui_state_t* ui_state)
|
||||
{
|
||||
char bw_str[8] = { 0 };
|
||||
char encdec_str[9] = { 0 };
|
||||
|
||||
switch(last_state.channel.mode)
|
||||
{
|
||||
case OPMODE_FM:
|
||||
// Get Bandwidth string
|
||||
if(last_state.channel.bandwidth == BW_12_5)
|
||||
snprintf(bw_str, 8, "12.5");
|
||||
else if(last_state.channel.bandwidth == BW_25)
|
||||
snprintf(bw_str, 8, "25");
|
||||
// Get encdec string
|
||||
bool tone_tx_enable = last_state.channel.fm.txToneEn;
|
||||
bool tone_rx_enable = last_state.channel.fm.rxToneEn;
|
||||
if (tone_tx_enable && tone_rx_enable)
|
||||
snprintf(encdec_str, 9, "E+D");
|
||||
else if (tone_tx_enable && !tone_rx_enable)
|
||||
snprintf(encdec_str, 9, "E");
|
||||
else if (!tone_tx_enable && tone_rx_enable)
|
||||
snprintf(encdec_str, 9, "D");
|
||||
else
|
||||
snprintf(encdec_str, 9, " ");
|
||||
|
||||
// Print Bandwidth, Tone and encdec info
|
||||
gfx_print(layout.line2_pos, layout.line2_font, TEXT_ALIGN_CENTER,
|
||||
color_white, "B:%s T:%4.1f S:%s",
|
||||
bw_str, ctcss_tone[last_state.channel.fm.txTone]/10.0f,
|
||||
encdec_str);
|
||||
break;
|
||||
case OPMODE_DMR:
|
||||
// Print talkgroup
|
||||
gfx_print(layout.line2_pos, layout.line2_font, TEXT_ALIGN_CENTER,
|
||||
color_white, "TG:%s",
|
||||
"");
|
||||
break;
|
||||
case OPMODE_M17:
|
||||
{
|
||||
rtxStatus_t rtxStatus = rtx_getCurrentStatus();
|
||||
|
@ -176,141 +134,10 @@ void _ui_drawModeInfo(ui_state_t* ui_state)
|
|||
}
|
||||
}
|
||||
|
||||
void _ui_drawFrequency()
|
||||
{
|
||||
unsigned long frequency = platform_getPttStatus() ?
|
||||
frequency = last_state.channel.tx_frequency : last_state.channel.rx_frequency;
|
||||
|
||||
// Print big numbers frequency
|
||||
gfx_print(layout.line3_pos, layout.line3_font, TEXT_ALIGN_CENTER,
|
||||
color_white, "%03lu.%05lu",
|
||||
(unsigned long)frequency/1000000,
|
||||
(unsigned long)frequency%1000000/10);
|
||||
}
|
||||
|
||||
void _ui_drawVFOMiddleInput(ui_state_t* ui_state)
|
||||
{
|
||||
// Add inserted number to string, skipping "Rx: "/"Tx: " and "."
|
||||
uint8_t insert_pos = ui_state->input_position + 3;
|
||||
if(ui_state->input_position > 3) insert_pos += 1;
|
||||
char input_char = ui_state->input_number + '0';
|
||||
|
||||
if(ui_state->input_set == SET_RX)
|
||||
{
|
||||
if(ui_state->input_position == 0)
|
||||
{
|
||||
gfx_print(layout.line2_pos, layout.input_font, TEXT_ALIGN_CENTER,
|
||||
color_white, ">Rx:%03lu.%04lu",
|
||||
(unsigned long)ui_state->new_rx_frequency/1000000,
|
||||
(unsigned long)(ui_state->new_rx_frequency%1000000)/100);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Replace Rx frequency with underscorses
|
||||
if(ui_state->input_position == 1)
|
||||
strcpy(ui_state->new_rx_freq_buf, ">Rx:___.____");
|
||||
ui_state->new_rx_freq_buf[insert_pos] = input_char;
|
||||
gfx_print(layout.line2_pos, layout.input_font, TEXT_ALIGN_CENTER,
|
||||
color_white, ui_state->new_rx_freq_buf);
|
||||
}
|
||||
gfx_print(layout.line3_pos, layout.input_font, TEXT_ALIGN_CENTER,
|
||||
color_white, " Tx:%03lu.%04lu",
|
||||
(unsigned long)last_state.channel.tx_frequency/1000000,
|
||||
(unsigned long)(last_state.channel.tx_frequency%1000000)/100);
|
||||
}
|
||||
else if(ui_state->input_set == SET_TX)
|
||||
{
|
||||
gfx_print(layout.line2_pos, layout.input_font, TEXT_ALIGN_CENTER,
|
||||
color_white, " Rx:%03lu.%04lu",
|
||||
(unsigned long)ui_state->new_rx_frequency/1000000,
|
||||
(unsigned long)(ui_state->new_rx_frequency%1000000)/100);
|
||||
// Replace Rx frequency with underscorses
|
||||
if(ui_state->input_position == 0)
|
||||
{
|
||||
gfx_print(layout.line3_pos, layout.input_font, TEXT_ALIGN_CENTER,
|
||||
color_white, ">Tx:%03lu.%04lu",
|
||||
(unsigned long)ui_state->new_rx_frequency/1000000,
|
||||
(unsigned long)(ui_state->new_rx_frequency%1000000)/100);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ui_state->input_position == 1)
|
||||
strcpy(ui_state->new_tx_freq_buf, ">Tx:___.____");
|
||||
ui_state->new_tx_freq_buf[insert_pos] = input_char;
|
||||
gfx_print(layout.line3_pos, layout.input_font, TEXT_ALIGN_CENTER,
|
||||
color_white, ui_state->new_tx_freq_buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _ui_drawMainBottom()
|
||||
{
|
||||
// Squelch bar
|
||||
float rssi = last_state.rssi;
|
||||
float squelch = last_state.settings.sqlLevel / 16.0f;
|
||||
// Module17 0.1e does not know the volume level, so we will never draw it
|
||||
float volume = platform_getVolumeLevel() / 255.0f;
|
||||
uint16_t meter_width = CONFIG_SCREEN_WIDTH - 2 * layout.horizontal_pad;
|
||||
uint16_t meter_height = layout.bottom_h;
|
||||
point_t meter_pos = { layout.horizontal_pad,
|
||||
CONFIG_SCREEN_HEIGHT - meter_height - layout.bottom_pad};
|
||||
uint8_t mic_level = platform_getMicLevel();
|
||||
switch(last_state.channel.mode)
|
||||
{
|
||||
case OPMODE_FM:
|
||||
gfx_drawSmeter(meter_pos,
|
||||
meter_width,
|
||||
meter_height,
|
||||
rssi,
|
||||
squelch,
|
||||
volume,
|
||||
false,
|
||||
yellow_fab413);
|
||||
break;
|
||||
case OPMODE_DMR:
|
||||
gfx_drawSmeterLevel(meter_pos,
|
||||
meter_width,
|
||||
meter_height,
|
||||
rssi,
|
||||
mic_level,
|
||||
volume,
|
||||
false);
|
||||
break;
|
||||
case OPMODE_M17:
|
||||
/*gfx_drawSmeterLevel(meter_pos,
|
||||
meter_width,
|
||||
meter_height,
|
||||
rssi,
|
||||
mic_level,
|
||||
volume,
|
||||
false);*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void _ui_drawMainVFO(ui_state_t* ui_state)
|
||||
{
|
||||
gfx_clearScreen();
|
||||
_ui_drawMainTop();
|
||||
_ui_drawModeInfo(ui_state);
|
||||
//_ui_drawFrequency(); //has to be replaced with Line 1 and Line 2
|
||||
_ui_drawMainBottom();
|
||||
}
|
||||
|
||||
void _ui_drawMainVFOInput(ui_state_t* ui_state)
|
||||
{
|
||||
gfx_clearScreen();
|
||||
_ui_drawMainTop();
|
||||
_ui_drawVFOMiddleInput(ui_state);
|
||||
_ui_drawMainBottom();
|
||||
}
|
||||
|
||||
void _ui_drawMainMEM(ui_state_t* ui_state)
|
||||
{
|
||||
gfx_clearScreen();
|
||||
_ui_drawMainTop();
|
||||
_ui_drawBankChannel();
|
||||
_ui_drawModeInfo(ui_state);
|
||||
//_ui_drawFrequency(); //has to be replaced with Line 1 and Line 2
|
||||
_ui_drawMainBottom();
|
||||
}
|
||||
|
|
|
@ -32,25 +32,6 @@
|
|||
/* UI main screen helper functions, their implementation is in "ui_main.c" */
|
||||
extern void _ui_drawMainBottom();
|
||||
|
||||
const char *display_timer_values[] =
|
||||
{
|
||||
"Off",
|
||||
"5 s",
|
||||
"10 s",
|
||||
"15 s",
|
||||
"20 s",
|
||||
"25 s",
|
||||
"30 s",
|
||||
"1 min",
|
||||
"2 min",
|
||||
"3 min",
|
||||
"4 min",
|
||||
"5 min",
|
||||
"15 min",
|
||||
"30 min",
|
||||
"45 min",
|
||||
"1 hour"
|
||||
};
|
||||
|
||||
const char *mic_gain_values[] =
|
||||
{
|
||||
|
|
Ładowanie…
Reference in New Issue