Skip to content

Commit

Permalink
Fix serial comms mishap, fix dual-watch not starting at power-on
Browse files Browse the repository at this point in the history
  • Loading branch information
OneOfEleven authored and OneOfEleven committed Oct 11, 2023
1 parent 5942582 commit 46a082e
Show file tree
Hide file tree
Showing 23 changed files with 613 additions and 507 deletions.
20 changes: 11 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ ENABLE_AIRCOPY := 1
ENABLE_FMRADIO := 1
ENABLE_NOAA := 0
ENABLE_VOICE := 1
ENABLE_MUTE_RADIO_FOR_VOICE := 0
ENABLE_VOX := 1
ENABLE_ALARM := 1
ENABLE_TX1750 := 1
ENABLE_PWRON_PASSWORD := 0
ENABLE_RESET_AES_KEY := 1
ENABLE_BIG_FREQ := 0
ENABLE_SMALL_BOLD := 1
ENABLE_KEEP_MEM_NAME := 1
Expand All @@ -30,7 +32,6 @@ ENABLE_SHOW_CHARGE_LEVEL := 0
ENABLE_REVERSE_BAT_SYMBOL := 1
ENABLE_CODE_SCAN_TIMEOUT := 0
ENABLE_FREQ_CODE_SCAN_TIMEOUT := 1
ENABLE_FREQ_CODE_ROUNDING := 0
ENABLE_AM_FIX := 1
ENABLE_AM_FIX_SHOW_DATA := 1
ENABLE_SQUELCH_MORE_SENSITIVE := 1
Expand Down Expand Up @@ -209,10 +210,10 @@ CFLAGS =

ifeq ($(ENABLE_CLANG),0)
#CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
CFLAGS += -Os -Wall -Werror -mcpu=cortex-m0 -std=c11 -MMD
CFLAGS += -Os -Werror -mcpu=cortex-m0 -std=c11 -MMD
else
# Oz needed to make it fit on flash
CFLAGS += -Oz -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
CFLAGS += -Oz -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
endif

ifeq ($(ENABLE_LTO),1)
Expand All @@ -227,9 +228,7 @@ endif

# catch any and all warnings
# better to bust than add new bugs
#CFLAGS += -Wall
#CFLAGS += -Wextra
#CFLAGS += -Wpedantic
CFLAGS += -Wall -Wextra -Wpedantic

CFLAGS += -DPRINTF_INCLUDE_CONFIG_H
CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\"
Expand Down Expand Up @@ -263,6 +262,9 @@ endif
ifeq ($(ENABLE_VOICE),1)
CFLAGS += -DENABLE_VOICE
endif
ifeq ($(ENABLE_MUTE_RADIO_FOR_VOICE),1)
CFLAGS += -DENABLE_MUTE_RADIO_FOR_VOICE
endif
ifeq ($(ENABLE_VOX),1)
CFLAGS += -DENABLE_VOX
endif
Expand All @@ -275,6 +277,9 @@ endif
ifeq ($(ENABLE_PWRON_PASSWORD),1)
CFLAGS += -DENABLE_PWRON_PASSWORD
endif
ifeq ($(ENABLE_RESET_AES_KEY),1)
CFLAGS += -DENABLE_RESET_AES_KEY
endif
ifeq ($(ENABLE_KEEP_MEM_NAME),1)
CFLAGS += -DENABLE_KEEP_MEM_NAME
endif
Expand Down Expand Up @@ -308,9 +313,6 @@ endif
ifeq ($(ENABLE_FREQ_CODE_SCAN_TIMEOUT),1)
CFLAGS += -DENABLE_FREQ_CODE_SCAN_TIMEOUT
endif
ifeq ($(ENABLE_FREQ_CODE_ROUNDING),1)
CFLAGS += -DENABLE_FREQ_CODE_ROUNDING
endif
ifeq ($(ENABLE_AM_FIX),1)
CFLAGS += -DENABLE_AM_FIX
endif
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ ENABLE_OVERLAY := 0 cpu FLASH stuff, not needed
ENABLE_LTO := 0 **experimental, reduces size of compiled firmware but might break EEPROM reads (OVERLAY will be disabled if you enable this)
ENABLE_UART := 1 without this you can't configure radio via PC
ENABLE_UART_DEBUG := 0 just for code debugging, it sends debug info along the USB serial connection (programming lead)
ENABLE_AIRCOPY := 0 easier to just enter frequency with butts
ENABLE_AIRCOPY := 1 clone radio-to-radio via RF
ENABLE_FMRADIO := 1 WBFM VHF broadcast band receiver
ENABLE_NOAA := 1 everything NOAA (only of any use in the USA)
ENABLE_VOICE := 0 want to hear voices ?
ENABLE_MUTE_RADIO_FOR_VOICE := 1 mute the radios audio when a voice is playing
ENABLE_VOX := 1 voice operated transmission
ENABLE_ALARM := 1 TX alarms
ENABLE_1750HZ := 1 side key 1750Hz TX tone (older style repeater access)
ENABLE_PWRON_PASSWORD := 1 power-on password stuff
ENABLE_PWRON_PASSWORD := 0 '1' = allow power-on password
ENABLE_RESET_AES_KEY := 1 '1' = reset/clear the AES key stored in the eeprom
ENABLE_BIG_FREQ := 0 big font frequencies (like original QS firmware)
ENABLE_SMALL_BOLD := 1 bold channel name/no. (when name + freq channel display mode)
ENABLE_KEEP_MEM_NAME := 1 maintain channel name when (re)saving memory channel
Expand Down
91 changes: 47 additions & 44 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,15 @@ void APP_StartListening(function_type_t Function, const bool reset_am_fix)
(g_eeprom.dac_gain << 0)); // AF DAC Gain (after Gain-1 and Gain-2)

