diff --git a/Makefile b/Makefile index 359c389..0a6e380 100644 --- a/Makefile +++ b/Makefile @@ -39,6 +39,7 @@ ENABLE_MDC1200_SIDE_BEEP := 1 ENABLE_PWRON_PASSWORD := 0 ENABLE_RESET_AES_KEY := 0 ENABLE_BIG_FREQ := 0 +ENABLE_DTMF_LIVE_DECODER := 0 ENABLE_SHOW_FREQS_CHAN := 0 # smaa bolf 580 B ENABLE_SMALL_BOLD := 1 @@ -327,6 +328,9 @@ endif ifeq ($(ENABLE_BIG_FREQ),1) CFLAGS += -DENABLE_BIG_FREQ endif +ifeq ($(ENABLE_DTMF_LIVE_DECODER),1) + CFLAGS += -DENABLE_DTMF_LIVE_DECODER +endif ifeq ($(ENABLE_SHOW_FREQS_CHAN),1) CFLAGS += -DENABLE_SHOW_FREQS_CHAN endif diff --git a/README.md b/README.md index d4e8f27..f9cb4d6 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ ENABLE_MDC1200_SIDE_BEEP := 1 enable short side tone/beep when MDC ENABLE_PWRON_PASSWORD := 0 include power-on password code ENABLE_RESET_AES_KEY := 1 '1' = reset/clear the AES key stored in the eeprom (only if it's set) ENABLE_BIG_FREQ := 0 big font frequencies (like original QS firmware) +ENABLE_DTMF_LIVE_DECODER := 0 enable the live DTMF display/decoder .. adds a menu option ENABLE_SHOW_FREQS_CHAN := 1 show the channel name under the frequency if the frequency is found in a channel ENABLE_SMALL_BOLD := 1 bold channel name/no. (when name + freq channel display mode) ENABLE_TRIM_TRAILING_ZEROS := 1 trim away any trailing zeros on frequencies diff --git a/app/action.c b/app/action.c index 71f712c..75468c3 100644 --- a/app/action.c +++ b/app/action.c @@ -209,8 +209,10 @@ void ACTION_Scan(bool bRestart) DTMF_clear_RX(); - g_dtmf_rx_live_timeout = 0; - memset(g_dtmf_rx_live, 0, sizeof(g_dtmf_rx_live)); + #ifdef ENABLE_DTMF_LIVE_DECODER + g_dtmf_rx_live_timeout = 0; + memset(g_dtmf_rx_live, 0, sizeof(g_dtmf_rx_live)); + #endif RADIO_select_vfos(); diff --git a/app/app.c b/app/app.c index bd682ea..b36e4dd 100644 --- a/app/app.c +++ b/app/app.c @@ -986,19 +986,21 @@ void APP_process_radio_interrupts(void) const char c = DTMF_GetCharacter(BK4819_GetDTMF_5TONE_Code()); if (c != 0xff && g_current_function != FUNCTION_TRANSMIT) { - if (g_eeprom.config.setting.dtmf_live_decoder) - { - size_t len = strlen(g_dtmf_rx_live); - if (len >= (sizeof(g_dtmf_rx_live) - 1)) - { // make room - memmove(&g_dtmf_rx_live[0], &g_dtmf_rx_live[1], sizeof(g_dtmf_rx_live) - 1); - len--; + #ifdef ENABLE_DTMF_LIVE_DECODER + if (g_eeprom.config.setting.dtmf_live_decoder) + { + size_t len = strlen(g_dtmf_rx_live); + if (len >= (sizeof(g_dtmf_rx_live) - 1)) + { // make room + memmove(&g_dtmf_rx_live[0], &g_dtmf_rx_live[1], sizeof(g_dtmf_rx_live) - 1); + len--; + } + g_dtmf_rx_live[len++] = c; + g_dtmf_rx_live[len] = 0; + g_dtmf_rx_live_timeout = dtmf_rx_live_timeout_500ms; // time till we delete it + g_update_display = true; } - g_dtmf_rx_live[len++] = c; - g_dtmf_rx_live[len] = 0; - g_dtmf_rx_live_timeout = dtmf_rx_live_timeout_500ms; // time till we delete it - g_update_display = true; - } + #endif #ifdef ENABLE_KILL_REVIVE if (g_rx_vfo->channel.dtmf_decoding_enable || g_eeprom.config.setting.radio_disabled) @@ -1264,9 +1266,14 @@ void APP_end_tx(void) if (g_current_function == FUNCTION_POWER_SAVE) FUNCTION_Select(FUNCTION_FOREGROUND); - if (g_current_function == FUNCTION_TRANSMIT || g_serial_config_tick_500ms > 0) + if (g_current_function == FUNCTION_TRANSMIT) return; + #if defined(ENABLE_UART) + if (g_serial_config_tick_500ms > 0) + return; + #endif + // ************* go into TX mode g_dtmf_reply_state = DTMF_REPLY_NONE; @@ -1303,25 +1310,31 @@ void APP_process_keys(void) if (ptt_pressed) { // PTT pressed - #ifdef ENABLE_AIRCOPY - if (!g_ptt_is_pressed && g_serial_config_tick_500ms == 0 && g_eeprom.config.setting.tx_enable && g_current_function != FUNCTION_TRANSMIT && g_current_display_screen != DISPLAY_AIRCOPY) - #else - if (!g_ptt_is_pressed && g_serial_config_tick_500ms == 0 && g_eeprom.config.setting.tx_enable && g_current_function != FUNCTION_TRANSMIT) - #endif + if (!g_ptt_is_pressed && g_eeprom.config.setting.tx_enable && g_current_function != FUNCTION_TRANSMIT) { - #ifdef ENABLE_KILL_REVIVE - if (!g_eeprom.config.setting.radio_disabled) - #endif + #if defined(ENABLE_UART) + if (g_serial_config_tick_500ms == 0) + #endif { - if (++g_ptt_debounce >= 3) // 30ms debounce - { // start TX'ing - - g_boot_tick_10ms = 0; // cancel the boot-up screen - g_ptt_is_pressed = ptt_pressed; - g_ptt_was_released = false; - g_ptt_debounce = 3; - - APP_process_key(KEY_PTT, true, false); + #ifdef ENABLE_AIRCOPY + if (g_current_display_screen != DISPLAY_AIRCOPY) + #endif + { + #ifdef ENABLE_KILL_REVIVE + if (!g_eeprom.config.setting.radio_disabled) + #endif + { + if (++g_ptt_debounce >= 3) // 30ms debounce + { // start TX'ing + + g_boot_tick_10ms = 0; // cancel the boot-up screen + g_ptt_is_pressed = ptt_pressed; + g_ptt_was_released = false; + g_ptt_debounce = 3; + + APP_process_key(KEY_PTT, true, false); + } + } } } } @@ -1329,7 +1342,11 @@ void APP_process_keys(void) else { // PTT released + #if defined(ENABLE_UART) if (g_ptt_is_pressed || g_serial_config_tick_500ms > 0) + #else + if (g_ptt_is_pressed) + #endif { // if (g_ptt_debounce > 0) { @@ -1357,15 +1374,17 @@ void APP_process_keys(void) // scan the hardware keys key = KEYBOARD_Poll(); - if (g_serial_config_tick_500ms > 0) - { // config upload/download in progress - g_key_debounce_press = 0; - g_key_debounce_repeat = 0; - g_key_prev = KEY_INVALID; - g_key_held = false; - g_fkey_pressed = false; - return; - } + #if defined(ENABLE_UART) + if (g_serial_config_tick_500ms > 0) + { // config upload/download in progress + g_key_debounce_press = 0; + g_key_debounce_repeat = 0; + g_key_prev = KEY_INVALID; + g_key_held = false; + g_fkey_pressed = false; + return; + } + #endif if (key == KEY_INVALID || (g_key_prev != KEY_INVALID && key != g_key_prev)) { // key not pressed or different key pressed @@ -1974,7 +1993,9 @@ void APP_time_slice_500ms(void) if (g_beep_to_play != BEEP_NONE) { + #if defined(ENABLE_UART) if (g_serial_config_tick_500ms == 0) + #endif AUDIO_PlayBeep(g_beep_to_play); g_beep_to_play = BEEP_NONE; } @@ -1995,10 +2016,10 @@ void APP_time_slice_500ms(void) if (--g_keypad_locked == 0) g_update_display = true; - if (g_serial_config_tick_500ms > 0) - { // config upload/download is running - return; - } + #if defined(ENABLE_UART) + if (g_serial_config_tick_500ms > 0) + return; + #endif if (g_current_function == FUNCTION_TRANSMIT) { @@ -2039,23 +2060,25 @@ void APP_time_slice_500ms(void) } #endif - if (g_dtmf_rx_live_timeout > 0) - { - #ifdef ENABLE_RX_SIGNAL_BAR - if (g_center_line == CENTER_LINE_DTMF_DEC || - g_center_line == CENTER_LINE_NONE) // wait till the center line is free for us to use before timing out - #endif + #ifdef ENABLE_DTMF_LIVE_DECODER + if (g_dtmf_rx_live_timeout > 0) { - if (--g_dtmf_rx_live_timeout == 0) + #ifdef ENABLE_RX_SIGNAL_BAR + if (g_center_line == CENTER_LINE_DTMF_DEC || + g_center_line == CENTER_LINE_NONE) // wait till the center line is free for us to use before timing out + #endif { - if (g_dtmf_rx_live[0] != 0) + if (--g_dtmf_rx_live_timeout == 0) { - memset(g_dtmf_rx_live, 0, sizeof(g_dtmf_rx_live)); - g_update_display = true; + if (g_dtmf_rx_live[0] != 0) + { + memset(g_dtmf_rx_live, 0, sizeof(g_dtmf_rx_live)); + g_update_display = true; + } } } } - } + #endif if (g_menu_tick_10ms > 0) if (--g_menu_tick_10ms == 0) @@ -2412,7 +2435,11 @@ void APP_time_slice_10ms(void) } #endif +#if defined(ENABLE_UART) if (g_current_function == FUNCTION_TRANSMIT && (g_tx_timeout_reached || g_serial_config_tick_500ms > 0)) +#else + if (g_current_function == FUNCTION_TRANSMIT && g_tx_timeout_reached) +#endif { // transmitter timed out or must de-key BK4819_stop_tones(true); @@ -2450,7 +2477,11 @@ void APP_time_slice_10ms(void) } #endif +#if defined(ENABLE_UART) if (g_reduced_service || g_serial_config_tick_500ms > 0) +#else + if (g_reduced_service) +#endif { if (g_current_function == FUNCTION_TRANSMIT) g_tx_timeout_reached = true; @@ -2659,13 +2690,15 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const if (Key == KEY_EXIT && key_held && key_pressed) { // exit key held pressed - // clear the live DTMF decoder - if (g_dtmf_rx_live[0] != 0) - { - memset(g_dtmf_rx_live, 0, sizeof(g_dtmf_rx_live)); - g_dtmf_rx_live_timeout = 0; - g_update_display = true; - } + #ifdef ENABLE_DTMF_LIVE_DECODER + // clear the live DTMF decoder + if (g_dtmf_rx_live[0] != 0) + { + memset(g_dtmf_rx_live, 0, sizeof(g_dtmf_rx_live)); + g_dtmf_rx_live_timeout = 0; + g_update_display = true; + } + #endif // cancel user input APP_cancel_user_input_modes(); diff --git a/app/dtmf.c b/app/dtmf.c index a803278..7a05303 100644 --- a/app/dtmf.c +++ b/app/dtmf.c @@ -46,8 +46,10 @@ uint8_t g_dtmf_rx_index; uint8_t g_dtmf_rx_timeout; bool g_dtmf_rx_pending; -char g_dtmf_rx_live[20]; -uint8_t g_dtmf_rx_live_timeout; +#ifdef ENABLE_DTMF_LIVE_DECODER + char g_dtmf_rx_live[20]; + uint8_t g_dtmf_rx_live_timeout; +#endif bool g_dtmf_is_contact_valid; char g_dtmf_id[4]; diff --git a/app/dtmf.h b/app/dtmf.h index f2f0c89..d497628 100644 --- a/app/dtmf.h +++ b/app/dtmf.h @@ -77,8 +77,10 @@ extern uint8_t g_dtmf_rx_index; extern uint8_t g_dtmf_rx_timeout; extern bool g_dtmf_rx_pending; -extern char g_dtmf_rx_live[20]; -extern uint8_t g_dtmf_rx_live_timeout; +#ifdef ENABLE_DTMF_LIVE_DECODER + extern char g_dtmf_rx_live[20]; + extern uint8_t g_dtmf_rx_live_timeout; +#endif extern bool g_dtmf_is_contact_valid; extern char g_dtmf_id[4]; diff --git a/app/generic.c b/app/generic.c index 7ab8d68..e816312 100644 --- a/app/generic.c +++ b/app/generic.c @@ -99,7 +99,11 @@ void GENERIC_Key_PTT(bool key_pressed) { g_input_box_index = 0; +#if defined(ENABLE_UART) if (!key_pressed || g_serial_config_tick_500ms > 0) +#else + if (!key_pressed) +#endif { // PTT released if (g_current_function == FUNCTION_TRANSMIT) diff --git a/app/menu.c b/app/menu.c index 0cee02c..c7ed1f1 100644 --- a/app/menu.c +++ b/app/menu.c @@ -264,7 +264,9 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax) case MENU_STE: case MENU_DTMF_ST: case MENU_DTMF_DCD: - case MENU_DTMF_LIVE_DEC: + #ifdef ENABLE_DTMF_LIVE_DECODER + case MENU_DTMF_LIVE_DEC: + #endif *pMin = 0; *pMax = ARRAY_SIZE(g_sub_menu_off_on) - 1; break; @@ -771,15 +773,17 @@ void MENU_AcceptSetting(void) g_request_save_channel = 1; return; - case MENU_DTMF_LIVE_DEC: - g_eeprom.config.setting.dtmf_live_decoder = g_sub_menu_selection; - g_dtmf_rx_live_timeout = 0; - memset(g_dtmf_rx_live, 0, sizeof(g_dtmf_rx_live)); - if (!g_eeprom.config.setting.dtmf_live_decoder) - BK4819_DisableDTMF(); - g_flag_reconfigure_vfos = true; - g_update_status = true; - break; + #ifdef ENABLE_DTMF_LIVE_DECODER + case MENU_DTMF_LIVE_DEC: + g_eeprom.config.setting.dtmf_live_decoder = g_sub_menu_selection; + g_dtmf_rx_live_timeout = 0; + memset(g_dtmf_rx_live, 0, sizeof(g_dtmf_rx_live)); + if (!g_eeprom.config.setting.dtmf_live_decoder) + BK4819_DisableDTMF(); + g_flag_reconfigure_vfos = true; + g_update_status = true; + break; + #endif case MENU_DTMF_LIST: g_dtmf_chosen_contact = g_sub_menu_selection - 1; @@ -1285,9 +1289,11 @@ void MENU_ShowCurrentSetting(void) g_sub_menu_selection = g_dtmf_chosen_contact + 1; break; - case MENU_DTMF_LIVE_DEC: - g_sub_menu_selection = g_eeprom.config.setting.dtmf_live_decoder; - break; + #ifdef ENABLE_DTMF_LIVE_DECODER + case MENU_DTMF_LIVE_DEC: + g_sub_menu_selection = g_eeprom.config.setting.dtmf_live_decoder; + break; + #endif case MENU_PON_MSG: g_sub_menu_selection = g_eeprom.config.setting.power_on_display_mode; @@ -1712,7 +1718,7 @@ static void MENU_Key_MENU(const bool key_pressed, const bool key_held) g_edit_index = g_tx_vfo->channel.tx_power_user; } else - { + { // save the new power level g_tx_vfo->channel.tx_power_user = g_edit_index; g_request_save_channel = 1; diff --git a/firmware.bin b/firmware.bin index a2552e0..eee2f26 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 44f4ccb..af94050 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/functions.c b/functions.c index 043976e..3551fef 100644 --- a/functions.c +++ b/functions.c @@ -215,9 +215,11 @@ void FUNCTION_Select(function_type_t Function) // clear the DTMF RX buffer DTMF_clear_RX(); - // clear the DTMF RX live decoder buffer - g_dtmf_rx_live_timeout = 0; - memset(g_dtmf_rx_live, 0, sizeof(g_dtmf_rx_live)); + #ifdef ENABLE_DTMF_LIVE_DECODER + // clear the DTMF RX live decoder buffer + g_dtmf_rx_live_timeout = 0; + memset(g_dtmf_rx_live, 0, sizeof(g_dtmf_rx_live)); + #endif #ifdef ENABLE_FMRADIO // disable the FM radio diff --git a/misc.c b/misc.c index facb6b2..048e3eb 100644 --- a/misc.c +++ b/misc.c @@ -33,7 +33,9 @@ const uint16_t menu_timeout_long_500ms = 120000 / 500; // 2 min const uint16_t backlight_tx_rx_time_secs = 10; // 10 seconds -const uint8_t dtmf_rx_live_timeout_500ms = 6000 / 500; // 6 seconds live decoder on screen +#ifdef ENABLE_DTMF_LIVE_DECODER + const uint8_t dtmf_rx_live_timeout_500ms = 6000 / 500; // 6 seconds live decoder on screen +#endif const uint8_t dtmf_rx_timeout_500ms = 10000 / 500; // 10 seconds till we wipe the DTMF receiver const uint8_t dtmf_decode_ring_500ms = 15000 / 500; // 15 seconds .. time we sound the ringing for const uint8_t dtmf_txstop_500ms = 3000 / 500; // 6 seconds @@ -101,7 +103,9 @@ volatile bool g_power_save_expired; volatile uint16_t g_dual_watch_tick_10ms; volatile bool g_dual_watch_delay_down_expired = true; -volatile uint8_t g_serial_config_tick_500ms; +#if defined(ENABLE_UART) + volatile uint8_t g_serial_config_tick_500ms; +#endif volatile bool g_next_time_slice_500ms; diff --git a/misc.h b/misc.h index 2237beb..228ccb4 100644 --- a/misc.h +++ b/misc.h @@ -132,7 +132,9 @@ extern const uint16_t menu_timeout_long_500ms; extern const uint16_t backlight_tx_rx_time_secs; -extern const uint8_t dtmf_rx_live_timeout_500ms; +#ifdef ENABLE_DTMF_LIVE_DECODER + extern const uint8_t dtmf_rx_live_timeout_500ms; +#endif extern const uint8_t dtmf_rx_timeout_500ms; extern const uint8_t dtmf_decode_ring_500ms; extern const uint8_t dtmf_txstop_500ms; @@ -197,7 +199,9 @@ extern volatile bool g_power_save_expired; extern volatile uint16_t g_dual_watch_tick_10ms; extern volatile bool g_dual_watch_delay_down_expired; -extern volatile uint8_t g_serial_config_tick_500ms; +#if defined(ENABLE_UART) + extern volatile uint8_t g_serial_config_tick_500ms; +#endif extern volatile bool g_next_time_slice_500ms; diff --git a/panadapter.c b/panadapter.c index 0517293..fbbba27 100644 --- a/panadapter.c +++ b/panadapter.c @@ -139,7 +139,6 @@ void PAN_process_10ms(void) #endif // g_single_vfo < 0 || g_reduced_service || - g_monitor_enabled || g_current_function == FUNCTION_POWER_SAVE || g_current_display_screen == DISPLAY_SEARCH || g_css_scan_mode != CSS_SCAN_MODE_OFF || @@ -156,7 +155,7 @@ void PAN_process_10ms(void) return; } - if (g_current_function == FUNCTION_TRANSMIT) + if (g_current_function == FUNCTION_TRANSMIT || g_monitor_enabled) { panadapter_rssi_index = -1; return; diff --git a/radio.c b/radio.c index 616361e..ab11cc4 100644 --- a/radio.c +++ b/radio.c @@ -1114,7 +1114,11 @@ void RADIO_PrepareTX(void) } else #endif - if (!g_eeprom.config.setting.tx_enable || g_serial_config_tick_500ms > 0) + #if defined(ENABLE_UART) + if (!g_eeprom.config.setting.tx_enable || g_serial_config_tick_500ms > 0) + #else + if (!g_eeprom.config.setting.tx_enable) + #endif { // TX is disabled or config upload/download in progress State = VFO_STATE_TX_DISABLE; } diff --git a/scheduler.c b/scheduler.c index 33e7616..8d5adf4 100644 --- a/scheduler.c +++ b/scheduler.c @@ -58,7 +58,10 @@ void SystickHandler(void) g_next_time_slice_500ms = true; DECREMENT_AND_TRIGGER(g_tx_timer_tick_500ms, g_tx_timeout_reached); - DECREMENT(g_serial_config_tick_500ms); + + #if defined(ENABLE_UART) + DECREMENT(g_serial_config_tick_500ms); + #endif } if ((g_global_sys_tick_counter & 3) == 0) diff --git a/ui/main.c b/ui/main.c index 8f47dd9..785ecda 100644 --- a/ui/main.c +++ b/ui/main.c @@ -53,7 +53,8 @@ const int rssi_offset_band_123 = -44; const int rssi_offset_band_4567 = -18; -int single_vfo = -1; +int single_vfo = -1; +bool pan_enabled = false; center_line_t g_center_line = CENTER_LINE_NONE; @@ -395,6 +396,7 @@ void big_freq(const uint32_t frequency, const unsigned int x, const unsigned int void UI_DisplayMain_pan(const bool now) { + const bool valid = (g_panadapter_cycles > 0 && !g_monitor_enabled && g_current_function != FUNCTION_TRANSMIT) ? true : false; const unsigned int line = (g_eeprom.config.setting.tx_vfo_num == 0) ? 4 : 0; uint8_t *base_line = g_frame_buffer[line + 2]; uint8_t max_rssi; @@ -404,21 +406,22 @@ void big_freq(const uint32_t frequency, const unsigned int x, const unsigned int if (!g_eeprom.config.setting.panadapter || !g_panadapter_enabled || - g_monitor_enabled || - single_vfo < 0 || + !pan_enabled || + g_reduced_service || g_current_display_screen != DISPLAY_MAIN || g_current_function == FUNCTION_POWER_SAVE || -// g_current_function == FUNCTION_TRANSMIT || g_dtmf_call_state != DTMF_CALL_STATE_NONE || -// g_dtmf_is_tx || g_dtmf_input_mode) { // don't draw the panadapter return; } - // auto vertical scale - if (g_panadapter_cycles > 0) + // clear our assigned screen area + memset(g_frame_buffer[line], 0, LCD_WIDTH * 3); + + if (valid) { + // auto vertical scale max_rssi = g_panadapter_max_rssi; min_rssi = g_panadapter_min_rssi; span_rssi = max_rssi - min_rssi; @@ -429,60 +432,60 @@ void big_freq(const uint32_t frequency, const unsigned int x, const unsigned int min_rssi = 255 - span_rssi; max_rssi = min_rssi + span_rssi; } + + #ifdef ENABLE_PANADAPTER_PEAK_FREQ + if (g_panadapter_peak_freq > 0) + { // print the peak frequency + char str[16]; + sprintf(str, "%u.%05u", g_panadapter_peak_freq / 100000, g_panadapter_peak_freq % 100000); + NUMBER_trim_trailing_zeros(str); + UI_PrintStringSmall(str, 8, 0, line + 0); + } + #endif } - // clear our assigned screen area - memset(g_frame_buffer[line], 0, LCD_WIDTH * 3); - - #ifdef ENABLE_PANADAPTER_PEAK_FREQ - if (g_panadapter_peak_freq > 0 && g_panadapter_cycles > 0) - { // print the peak frequency - char str[16]; - sprintf(str, "%u.%05u", g_panadapter_peak_freq / 100000, g_panadapter_peak_freq % 100000); - NUMBER_trim_trailing_zeros(str); - UI_PrintStringSmall(str, 8, 0, line + 0); - } - #endif - - // draw top center vertical marker (the VFO frequency) - base_line[PANADAPTER_BINS - (LCD_WIDTH * 2)] = 0x3F; - { // draw top & bottom horizontal dotted line const unsigned int top = PANADAPTER_BINS - (LCD_WIDTH * 2); const unsigned int bot = PANADAPTER_BINS - (LCD_WIDTH * 0); for (i = 0; i < PANADAPTER_BINS; i += 4) { // top line - base_line[top - i] |= 0x01; - base_line[top + i] |= 0x01; + if (i <= 4) + { + base_line[top - i] |= 1u << 0; + base_line[top + i] |= 1u << 0; + } // bottom line - base_line[bot - i] |= 0x20; - base_line[bot + i] |= 0x20; + base_line[bot - i] |= 1u << 6; + base_line[bot + i] |= 1u << 6; } } + // draw top center vertical marker (the VFO frequency) + base_line[PANADAPTER_BINS - (LCD_WIDTH * 2)] = 0x15; + // draw the panadapter vertical bins - if (g_panadapter_cycles > 0) + if (valid) { for (i = 0; i < ARRAY_SIZE(g_panadapter_rssi); i++) { uint32_t pixels; uint8_t rssi = g_panadapter_rssi[i]; - + #if 0 rssi = (rssi < ((-129 + 160) * 2)) ? 0 : rssi - ((-129 + 160) * 2); // min of -129dBm (S3) rssi = rssi >> 2; #else - rssi = ((uint16_t)(rssi - min_rssi) * 21) / span_rssi; // 0 ~ 21 + rssi = ((uint16_t)(rssi - min_rssi) * 22) / span_rssi; // 0 ~ 22 #endif - + rssi += 2; // offset from the bottom - if (rssi > 22) - rssi = 22; // limit peak value - - pixels = (1u << rssi) - 1; // set the line pixels + if (rssi > 24) + rssi = 24; // limit peak value + + pixels = (1u << rssi) - 1; // pixels pixels &= 0xfffffffe; // clear the bottom line - + base_line[i - (LCD_WIDTH * 2)] |= bit_reverse_8(pixels >> 16); base_line[i - (LCD_WIDTH * 1)] |= bit_reverse_8(pixels >> 8); base_line[i - (LCD_WIDTH * 0)] |= bit_reverse_8(pixels >> 0); @@ -508,23 +511,33 @@ void UI_DisplayMain(void) g_center_line = CENTER_LINE_NONE; - single_vfo = -1; + if (g_eeprom.config.setting.dual_watch == DUAL_WATCH_OFF && g_eeprom.config.setting.cross_vfo == CROSS_BAND_OFF) + { + single_vfo = main_vfo_num; + } + else + { + single_vfo = -1; + pan_enabled = false; - if (g_eeprom.config.setting.dual_watch != DUAL_WATCH_OFF && g_rx_vfo_is_active) - current_vfo_num = g_rx_vfo_num; // we're currently monitoring the other VFO + if (g_eeprom.config.setting.dual_watch != DUAL_WATCH_OFF && g_rx_vfo_is_active) + current_vfo_num = g_rx_vfo_num; // we're currently monitoring the other VFO + } - // clear the screen + // clear the screen buffer memset(g_frame_buffer, 0, sizeof(g_frame_buffer)); - if (g_serial_config_tick_500ms > 0) - { - BACKLIGHT_turn_on(5); // 5 seconds - UI_PrintString("UART", 0, LCD_WIDTH, 1, 8); - UI_PrintString("CONFIG COMMS", 0, LCD_WIDTH, 3, 8); - ST7565_BlitFullScreen(); - g_center_line = CENTER_LINE_IN_USE; - return; - } + #if defined(ENABLE_UART) + if (g_serial_config_tick_500ms > 0) + { // tell user the serial comms is in use + BACKLIGHT_turn_on(5); // 5 seconds + UI_PrintString("UART", 0, LCD_WIDTH, 1, 8); + UI_PrintString("CONFIG COMMS", 0, LCD_WIDTH, 3, 8); + ST7565_BlitFullScreen(); + g_center_line = CENTER_LINE_IN_USE; + return; + } + #endif #ifdef ENABLE_KEYLOCK if (g_eeprom.config.setting.key_lock && g_keypad_locked > 0) @@ -539,20 +552,19 @@ void UI_DisplayMain(void) #endif #ifdef ENABLE_PANADAPTER - if (g_eeprom.config.setting.dual_watch == DUAL_WATCH_OFF && g_eeprom.config.setting.cross_vfo == CROSS_BAND_OFF) - if (g_dtmf_call_state == DTMF_CALL_STATE_NONE && !g_dtmf_is_tx && !g_dtmf_input_mode) - if (g_eeprom.config.setting.panadapter && g_panadapter_enabled) - if (!g_monitor_enabled) - single_vfo = g_eeprom.config.setting.tx_vfo_num; + if (g_eeprom.config.setting.panadapter && g_panadapter_enabled && single_vfo >= 0) + pan_enabled = true; + else + single_vfo = -1; #endif for (vfo_num = 0; vfo_num < 2; vfo_num++) { - const unsigned int scrn_chan = g_eeprom.config.setting.indices.vfo[vfo_num].screen; - const unsigned int line = (vfo_num == 0) ? line0 : line1; - uint8_t *p_line0 = g_frame_buffer[line + 0]; - uint8_t *p_line1 = g_frame_buffer[line + 1]; - unsigned int mode = 0; + const unsigned int scrn_chan = g_eeprom.config.setting.indices.vfo[vfo_num].screen; + const unsigned int line = (vfo_num == 0) ? line0 : line1; + uint8_t *p_line0 = g_frame_buffer[line + 0]; + uint8_t *p_line1 = g_frame_buffer[line + 1]; + unsigned int mode = 0; unsigned int state; if (single_vfo >= 0 && single_vfo != vfo_num) @@ -618,6 +630,8 @@ void UI_DisplayMain(void) str[16] = 0; UI_PrintString(str, 2, 0, 2 + (vfo_num * 3), 8); + pan_enabled = false; + g_center_line = CENTER_LINE_IN_USE; continue; } @@ -1096,36 +1110,38 @@ void UI_DisplayMain(void) if (rx || g_current_function == FUNCTION_FOREGROUND || g_current_function == FUNCTION_POWER_SAVE) { - #if 1 - if (g_eeprom.config.setting.dtmf_live_decoder && g_dtmf_rx_live[0] != 0) - { // show live DTMF decode - const unsigned int len = strlen(g_dtmf_rx_live); - const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // limit to last 'n' chars - - if (g_current_display_screen != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE) - return; - - g_center_line = CENTER_LINE_DTMF_DEC; - - strcpy(str, "DTMF "); - strcat(str, g_dtmf_rx_live + idx); - UI_PrintStringSmall(str, 2, 0, 3); - } - #else - if (g_eeprom.config.setting.dtmf_live_decoder && g_dtmf_rx_index > 0) - { // show live DTMF decode - const unsigned int len = g_dtmf_rx_index; - const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // limit to last 'n' chars - - if (g_current_display_screen != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE) - return; - - g_center_line = CENTER_LINE_DTMF_DEC; - - strcpy(str, "DTMF "); - strcat(str, g_dtmf_rx + idx); - UI_PrintStringSmall(str, 2, 0, 3); - } + #ifdef ENABLE_DTMF_LIVE_DECODER + #if 1 + if (g_eeprom.config.setting.dtmf_live_decoder && g_dtmf_rx_live[0] != 0) + { // show live DTMF decode + const unsigned int len = strlen(g_dtmf_rx_live); + const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // limit to last 'n' chars + + if (g_current_display_screen != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE) + return; + + g_center_line = CENTER_LINE_DTMF_DEC; + + strcpy(str, "DTMF "); + strcat(str, g_dtmf_rx_live + idx); + UI_PrintStringSmall(str, 2, 0, 3); + } + #else + if (g_eeprom.config.setting.dtmf_live_decoder && g_dtmf_rx_index > 0) + { // show live DTMF decode + const unsigned int len = g_dtmf_rx_index; + const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // limit to last 'n' chars + + if (g_current_display_screen != DISPLAY_MAIN || g_dtmf_call_state != DTMF_CALL_STATE_NONE) + return; + + g_center_line = CENTER_LINE_DTMF_DEC; + + strcpy(str, "DTMF "); + strcat(str, g_dtmf_rx + idx); + UI_PrintStringSmall(str, 2, 0, 3); + } + #endif #endif #ifdef ENABLE_SHOW_CHARGE_LEVEL @@ -1147,8 +1163,7 @@ void UI_DisplayMain(void) } #ifdef ENABLE_PANADAPTER - //if (single_vfo >= 0) - UI_DisplayMain_pan(false); + UI_DisplayMain_pan(false); #endif ST7565_BlitFullScreen(); diff --git a/ui/menu.c b/ui/menu.c index 7f6e3f6..f28d76b 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -125,7 +125,9 @@ const t_menu_item g_menu_list[] = {"D PRE", VOICE_ID_INVALID, MENU_DTMF_PRE }, {"D DCD", VOICE_ID_INVALID, MENU_DTMF_DCD }, {"D LIST", VOICE_ID_INVALID, MENU_DTMF_LIST }, +#ifdef ENABLE_DTMF_LIVE_DECODER {"D LIVE", VOICE_ID_INVALID, MENU_DTMF_LIVE_DEC }, // live DTMF decoder +#endif {"PonMSG", VOICE_ID_INVALID, MENU_PON_MSG }, {"ROGER", VOICE_ID_INVALID, MENU_ROGER_MODE }, {"BatVOL", VOICE_ID_INVALID, MENU_VOLTAGE }, // was "VOL" @@ -829,10 +831,14 @@ void UI_DisplayMenu(void) // Fallthrough - case MENU_DTMF_LIVE_DEC: - strcpy(str, "DTMF\nDECODE\n"); - strcat(str, g_sub_menu_off_on[g_sub_menu_selection]); - break; + #ifdef ENABLE_DTMF_LIVE_DECODER + case MENU_DTMF_LIVE_DEC: + strcpy(str, "DTMF\nDECODE\n"); + strcat(str, g_sub_menu_off_on[g_sub_menu_selection]); + break; + #endif + + // Fallthrough case MENU_STE: strcpy(str, "SUB TAIL\nELIMIN\n"); diff --git a/ui/menu.h b/ui/menu.h index 6248293..41c391e 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -106,7 +106,9 @@ enum MENU_DTMF_PRE, MENU_DTMF_DCD, MENU_DTMF_LIST, +#ifdef ENABLE_DTMF_LIVE_DECODER MENU_DTMF_LIVE_DEC, +#endif #ifdef ENABLE_MDC1200 MENU_MDC1200_MODE, MENU_MDC1200_ID,