From 3b4178d59d1f81a119beb2263e3432bf305421ea Mon Sep 17 00:00:00 2001 From: OneOfEleven Date: Mon, 23 Oct 2023 14:02:54 +0100 Subject: [PATCH] renames to reduce confusion --- Makefile | 2 +- README.md | 6 +-- am_fix.c | 2 +- app/app.c | 117 +++++++++++++++++++++++++++---------------- app/dtmf.c | 4 +- app/fm.c | 10 ++-- app/main.c | 65 ++++++++++++++---------- app/search.c | 2 +- audio.c | 6 +-- bitmaps.c | 16 +++--- board.c | 2 +- driver/bk4819-regs.h | 4 +- driver/bk4819.c | 2 +- functions.c | 17 +++++-- functions.h | 4 +- misc.c | 8 +-- misc.h | 6 +-- radio.c | 8 +-- settings.h | 6 +-- ui/main.c | 15 +++--- ui/menu.h | 2 +- ui/status.c | 2 +- 22 files changed, 177 insertions(+), 129 deletions(-) diff --git a/Makefile b/Makefile index f2009c2..d55b50c 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ ENABLE_OVERLAY := 0 ENABLE_LTO := 1 # UART Programming 2.9 kB ENABLE_UART := 1 -ENABLE_UART_DEBUG := 0 +ENABLE_UART_DEBUG := 1 # AirCopy 2.5 kB ENABLE_AIRCOPY := 1 ENABLE_AIRCOPY_REMEMBER_FREQ := 1 diff --git a/README.md b/README.md index ba5af51..710e03c 100644 --- a/README.md +++ b/README.md @@ -80,10 +80,10 @@ ENABLE_SQUELCH_MORE_SENSITIVE := 1 make squelch levels a little bit mor ENABLE_SQ_OPEN_WITH_UP_DN_BUTTS := 1 open the squelch when holding down UP or DN buttons when in frequency mode ENABLE_FASTER_CHANNEL_SCAN := 1 increase the channel scan speed, but also make the squelch more twitchy ENABLE_COPY_CHAN_TO_VFO_TO_CHAN := 1 long press M, copy channel to VFO, or VFO to channel -ENABLE_RX_SIGNAL_BAR := 1 enable a dBm/Sn RSSI bar graph level inplace of the little antenna symbols +ENABLE_RX_SIGNAL_BAR := 1 enable a menu option for showing an RSSI bar graph ENABLE_TX_TIMEOUT_BAR := 0 show the remainng TX time -ENABLE_TX_AUDIO_BAR := 1 enable TX audio level bar, includes remaining TX time (in seconds) -ENABLE_SIDE_BUTT_MENU := 1 change programmable side buttons in menu +ENABLE_TX_AUDIO_BAR := 1 enable a menu option for showing a TX audio level bar +ENABLE_SIDE_BUTT_MENU := 1 enable menu option for configuring the programmable side buttons ENABLE_KEYLOCK := 1 auto lock after 30 sec or long press F to lock #ENABLE_BAND_SCOPE := 0 not yet implemented - spectrum/pan-adapter #ENABLE_SINGLE_VFO_CHAN := 0 not yet implemented - single VFO on display when possible diff --git a/am_fix.c b/am_fix.c index 7c787e4..9ae5ab9 100644 --- a/am_fix.c +++ b/am_fix.c @@ -327,7 +327,7 @@ case FUNCTION_FOREGROUND: case FUNCTION_RECEIVE: case FUNCTION_MONITOR: - case FUNCTION_INCOMING: + case FUNCTION_NEW_RECEIVE: break; } diff --git a/app/app.c b/app/app.c index ee29897..cadd23d 100644 --- a/app/app.c +++ b/app/app.c @@ -90,9 +90,9 @@ static void APP_update_rssi(const int vfo) UI_update_rssi(rssi, vfo); } -static void APP_check_for_incoming_rx(void) +static void APP_check_for_new_receive(void) { - if (!g_squelch_lost) + if (!g_squelch_open) return; // squelch is open @@ -139,23 +139,22 @@ static void APP_check_for_incoming_rx(void) } g_rx_reception_mode = RX_MODE_DETECTED; - g_scan_pause_mode = true; // 1of11 done: - if (g_current_function != FUNCTION_INCOMING) + if (g_current_function != FUNCTION_NEW_RECEIVE) { - FUNCTION_Select(FUNCTION_INCOMING); + FUNCTION_Select(FUNCTION_NEW_RECEIVE); APP_update_rssi(g_eeprom.rx_vfo); g_update_rssi = true; } } -static void APP_process_incoming_rx(void) +static void APP_process_new_receive(void) { bool flag; - if (!g_squelch_lost) + if (!g_squelch_open) { // squelch is closed if (g_dtmf_rx_index > 0) @@ -166,6 +165,7 @@ static void APP_process_incoming_rx(void) FUNCTION_Select(FUNCTION_FOREGROUND); g_update_display = true; } + return; } @@ -243,7 +243,7 @@ static void APP_process_rx(void) if (g_scan_state_dir != SCAN_STATE_DIR_OFF && IS_FREQ_CHANNEL(g_scan_next_channel)) { - if (g_squelch_lost) + if (g_squelch_open) return; Mode = END_OF_RX_MODE_END; @@ -261,7 +261,7 @@ static void APP_process_rx(void) { g_found_ctcss = false; g_found_cdcss = false; - Mode = END_OF_RX_MODE_END; + Mode = END_OF_RX_MODE_END; goto Skip; } break; @@ -272,13 +272,13 @@ static void APP_process_rx(void) { g_found_ctcss = false; g_found_cdcss = false; - Mode = END_OF_RX_MODE_END; + Mode = END_OF_RX_MODE_END; goto Skip; } break; } - if (g_squelch_lost) + if (g_squelch_open) { if (!g_end_of_rx_detected_maybe && IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save)) { @@ -340,8 +340,10 @@ static void APP_process_rx(void) } } else + { Mode = END_OF_RX_MODE_END; - + } + if (!g_end_of_rx_detected_maybe && Mode == END_OF_RX_MODE_SKIP && g_next_time_slice_40ms && @@ -376,14 +378,14 @@ Skip: { switch (g_eeprom.scan_resume_mode) { - case SCAN_RESUME_TO: + case SCAN_RESUME_TIME: break; - case SCAN_RESUME_CO: + case SCAN_RESUME_CARRIER: g_scan_pause_10ms = g_eeprom.scan_hold_time_500ms * 50; break; - case SCAN_RESUME_SE: + case SCAN_RESUME_SEARCH: APP_stop_scan(); break; } @@ -399,7 +401,7 @@ Skip: g_tail_tone_elimination_count_down_10ms = 20; g_flag_tail_tone_elimination_complete = false; g_end_of_rx_detected_maybe = true; - g_enable_speaker = false; + g_speaker_enabled = false; } break; } @@ -413,7 +415,7 @@ static void APP_process_function(void) switch (g_current_function) { case FUNCTION_FOREGROUND: - APP_check_for_incoming_rx(); + APP_check_for_new_receive(); break; case FUNCTION_TRANSMIT: @@ -421,8 +423,8 @@ static void APP_process_function(void) backlight_turn_on(backlight_tx_rx_time_500ms); break; - case FUNCTION_INCOMING: - APP_process_incoming_rx(); + case FUNCTION_NEW_RECEIVE: + APP_process_new_receive(); case FUNCTION_MONITOR: break; @@ -433,7 +435,7 @@ static void APP_process_function(void) case FUNCTION_POWER_SAVE: if (!g_rx_idle_mode) - APP_check_for_incoming_rx(); + APP_check_for_new_receive(); break; case FUNCTION_PANADAPTER: @@ -465,13 +467,17 @@ void APP_start_listening(function_type_t Function, const bool reset_am_fix) g_vfo_rssi_bar_level[(chan + 1) & 1u] = 0; GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); - g_enable_speaker = true; + g_speaker_enabled = true; if (g_scan_state_dir != SCAN_STATE_DIR_OFF) { // we're RF scanning + + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" + switch (g_eeprom.scan_resume_mode) { - case SCAN_RESUME_TO: + case SCAN_RESUME_TIME: if (!g_scan_pause_mode) { g_scan_pause_10ms = g_eeprom.scan_hold_time_500ms * 50; @@ -479,11 +485,14 @@ void APP_start_listening(function_type_t Function, const bool reset_am_fix) } break; - case SCAN_RESUME_CO: - case SCAN_RESUME_SE: + case SCAN_RESUME_CARRIER: + + case SCAN_RESUME_SEARCH: g_scan_pause_10ms = 0; break; } + + #pragma GCC diagnostic pop } #ifdef ENABLE_NOAA @@ -610,7 +619,7 @@ void APP_stop_scan(void) g_scan_pause_10ms > (200 / 10) || g_current_function == FUNCTION_RECEIVE || g_current_function == FUNCTION_MONITOR || - g_current_function == FUNCTION_INCOMING) + g_current_function == FUNCTION_NEW_RECEIVE) { // stay where we are g_scan_pause_mode = false; g_scan_restore_channel = 0xff; @@ -953,16 +962,24 @@ void APP_process_radio_interrupts(void) } #endif - if (interrupt_bits & BK4819_REG_02_SQUELCH_LOST) + if (interrupt_bits & BK4819_REG_02_SQUELCH_CLOSED) { - g_squelch_lost = true; - BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, true); // LED on + BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, false); // LED off + g_squelch_open = false; + + #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) + UART_printf("squelch found (closed)\r\n"); + #endif } - if (interrupt_bits & BK4819_REG_02_SQUELCH_FOUND) + if (interrupt_bits & BK4819_REG_02_SQUELCH_OPENED) { - g_squelch_lost = false; - BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, false); // LED off +// BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, true); // LED on + g_squelch_open = true; + + #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) + UART_printf("squelch lost (opened)\r\n"); + #endif } } } @@ -1114,31 +1131,43 @@ void APP_process(void) if (g_voice_write_index == 0) #endif { - if ((g_current_function == FUNCTION_FOREGROUND || - g_current_function == FUNCTION_INCOMING) && // TODO: check me + if ((g_current_function == FUNCTION_FOREGROUND || g_current_function == FUNCTION_NEW_RECEIVE) && // TODO: check me g_screen_to_display != DISPLAY_SEARCH && g_scan_state_dir != SCAN_STATE_DIR_OFF && g_scan_pause_10ms == 0 && !g_ptt_is_pressed) { // RF scanning + + // TODO: check to see if signal stays present for minimum time before pausing + + if (IS_FREQ_CHANNEL(g_scan_next_channel)) { - if (g_current_function == FUNCTION_INCOMING) + if (g_current_function == FUNCTION_NEW_RECEIVE) + { APP_start_listening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true); + } else - APP_next_freq(); // switch to next frequency + { // switch to next frequency + g_scan_pause_mode = false; + g_rx_reception_mode = RX_MODE_NONE; + APP_next_freq(); + } } else { - if (g_current_code_type == CODE_TYPE_NONE && g_current_function == FUNCTION_INCOMING) + if (g_current_code_type == CODE_TYPE_NONE && g_current_function == FUNCTION_NEW_RECEIVE) + { APP_start_listening(g_monitor_enabled ? FUNCTION_MONITOR : FUNCTION_RECEIVE, true); + } else - APP_next_channel(); // switch to next channel + { // switch to next channel + g_scan_pause_mode = false; + g_rx_reception_mode = RX_MODE_NONE; + APP_next_channel(); + } } - - g_scan_pause_mode = false; - g_rx_reception_mode = RX_MODE_NONE; } } @@ -1711,7 +1740,7 @@ void APP_time_slice_10ms(void) SYSTEM_DelayMs(2); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); - g_enable_speaker = true; + g_speaker_enabled = true; g_alarm_tone_counter_10ms = 0; } } @@ -2339,7 +2368,7 @@ void APP_time_slice_500ms(void) static void APP_alarm_off(void) { GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); - g_enable_speaker = false; + g_speaker_enabled = false; if (g_eeprom.alarm_mode == ALARM_MODE_TONE) { @@ -2619,7 +2648,7 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const { GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); - g_enable_speaker = false; + g_speaker_enabled = false; BK4819_ExitDTMF_TX(false); @@ -2634,7 +2663,7 @@ static void APP_process_key(const key_code_t Key, const bool key_pressed, const if (g_eeprom.dtmf_side_tone) { // user will here the DTMF tones in speaker GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); - g_enable_speaker = true; + g_speaker_enabled = true; } BK4819_DisableScramble(); diff --git a/app/dtmf.c b/app/dtmf.c index 7894da0..b3f24d7 100644 --- a/app/dtmf.c +++ b/app/dtmf.c @@ -442,7 +442,7 @@ bool DTMF_Reply(void) if (g_eeprom.dtmf_side_tone) { // the user will also hear the transmitted tones GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); - g_enable_speaker = true; + g_speaker_enabled = true; } SYSTEM_DelayMs(Delay); @@ -459,7 +459,7 @@ bool DTMF_Reply(void) GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); - g_enable_speaker = false; + g_speaker_enabled = false; BK4819_ExitDTMF_TX(false); diff --git a/app/fm.c b/app/fm.c index 000cb46..9fadb28 100644 --- a/app/fm.c +++ b/app/fm.c @@ -101,7 +101,7 @@ void FM_TurnOff(void) GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); - g_enable_speaker = false; + g_speaker_enabled = false; BK1080_Init(0, false); @@ -124,7 +124,7 @@ void FM_Tune(uint16_t Frequency, int8_t Step, bool flag) { GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); - g_enable_speaker = false; + g_speaker_enabled = false; g_fm_play_count_down_10ms = (g_fm_scan_state == FM_SCAN_OFF) ? fm_play_countdown_noscan_10ms : fm_play_countdown_scan_10ms; @@ -171,7 +171,7 @@ void FM_PlayAndUpdate(void) GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); - g_enable_speaker = true; + g_speaker_enabled = true; } int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit) @@ -660,7 +660,7 @@ void FM_Play(void) g_eeprom.fm_selected_frequency = g_eeprom.fm_frequency_playing; GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); - g_enable_speaker = true; + g_speaker_enabled = true; GUI_SelectNextDisplay(DISPLAY_FM); return; @@ -695,6 +695,6 @@ void FM_Start(void) GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); - g_enable_speaker = true; + g_speaker_enabled = true; g_update_status = true; } diff --git a/app/main.c b/app/main.c index 6c1300e..e56f627 100644 --- a/app/main.c +++ b/app/main.c @@ -40,6 +40,19 @@ #include "ui/ui.h" #include "ui/menu.h" +bool scanning_paused(void) +{ + if ((g_scan_state_dir != SCAN_STATE_DIR_OFF || g_eeprom.dual_watch != DUAL_WATCH_OFF) && + g_scan_pause_10ms > 0 && + g_scan_pause_10ms <= (200 / 10) && + !g_scan_pause_mode) + { // scanning isn't paused + return false; + } + + return true; +} + void toggle_chan_scanlist(void) { // toggle the selected channels scanlist setting @@ -58,10 +71,7 @@ void toggle_chan_scanlist(void) return; } - if (g_scan_state_dir != SCAN_STATE_DIR_OFF && - g_scan_pause_10ms > 0 && - g_scan_pause_10ms <= (200 / 10) && - !g_scan_pause_mode) + if (!scanning_paused()) { // scanning isn't paused g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; @@ -90,28 +100,31 @@ void toggle_chan_scanlist(void) #ifdef ENABLE_COPY_CHAN_TO_VFO_TO_CHAN void MAIN_copy_mem_vfo_mem(void) - { + { //const unsigned int vfo = get_RX_VFO(); const unsigned int vfo = g_eeprom.tx_vfo; - if (g_scan_state_dir != SCAN_STATE_DIR_OFF || - g_css_scan_mode != CSS_SCAN_MODE_OFF || - g_eeprom.dual_watch != DUAL_WATCH_OFF || - !g_eeprom.vfo_open) - { // scanning + if (g_css_scan_mode != CSS_SCAN_MODE_OFF || !g_eeprom.vfo_open) + { // scanning or VFO disabled g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } - + + if (!scanning_paused()) + { // RF scanning + g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + return; + } + if (IS_USER_CHANNEL(g_eeprom.screen_channel[vfo])) { // copy channel to VFO, then swap to the VFO - + const unsigned int channel = FREQ_CHANNEL_FIRST + g_eeprom.vfo_info[vfo].band; - + g_eeprom.screen_channel[vfo] = channel; g_eeprom.vfo_info[vfo].channel_save = channel; g_eeprom.tx_vfo = vfo; - + RADIO_select_vfos(); RADIO_ApplyOffset(g_tx_vfo); RADIO_ConfigureSquelchAndOutputPower(g_tx_vfo); @@ -121,17 +134,17 @@ void toggle_chan_scanlist(void) g_tx_vfo->freq_in_channel = BOARD_find_channel(g_tx_vfo->freq_config_tx.frequency); g_request_save_vfo = true; - + g_beep_to_play = BEEP_880HZ_60MS_TRIPLE_BEEP; //g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL; - + g_update_status = true; g_update_display = true; } else if (IS_NOT_NOAA_CHANNEL(g_eeprom.screen_channel[vfo])) { // copy VFO to a channel - + // search the channels to see if the frequency is already present unsigned int chan = BOARD_find_channel(g_eeprom.vfo_info[vfo].p_tx->frequency); if (chan > USER_CHANNEL_LAST) @@ -141,7 +154,7 @@ void toggle_chan_scanlist(void) if (!RADIO_CheckValidChannel(chan, false, vfo)) break; } - + g_screen_to_display = DISPLAY_INVALID; GUI_SelectNextDisplay(DISPLAY_MENU); g_menu_cursor = MENU_MEM_SAVE; @@ -151,18 +164,18 @@ void toggle_chan_scanlist(void) #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) UART_printf("vfo to mem %u\r\n", chan); #endif - + g_sub_menu_selection = chan; g_flag_refresh_menu = false; g_screen_to_display = DISPLAY_MENU; g_update_display = false; UI_DisplayMenu(); } - + #ifdef ENABLE_VOICE g_another_voice_id = VOICE_ID_MENU; #endif - + g_beep_to_play = BEEP_880HZ_60MS_TRIPLE_BEEP; } } @@ -683,7 +696,7 @@ void MAIN_Key_MENU(const bool key_pressed, const bool key_held) { // key just pressed AUDIO_PlayBeep(BEEP_1KHZ_60MS_OPTIONAL); } - + if (key_held) { // menu key held down (long press) @@ -834,19 +847,19 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio #endif g_tx_vfo->freq_config_tx.frequency = g_tx_vfo->freq_config_rx.frequency; - + // find the first channel that contains this frequency g_tx_vfo->freq_in_channel = BOARD_find_channel(g_tx_vfo->freq_config_rx.frequency); - + // only update eeprom when the key is released - saves a LOT of wear and tear on the little eeprom SETTINGS_save_channel(g_tx_vfo->channel_save, g_eeprom.tx_vfo, g_tx_vfo, 1); - + #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) // UART_printf("save chan\r\n"); #endif } } - + if (key_held || !key_pressed) { // long press diff --git a/app/search.c b/app/search.c index bf4a5e9..263b2dc 100644 --- a/app/search.c +++ b/app/search.c @@ -447,7 +447,7 @@ void SEARCH_Start(void) g_cdcss_code_type = 0; g_ctcss_lost = false; - g_squelch_lost = false; + g_squelch_open = false; g_search_delay_10ms = scan_freq_css_delay_10ms; g_search_css_result_type = CODE_TYPE_NONE; g_search_css_result_code = 0xff; diff --git a/audio.c b/audio.c index 9a3c0a6..8db9008 100644 --- a/audio.c +++ b/audio.c @@ -220,7 +220,7 @@ void AUDIO_PlayBeep(beep_type_t Beep) // restore the register BK4819_WriteRegister(BK4819_REG_71, ToneConfig); - if (g_enable_speaker) + if (g_speaker_enabled) GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); #if defined(ENABLE_FMRADIO_68_108) || defined(ENABLE_FMRADIO_76_108) || defined(ENABLE_FMRADIO_875_108) @@ -322,7 +322,7 @@ void AUDIO_PlayBeep(beep_type_t Beep) BK1080_Mute(false); #endif - if (!g_enable_speaker) + if (!g_speaker_enabled) GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); g_voice_write_index = 0; @@ -470,7 +470,7 @@ void AUDIO_PlayBeep(beep_type_t Beep) BK1080_Mute(false); #endif - if (!g_enable_speaker) + if (!g_speaker_enabled) GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); // ********************** diff --git a/bitmaps.c b/bitmaps.c index 421b061..a9cdc3a 100644 --- a/bitmaps.c +++ b/bitmaps.c @@ -376,19 +376,19 @@ const uint8_t BITMAP_VFO_NOT_DEFAULT[8] = const uint8_t BITMAP_SCANLIST1[6] = { // 'I' symbol __extension__ 0b00000000, + __extension__ 0b00010001, + __extension__ 0b00011111, + __extension__ 0b00010001, __extension__ 0b00000000, - __extension__ 0b01000010, - __extension__ 0b01111110, - __extension__ 0b01000010, __extension__ 0b00000000 }; const uint8_t BITMAP_SCANLIST2[6] = { // 'II' symbol __extension__ 0b00000000, - __extension__ 0b01000010, - __extension__ 0b01111110, - __extension__ 0b01000010, - __extension__ 0b01111110, - __extension__ 0b01000010 + __extension__ 0b00010001, + __extension__ 0b00011111, + __extension__ 0b00010001, + __extension__ 0b00011111, + __extension__ 0b00010001 }; diff --git a/board.c b/board.c index 511c586..6659f86 100644 --- a/board.c +++ b/board.c @@ -599,7 +599,7 @@ void BOARD_EEPROM_load(void) g_eeprom.key1_long_press_action = (Data[2] < ACTION_OPT_LEN) ? Data[2] : ACTION_OPT_FLASHLIGHT; g_eeprom.key2_short_press_action = (Data[3] < ACTION_OPT_LEN) ? Data[3] : ACTION_OPT_SCAN; g_eeprom.key2_long_press_action = (Data[4] < ACTION_OPT_LEN) ? Data[4] : ACTION_OPT_NONE; - g_eeprom.scan_resume_mode = (Data[5] < 3) ? Data[5] : SCAN_RESUME_CO; + g_eeprom.scan_resume_mode = (Data[5] < 3) ? Data[5] : SCAN_RESUME_CARRIER; g_eeprom.auto_keypad_lock = (Data[6] < 2) ? Data[6] : false; g_eeprom.pwr_on_display_mode = (Data[7] < 4) ? Data[7] : PWR_ON_DISPLAY_MODE_VOLTAGE; diff --git a/driver/bk4819-regs.h b/driver/bk4819-regs.h index 37a9f19..820ab5f 100644 --- a/driver/bk4819-regs.h +++ b/driver/bk4819-regs.h @@ -149,8 +149,8 @@ typedef enum bk4819_gpio_pin_e bk4819_gpio_pin_t; #define BK4819_REG_02_CTCSS_LOST (1U << BK4819_REG_02_SHIFT_CTCSS_LOST) #define BK4819_REG_02_VOX_FOUND (1U << BK4819_REG_02_SHIFT_VOX_FOUND) #define BK4819_REG_02_VOX_LOST (1U << BK4819_REG_02_SHIFT_VOX_LOST) -#define BK4819_REG_02_SQUELCH_FOUND (1U << BK4819_REG_02_SHIFT_SQUELCH_FOUND) -#define BK4819_REG_02_SQUELCH_LOST (1U << BK4819_REG_02_SHIFT_SQUELCH_LOST) +#define BK4819_REG_02_SQUELCH_CLOSED (1U << BK4819_REG_02_SHIFT_SQUELCH_FOUND) +#define BK4819_REG_02_SQUELCH_OPENED (1U << BK4819_REG_02_SHIFT_SQUELCH_LOST) #define BK4819_REG_02_FSK_RX_SYNC (1U << BK4819_REG_02_SHIFT_FSK_RX_SYNC) // REG 07 diff --git a/driver/bk4819.c b/driver/bk4819.c index 7af23a5..10d9b34 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -1057,7 +1057,7 @@ void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const void BK4819_StopTones(void) { -// if (!g_enable_speaker) +// if (!g_speaker_enabled) GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); BK4819_EnterTxMute(); diff --git a/functions.c b/functions.c index 450a03c..1ed67e4 100644 --- a/functions.c +++ b/functions.c @@ -62,7 +62,7 @@ void FUNCTION_Init(void) g_vox_lost = false; #endif - g_squelch_lost = false; + g_squelch_open = false; g_flag_tail_tone_elimination_complete = false; g_tail_tone_elimination_count_down_10ms = 0; @@ -138,16 +138,18 @@ void FUNCTION_Select(function_type_t Function) g_monitor_enabled = true; break; - case FUNCTION_INCOMING: + case FUNCTION_NEW_RECEIVE: #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) - UART_SendText("func incoming\r\n"); + UART_SendText("func new receive\r\n"); #endif + break; case FUNCTION_RECEIVE: #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) UART_SendText("func receive\r\n"); #endif + break; case FUNCTION_POWER_SAVE: @@ -224,7 +226,7 @@ void FUNCTION_Select(function_type_t Function) GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); - g_enable_speaker = true; + g_speaker_enabled = true; SYSTEM_DelayMs(60); BK4819_ExitTxMute(); @@ -259,7 +261,7 @@ void FUNCTION_Select(function_type_t Function) g_alarm_tone_counter_10ms = 0; #endif - g_enable_speaker = true; + g_speaker_enabled = true; break; } else @@ -275,6 +277,11 @@ void FUNCTION_Select(function_type_t Function) break; case FUNCTION_PANADAPTER: + #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) + UART_SendText("func panadpter\r\n"); + #endif + + break; } diff --git a/functions.h b/functions.h index 88aab2b..919ac8e 100644 --- a/functions.h +++ b/functions.h @@ -24,8 +24,8 @@ enum function_type_e FUNCTION_FOREGROUND = 0, // idle, scanning FUNCTION_TRANSMIT, // transmitting FUNCTION_MONITOR, // receiving with squelch forced open - FUNCTION_INCOMING, // signal just received - FUNCTION_RECEIVE, // RX mode, squelch closed + FUNCTION_NEW_RECEIVE, // signal just received + FUNCTION_RECEIVE, // receive mode FUNCTION_POWER_SAVE, // sleeping FUNCTION_PANADAPTER // bandscope mode (panadpter/spectrum) .. not yet implemented }; diff --git a/misc.c b/misc.c index 0a1c31e..be2cbf3 100644 --- a/misc.c +++ b/misc.c @@ -43,9 +43,9 @@ const uint8_t dtmf_txstop_countdown_500ms = 3000 / 500; // 6 sec const uint8_t serial_config_count_down_500ms = 3000 / 500; // 3 seconds -const uint8_t key_input_timeout_500ms = 6000 / 500; // 6 seconds +const uint8_t key_input_timeout_500ms = 6000 / 500; // 6 seconds #ifdef ENABLE_KEYLOCK - const uint8_t key_lock_timeout_500ms = 30000 / 500; // 30 seconds + const uint8_t key_lock_timeout_500ms = 30000 / 500; // 30 seconds #endif const uint8_t key_debounce_10ms = 30 / 10; // 30ms @@ -160,7 +160,7 @@ volatile uint16_t g_tail_tone_elimination_count_down_10ms; volatile uint16_t g_noaa_count_down_10ms; #endif -bool g_enable_speaker; +bool g_speaker_enabled; uint8_t g_key_input_count_down; #ifdef ENABLE_KEYLOCK uint8_t g_key_lock_count_down_500ms; @@ -213,7 +213,7 @@ bool g_cxcss_tail_found; uint16_t g_vox_resume_count_down; uint16_t g_vox_pause_count_down; #endif -bool g_squelch_lost; +bool g_squelch_open; uint8_t g_flash_light_state; volatile uint16_t g_flash_light_blink_counter; diff --git a/misc.h b/misc.h index 97fe356..221223f 100644 --- a/misc.h +++ b/misc.h @@ -131,7 +131,7 @@ extern const uint8_t serial_config_count_down_500ms; extern const uint8_t key_input_timeout_500ms; #ifdef ENABLE_KEYLOCK - extern const uint8_t key_lock_timeout_500ms; + extern const uint8_t key_lock_timeout_500ms; #endif extern const uint8_t key_debounce_10ms; @@ -246,7 +246,7 @@ extern volatile uint16_t g_tail_tone_elimination_count_down_10ms; #ifdef ENABLE_NOAA extern volatile uint16_t g_noaa_count_down_10ms; #endif -extern bool g_enable_speaker; +extern bool g_speaker_enabled; extern uint8_t g_key_input_count_down; #ifdef ENABLE_KEYLOCK @@ -299,7 +299,7 @@ extern bool g_cxcss_tail_found; extern uint16_t g_vox_resume_count_down; extern uint16_t g_vox_pause_count_down; #endif -extern bool g_squelch_lost; +extern bool g_squelch_open; extern uint8_t g_flash_light_state; extern volatile uint16_t g_flash_light_blink_counter; extern bool g_flag_end_tx; diff --git a/radio.c b/radio.c index 962d438..b7a19f5 100644 --- a/radio.c +++ b/radio.c @@ -594,7 +594,7 @@ void RADIO_setup_registers(bool switch_to_function_foreground) uint32_t Frequency; GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); - g_enable_speaker = false; + g_speaker_enabled = false; BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, false); @@ -845,7 +845,7 @@ void RADIO_enableTX(const bool fsk_tx) GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); - g_enable_speaker = false; + g_speaker_enabled = false; BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_RX_ENABLE, false); // ??? @@ -1101,7 +1101,7 @@ void RADIO_tx_eot(void) if (g_eeprom.dtmf_side_tone) { GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); - g_enable_speaker = true; + g_speaker_enabled = true; SYSTEM_DelayMs(60); } BK4819_EnterDTMF_TX(g_eeprom.dtmf_side_tone); @@ -1114,7 +1114,7 @@ void RADIO_tx_eot(void) g_eeprom.dtmf_code_interval_time); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); - g_enable_speaker = false; + g_speaker_enabled = false; } else if (g_eeprom.roger_mode == ROGER_MODE_ROGER) diff --git a/settings.h b/settings.h index bd033e2..fe9f471 100644 --- a/settings.h +++ b/settings.h @@ -46,9 +46,9 @@ enum { }; enum { - SCAN_RESUME_TO = 0, - SCAN_RESUME_CO, - SCAN_RESUME_SE + SCAN_RESUME_TIME = 0, + SCAN_RESUME_CARRIER, + SCAN_RESUME_SEARCH }; enum { diff --git a/ui/main.c b/ui/main.c index 544c87a..256272b 100644 --- a/ui/main.c +++ b/ui/main.c @@ -361,7 +361,7 @@ void UI_update_rssi(const int16_t rssi, const int vfo) else if (rssi >= level0 || g_current_function == FUNCTION_MONITOR || - g_current_function == FUNCTION_INCOMING) + g_current_function == FUNCTION_NEW_RECEIVE) { rssi_level = 1; } @@ -569,7 +569,7 @@ void UI_DisplayMain(void) mode = 2; if ((g_current_function == FUNCTION_RECEIVE || g_current_function == FUNCTION_MONITOR || - g_current_function == FUNCTION_INCOMING) && + g_current_function == FUNCTION_NEW_RECEIVE) && g_eeprom.rx_vfo == vfo_num) { #ifdef ENABLE_SMALL_BOLD @@ -690,7 +690,6 @@ void UI_DisplayMain(void) case MDF_NAME_FREQ: // channel name and frequency BOARD_fetchChannelName(String, g_eeprom.screen_channel[vfo_num]); - if (String[0] == 0) { // no channel name available, channel number instead sprintf(String, "CH-%03u", 1 + g_eeprom.screen_channel[vfo_num]); @@ -698,16 +697,16 @@ void UI_DisplayMain(void) if (g_eeprom.channel_display_mode == MDF_NAME) { // just the name - UI_PrintString(String, x, 0, line, 8); + UI_PrintString(String, x + 4, 0, line, 8); } else { // name & frequency // name #ifdef ENABLE_SMALL_BOLD - UI_PrintStringSmallBold(String, x, 0, line); + UI_PrintStringSmallBold(String, x + 4, 0, line); #else - UI_PrintStringSmall(String, x, 0, line); + UI_PrintStringSmall(String, x + 4, 0, line); #endif // frequency @@ -715,7 +714,7 @@ void UI_DisplayMain(void) #ifdef ENABLE_TRIM_TRAILING_ZEROS NUMBER_trim_trailing_zeros(String); #endif - UI_PrintStringSmall(String, x, 0, line + 1); + UI_PrintStringSmall(String, x + 4, 0, line + 1); } break; @@ -890,7 +889,7 @@ void UI_DisplayMain(void) const bool rx = (g_current_function == FUNCTION_RECEIVE || g_current_function == FUNCTION_MONITOR || - g_current_function == FUNCTION_INCOMING); + g_current_function == FUNCTION_NEW_RECEIVE); #ifdef ENABLE_TX_TIMEOUT_BAR // show the TX timeout count down diff --git a/ui/menu.h b/ui/menu.h index a475dfd..7e54a0a 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -54,6 +54,7 @@ enum MENU_TX_TO, MENU_CROSS_VFO, MENU_DUAL_WATCH, + MENU_SCAN_CAR_RESUME, MENU_SCAN_HOLD, MENU_SCRAMBLER, MENU_BUSY_CHAN_LOCK, @@ -70,7 +71,6 @@ enum #ifdef ENABLE_CONTRAST MENU_CONTRAST, #endif - MENU_SCAN_CAR_RESUME, MENU_S_ADD1, MENU_S_ADD2, #ifdef ENABLE_NOAA diff --git a/ui/status.c b/ui/status.c index 12f8487..2cb28c5 100644 --- a/ui/status.c +++ b/ui/status.c @@ -55,7 +55,7 @@ void UI_DisplayStatus(const bool test_display) else if (g_current_function == FUNCTION_RECEIVE || g_current_function == FUNCTION_MONITOR || - g_current_function == FUNCTION_INCOMING) + g_current_function == FUNCTION_NEW_RECEIVE) { memmove(line + x, BITMAP_RX, sizeof(BITMAP_RX)); x1 = x + sizeof(BITMAP_RX);