#ifdef ENABLE_VOICE
if (g_voice_write_index == 0) // AM/FM RX mode will be set when the voice has finished
#ifdef MUTE_AUDIO_FOR_VOICE
if (g_voice_write_index == 0)
BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM);
#else
BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM);
#endif
#else
BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM);
#endif
BK4819_SetAF(g_rx_vfo->am_mode ? BK4819_AF_AM : BK4819_AF_FM); // no need, set it now

FUNCTION_Select(Function);

Expand Down Expand Up @@ -887,14 +893,15 @@ void APP_CheckRadioInterrupts(void)
g_power_save_expired = false;
}

if (g_eeprom.dual_watch != DUAL_WATCH_OFF && (g_schedule_dual_watch || g_dual_watch_count_down_10ms < dual_watch_count_after_vox_10ms))
if (g_eeprom.dual_watch != DUAL_WATCH_OFF &&
(g_schedule_dual_watch || g_dual_watch_count_down_10ms < dual_watch_count_after_vox_10ms))
{
g_dual_watch_count_down_10ms = dual_watch_count_after_vox_10ms;
g_schedule_dual_watch = false;

// let the user see DW is not active
g_dual_watch_active = false;
g_update_status = true;
g_update_status = true;
}
}
}
Expand Down Expand Up @@ -1127,6 +1134,7 @@ void APP_Update(void)
{
NOAA_IncreaseChannel();
RADIO_SetupRegisters(false);

g_noaa_count_down_10ms = 7; // 70ms
g_schedule_noaa = false;
}
Expand All @@ -1136,17 +1144,21 @@ void APP_Update(void)
// toggle between the VFO's if dual watch is enabled
if (g_screen_to_display != DISPLAY_SCANNER && g_eeprom.dual_watch != DUAL_WATCH_OFF)
{
#ifdef ENABLE_VOICE
if (g_voice_write_index == 0)
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
//UART_SendText("dual watch\r\n");
#endif

#ifdef ENABLE_VOICE
if (g_voice_write_index == 0)
#endif
{
if (g_schedule_dual_watch)
{
if (g_scan_state_dir == SCAN_OFF && g_css_scan_mode == CSS_SCAN_MODE_OFF)
{
#ifdef ENABLE_FMRADIO
if (!g_fm_radio_mode)
#endif
#ifdef ENABLE_FMRADIO
if (!g_fm_radio_mode)
#endif
{
if (!g_ptt_is_pressed &&
g_dtmf_call_state == DTMF_CALL_STATE_NONE &&
Expand All @@ -1168,30 +1180,30 @@ void APP_Update(void)
}
}

#ifdef ENABLE_FMRADIO
if (g_schedule_fm &&
g_fm_scan_state != FM_SCAN_OFF &&
g_current_function != FUNCTION_MONITOR &&
g_current_function != FUNCTION_RECEIVE &&
g_current_function != FUNCTION_TRANSMIT)
{ // switch to FM radio mode
FM_Play();
g_schedule_fm = false;
}
#endif
#ifdef ENABLE_FMRADIO
if (g_schedule_fm &&
g_fm_scan_state != FM_SCAN_OFF &&
g_current_function != FUNCTION_MONITOR &&
g_current_function != FUNCTION_RECEIVE &&
g_current_function != FUNCTION_TRANSMIT)
{ // switch to FM radio mode
FM_Play();
g_schedule_fm = false;
}
#endif

#ifdef ENABLE_VOX
if (g_eeprom.vox_switch)
APP_HandleVox();
#endif
#ifdef ENABLE_VOX
if (g_eeprom.vox_switch)
APP_HandleVox();
#endif

if (g_schedule_power_save)
{
#ifdef ENABLE_NOAA
if (
#ifdef ENABLE_FMRADIO
g_fm_radio_mode ||
#endif
#ifdef ENABLE_FMRADIO
g_fm_radio_mode ||
#endif
g_ptt_is_pressed ||
g_key_held ||
g_eeprom.battery_save == 0 ||
Expand Down Expand Up @@ -1495,7 +1507,7 @@ void APP_TimeSlice10ms(void)
UI_DisplayStatus(false);
return;
}

#ifdef ENABLE_BOOT_BEEPS
if (g_boot_counter_10ms > 0 && (g_boot_counter_10ms % 25) == 0)
AUDIO_PlayBeep(BEEP_880HZ_40MS_OPTIONAL);
Expand Down Expand Up @@ -1641,7 +1653,7 @@ void APP_TimeSlice10ms(void)
}

if (g_scanner_edit_state != SCAN_EDIT_STATE_NONE)
{
{ // waiting for user input choice
APP_CheckKeys();
return;
}
Expand Down Expand Up @@ -1673,14 +1685,7 @@ void APP_TimeSlice10ms(void)

BK4819_DisableFrequencyScan();

#ifdef ENABLE_FREQ_CODE_ROUNDING
{ // round to nearest step multiple
const uint32_t step = STEP_FREQ_TABLE[g_step_setting];
g_scan_frequency = ((Result + (step / 2)) / step) * step;
}
#else
g_scan_frequency = Result;
#endif
g_scan_frequency = Result;

if (g_scan_hit_count < 3)
{ // keep scanning for an RF carrier
Expand Down Expand Up @@ -1736,7 +1741,7 @@ void APP_TimeSlice10ms(void)
BK4819_Disable();

if (ScanResult == BK4819_CSS_RESULT_CDCSS)
{
{ // found a CDCSS code
const uint8_t Code = DCS_GetCdcssCode(Result);
if (Code != 0xFF)
{
Expand All @@ -1750,7 +1755,7 @@ void APP_TimeSlice10ms(void)
}
else
if (ScanResult == BK4819_CSS_RESULT_CTCSS)
{
{ // found a CTCSS tone
const uint8_t code = DCS_GetCtcssCode(CtcssFreq);
if (code != 0xFF)
{
Expand All @@ -1773,8 +1778,7 @@ void APP_TimeSlice10ms(void)
}
}

if (g_scan_css_state == SCAN_CSS_STATE_OFF ||
g_scan_css_state == SCAN_CSS_STATE_SCANNING)
if (g_scan_css_state == SCAN_CSS_STATE_OFF || g_scan_css_state == SCAN_CSS_STATE_SCANNING)
{ // re-start scan
BK4819_SetScanFrequency(g_scan_frequency);
g_scan_delay_10ms = scan_freq_css_delay_10ms;
Expand Down Expand Up @@ -1840,7 +1844,7 @@ void APP_TimeSlice500ms(void)
{ // config upload/download is running
return;
}

if (g_keypad_locked > 0)
if (--g_keypad_locked == 0)
g_update_display = true;
Expand Down Expand Up @@ -2269,7 +2273,7 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
return;

backlight_turn_on();

g_beep_to_play = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
// AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL);

Expand Down Expand Up @@ -2393,7 +2397,6 @@ static void APP_ProcessKey(const key_code_t Key, const bool key_pressed, const b
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
UART_printf("proc key 1 %3u %u %u %u %u\r\n", Key, key_pressed, key_held, g_fkey_pressed, flag);
#endif

}

if (g_fkey_pressed && (Key == KEY_PTT || Key == KEY_EXIT || Key == KEY_SIDE1 || Key == KEY_SIDE2))
Expand Down
2 changes: 2 additions & 0 deletions app/fm.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,8 @@ static void FM_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)

static void FM_Key_STAR(bool key_pressed, bool key_held)
{
(void)key_held; // stop compiler warning

// if (key_held)
// return;

Expand Down
4 changes: 2 additions & 2 deletions app/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ void MENU_AcceptSetting(void)
break;

case MENU_F_LOCK:
g_setting_f_lock = g_sub_menu_selection;
g_setting_freq_lock = g_sub_menu_selection;
break;

case MENU_200TX:
Expand Down Expand Up @@ -1226,7 +1226,7 @@ void MENU_ShowCurrentSetting(void)
break;

case MENU_F_LOCK:
g_sub_menu_selection = g_setting_f_lock;
g_sub_menu_selection = g_setting_freq_lock;
break;

case MENU_200TX:
Expand Down
Loading

0 comments on commit 46a082e

Please sign in to comment.