diff --git a/Makefile b/Makefile index d557657..227c627 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,13 @@ -# compile options (see Readme.md) -# '0' = disable -# '1' = enable +# compile options (see README.md for descriptions) +# 0 = disable +# 1 = enable # ENABLE_SWD := 0 ENABLE_OVERLAY := 1 ENABLE_UART := 1 ENABLE_AIRCOPY := 0 -ENABLE_FMRADIO := 0 +ENABLE_FMRADIO := 1 ENABLE_NOAA := 0 ENABLE_VOICE := 0 ENABLE_ALARM := 0 @@ -137,7 +137,10 @@ OBJCOPY = arm-none-eabi-objcopy SIZE = arm-none-eabi-size # the user might not have/want git installed +# can set own version string here (max 7 chars here) GIT_HASH := $(shell git rev-parse --short HEAD) +#GIT_HASH := 230925b + $(info GIT_HASH = $(GIT_HASH)) ASFLAGS = -c -mcpu=cortex-m0 diff --git a/README.md b/README.md index c4d04a4..88584f7 100644 --- a/README.md +++ b/README.md @@ -16,12 +16,12 @@ ENABLE_SWD := 0 only needed if using CPU's SWD port (de ENABLE_OVERLAY := 1 cpu FLASH stuff ENABLE_UART := 1 without this you can't configure radio via PC ENABLE_AIRCOPY := 0 easier to just enter frequency -ENABLE_FMRADIO := 0 WBFM VHF band 2 RX -ENABLE_NOAA := 0 Everything NOAA +ENABLE_FMRADIO := 1 WBFM VHF band 2 RX +ENABLE_NOAA := 0 everything NOAA ENABLE_VOICE := 0 want to hear voices ? ENABLE_ALARM := 0 TX alarms ENABLE_BIG_FREQ := 0 big font frequencies -ENABLE_SMALL_BOLD := 1 bold channel name/no. (name + freq channel display mode) +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_TX_WHEN_AM := 0 allow TX (always FM) when RX is set to AM @@ -29,11 +29,12 @@ ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1 standard CTCSS tail phase shift rather 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_SHOW_CHARGE_LEVEL := 1 show the charge level when the radio is on charge +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_NO_SCAN_TIMEOUT := 1 remove the 32 sec timeout from the CTCSS/DCS scan (press exit butt 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 (for now) ENABLE_AM_FIX_SHOW_DATA := 1 show debug data for the AM fix -ENABLE_SQUELCH1_LOWER := 1 adjusts squelch setting '1' to be more sensitive - I plan to let user adjust it in the menu +ENABLE_SQUELCH1_LOWER := 0 adjusts squelch setting '1' to be more sensitive - I plan to let user adjust it in the menu ENABLE_AUDIO_BAR := 0 experimental, display an audo bar level when TX'ing #ENABLE_SINGLE_VFO_CHAN := 1 not yet implemented - single VFO on display when possible #ENABLE_BAND_SCOPE := 1 not yet implemented - spectrum/pan-adapter @@ -45,7 +46,7 @@ ENABLE_AUDIO_BAR := 0 experimental, display an audo bar level * Added new bugs * Mic menu includes max gain possible * AM RX everywhere (left the TX as is) -* An attempt to improve the AM RX audio (demodulator getting saturated/overloaded) +* An attempt to improve the AM RX audio (demodulator getting saturated/overloaded in Quansheng firmware) * keypad-5/NOAA button now toggles scanlist-1 on/off for current channel when held down - IF NOAA not used * Better backlight times (inc always on) * Live DTMF decoder option, though the decoder needs some coeff tuning changes to decode other radios it seems diff --git a/am_fix.c b/am_fix.c index 416bdbb..ab7e7e8 100644 --- a/am_fix.c +++ b/am_fix.c @@ -352,7 +352,7 @@ const uint8_t orig_pga = 6; // -3dB return; case FUNCTION_FOREGROUND: - return; +// return; // only adjust stuff if we're in one of these modes case FUNCTION_RECEIVE: diff --git a/app/action.c b/app/action.c index 724d46c..a95c9e0 100644 --- a/app/action.c +++ b/app/action.c @@ -94,7 +94,7 @@ static void ACTION_Monitor(void) #ifdef ENABLE_NOAA if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode) { - gNOAA_Countdown_10ms = 500; // 5 sec + gNOAA_Countdown_10ms = NOAA_countdown_10ms; gScheduleNOAA = false; } #endif @@ -155,6 +155,7 @@ void ACTION_Scan(bool bRestart) #endif } } + return; } #endif diff --git a/app/app.c b/app/app.c index b57a13d..a49d1ca 100644 --- a/app/app.c +++ b/app/app.c @@ -102,7 +102,7 @@ static void APP_CheckForIncoming(void) #ifdef ENABLE_NOAA if (gIsNoaaMode) { - gNOAA_Countdown_10ms = 20; // 200ms + gNOAA_Countdown_10ms = NOAA_countdown_3_10ms; gScheduleNOAA = false; } #endif @@ -965,7 +965,8 @@ void APP_Update(void) APP_HandleFunction(); #ifdef ENABLE_FMRADIO - if (gFmRadioCountdown_500ms > 0) +// if (gFmRadioCountdown_500ms > 0) + if (gFmRadioMode && gFmRadioCountdown_500ms > 0) // 1of11 return; #endif @@ -1058,7 +1059,7 @@ void APP_Update(void) gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_TRANSMIT) - { + { // switch to FM radio mode FM_Play(); gScheduleFM = false; } @@ -1091,7 +1092,7 @@ void APP_Update(void) } else { - gBatterySaveCountdown_10ms = battery_save_count_10ms; + gBatterySaveCountdown_10ms = battery_save_count_10ms; } #else if ( @@ -1106,7 +1107,7 @@ void APP_Update(void) gScreenToDisplay != DISPLAY_MAIN || gDTMF_CallState != DTMF_CALL_STATE_NONE) { - gBatterySaveCountdown_10ms = battery_save_count_10ms; + gBatterySaveCountdown_10ms = battery_save_count_10ms; } else { @@ -1362,9 +1363,8 @@ void APP_TimeSlice10ms(void) else { // transmitting #ifdef ENABLE_AUDIO_BAR - if (gSetting_mic_bar && (gFlashLightBlinkCounter % (100 / 10)) == 0) // once every 100ms + if (gSetting_mic_bar && (gFlashLightBlinkCounter % (150 / 10)) == 0) // once every 150ms UI_DisplayAudioBar(); - //gUpdateDisplay = true; #endif if (gUpdateDisplay) @@ -1380,7 +1380,8 @@ void APP_TimeSlice10ms(void) // Skipping authentic device checks #ifdef ENABLE_FMRADIO - if (gFmRadioCountdown_500ms > 0) +// if (gFmRadioCountdown_500ms > 0) + if (gFmRadioMode && gFmRadioCountdown_500ms > 0) // 1of11 return; #endif @@ -1454,10 +1455,10 @@ void APP_TimeSlice10ms(void) } #ifdef ENABLE_FMRADIO - if (gFmRadioMode && gFM_RestoreCountdown > 0) + if (gFmRadioMode && gFM_RestoreCountdown_10ms > 0) { - if (--gFM_RestoreCountdown == 0) - { + if (--gFM_RestoreCountdown_10ms == 0) + { // switch back to FM radio mode FM_Start(); GUI_SelectNextDisplay(DISPLAY_FM); } @@ -1630,7 +1631,8 @@ void APP_TimeSlice500ms(void) if (gFmRadioCountdown_500ms > 0) { gFmRadioCountdown_500ms--; - return; + if (gFmRadioMode) // 1of11 + return; } #endif @@ -1743,7 +1745,7 @@ void APP_TimeSlice500ms(void) { RADIO_SetVfoState(VFO_STATE_NORMAL); if (gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_MONITOR && gFmRadioMode) - { + { // switch back to FM radio mode FM_Start(); GUI_SelectNextDisplay(DISPLAY_FM); } diff --git a/app/fm.c b/app/fm.c index 39e6a53..d91259c 100644 --- a/app/fm.c +++ b/app/fm.c @@ -46,7 +46,7 @@ uint8_t gFM_ChannelPosition; bool gFM_FoundFrequency; bool gFM_AutoScan; uint8_t gFM_ResumeCountdown_500ms; -uint16_t gFM_RestoreCountdown; +uint16_t gFM_RestoreCountdown_10ms; bool FM_CheckValidChannel(uint8_t Channel) { @@ -93,9 +93,9 @@ int FM_ConfigureChannelState(void) void FM_TurnOff(void) { - gFmRadioMode = false; - gFM_ScanState = FM_SCAN_OFF; - gFM_RestoreCountdown = 0; + gFmRadioMode = false; + gFM_ScanState = FM_SCAN_OFF; + gFM_RestoreCountdown_10ms = 0; GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); @@ -655,9 +655,9 @@ void FM_Play(void) void FM_Start(void) { - gFmRadioMode = true; - gFM_ScanState = FM_SCAN_OFF; - gFM_RestoreCountdown = 0; + gFmRadioMode = true; + gFM_ScanState = FM_SCAN_OFF; + gFM_RestoreCountdown_10ms = 0; BK1080_Init(gEeprom.FM_FrequencyPlaying, true); diff --git a/app/fm.h b/app/fm.h index 462852a..012119a 100644 --- a/app/fm.h +++ b/app/fm.h @@ -40,7 +40,7 @@ extern uint16_t gFM_FrequencyDeviation; extern bool gFM_FoundFrequency; extern bool gFM_AutoScan; extern uint8_t gFM_ResumeCountdown_500ms; -extern uint16_t gFM_RestoreCountdown; +extern uint16_t gFM_RestoreCountdown_10ms; bool FM_CheckValidChannel(uint8_t Channel); uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction); diff --git a/app/main.c b/app/main.c index 2f088ff..75954a6 100644 --- a/app/main.c +++ b/app/main.c @@ -50,6 +50,12 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) case KEY_0: #ifdef ENABLE_FMRADIO ACTION_FM(); + #else + + + // TODO: do something useful with the key + + #endif break; diff --git a/firmware.bin b/firmware.bin index 4b75d9d..67d4978 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 8c44166..4f2c9b4 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/functions.c b/functions.c index ffb445c..a7b4572 100644 --- a/functions.c +++ b/functions.c @@ -116,7 +116,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function) #if defined(ENABLE_FMRADIO) if (gFmRadioMode) - gFM_RestoreCountdown = 500; + gFM_RestoreCountdown_10ms = fm_restore_countdown_10ms; #endif if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED) @@ -201,6 +201,6 @@ void FUNCTION_Select(FUNCTION_Type_t Function) gSchedulePowerSave = false; #if defined(ENABLE_FMRADIO) - gFM_RestoreCountdown = 0; + gFM_RestoreCountdown_10ms = 0; #endif } diff --git a/misc.c b/misc.c index cfc96a3..17aeef1 100644 --- a/misc.c +++ b/misc.c @@ -22,6 +22,7 @@ const uint8_t fm_resume_countdown_500ms = 2500 / 500; // 2.5 second const uint8_t fm_radio_countdown_500ms = 2000 / 500; // 2 seconds const uint16_t fm_play_countdown_scan_10ms = 100 / 10; // 100ms const uint16_t fm_play_countdown_noscan_10ms = 1200 / 10; // 1.2 seconds +const uint16_t fm_restore_countdown_10ms = 5000 / 10; // 5 seconds const uint8_t menu_timeout_500ms = 20000 / 500; // 20 seconds @@ -38,7 +39,6 @@ const uint16_t key_debounce_10ms = 20 / 10; // 20ms const uint8_t scan_delay_10ms = 210 / 10; // 210ms -// 10ms count down resolution const uint16_t dual_watch_count_after_tx_10ms = 3600 / 10; // 3.6 sec after TX ends const uint16_t dual_watch_count_after_rx_10ms = 1000 / 10; // 1 sec after RX ends ? const uint16_t dual_watch_count_after_1_10ms = 5000 / 10; // 5 sec @@ -52,6 +52,10 @@ const uint16_t battery_save_count_10ms = 10000 / 10; // 10 seconds const uint16_t power_save1_10ms = 100 / 10; // 100ms const uint16_t power_save2_10ms = 200 / 10; // 200ms +const uint16_t NOAA_countdown_10ms = 5000 / 10; // 5 seconds +const uint16_t NOAA_countdown_2_10ms = 500 / 10; // 500ms +const uint16_t NOAA_countdown_3_10ms = 200 / 10; // 200ms + const uint16_t gMax_bat_v = 840; // 8.4V const uint16_t gMin_bat_v = 660; // 6.6V diff --git a/misc.h b/misc.h index ef2591e..e0d7327 100644 --- a/misc.h +++ b/misc.h @@ -87,6 +87,7 @@ extern const uint8_t fm_resume_countdown_500ms; extern const uint8_t fm_radio_countdown_500ms; extern const uint16_t fm_play_countdown_scan_10ms; extern const uint16_t fm_play_countdown_noscan_10ms; +extern const uint16_t fm_restore_countdown_10ms; extern const uint8_t menu_timeout_500ms; @@ -108,6 +109,10 @@ extern const uint16_t battery_save_count_10ms; extern const uint16_t power_save1_10ms; extern const uint16_t power_save2_10ms; +extern const uint16_t NOAA_countdown_10ms; +extern const uint16_t NOAA_countdown_2_10ms; +extern const uint16_t NOAA_countdown_3_10ms; + extern const uint16_t dual_watch_count_after_tx_10ms; extern const uint16_t dual_watch_count_after_rx_10ms; extern const uint16_t dual_watch_count_after_1_10ms; diff --git a/radio.c b/radio.c index a2efdb8..3e65610 100644 --- a/radio.c +++ b/radio.c @@ -595,8 +595,8 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) case BK4819_FILTER_BW_WIDE: case BK4819_FILTER_BW_NARROW: #ifdef ENABLE_AM_FIX -// BK4819_SetFilterBandwidth(Bandwidth, gRxVfo->IsAM && gSetting_AM_fix); - BK4819_SetFilterBandwidth(Bandwidth, false); + BK4819_SetFilterBandwidth(Bandwidth, gRxVfo->IsAM && gSetting_AM_fix); +// BK4819_SetFilterBandwidth(Bandwidth, false); #else BK4819_SetFilterBandwidth(Bandwidth, false); #endif @@ -815,7 +815,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) { gIsNoaaMode = true; gNoaaChannel = gRxVfo->CHANNEL_SAVE - NOAA_CHANNEL_FIRST; - gNOAA_Countdown_10ms = 50; // 500ms + gNOAA_Countdown_10ms = NOAA_countdown_2_10ms; gScheduleNOAA = false; } else @@ -844,8 +844,8 @@ void RADIO_SetTxParameters(void) case BK4819_FILTER_BW_WIDE: case BK4819_FILTER_BW_NARROW: #ifdef ENABLE_AM_FIX -// BK4819_SetFilterBandwidth(Bandwidth, gCurrentVfo->IsAM && gSetting_AM_fix); - BK4819_SetFilterBandwidth(Bandwidth, false); + BK4819_SetFilterBandwidth(Bandwidth, gCurrentVfo->IsAM && gSetting_AM_fix); +// BK4819_SetFilterBandwidth(Bandwidth, false); #else BK4819_SetFilterBandwidth(Bandwidth, false); #endif diff --git a/ui/main.c b/ui/main.c index 11288d0..99fcbbb 100644 --- a/ui/main.c +++ b/ui/main.c @@ -42,7 +42,6 @@ #ifdef ENABLE_AUDIO_BAR void UI_DisplayAudioBar(void) { -// if (gCurrentFunction == FUNCTION_TRANSMIT && gSetting_mic_bar) if (gSetting_mic_bar) { const unsigned int line = 3; @@ -51,6 +50,8 @@ #if 1 // TX audio level + if (gCurrentFunction != FUNCTION_TRANSMIT) + return; // TODO: logify this to make the bar visible with the mostly small value @@ -76,7 +77,8 @@ pLine[i] = 0x3e; #endif - ST7565_BlitFullScreen(); + if (gCurrentFunction == FUNCTION_TRANSMIT) + ST7565_BlitFullScreen(); } } #endif diff --git a/win_make.bat b/win_make.bat index bc29e68..974c2be 100644 --- a/win_make.bat +++ b/win_make.bat @@ -1,22 +1,27 @@ @echo off + + + :: Compile directly in windows without the need of a linux virtual machine: :: :: 1. Download and install "gcc-arm-none-eabi-10.3-2021.10-win32.exe" from https://developer.arm.com/downloads/-/gnu-rm :: 2. Download and install "gnu_make-3.81.exe" from https://gnuwin32.sourceforge.net/packages/make.htm :: -:: 3. You may (or not) need to manualy add gcc path to you OS environment PATH, ie .. +:: 3. You may (or may not) need to manualy add a path to you OS environment PATH, ie .. :: C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2021.10\bin :: -:: 4. You may (or not) need to reboot your PC after installing the above +:: 4. You may (or may not) need to reboot windows after installing the above :: -:: Then you can run this bat from the directory you saved this source code too. -:: -:: You will need to edit the line below that runs the make.exe file to point to it's actual location if -:: it's different from mine. +:: You can then run this bat from the directory you saved this source code too. -:: delete any left over files from any previous compile + + + + +:: Delete any left over files from any previous compile +:: del /S /Q *.o >nul 2>nul del /S /Q *.d >nul 2>nul del /Q firmware >nul 2>nul @@ -28,16 +33,20 @@ del /Q *.bin >nul 2>nul @set PATH="C:\Program Files (x86)\GNU Arm Embedded Toolchain\10 2021.10\arm-none-eabi\bin";%PATH% @set PATH="C:\Program Files (x86)\GnuWin32\bin\";%PATH% -:: do the compile +:: Do the compile +:: ::"C:\Program Files (x86)\GnuWin32\bin\make" make -:: delete the unused created when compiling files +:: Delete the spent files :: del /S /Q *.o >nul 2>nul del /S /Q *.d >nul 2>nul del /Q firmware >nul 2>nul + + + :: If you have python installed, you can create a 'packed' .bin from the compiled firmware.bin file. :: The Quansheng windows upload-to-radio program requires a 'packed' .bin file. :: @@ -47,13 +56,22 @@ del /Q firmware >nul 2>nul :: I wrote a GUI version of k5prog to do this easily in windows .. :: https://github.com/OneOfEleven/k5prog-win -:: these just install the required initial python module if you want to create the packed firmware bin file, either -:: only needs running once, ever. + + +:: These two lines just install the required initial python module if you want to create the packed +:: firmware bin file, either only needs running once, ever. :: ::python -m pip install --upgrade pip crcmod ::python3 -m pip install --upgrade pip crcmod + + :: show the compiled .bin file size +:: ::arm-none-eabi-size firmware + + + pause +@echo on