diff --git a/Makefile b/Makefile index da497a1..087125c 100644 --- a/Makefile +++ b/Makefile @@ -22,14 +22,14 @@ ENABLE_F_CAL_MENU := 0 ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1 ENABLE_MAIN_KEY_HOLD := 1 ENABLE_BOOT_BEEPS := 0 -ENABLE_COMPANDER := 1 +ENABLE_COMPANDER := 0 ENABLE_SHOW_CHARGE_LEVEL := 1 ENABLE_REVERSE_BAT_SYMBOL := 1 ENABLE_CODE_SCAN_TIMEOUT := 0 ENABLE_AM_FIX := 1 ENABLE_AM_FIX_SHOW_DATA := 0 ENABLE_SQUELCH_LOWER := 0 -ENABLE_RSSI_BAR := 1 +ENABLE_FASTER_CHANNEL_SCAN := 1ENABLE_RSSI_BAR := 1 ENABLE_AUDIO_BAR := 1 ENABLE_SPECTRUM := 1 #ENABLE_COPY_CHAN_TO_VFO := 1 @@ -40,7 +40,8 @@ ENABLE_SPECTRUM := 1 TARGET = firmware -ifeq ($(ENABLE_LTO),1) +ifeq ($(ENABLE_LTO), 1) + # can't have LTO and OVERLAY enabled at same time ENABLE_OVERLAY := 0 endif @@ -105,7 +106,9 @@ OBJS += app/scanner.o ifeq ($(ENABLE_UART),1) OBJS += app/uart.o endif -OBJS += am_fix.o +ifeq ($(ENABLE_AM_FIX), 1) + OBJS += am_fix.o +endif OBJS += audio.o OBJS += bitmaps.o OBJS += board.o @@ -138,7 +141,7 @@ OBJS += ui/welcome.o OBJS += version.o OBJS += main.o -ifeq ($(OS),Windows_NT) +ifeq ($(OS), Windows_NT) TOP := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) else TOP := $(shell pwd) @@ -167,7 +170,7 @@ CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delet #CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu99 -MMD #CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=gnu11 -MMD -ifeq ($(ENABLE_LTO),1) +ifeq ($(ENABLE_LTO), 1) # CFLAGS += -flto CFLAGS += -flto=2 endif @@ -253,8 +256,14 @@ endif ifeq ($(ENABLE_AM_FIX_TEST1),1) CFLAGS += -DENABLE_AM_FIX_TEST1 endif -ifeq ($(ENABLE_SQUELCH_LOWER),1) - CFLAGS += -DENABLE_SQUELCH_LOWER +ifeq ($(ENABLE_SQUELCH_MORE_SENSITIVE),1) + CFLAGS += -DENABLE_SQUELCH_MORE_SENSITIVE +endif +ifeq ($(ENABLE_FASTER_CHANNEL_SCAN),1) + CFLAGS += -DENABLE_FASTER_CHANNEL_SCAN +endif +ifeq ($(ENABLE_BACKLIGHT_ON_RX),1) + CFLAGS += -DENABLE_BACKLIGHT_ON_RX endif ifeq ($(ENABLE_RSSI_BAR),1) CFLAGS += -DENABLE_RSSI_BAR diff --git a/README.md b/README.md index 17a3512..2a144d1 100644 --- a/README.md +++ b/README.md @@ -51,34 +51,35 @@ You'll find the options at the top of "Makefile" ('0' = disable, '1' = enable) . ``` ENABLE_SWD := 0 only needed if using CPU's SWD port (debugging/programming) -ENABLE_OVERLAY := 0 cpu FLASH stuff -ENABLE_LTO := 0 **experimental, reduces size of compiled firmware but might break EEPROM reads - DISABLE overlay if you enable this -ENABLE_UART := 1 without this you can't configure radio via PC -ENABLE_AIRCOPY := 0 easier to just enter frequency -ENABLE_FMRADIO := 1 WBFM VHF band 2 RX -ENABLE_NOAA := 0 everything NOAA +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_AIRCOPY := 0 easier to just enter frequency with butts +ENABLE_FMRADIO := 1 WBFM VHF broadcast band receiver +ENABLE_NOAA := 0 everything NOAA (only of any use in the USA) ENABLE_VOICE := 0 want to hear voices ? ENABLE_ALARM := 0 TX alarms -ENABLE_1750HZ := 0 side key 1750Hz TX tone -ENABLE_BIG_FREQ := 0 big font frequencies +ENABLE_1750HZ := 0 side key 1750Hz TX tone (older style repeater access) +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 -ENABLE_WIDE_RX := 1 full 18MHz to 1300MHz RX (though frontend not tuned over full range) +ENABLE_WIDE_RX := 1 full 18MHz to 1300MHz RX (though front-end/PA not designed for full range) ENABLE_TX_WHEN_AM := 0 allow TX (always FM) when RX is set to AM ENABLE_F_CAL_MENU := 0 enable/disable the radios hidden frequency calibration menu ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1 standard CTCSS tail phase shift rather than QS's own 55Hz tone method -ENABLE_MAIN_KEY_HOLD := 1 initial F-key press not needed, instead hold down keys 0-9 to access the functions -ENABLE_BOOT_BEEPS := 0 give user audio feedback on volume knob position at boot-up -ENABLE_COMPANDER := 1 compander option (per channel) +ENABLE_MAIN_KEY_HOLD := 1 initial F-key press not needed, instead just hold down keys 0-9 to access the secondary butt functions +ENABLE_BOOT_BEEPS := 0 gives user audio feedback on volume knob position at boot-up +ENABLE_COMPANDER := 0 this is broken, don't bother with it for now .. compander option (per channel) ENABLE_SHOW_CHARGE_LEVEL := 0 show the charge level when the radio is on charge ENABLE_REVERSE_BAT_SYMBOL := 1 mirror the battery symbol on the status bar (+ pole on the right) -ENABLE_CODE_SCAN_TIMEOUT := 0 enable/disable 32-sec CTCSS/DCS scan timeout (press exit butt to end scan if disabled) -ENABLE_AM_FIX := 1 dynamically adjust the front end gains when in AM mode to helo prevent AM demodulator saturation - ignore the on-screen RSSI (for now) -ENABLE_AM_FIX_SHOW_DATA := 1 show debug data for the AM fix -ENABLE_SQUELCH_LOWER := 1 squelch settings more sensitive - plan to let user adjust it in the menu -ENABLE_RSSI_BAR := 1 enable a dBm/Sx RSSI bar graph level +ENABLE_CODE_SCAN_TIMEOUT := 0 enable/disable 32-sec CTCSS/DCS scan timeout (press exit butt instead of time-out to end scan) +ENABLE_AM_FIX := 1 dynamically adjust the front end gains when in AM mode to helo prevent AM demodulator saturation, ignore the on-screen RSSI level (for now) +ENABLE_AM_FIX_SHOW_DATA := 1 show debug data for the AM fix (still tweaking it) +ENABLE_SQUELCH_MORE_SENSITIVE := 1 make squelch levels a little bit more sensitive - I plan to let user adjust the values themselves +ENABLE_FASTER_CHANNEL_SCAN := 0 increases the channel scan speed, but the squelch is also made more twitchy +ENABLE_RSSI_BAR := 1 enable a dBm/Sn RSSI bar graph level inplace of the little antenna symbols ENABLE_AUDIO_BAR := 0 experimental, display an audo bar level when TX'ing -#ENABLE_COPY_CHAN_TO_VFO := 1 not yet implemented - copy the channel into the VFO +#ENABLE_COPY_CHAN_TO_VFO := 1 not yet implemented - copy the current channel into the VFO #ENABLE_SINGLE_VFO_CHAN := 1 not yet implemented - single VFO on display when possible #ENABLE_BAND_SCOPE := 1 not yet implemented - spectrum/pan-adapter ``` diff --git a/am_fix.c b/am_fix.c index 54a4bce..74fe946 100644 --- a/am_fix.c +++ b/am_fix.c @@ -30,12 +30,6 @@ #include "functions.h" #include "misc.h" -// original QS front end register settings -const uint8_t orig_lna_short = 3; // 0dB -const uint8_t orig_lna = 2; // -14dB -const uint8_t orig_mixer = 3; // 0dB -const uint8_t orig_pga = 6; // -3dB - #ifdef ENABLE_AM_FIX typedef struct @@ -449,7 +443,7 @@ const uint8_t orig_pga = 6; // -3dB #if 0 if (gain_table_index[vfo] == gain_table_index_prev[vfo]) - return; // no gain change + return; // no gain change - this is to reduce writing to the BK chip on ever call #endif #endif diff --git a/am_fix.h b/am_fix.h index 62973f7..3c94d17 100644 --- a/am_fix.h +++ b/am_fix.h @@ -20,11 +20,6 @@ #include #include -extern const uint8_t orig_lna_short; -extern const uint8_t orig_lna; -extern const uint8_t orig_mixer; -extern const uint8_t orig_pga; - #ifdef ENABLE_AM_FIX extern int16_t rssi_gain_diff[2]; diff --git a/app/action.c b/app/action.c index 3fa0ca5..68ddf14 100644 --- a/app/action.c +++ b/app/action.c @@ -109,7 +109,7 @@ void ACTION_Monitor(void) } else #endif - gRequestDisplayScreen = gScreenToDisplay; + gRequestDisplayScreen = gScreenToDisplay; } void ACTION_Scan(bool bRestart) @@ -251,7 +251,9 @@ void ACTION_Vox(void) #endif gFlagPrepareTX = true; - gRequestDisplayScreen = DISPLAY_MAIN; + +// if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu + gRequestDisplayScreen = DISPLAY_MAIN; } #endif @@ -268,6 +270,7 @@ void ACTION_Vox(void) gInputBoxIndex = 0; gVoxResumeCountdown = 80; gFlagReconfigureVfos = true; + gRequestDisplayScreen = DISPLAY_MAIN; return; } @@ -279,7 +282,8 @@ void ACTION_Vox(void) FM_Start(); - gInputBoxIndex = 0; + gInputBoxIndex = 0; + gRequestDisplayScreen = DISPLAY_FM; } } diff --git a/app/app.c b/app/app.c index db123a0..c691ab1 100644 --- a/app/app.c +++ b/app/app.c @@ -62,6 +62,12 @@ #include "ui/status.h" #include "ui/ui.h" +// original QS front end register settings +const uint8_t orig_lna_short = 3; // 0dB +const uint8_t orig_lna = 2; // -14dB +const uint8_t orig_mixer = 3; // 0dB +const uint8_t orig_pga = 6; // -3dB + static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld); static void updateRSSI(const int vfo) @@ -157,6 +163,7 @@ static void APP_CheckForIncoming(void) updateRSSI(gEeprom.RX_CHANNEL); gUpdateRSSI = true; } + return; } @@ -223,7 +230,7 @@ static void APP_HandleIncoming(void) if (gRxVfo->DTMF_DECODING_ENABLE || gSetting_KILLED) { // DTMF DCD is enabled -// DTMF_HandleRequest(); + DTMF_HandleRequest(); if (gDTMF_CallState == DTMF_CALL_STATE_NONE) { @@ -461,6 +468,9 @@ static void APP_HandleFunction(void) void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix) { + const unsigned int chan = gEeprom.RX_CHANNEL; +// const unsigned int chan = gRxVfo->CHANNEL_SAVE; + if (gSetting_KILLED) return; @@ -469,19 +479,15 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix) BK1080_Init(0, false); #endif - #ifdef ENABLE_AM_FIX - if (gEeprom.VfoInfo[gEeprom.RX_CHANNEL].AM_mode && reset_am_fix) - AM_fix_reset(gEeprom.RX_CHANNEL); // TODO: only reset it when moving channel/frequency - #endif - // clear the other vfo's rssi level (to hide the antenna symbol) - gVFO_RSSI_bar_level[gEeprom.RX_CHANNEL == 0] = 0; + gVFO_RSSI_bar_level[(chan + 1) & 1u] = 0; GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); gEnableSpeaker = true; - BACKLIGHT_TurnOn(); + if (gSetting_backlight_on_rx) + BACKLIGHT_TurnOn(); if (gScanState != SCAN_OFF) { @@ -509,19 +515,21 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix) #ifdef ENABLE_NOAA if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gIsNoaaMode) { - gRxVfo->CHANNEL_SAVE = gNoaaChannel + NOAA_CHANNEL_FIRST; - gRxVfo->pRX->Frequency = NoaaFrequencyTable[gNoaaChannel]; - gRxVfo->pTX->Frequency = NoaaFrequencyTable[gNoaaChannel]; - gEeprom.ScreenChannel[gEeprom.RX_CHANNEL] = gRxVfo->CHANNEL_SAVE; - gNOAA_Countdown_10ms = 500; // 5 sec - gScheduleNOAA = false; + gRxVfo->CHANNEL_SAVE = gNoaaChannel + NOAA_CHANNEL_FIRST; + gRxVfo->pRX->Frequency = NoaaFrequencyTable[gNoaaChannel]; + gRxVfo->pTX->Frequency = NoaaFrequencyTable[gNoaaChannel]; + gEeprom.ScreenChannel[chan] = gRxVfo->CHANNEL_SAVE; + gNOAA_Countdown_10ms = 500; // 5 sec + gScheduleNOAA = false; } #endif if (gCssScanMode != CSS_SCAN_MODE_OFF) gCssScanMode = CSS_SCAN_MODE_FOUND; - if (gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + if (gScanState == SCAN_OFF && + gCssScanMode == CSS_SCAN_MODE_OFF && + gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) { // not scanning, dual watch is enabled gDualWatchCountdown_10ms = dual_watch_count_after_2_10ms; @@ -534,53 +542,31 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix) gUpdateStatus = true; } - // ****************************************** + { // RF RX front end gain + + // original setting + uint16_t lna_short = orig_lna_short; + uint16_t lna = orig_lna; + uint16_t mixer = orig_mixer; + uint16_t pga = orig_pga; - // original setting - uint8_t lna_short = orig_lna_short; - uint8_t lna = orig_lna; - uint8_t mixer = orig_mixer; - uint8_t pga = orig_pga; - - if (gRxVfo->AM_mode) - { // AM -/* - #ifndef ENABLE_AM_FIX - const uint32_t rx_frequency = gRxVfo->pRX->Frequency; - - // the RX gain abrutly reduces above this frequency - // I guess this is (one of) the freq the hardware switches the front ends over ? - if (rx_frequency <= 22640000) - { // decrease front end gain - AM demodulator saturates at a slightly higher signal level - lna_short = 3; // 3 original - lna = 2; // 2 original - mixer = 3; // 3 original - pga = 3; // 6 original, 3 reduced + #ifdef ENABLE_AM_FIX + if (gRxVfo->AM_mode && gSetting_AM_fix) + { // AM RX mode + if (reset_am_fix) + AM_fix_reset(chan); // TODO: only reset it when moving channel/frequency + AM_fix_10ms(chan); } else - { // increase the front end to compensate the reduced gain, but more gain decreases dynamic range :( - lna_short = 3; // 3 original - lna = 4; // 2 original, 4 increased - mixer = 3; // 3 original - pga = 7; // 6 original, 7 increased + { // FM RX mode + BK4819_WriteRegister(BK4819_REG_13, (lna_short << 8) | (lna << 5) | (mixer << 3) | (pga << 0)); } + #else + BK4819_WriteRegister(BK4819_REG_13, (lna_short << 8) | (lna << 5) | (mixer << 3) | (pga << 0)); #endif -*/ - // what do these 4 other gain settings do ??? - //BK4819_WriteRegister(BK4819_REG_12, 0x037B); // 000000 11 011 11 011 - //BK4819_WriteRegister(BK4819_REG_11, 0x027B); // 000000 10 011 11 011 - //BK4819_WriteRegister(BK4819_REG_10, 0x007A); // 000000 00 011 11 010 - //BK4819_WriteRegister(BK4819_REG_14, 0x0019); // 000000 00 000 11 001 - - gNeverUsed = 0; } - // apply the front end gain settings - BK4819_WriteRegister(BK4819_REG_13, ((uint16_t)lna_short << 8) | ((uint16_t)lna << 5) | ((uint16_t)mixer << 3) | ((uint16_t)pga << 0)); - - // ****************************************** - - // AF gain - original + // AF gain - original QS values BK4819_WriteRegister(BK4819_REG_48, (11u << 12) | // ??? .. 0 to 15, doesn't seem to make any difference ( 0u << 10) | // AF Rx Gain-1 @@ -588,7 +574,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix) (gEeprom.DAC_GAIN << 0)); // AF DAC Gain (after Gain-1 and Gain-2) #ifdef ENABLE_VOICE - if (gVoiceWriteIndex == 0) +// if (gVoiceWriteIndex == 0) #endif BK4819_SetAF(gRxVfo->AM_mode ? BK4819_AF_AM : BK4819_AF_OPEN); @@ -600,11 +586,13 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix) if (Function == FUNCTION_MONITOR) #endif { // squelch is disabled - GUI_SelectNextDisplay(DISPLAY_MAIN); - return; + if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu + GUI_SelectNextDisplay(DISPLAY_MAIN); } + else + gUpdateDisplay = true; - gUpdateDisplay = true; + gUpdateStatus = true; } uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step) @@ -678,7 +666,7 @@ static void MR_NextChannel(void) break; } - // this bit doesn't work at all :( + // this bit doesn't work at all - yet :( case SCAN_NEXT_CHAN_DUAL_WATCH: // if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) { @@ -724,8 +712,11 @@ static void MR_NextChannel(void) gUpdateDisplay = true; } -// ScanPauseDelayIn_10ms = scan_pause_delay_in_3_10ms; - ScanPauseDelayIn_10ms = 8; // 80ms .. <= ~60ms it misses signals (squelch response and/or PLL lock time) ? + #ifdef ENABLE_FASTER_CHANNEL_SCAN + ScanPauseDelayIn_10ms = 8; // 80ms .. <= ~60ms it misses signals (squelch response and/or PLL lock time) ? + #else + ScanPauseDelayIn_10ms = scan_pause_delay_in_3_10ms; + #endif bScanKeepFrequency = false; @@ -1013,7 +1004,7 @@ static void APP_HandleVox(void) if (gCurrentFunction == FUNCTION_POWER_SAVE) FUNCTION_Select(FUNCTION_FOREGROUND); - if (gCurrentFunction != FUNCTION_TRANSMIT) + if (gCurrentFunction != FUNCTION_TRANSMIT && gSerialConfigCountDown_500ms == 0) { gDTMF_ReplyState = DTMF_REPLY_NONE; RADIO_PrepareTX(); @@ -1032,8 +1023,8 @@ void APP_Update(void) } #endif - if (gCurrentFunction == FUNCTION_TRANSMIT && gTxTimeoutReached) - { // transmitter timed out + if ((gCurrentFunction == FUNCTION_TRANSMIT && gTxTimeoutReached) || gSerialConfigCountDown_500ms > 0) + { // transmitter timed out or must de-key gTxTimeoutReached = false; gFlagEndTransmission = true; @@ -1486,22 +1477,27 @@ void APP_TimeSlice10ms(void) if (gAlarmState == ALARM_STATE_TXALARM) { gAlarmState = ALARM_STATE_ALARM; + RADIO_EnableCxCSS(); BK4819_SetupPowerAmplifier(0, 0); BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1, false); BK4819_Enable_AfDac_DiscMode_TxDsp(); BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_RED, false); + GUI_DisplayScreen(); } else { gAlarmState = ALARM_STATE_TXALARM; + GUI_DisplayScreen(); + BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_RED, true); RADIO_SetTxParameters(); BK4819_TransmitTone(true, 500); SYSTEM_DelayMs(2); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); + gEnableSpeaker = true; gAlarmToneCounter = 0; } @@ -1588,7 +1584,9 @@ void APP_TimeSlice10ms(void) gScanUseCssResult = false; gScanProgressIndicator = 0; gScanCssState = SCAN_CSS_STATE_SCANNING; + GUI_SelectNextDisplay(DISPLAY_SCANNER); + gUpdateStatus = true; } @@ -1679,7 +1677,9 @@ void cancelUserInputModes(void) gDTMF_InputMode = false; gDTMF_InputIndex = 0; gInputBoxIndex = 0; + gRequestDisplayScreen = DISPLAY_MAIN; + gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; } } @@ -1715,14 +1715,9 @@ void APP_TimeSlice500ms(void) if (gSerialConfigCountDown_500ms > 0) { - gReducedService = true; // a serial config upload/download is in progress - -// if (gCurrentFunction == FUNCTION_TRANSMIT) -// { // stop transmitting -// -// } +// gReducedService = true; // a serial config upload/download is in progress } - + // Skipped authentic device check #ifdef ENABLE_FMRADIO @@ -1754,30 +1749,27 @@ void APP_TimeSlice500ms(void) // Skipped authentic device check + if ((gBatteryCheckCounter & 1) == 0) + { + BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[gBatteryVoltageIndex++], &gBatteryCurrent); + if (gBatteryVoltageIndex > 3) + gBatteryVoltageIndex = 0; + BATTERY_GetReadings(true); + } + + // regular display updates (once every 2 sec) - if need be + if ((gBatteryCheckCounter & 3) == 0) + { + if (gChargingWithTypeC || gSetting_battery_text > 0) + gUpdateStatus = true; + #ifdef ENABLE_SHOW_CHARGE_LEVEL + if (gChargingWithTypeC) + gUpdateDisplay = true; + #endif + } + if (gCurrentFunction != FUNCTION_TRANSMIT) { - if ((gBatteryCheckCounter & 1) == 0) - { - BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[gBatteryVoltageIndex++], &gBatteryCurrent); - - if (gBatteryVoltageIndex > 3) - gBatteryVoltageIndex = 0; - - BATTERY_GetReadings(true); - } - - // regular display updates (once every 2 sec) - if need be - if ((gBatteryCheckCounter & 3) == 0) - { - if (gChargingWithTypeC || gSetting_battery_text > 0) - gUpdateStatus = true; - - #ifdef ENABLE_SHOW_CHARGE_LEVEL - if (gChargingWithTypeC) - gUpdateDisplay = true; - #endif - } - if (gCurrentFunction != FUNCTION_POWER_SAVE) updateRSSI(gEeprom.RX_CHANNEL); @@ -1800,7 +1792,7 @@ void APP_TimeSlice500ms(void) #endif { bool exit_menu = false; - + if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown > 0 && !gDTMF_InputMode) { if (--gKeyLockCountdown == 0) @@ -1812,11 +1804,11 @@ void APP_TimeSlice500ms(void) if (gMenuCountdown > 0) if (--gMenuCountdown == 0) exit_menu = true; // exit menu mode - + if (exit_menu) { gMenuCountdown = 0; - + if (gEeprom.BACKLIGHT == 0 && gScreenToDisplay == DISPLAY_MENU) { gBacklightCountdown = 0; @@ -2008,7 +2000,8 @@ void APP_TimeSlice500ms(void) RADIO_SetupRegisters(true); - gRequestDisplayScreen = DISPLAY_MAIN; +// if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu + gRequestDisplayScreen = DISPLAY_MAIN; } #endif @@ -2098,18 +2091,18 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_CHANNEL, gTxVfo, gFlagSaveChannel); gFlagSaveChannel = false; + RADIO_ConfigureChannel(gEeprom.TX_CHANNEL, VFO_CONFIGURE); RADIO_SetupRegisters(true); + GUI_SelectNextDisplay(DISPLAY_MAIN); } } else { - if (Key != KEY_PTT) - { + if (gScreenToDisplay == DISPLAY_MENU) // 1of11 gMenuCountdown = menu_timeout_500ms; - } - + BACKLIGHT_TurnOn(); if (gDTMF_DecodeRingCountdown_500ms > 0) @@ -2293,9 +2286,11 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { case DISPLAY_MAIN: MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld); + #ifdef ENABLE_MAIN_KEY_HOLD bKeyHeld = false; // allow the channel setting to be saved #endif + break; #ifdef ENABLE_FMRADIO @@ -2401,6 +2396,7 @@ Skip: if (!bKeyHeld) { SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_CHANNEL, gTxVfo, gRequestSaveChannel); + if (gScreenToDisplay != DISPLAY_SCANNER) if (gVfoConfigureMode == VFO_CONFIGURE_NONE) // 'if' is so as we don't wipe out previously setting this variable elsewhere gVfoConfigureMode = VFO_CONFIGURE; @@ -2408,6 +2404,7 @@ Skip: else { gFlagSaveChannel = gRequestSaveChannel; + if (gRequestDisplayScreen == DISPLAY_INVALID) gRequestDisplayScreen = DISPLAY_MAIN; } diff --git a/app/app.h b/app/app.h index f71765d..8d029b0 100644 --- a/app/app.h +++ b/app/app.h @@ -23,6 +23,11 @@ #include "frequencies.h" #include "radio.h" +extern const uint8_t orig_lna_short; +extern const uint8_t orig_lna; +extern const uint8_t orig_mixer; +extern const uint8_t orig_pga; + void APP_EndTransmission(void); void CHANNEL_Next(bool bFlag, int8_t Direction); void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix); diff --git a/app/generic.c b/app/generic.c index ca05855..fb378c1 100644 --- a/app/generic.c +++ b/app/generic.c @@ -86,7 +86,7 @@ void GENERIC_Key_F(bool bKeyPressed, bool bKeyHeld) gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; return; } - + #ifdef ENABLE_FMRADIO if (gFM_ScanState == FM_SCAN_OFF) { @@ -104,9 +104,9 @@ void GENERIC_Key_PTT(bool bKeyPressed) { gInputBoxIndex = 0; - if (!bKeyPressed) + if (!bKeyPressed || gSerialConfigCountDown_500ms > 0) { - if (gScreenToDisplay == DISPLAY_MAIN) + //if (gScreenToDisplay == DISPLAY_MAIN) { if (gCurrentFunction == FUNCTION_TRANSMIT) { @@ -132,10 +132,9 @@ void GENERIC_Key_PTT(bool bKeyPressed) RADIO_SetVfoState(VFO_STATE_NORMAL); - // beep when you release the PTT - //gBeepToPlay = BEEP_880HZ_40MS_OPTIONAL; // 1of11 + if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu + gRequestDisplayScreen = DISPLAY_MAIN; - gRequestDisplayScreen = DISPLAY_MAIN; return; } @@ -149,7 +148,10 @@ void GENERIC_Key_PTT(bool bKeyPressed) gPttDebounceCounter = 0; gPttIsPressed = false; - gRequestDisplayScreen = DISPLAY_MAIN; + + if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu + gRequestDisplayScreen = DISPLAY_MAIN; + return; } @@ -160,17 +162,15 @@ void GENERIC_Key_PTT(bool bKeyPressed) if (gCssScanMode == CSS_SCAN_MODE_OFF) { #ifdef ENABLE_FMRADIO - if (gScreenToDisplay == DISPLAY_MENU || gScreenToDisplay == DISPLAY_FM) - #else - if (gScreenToDisplay == DISPLAY_MENU) + if (gScreenToDisplay == DISPLAY_FM) + { + gRequestDisplayScreen = DISPLAY_MAIN; + gInputBoxIndex = 0; + gPttIsPressed = false; + gPttDebounceCounter = 0; + return; + } #endif - { - gRequestDisplayScreen = DISPLAY_MAIN; - gInputBoxIndex = 0; - gPttIsPressed = false; - gPttDebounceCounter = 0; - return; - } if (gScreenToDisplay != DISPLAY_SCANNER) { @@ -213,21 +213,26 @@ void GENERIC_Key_PTT(bool bKeyPressed) gDTMF_State = DTMF_STATE_0; } - gRequestDisplayScreen = DISPLAY_MAIN; + if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu + gRequestDisplayScreen = DISPLAY_MAIN; gDTMF_InputMode = false; gDTMF_InputIndex = 0; return; } - gRequestDisplayScreen = DISPLAY_MAIN; + if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu + gRequestDisplayScreen = DISPLAY_MAIN; + gFlagPrepareTX = true; gInputBoxIndex = 0; return; } - gRequestDisplayScreen = DISPLAY_MAIN; + if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu + gRequestDisplayScreen = DISPLAY_MAIN; + gEeprom.CROSS_BAND_RX_TX = gBackupCROSS_BAND_RX_TX; gUpdateStatus = true; gFlagStopScan = true; @@ -237,7 +242,9 @@ void GENERIC_Key_PTT(bool bKeyPressed) else { MENU_StopCssScan(); - gRequestDisplayScreen = DISPLAY_MENU; + + if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu + gRequestDisplayScreen = DISPLAY_MENU; } } #ifdef ENABLE_FMRADIO @@ -247,11 +254,10 @@ void GENERIC_Key_PTT(bool bKeyPressed) gRequestDisplayScreen = DISPLAY_FM; } #endif - + #ifdef ENABLE_VOICE gAnotherVoiceID = VOICE_ID_SCANNING_STOP; #endif gPttWasPressed = true; } - diff --git a/app/main.c b/app/main.c index 1701af2..9686e26 100644 --- a/app/main.c +++ b/app/main.c @@ -80,6 +80,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) gRequestSaveVFO = true; gVfoConfigureMode = VFO_CONFIGURE_RELOAD; + gRequestDisplayScreen = DISPLAY_MAIN; if (beep) @@ -104,6 +105,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) gRequestSaveSettings = 1; gFlagReconfigureVfos = true; + gRequestDisplayScreen = DISPLAY_MAIN; if (beep) @@ -650,6 +652,7 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld) gDTMF_InputMode = true; memmove(gDTMF_InputBox, gDTMF_String, sizeof(gDTMF_InputBox)); gDTMF_InputIndex = 0; + gRequestDisplayScreen = DISPLAY_MAIN; return; } @@ -807,7 +810,9 @@ void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) DTMF_Append(Character); gKeyInputCountdown = key_input_timeout_500ms; + gRequestDisplayScreen = DISPLAY_MAIN; + gPttWasReleased = true; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; return; diff --git a/app/menu.c b/app/menu.c index 5ad3596..aed2dbf 100644 --- a/app/menu.c +++ b/app/menu.c @@ -212,6 +212,7 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax) #ifdef ENABLE_AUDIO_BAR case MENU_MIC_BAR: #endif + case MENU_ABR_ON_RX: case MENU_BCL: case MENU_BEEP: case MENU_AUTOLK: @@ -406,9 +407,6 @@ void MENU_AcceptSetting(void) case MENU_T_CTCS: pConfig = &gTxVfo->freq_config_TX; - - // Fallthrough - case MENU_R_CTCS: if (gSubMenuSelection == 0) { @@ -418,14 +416,20 @@ void MENU_AcceptSetting(void) return; } Code = 0; + pConfig->Code = Code; pConfig->CodeType = CODE_TYPE_OFF; + + BK4819_ExitSubAu(); } else - { + { pConfig->CodeType = CODE_TYPE_CONTINUOUS_TONE; Code = gSubMenuSelection - 1; + pConfig->Code = Code; + + BK4819_SetCTCSSFrequency(CTCSS_Options[Code]); } - pConfig->Code = Code; + gRequestSaveChannel = 1; return; @@ -446,6 +450,12 @@ void MENU_AcceptSetting(void) case MENU_SCR: gTxVfo->SCRAMBLING_TYPE = gSubMenuSelection; + #if 0 + if (gSubMenuSelection > 0 && gSetting_ScrambleEnable) + BK4819_EnableScramble(gSubMenuSelection - 1); + else + BK4819_DisableScramble(); + #endif gRequestSaveChannel = 1; return; @@ -500,6 +510,10 @@ void MENU_AcceptSetting(void) gEeprom.BACKLIGHT = gSubMenuSelection; break; + case MENU_ABR_ON_RX: + gSetting_backlight_on_rx = gSubMenuSelection; + break; + case MENU_TDR: gEeprom.DUAL_WATCH = gSubMenuSelection; gFlagReconfigureVfos = true; @@ -584,7 +598,10 @@ void MENU_AcceptSetting(void) #ifdef ENABLE_COMPANDER case MENU_COMPAND: gTxVfo->Compander = gSubMenuSelection; - gRequestSaveChannel = 1; + SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true); + gVfoConfigureMode = VFO_CONFIGURE; + gFlagResetVfos = true; +// gRequestSaveChannel = 1; return; #endif @@ -915,6 +932,10 @@ void MENU_ShowCurrentSetting(void) GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); // turn the backlight ON while in backlight menu break; + case MENU_ABR_ON_RX: + gSubMenuSelection = gSetting_backlight_on_rx; + break; + case MENU_TDR: gSubMenuSelection = gEeprom.DUAL_WATCH; break; diff --git a/app/scanner.c b/app/scanner.c index d4038b0..1035547 100644 --- a/app/scanner.c +++ b/app/scanner.c @@ -92,6 +92,7 @@ static void SCANNER_Key_EXIT(bool bKeyPressed, bool bKeyHeld) { case 0: gRequestDisplayScreen = DISPLAY_MAIN; + gEeprom.CROSS_BAND_RX_TX = gBackupCROSS_BAND_RX_TX; gUpdateStatus = true; gFlagStopScan = true; diff --git a/app/uart.c b/app/uart.c index 21f7f1d..913b56f 100644 --- a/app/uart.c +++ b/app/uart.c @@ -230,8 +230,7 @@ static void CMD_0514(const uint8_t *pBuffer) gFmRadioCountdown_500ms = fm_radio_countdown_500ms; #endif - gSerialConfigCountDown_500ms = 6; // 3 sec - gSerialConfigCountDown_done = false; + gSerialConfigCountDown_500ms = 12; // 6 sec // turn the LCD backlight off GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); @@ -248,8 +247,7 @@ static void CMD_051B(const uint8_t *pBuffer) if (pCmd->Timestamp != Timestamp) return; - gSerialConfigCountDown_500ms = 6; // 3 sec - gSerialConfigCountDown_done = false; + gSerialConfigCountDown_500ms = 12; // 6 sec #ifdef ENABLE_FMRADIO gFmRadioCountdown_500ms = fm_radio_countdown_500ms; @@ -280,9 +278,8 @@ static void CMD_051D(const uint8_t *pBuffer) if (pCmd->Timestamp != Timestamp) return; - gSerialConfigCountDown_500ms = 6; // 3 sec - gSerialConfigCountDown_done = false; - + gSerialConfigCountDown_500ms = 12; // 6 sec + bReloadEeprom = false; #ifdef ENABLE_FMRADIO @@ -404,8 +401,7 @@ static void CMD_052F(const uint8_t *pBuffer) if (gCurrentFunction == FUNCTION_POWER_SAVE) FUNCTION_Select(FUNCTION_FOREGROUND); - gSerialConfigCountDown_500ms = 6; // 3 sec - gSerialConfigCountDown_done = false; + gSerialConfigCountDown_500ms = 12; // 6 sec Timestamp = pCmd->Timestamp; diff --git a/audio.c b/audio.c index 94d54d6..eff3393 100644 --- a/audio.c +++ b/audio.c @@ -279,12 +279,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) SYSTEM_DelayMs(Delay * 10); if (gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR) - { - if (gRxVfo->AM_mode) - BK4819_SetAF(BK4819_AF_AM); - else - BK4819_SetAF(BK4819_AF_OPEN); - } + BK4819_SetAF(gRxVfo->AM_mode ? BK4819_AF_AM : BK4819_AF_OPEN); #ifdef ENABLE_FMRADIO if (gFmRadioMode) diff --git a/bitmaps.c b/bitmaps.c index 3f5a105..0f6b6de 100644 --- a/bitmaps.c +++ b/bitmaps.c @@ -4,7 +4,7 @@ // all these images are on their right sides // turn your monitor 90-deg anti-clockwise to see the images -const uint8_t BITMAP_PowerSave[8] = +const uint8_t BITMAP_POWERSAVE[8] = { #if 0 // "S" @@ -29,6 +29,30 @@ const uint8_t BITMAP_PowerSave[8] = #endif }; +const uint8_t BITMAP_TX[8] = +{ // "TX" + 0b00000000, + 0b00000001, + 0b00000001, + 0b01111111, + 0b00000001, + 0b00000001, + 0b00000000, + 0b00000000 +}; + +const uint8_t BITMAP_RX[8] = +{ // "RX" + 0b00000000, + 0b01111111, + 0b00001001, + 0b00011001, + 0b01100110, + 0b00000000, + 0b00000000, + 0b00000000 +}; + const uint8_t BITMAP_BatteryLevel[2] = { 0b01011101, diff --git a/bitmaps.h b/bitmaps.h index 96b984a..51e2fbb 100644 --- a/bitmaps.h +++ b/bitmaps.h @@ -4,7 +4,9 @@ #include -extern const uint8_t BITMAP_PowerSave[8]; +extern const uint8_t BITMAP_POWERSAVE[8]; +extern const uint8_t BITMAP_TX[8]; +extern const uint8_t BITMAP_RX[8]; extern const uint8_t BITMAP_BatteryLevel[2]; extern const uint8_t BITMAP_BatteryLevel1[17]; diff --git a/board.c b/board.c index 2b5f729..2a9ca2c 100644 --- a/board.c +++ b/board.c @@ -712,6 +712,7 @@ void BOARD_EEPROM_Init(void) #ifdef ENABLE_AM_FIX gSetting_AM_fix = (Data[7] & (1u << 5)) ? true : false; #endif + gSetting_backlight_on_rx = (Data[7] & (1u << 6)) ? true : false; if (!gEeprom.VFO_OPEN) { diff --git a/driver/bk4819.c b/driver/bk4819.c index d28ad6b..551de68 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -716,14 +716,14 @@ void BK4819_SetupSquelch( // 0 ~ 255 // BK4819_WriteRegister(BK4819_REG_4E, // 01 101 11 1 00000000 - #if 0 + #ifndef ENABLE_FASTER_CHANNEL_SCAN // original (1u << 14) // 1 ??? | (5u << 11) // 5 squelch = 1 delay .. 0 ~ 7 | (3u << 9) // 3 squelch = 0 delay .. 0 ~ 3 | SquelchOpenGlitchThresh); // 0 ~ 255 #else - // supposedly fast + // faster (but twitchier) (1u << 14) // 1 ??? | SquelchOpenGlitchThresh); // 0 ~ 255 #endif @@ -831,14 +831,16 @@ void BK4819_SetCompander(const unsigned int mode) // mode 2 .. RX // mode 3 .. TX and RX + const uint16_t r31 = BK4819_ReadRegister(BK4819_REG_31); + if (mode == 0) { // disable - BK4819_WriteRegister(BK4819_REG_31, BK4819_ReadRegister(BK4819_REG_31) & ~(1u < 3)); + BK4819_WriteRegister(BK4819_REG_31, r31 & ~(1u < 3)); return; } // enable - BK4819_WriteRegister(BK4819_REG_31, BK4819_ReadRegister(BK4819_REG_31) | (1u < 3)); + BK4819_WriteRegister(BK4819_REG_31, r31 | (1u < 3)); // set the compressor ratio // @@ -848,9 +850,18 @@ void BK4819_SetCompander(const unsigned int mode) // 10 = 2:1 // 11 = 4:1 // - const uint16_t compress_ratio = (mode == 1 || mode >= 3) ? 3 : 0; // 4:1 - BK4819_WriteRegister(BK4819_REG_29, (BK4819_ReadRegister(BK4819_REG_29) & ~(3u < 14)) | (compress_ratio < 14)); - + // REG_29 <13:7> 86 Compress (AF Tx) 0 dB point (dB) + // + // REG_29 <6:0> 64 Compress (AF Tx) noise point (dB) + // +// const uint16_t compress_ratio = (mode == 1 || mode >= 3) ? 2 : 0; // 2:1 +// const uint16_t compress_0dB = 86; +// const uint16_t compress_noise_dB = 64; +// BK4819_WriteRegister(BK4819_REG_29, // (BK4819_ReadRegister(BK4819_REG_29) & ~(3u < 14)) | (compress_ratio < 14)); +// (compress_ratio < 14) +// | (compress_0dB < 7) +// | (compress_noise_dB < 0)); + // set the expander ratio // // REG_28 <15:14> 01 Expander (AF Rx) Ratio @@ -859,8 +870,17 @@ void BK4819_SetCompander(const unsigned int mode) // 10 = 1:3 // 11 = 1:4 // - const uint16_t expand_ratio = (mode >= 2) ? 3 : 0; // 1:4 - BK4819_WriteRegister(BK4819_REG_28, (BK4819_ReadRegister(BK4819_REG_28) & ~(3u < 14)) | (expand_ratio < 14)); + // REG_28 <13:7> 86 Expander (AF Rx) 0 dB point (dB) + // + // REG_28 <6:0> 56 Expander (AF Rx) noise point (dB) + // +// const uint16_t expand_ratio = (mode >= 2) ? 1 : 0; // 1:2 +// const uint16_t expand_0dB = 86; +// const uint16_t expand_noise_dB = 56; +// BK4819_WriteRegister(BK4819_REG_28, // (BK4819_ReadRegister(BK4819_REG_28) & ~(3u < 14)) | (expand_ratio < 14)); +// (expand_ratio < 14) +// | (expand_0dB < 7) +// | (expand_noise_dB < 0)); } void BK4819_DisableVox(void) diff --git a/firmware.bin b/firmware.bin index 85791de..01a16ca 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index b721073..1541aad 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/functions.c b/functions.c index 01fb967..232a01b 100644 --- a/functions.c +++ b/functions.c @@ -74,6 +74,8 @@ void FUNCTION_Init(void) #ifdef ENABLE_NOAA gNOAACountdown_10ms = 0; #endif + + gUpdateStatus = true; } void FUNCTION_Select(FUNCTION_Type_t Function) @@ -113,6 +115,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function) if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED) gDTMF_AUTO_RESET_TIME = 1 + (gEeprom.DTMF_AUTO_RESET_TIME * 2); + gUpdateStatus = true; return; case FUNCTION_MONITOR: @@ -138,7 +141,9 @@ void FUNCTION_Select(FUNCTION_Type_t Function) gUpdateStatus = true; - GUI_SelectNextDisplay(DISPLAY_MAIN); + if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu + GUI_SelectNextDisplay(DISPLAY_MAIN); + return; case FUNCTION_TRANSMIT: @@ -184,6 +189,8 @@ void FUNCTION_Select(FUNCTION_Type_t Function) } #endif + gUpdateStatus = true; + GUI_DisplayScreen(); RADIO_SetTxParameters(); diff --git a/misc.c b/misc.c index ab3897b..e9fa122 100644 --- a/misc.c +++ b/misc.c @@ -83,6 +83,8 @@ bool gSetting_TX_EN; uint8_t gSetting_F_LOCK; bool gSetting_ScrambleEnable; +bool gSetting_backlight_on_rx; + #ifdef ENABLE_AM_FIX bool gSetting_AM_fix; #endif @@ -126,7 +128,6 @@ volatile bool gDualWatchCountdownExpired = true; bool gDualWatchActive = false; volatile uint8_t gSerialConfigCountDown_500ms; -volatile bool gSerialConfigCountDown_done; volatile bool gNextTimeslice_500ms; @@ -218,7 +219,6 @@ uint8_t gScanDelay_10ms; uint8_t gAircopySendCountdown; #endif uint8_t gFSKWriteIndex; -uint8_t gNeverUsed; #ifdef ENABLE_NOAA bool gIsNoaaMode; diff --git a/misc.h b/misc.h index 5d8bd8a..f229649 100644 --- a/misc.h +++ b/misc.h @@ -152,6 +152,8 @@ extern bool gSetting_TX_EN; extern uint8_t gSetting_F_LOCK; extern bool gSetting_ScrambleEnable; +extern bool gSetting_backlight_on_rx; + #ifdef ENABLE_AM_FIX extern bool gSetting_AM_fix; #endif @@ -196,7 +198,6 @@ extern volatile bool gDualWatchCountdownExpired; extern bool gDualWatchActive; extern volatile uint8_t gSerialConfigCountDown_500ms; -extern volatile bool gSerialConfigCountDown_done; extern volatile bool gNextTimeslice_500ms; @@ -286,7 +287,6 @@ extern uint8_t gScanDelay_10ms; extern uint8_t gAircopySendCountdown; #endif extern uint8_t gFSKWriteIndex; -extern uint8_t gNeverUsed; #ifdef ENABLE_NOAA extern bool gIsNoaaMode; extern uint8_t gNoaaChannel; diff --git a/radio.c b/radio.c index de133e5..22c67e7 100644 --- a/radio.c +++ b/radio.c @@ -218,7 +218,6 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure if (Band > BAND7_470MHz) { Band = BAND6_400MHz; -// Band = FREQUENCY_GetBand(gEeprom.ScreenChannel[VFO]); // 1of11 bug fix, or have I broke it ? } if (IS_MR_CHANNEL(Channel)) @@ -344,7 +343,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure } // *************** - + struct { uint32_t Frequency; @@ -372,8 +371,8 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure if (Frequency < frequencyBandTable[Band].lower) Frequency = frequencyBandTable[Band].lower; else - if (Frequency > frequencyBandTable[Band + 1].upper) - Frequency = frequencyBandTable[Band + 1].upper; + if (Frequency > frequencyBandTable[Band].upper) + Frequency = frequencyBandTable[Band].upper; else if (Channel >= FREQ_CHANNEL_FIRST) Frequency = FREQUENCY_FloorToStep(Frequency, gEeprom.VfoInfo[VFO].StepFrequency, frequencyBandTable[Band].lower); @@ -457,17 +456,21 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo) EEPROM_ReadBuffer(Base + 0x40, &pInfo->SquelchCloseGlitchThresh, 1); // 90 90 EEPROM_ReadBuffer(Base + 0x50, &pInfo->SquelchOpenGlitchThresh, 1); // 100 100 - #if ENABLE_SQUELCH_LOWER - // make squelch more sensitive + #if ENABLE_SQUELCH_MORE_SENSITIVE + // make squelch a little more sensitive + // + // getting the best setting here is still experimental, bare with me + // + // note that 'noise' and 'glitch' value are inverted compared to 'rssi' values - pInfo->SquelchOpenRSSIThresh = ((uint16_t)pInfo->SquelchOpenRSSIThresh * 8) / 9; - pInfo->SquelchCloseRSSIThresh = ((uint16_t)pInfo->SquelchOpenRSSIThresh * 7) / 8; + pInfo->SquelchOpenRSSIThresh = ((uint16_t)pInfo->SquelchOpenRSSIThresh * 10) / 11; + pInfo->SquelchCloseRSSIThresh = ((uint16_t)pInfo->SquelchOpenRSSIThresh * 10) / 11; - pInfo->SquelchOpenNoiseThresh = ((uint16_t)pInfo->SquelchOpenNoiseThresh * 8) / 7; - pInfo->SquelchCloseNoiseThresh = ((uint16_t)pInfo->SquelchOpenNoiseThresh * 9) / 8; + pInfo->SquelchOpenNoiseThresh = ((uint16_t)pInfo->SquelchOpenNoiseThresh * 11) / 10; + pInfo->SquelchCloseNoiseThresh = ((uint16_t)pInfo->SquelchOpenNoiseThresh * 11) / 10; - pInfo->SquelchOpenGlitchThresh = ((uint16_t)pInfo->SquelchOpenGlitchThresh * 8) / 7; - pInfo->SquelchCloseGlitchThresh = ((uint16_t)pInfo->SquelchOpenGlitchThresh * 9) / 8; + pInfo->SquelchOpenGlitchThresh = ((uint16_t)pInfo->SquelchOpenGlitchThresh * 11) / 10; + pInfo->SquelchCloseGlitchThresh = ((uint16_t)pInfo->SquelchOpenGlitchThresh * 11) / 10; #endif if (pInfo->SquelchOpenNoiseThresh > 127) @@ -548,7 +551,7 @@ void RADIO_SelectVfos(void) void RADIO_SetupRegisters(bool bSwitchToFunction0) { - BK4819_FilterBandwidth_t Bandwidth; + BK4819_FilterBandwidth_t Bandwidth = gRxVfo->CHANNEL_BANDWIDTH; uint16_t InterruptMask; uint32_t Frequency; @@ -558,7 +561,6 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) BK4819_ToggleGpioOut(BK4819_GPIO0_PIN28_GREEN, false); - Bandwidth = gRxVfo->CHANNEL_BANDWIDTH; switch (Bandwidth) { default: @@ -611,6 +613,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) BK4819_PickRXFilterPathBasedOnFrequency(Frequency); + // what does this in do ? BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, true); // AF RX Gain and DAC @@ -623,7 +626,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) #endif { if (gRxVfo->AM_mode == 0) - { + { // FM uint8_t CodeType = gSelectedCodeType; uint8_t Code = gSelectedCode; if (gCssScanMode == CSS_SCAN_MODE_OFF) @@ -936,8 +939,8 @@ void RADIO_PrepareTX(void) } else #endif - if (!gSetting_TX_EN) - { // TX is disabled + if (!gSetting_TX_EN || gSerialConfigCountDown_500ms > 0) + { // TX is disabled or config upload/download in progress State = VFO_STATE_TX_DISABLE; } else @@ -969,7 +972,7 @@ void RADIO_PrepareTX(void) } // TX is allowed - + if (gDTMF_ReplyState == DTMF_REPLY_ANI) { if (gDTMF_CallMode == DTMF_CALL_MODE_DTMF) diff --git a/scheduler.c b/scheduler.c index 2afecfa..21ae085 100644 --- a/scheduler.c +++ b/scheduler.c @@ -57,7 +57,7 @@ void SystickHandler(void) gNextTimeslice_500ms = true; DECREMENT_AND_TRIGGER(gTxTimerCountdown_500ms, gTxTimeoutReached); - DECREMENT_AND_TRIGGER(gSerialConfigCountDown_500ms, gSerialConfigCountDown_done); + DECREMENT(gSerialConfigCountDown_500ms); } if ((gGlobalSysTickCounter & 3) == 0) diff --git a/settings.c b/settings.c index 207e0c6..aa60e2d 100644 --- a/settings.c +++ b/settings.c @@ -174,6 +174,8 @@ void SETTINGS_SaveSettings(void) #ifdef ENABLE_AM_FIX if (!gSetting_AM_fix) State[7] &= ~(1u << 5); #endif + if (!gSetting_backlight_on_rx) State[7] &= ~(1u << 6); + EEPROM_WriteBuffer(0x0F40, State); } diff --git a/ui/main.c b/ui/main.c index f48b3cd..12560ee 100644 --- a/ui/main.c +++ b/ui/main.c @@ -80,6 +80,9 @@ center_line_t center_line = CENTER_LINE_NONE; const unsigned int bar_width = LCD_WIDTH - 2 - bar_x; unsigned int i; + if (gScreenToDisplay != DISPLAY_MAIN) + return; + #if 1 // TX audio level @@ -332,7 +335,7 @@ void UI_DisplayMain(void) const bool same_vfo = (channel == vfo_num) ? true : false; uint8_t *p_line0 = gFrameBuffer[line + 0]; uint8_t *p_line1 = gFrameBuffer[line + 1]; - uint32_t duff_beer = 0; + uint8_t mode = 0; uint8_t state; if (single_vfo) @@ -419,23 +422,36 @@ void UI_DisplayMain(void) #ifdef ENABLE_ALARM if (gAlarmState == ALARM_STATE_ALARM) - duff_beer = 2; + mode = 2; else #endif { channel = (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) ? gEeprom.RX_CHANNEL : gEeprom.TX_CHANNEL; if (channel == vfo_num) { // show the TX symbol - duff_beer = 1; - UI_PrintStringSmall("TX", 14, 0, line); + mode = 1; + #ifdef ENABLE_SMALL_BOLD + UI_PrintStringSmallBold("TX", 14, 0, line); + #else + UI_PrintStringSmall("TX", 14, 0, line); + #endif } } } else { // receiving .. show the RX symbol - duff_beer = 2; - if ((gCurrentFunction == FUNCTION_RECEIVE || gCurrentFunction == FUNCTION_MONITOR) && gEeprom.RX_CHANNEL == vfo_num) - UI_PrintStringSmall("RX", 14, 0, line); + mode = 2; + if ((gCurrentFunction == FUNCTION_RECEIVE || + gCurrentFunction == FUNCTION_MONITOR || + gCurrentFunction == FUNCTION_INCOMING) && + gEeprom.RX_CHANNEL == vfo_num) + { + #ifdef ENABLE_SMALL_BOLD + UI_PrintStringSmallBold("RX", 14, 0, line); + #else + UI_PrintStringSmall("RX", 14, 0, line); + #endif + } } if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num])) @@ -607,7 +623,7 @@ void UI_DisplayMain(void) { // show the TX/RX level uint8_t Level = 0; - if (duff_beer == 1) + if (mode == 1) { // TX power level switch (gRxVfo->OUTPUT_POWER) { @@ -617,7 +633,7 @@ void UI_DisplayMain(void) } } else - if (duff_beer == 2) + if (mode == 2) { // RX signal level #ifndef ENABLE_RSSI_BAR // bar graph @@ -654,7 +670,7 @@ void UI_DisplayMain(void) } else { // or show the CTCSS/DCS symbol - const FREQ_Config_t *pConfig = (duff_beer == 1) ? gEeprom.VfoInfo[vfo_num].pTX : gEeprom.VfoInfo[vfo_num].pRX; + const FREQ_Config_t *pConfig = (mode == 1) ? gEeprom.VfoInfo[vfo_num].pTX : gEeprom.VfoInfo[vfo_num].pRX; const unsigned int code_type = pConfig->CodeType; const char *code_list[] = {"", "CT", "DCS", "DCR"}; if (code_type >= 0 && code_type < ARRAY_SIZE(code_list)) @@ -713,8 +729,8 @@ void UI_DisplayMain(void) #ifdef ENABLE_AUDIO_BAR if (gSetting_mic_bar && gCurrentFunction == FUNCTION_TRANSMIT) { - UI_DisplayAudioBar(); center_line = CENTER_LINE_AUDIO_BAR; + UI_DisplayAudioBar(); } else #endif @@ -722,9 +738,9 @@ void UI_DisplayMain(void) #if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA) if (rx && gEeprom.VfoInfo[gEeprom.RX_CHANNEL].AM_mode && gSetting_AM_fix) { + center_line = CENTER_LINE_AM_FIX_DATA; AM_fix_print_data(gEeprom.RX_CHANNEL, String); UI_PrintStringSmall(String, 2, 0, 3); - center_line = CENTER_LINE_AM_FIX_DATA; } else #endif @@ -732,8 +748,8 @@ void UI_DisplayMain(void) #ifdef ENABLE_RSSI_BAR if (rx) { - UI_DisplayRSSIBar(gCurrentRSSI[gEeprom.RX_CHANNEL], false); center_line = CENTER_LINE_RSSI; + UI_DisplayRSSIBar(gCurrentRSSI[gEeprom.RX_CHANNEL], false); } else #endif @@ -745,20 +761,20 @@ void UI_DisplayMain(void) { // show live DTMF decode const unsigned int len = strlen(gDTMF_RX_live); const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // limit to last 'n' chars + center_line = CENTER_LINE_DTMF_DEC; strcpy(String, "DTMF "); strcat(String, gDTMF_RX_live + idx); UI_PrintStringSmall(String, 2, 0, 3); - center_line = CENTER_LINE_DTMF_DEC; } #else if (gSetting_live_DTMF_decoder && gDTMF_RX_index > 0) { // show live DTMF decode const unsigned int len = gDTMF_RX_index; const unsigned int idx = (len > (17 - 5)) ? len - (17 - 5) : 0; // limit to last 'n' chars + center_line = CENTER_LINE_DTMF_DEC; strcpy(String, "DTMF "); strcat(String, gDTMF_RX + idx); UI_PrintStringSmall(String, 2, 0, 3); - center_line = CENTER_LINE_DTMF_DEC; } #endif @@ -766,11 +782,11 @@ void UI_DisplayMain(void) else if (gChargingWithTypeC) { // charging .. show the battery state + center_line = CENTER_LINE_CHARGE_DATA; sprintf(String, "Charge %u.%02uV %u%%", gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100, BATTERY_VoltsToPercent(gBatteryVoltageAverage)); UI_PrintStringSmall(String, 2, 0, 3); - center_line = CENTER_LINE_CHARGE_DATA; } #endif } diff --git a/ui/menu.c b/ui/menu.c index 76cbd2f..2c6e51d 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -62,7 +62,8 @@ const t_menu_item MenuList[] = {"CH DIS", VOICE_ID_INVALID, MENU_MDF }, // was "MDF" {"BATSAV", VOICE_ID_SAVE_MODE, MENU_SAVE }, // was "SAVE" {"VOX", VOICE_ID_VOX, MENU_VOX }, - {"BACKLT", VOICE_ID_INVALID, MENU_ABR }, // was "ABR" + {"BLT", VOICE_ID_INVALID, MENU_ABR }, // was "ABR" + {"BLT RX", VOICE_ID_INVALID, MENU_ABR_ON_RX }, {"DUALRX", VOICE_ID_DUAL_STANDBY, MENU_TDR }, // was "TDR" {"BEEP", VOICE_ID_BEEP_PROMPT, MENU_BEEP }, #ifdef ENABLE_VOICE @@ -476,12 +477,42 @@ void UI_DisplayMenu(void) case MENU_R_CTCS: case MENU_T_CTCS: - if (gSubMenuSelection == 0) - strcpy(String, "OFF"); - else - sprintf(String, "%u.%uHz", CTCSS_Options[gSubMenuSelection - 1] / 10, CTCSS_Options[gSubMenuSelection - 1] % 10); - break; + { + #if 1 + unsigned int Code; + FREQ_Config_t *pConfig = (gMenuCursor == MENU_R_CTCS) ? &gTxVfo->freq_config_RX : &gTxVfo->freq_config_TX; + if (gSubMenuSelection == 0) + { + strcpy(String, "OFF"); + if (pConfig->CodeType != CODE_TYPE_CONTINUOUS_TONE) + break; + Code = 0; + pConfig->CodeType = CODE_TYPE_OFF; + pConfig->Code = Code; + + BK4819_ExitSubAu(); + } + else + { + sprintf(String, "%u.%uHz", CTCSS_Options[gSubMenuSelection - 1] / 10, CTCSS_Options[gSubMenuSelection - 1] % 10); + + pConfig->CodeType = CODE_TYPE_CONTINUOUS_TONE; + Code = gSubMenuSelection - 1; + pConfig->Code = Code; + + BK4819_SetCTCSSFrequency(CTCSS_Options[Code]); + } + #else + if (gSubMenuSelection == 0) + strcpy(String, "OFF"); + else + sprintf(String, "%u.%uHz", CTCSS_Options[gSubMenuSelection - 1] / 10, CTCSS_Options[gSubMenuSelection - 1] % 10); + #endif + + break; + } + case MENU_SFT_D: strcpy(String, gSubMenu_SFT_D[gSubMenuSelection]); break; @@ -518,6 +549,12 @@ void UI_DisplayMenu(void) case MENU_SCR: strcpy(String, gSubMenu_SCRAMBLER[gSubMenuSelection]); + #if 1 + if (gSubMenuSelection > 0 && gSetting_ScrambleEnable) + BK4819_EnableScramble(gSubMenuSelection - 1); + else + BK4819_DisableScramble(); + #endif break; case MENU_VOX: @@ -538,6 +575,7 @@ void UI_DisplayMenu(void) #ifdef ENABLE_AM_FIX_TEST1 case MENU_AM_FIX_TEST1: strcpy(String, gSubMenu_AM_fix_test1[gSubMenuSelection]); +// gSetting_AM_fix = gSubMenuSelection; break; #endif @@ -554,6 +592,7 @@ void UI_DisplayMenu(void) #ifdef ENABLE_AM_FIX case MENU_AM_FIX: #endif + case MENU_ABR_ON_RX: case MENU_BCL: case MENU_BEEP: case MENU_S_ADD1: diff --git a/ui/menu.h b/ui/menu.h index f9bf805..9425844 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -51,6 +51,7 @@ enum MENU_SAVE, MENU_VOX, MENU_ABR, + MENU_ABR_ON_RX, MENU_TDR, MENU_BEEP, #ifdef ENABLE_VOICE diff --git a/ui/status.c b/ui/status.c index 4eb5528..3db670e 100644 --- a/ui/status.c +++ b/ui/status.c @@ -45,12 +45,26 @@ void UI_DisplayStatus(const bool test_display) // ************** // POWER-SAVE indicator + if (gCurrentFunction == FUNCTION_TRANSMIT) + { + memmove(line + x, BITMAP_TX, sizeof(BITMAP_TX)); + x1 = x + sizeof(BITMAP_TX); + } + else + if (gCurrentFunction == FUNCTION_RECEIVE || + gCurrentFunction == FUNCTION_MONITOR || + gCurrentFunction == FUNCTION_INCOMING) + { + memmove(line + x, BITMAP_RX, sizeof(BITMAP_RX)); + x1 = x + sizeof(BITMAP_RX); + } + else if (gCurrentFunction == FUNCTION_POWER_SAVE || test_display) { - memmove(line + x, BITMAP_PowerSave, sizeof(BITMAP_PowerSave)); - x1 = x + sizeof(BITMAP_PowerSave); + memmove(line + x, BITMAP_POWERSAVE, sizeof(BITMAP_POWERSAVE)); + x1 = x + sizeof(BITMAP_POWERSAVE); } - x += sizeof(BITMAP_PowerSave); + x += sizeof(BITMAP_POWERSAVE); #ifdef ENABLE_NOAA // NOASS SCAN indicator