diff --git a/Makefile b/Makefile index b68ee3c67..4f31d2bf7 100644 --- a/Makefile +++ b/Makefile @@ -89,9 +89,11 @@ OBJS += external/printf/printf.o # Drivers OBJS += driver/adc.o +ifeq ($(ENABLE_PWRON_PASSWORD),1) ifeq ($(ENABLE_UART),1) OBJS += driver/aes.o endif +endif OBJS += driver/backlight.o ifeq ($(ENABLE_FMRADIO),1) OBJS += driver/bk1080.o @@ -213,7 +215,7 @@ ifeq ($(ENABLE_FEAT_F4HWN),1) VERSION_STRING_1 ?= v2.8.1 AUTHOR_STRING_2 ?= Voxless - VERSION_STRING_2 ?= v1.0.2 + VERSION_STRING_2 ?= v1.0.3 AUTHOR_STRING ?= $(AUTHOR_STRING_1)+$(AUTHOR_STRING_2) VERSION_STRING ?= $(VERSION_STRING_2) diff --git a/app/app.c b/app/app.c index 7a97d816d..6cd961667 100644 --- a/app/app.c +++ b/app/app.c @@ -1075,7 +1075,7 @@ void APP_Update(void) gRxIdleMode = true; goToSleep = false; - BK4819_DisableVox(); + //BK4819_DisableVox(); BK4819_Sleep(); BK4819_ToggleGpioOut(BK4819_GPIO0_PIN28_RX_ENABLE, false); diff --git a/app/chFrScanner.c b/app/chFrScanner.c index 90034fa61..f9885c09f 100644 --- a/app/chFrScanner.c +++ b/app/chFrScanner.c @@ -56,10 +56,9 @@ void CHFRSCANNER_Start(const bool storeBackupSettings, const int8_t scan_directi if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) { dwchan = (gEeprom.RX_VFO + 1) & 1u; - dwchan = gEeprom.ScreenChannel[dwchan]; + dwchan = gEeprom.ScreenChannel[dwchan]+1; if (!IS_MR_CHANNEL(dwchan)) dwchan = 0; - } if (IS_MR_CHANNEL(gNextMrChannel)) @@ -265,7 +264,8 @@ static void NextMemChannel(void) if (++dualscan%4==0) { dualscan=0; currentScanList = SCAN_NEXT_CHAN_DUAL_WATCH; - gNextMrChannel = dwchan; + if (!gMR_ChannelExclude[dwchan-1]) + gNextMrChannel = dwchan-1; break; } } diff --git a/app/fm.c b/app/fm.c index 0d3db1d4b..5f0bc63a9 100644 --- a/app/fm.c +++ b/app/fm.c @@ -36,7 +36,7 @@ #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) #endif -uint16_t gFM_Channels[20]; +uint16_t gFM_Channels[24]; bool gFmRadioMode; uint8_t gFmRadioCountdown_500ms; volatile uint16_t gFmPlayCountdown_10ms; @@ -297,7 +297,7 @@ static void Key_DIGITS(KEY_Code_t Key, uint8_t state) return; } } - else if (Channel < 20) { + else if (Channel < ARRAY_SIZE(gFM_Channels)) { #ifdef ENABLE_VOICE gAnotherVoiceID = (VOICE_ID_t)Key; #endif @@ -569,10 +569,10 @@ void FM_Play(void) return; } - if (gFM_ChannelPosition < 20) + if (gFM_ChannelPosition < ARRAY_SIZE(gFM_Channels)) gFM_Channels[gFM_ChannelPosition++] = gEeprom.FM_FrequencyPlaying; - if (gFM_ChannelPosition >= 20) { + if (gFM_ChannelPosition >= ARRAY_SIZE(gFM_Channels)) { FM_PlayAndUpdate(); GUI_SelectNextDisplay(DISPLAY_FM); return; diff --git a/app/fm.h b/app/fm.h index 51bac66a6..daa0517db 100644 --- a/app/fm.h +++ b/app/fm.h @@ -28,7 +28,7 @@ enum { FM_SCAN_OFF = 0U, }; -extern uint16_t gFM_Channels[20]; +extern uint16_t gFM_Channels[24]; extern bool gFmRadioMode; extern uint8_t gFmRadioCountdown_500ms; extern volatile uint16_t gFmPlayCountdown_10ms; diff --git a/app/main.c b/app/main.c index 97cc9a119..eb9150342 100644 --- a/app/main.c +++ b/app/main.c @@ -362,13 +362,9 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (gScanStateDir != SCAN_OFF){ switch(Key){ case KEY_1: - gEeprom.SCAN_LIST_DEFAULT=0; - break; case KEY_2: - gEeprom.SCAN_LIST_DEFAULT=1; - break; case KEY_3: - gEeprom.SCAN_LIST_DEFAULT=2; + gEeprom.SCAN_LIST_DEFAULT=Key-1; break; case KEY_0: gEeprom.SCAN_LIST_DEFAULT=3; @@ -579,6 +575,11 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld) gInputBoxIndex = 0; gRequestDisplayScreen = DISPLAY_MAIN; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + } else { + if (gMR_ChannelExclude[gTxVfo->CHANNEL_SAVE]) { + gMR_ChannelExclude[gTxVfo->CHANNEL_SAVE] = false; + gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + } } } } @@ -594,14 +595,13 @@ static void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld) if (bKeyPressed) { // long press MENU key #ifdef ENABLE_FEAT_F4HWN - if(gScanStateDir != SCAN_OFF && gEeprom.SCAN_LIST_DEFAULT < 5) + if(gScanStateDir != SCAN_OFF) { if(FUNCTION_IsRx()) { - gTxVfo->SCANLIST_PARTICIPATION = 0; - - SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true, true, false); + gMR_ChannelExclude[gTxVfo->CHANNEL_SAVE] = true; + gVfoConfigureMode = VFO_CONFIGURE; gFlagResetVfos = true; diff --git a/app/uart.c b/app/uart.c index f7fce7f9c..b8417530b 100644 --- a/app/uart.c +++ b/app/uart.c @@ -26,7 +26,9 @@ #include "board.h" #include "bsp/dp32g030/dma.h" #include "bsp/dp32g030/gpio.h" -#include "driver/aes.h" +#ifdef ENABLE_PWRON_PASSWORD + #include "driver/aes.h" +#endif #include "driver/backlight.h" #include "driver/bk4819.h" #include "driver/crc.h" @@ -208,7 +210,7 @@ static void SendVersion(void) SendReply(&Reply, sizeof(Reply)); } - +#ifdef ENABLE_PWRON_PASSWORD static bool IsBadChallenge(const uint32_t *pKey, const uint32_t *pIn, const uint32_t *pResponse) { unsigned int i; @@ -227,7 +229,7 @@ static bool IsBadChallenge(const uint32_t *pKey, const uint32_t *pIn, const uint return false; } - +#endif // session init, sends back version info and state // timestamp is a session id really static void CMD_0514(const uint8_t *pBuffer) @@ -269,10 +271,10 @@ static void CMD_051B(const uint8_t *pBuffer) Reply.Header.Size = pCmd->Size + 4; Reply.Data.Offset = pCmd->Offset; Reply.Data.Size = pCmd->Size; - +#ifdef ENABLE_PWRON_PASSWORD if (bHasCustomAesKey) bLocked = gIsLocked; - +#endif if (!bLocked) EEPROM_ReadBuffer(pCmd->Offset, Reply.Data.Data, pCmd->Size); @@ -301,9 +303,9 @@ static void CMD_051D(const uint8_t *pBuffer) Reply.Header.ID = 0x051E; Reply.Header.Size = sizeof(Reply.Data); Reply.Data.Offset = pCmd->Offset; - +#ifdef ENABLE_PWRON_PASSWORD bIsLocked = bHasCustomAesKey ? gIsLocked : bHasCustomAesKey; - +#endif if (!bIsLocked) { unsigned int i; @@ -357,6 +359,7 @@ static void CMD_0529(void) static void CMD_052D(const uint8_t *pBuffer) { const CMD_052D_t *pCmd = (const CMD_052D_t *)pBuffer; + REPLY_052D_t Reply; bool bIsLocked; @@ -366,6 +369,7 @@ static void CMD_052D(const uint8_t *pBuffer) Reply.Header.ID = 0x052E; Reply.Header.Size = sizeof(Reply.Data); +#ifdef ENABLE_PWRON_PASSWORD bIsLocked = bHasCustomAesKey; if (!bIsLocked) @@ -388,7 +392,9 @@ static void CMD_052D(const uint8_t *pBuffer) gTryCount = 3; bIsLocked = true; } - +#else + bIsLocked = pCmd->Response[0]; +#endif gIsLocked = bIsLocked; Reply.Data.bIsLocked = bIsLocked; diff --git a/driver/bk4819.c b/driver/bk4819.c index d6390a15b..1f640748c 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -924,11 +924,11 @@ void BK4819_SetCompander(const unsigned int mode) BK4819_WriteRegister(BK4819_REG_31, r31 | (1u << 3)); } -void BK4819_DisableVox(void) +/* void BK4819_DisableVox(void) { const uint16_t Value = BK4819_ReadRegister(BK4819_REG_31); BK4819_WriteRegister(BK4819_REG_31, Value & 0xFFFB); -} +} */ void BK4819_DisableDTMF(void) { diff --git a/driver/bk4819.h b/driver/bk4819.h index 1a6d06efd..64af90a7b 100644 --- a/driver/bk4819.h +++ b/driver/bk4819.h @@ -101,7 +101,7 @@ void BK4819_EnableScramble(uint8_t Type); bool BK4819_CompanderEnabled(void); void BK4819_SetCompander(const unsigned int mode); -void BK4819_DisableVox(void); +//void BK4819_DisableVox(void); void BK4819_DisableDTMF(void); void BK4819_EnableDTMF(void); void BK4819_PlayTone(uint16_t Frequency, bool bTuningGainSwitch); diff --git a/functions.c b/functions.c index 3a98566b6..8514528c6 100644 --- a/functions.c +++ b/functions.c @@ -125,7 +125,7 @@ void FUNCTION_PowerSave() { gMonitor = false; - BK4819_DisableVox(); +// BK4819_DisableVox(); BK4819_Sleep(); BK4819_ToggleGpioOut(BK4819_GPIO0_PIN28_RX_ENABLE, false); diff --git a/misc.c b/misc.c index fd863758f..8cf8f068e 100644 --- a/misc.c +++ b/misc.c @@ -140,6 +140,7 @@ uint16_t gEEPROM_1F8A; uint16_t gEEPROM_1F8C; ChannelAttributes_t gMR_ChannelAttributes[FREQ_CHANNEL_LAST + 1]; +bool gMR_ChannelExclude[FREQ_CHANNEL_LAST + 1]; volatile uint16_t gBatterySaveCountdown_10ms = battery_save_count_10ms; diff --git a/misc.h b/misc.h index cd0b8cffc..7029abb81 100644 --- a/misc.h +++ b/misc.h @@ -203,6 +203,7 @@ typedef union { } ChannelAttributes_t; extern ChannelAttributes_t gMR_ChannelAttributes[207]; +extern bool gMR_ChannelExclude[207]; extern volatile uint16_t gBatterySaveCountdown_10ms; diff --git a/radio.c b/radio.c index bd15ebb65..9ca82bb0e 100644 --- a/radio.c +++ b/radio.c @@ -64,6 +64,9 @@ bool RADIO_CheckValidChannel(uint16_t channel, bool checkScanList, uint8_t scanL const ChannelAttributes_t att = gMR_ChannelAttributes[channel]; + if (checkScanList && gMR_ChannelExclude[channel] == true) + return false; + if (att.band > BAND7_470MHz) return false; @@ -843,7 +846,7 @@ void RADIO_SetupRegisters(bool switchToForeground) else #endif { - BK4819_DisableVox(); + //BK4819_DisableVox(); } // RX expander diff --git a/scheduler.c b/scheduler.c index 47d07ecd4..4dbbd993f 100644 --- a/scheduler.c +++ b/scheduler.c @@ -82,20 +82,21 @@ void SystickHandler(void) if (gCurrentFunction == FUNCTION_POWER_SAVE) DECREMENT_AND_TRIGGER(gPowerSave_10ms, gPowerSaveCountdownExpired); - if (gScanStateDir == SCAN_OFF && !gCssBackgroundScan && gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) - if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_RECEIVE) - DECREMENT_AND_TRIGGER(gDualWatchCountdown_10ms, gScheduleDualWatch); + if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT){ + if (gScanStateDir == SCAN_OFF && !gCssBackgroundScan && gCurrentFunction != FUNCTION_RECEIVE){ + if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + DECREMENT_AND_TRIGGER(gDualWatchCountdown_10ms, gScheduleDualWatch); #ifdef ENABLE_NOAA - if (gScanStateDir == SCAN_OFF && !gCssBackgroundScan && gEeprom.DUAL_WATCH == DUAL_WATCH_OFF) - if (gIsNoaaMode && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT) - if (gCurrentFunction != FUNCTION_RECEIVE) + + if (gIsNoaaMode && gEeprom.DUAL_WATCH == DUAL_WATCH_OFF) DECREMENT_AND_TRIGGER(gNOAA_Countdown_10ms, gScheduleNOAA); #endif + } - if (gScanStateDir != SCAN_OFF) - if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT) + if (gScanStateDir != SCAN_OFF) DECREMENT_AND_TRIGGER(gScanPauseDelayIn_10ms, gScheduleScanListen); + } DECREMENT_AND_TRIGGER(gTailNoteEliminationCountdown_10ms, gFlagTailNoteEliminationComplete); diff --git a/settings.c b/settings.c index 3f36029e7..1b5f5d9a4 100644 --- a/settings.c +++ b/settings.c @@ -27,6 +27,7 @@ #include "settings.h" #include "ui/menu.h" +/* static const uint32_t gDefaultFrequencyTable[] = { 14500000, // @@ -35,6 +36,7 @@ static const uint32_t gDefaultFrequencyTable[] = 43320000, // 43350000 // }; +*/ EEPROM_Config_t gEeprom = { 0 }; @@ -106,7 +108,7 @@ void SETTINGS_InitEEPROM(void) gEeprom.FM_IsMrMode = fmCfg.isMrMode; } - // 0E40..0E67 + // 0E40..0E67 -> 0E40..0E6F EEPROM_ReadBuffer(0x0E40, gFM_Channels, sizeof(gFM_Channels)); FM_ConfigureChannelState(); #endif @@ -441,6 +443,7 @@ void SETTINGS_FactoryReset(bool bIsAll) RADIO_InitInfo(gRxVfo, FREQ_CHANNEL_FIRST + BAND6_400MHz, 43350000); // set the first few memory channels + /* don't need this for (i = 0; i < ARRAY_SIZE(gDefaultFrequencyTable); i++) { const uint32_t Frequency = gDefaultFrequencyTable[i]; @@ -449,6 +452,7 @@ void SETTINGS_FactoryReset(bool bIsAll) gRxVfo->Band = FREQUENCY_GetBand(Frequency); SETTINGS_SaveChannel(MR_CHANNEL_FIRST + i, 0, gRxVfo, 2); } + */ } } @@ -618,12 +622,9 @@ void SETTINGS_SaveSettings(void) State[0] = gEeprom.SCAN_LIST_DEFAULT; //State[1] = gEeprom.SCAN_LIST_ENABLED[0]; - if (gEeprom.SCAN_LIST_ENABLED[0] == 1) - tmp = tmp | (1 << 0); - if (gEeprom.SCAN_LIST_ENABLED[1] == 1) - tmp = tmp | (1 << 1); - if (gEeprom.SCAN_LIST_ENABLED[2] == 1) - tmp = tmp | (1 << 2); + if (gEeprom.SCAN_LIST_ENABLED[0] == 1) tmp |= 1 << 0; + if (gEeprom.SCAN_LIST_ENABLED[1] == 1) tmp |= 1 << 1; + if (gEeprom.SCAN_LIST_ENABLED[2] == 1) tmp |= 1 << 2; State[2] = gEeprom.SCANLIST_PRIORITY_CH1[0]; State[3] = gEeprom.SCANLIST_PRIORITY_CH2[0]; State[4] = gEeprom.SCANLIST_PRIORITY_CH1[1]; @@ -665,16 +666,10 @@ void SETTINGS_SaveSettings(void) memset(State, 0xFF, sizeof(State)); tmp = 0; - - if(gSetting_set_inv == 1) - tmp = tmp | (1 << 0); - if (gSetting_set_lck == 1) - tmp = tmp | (1 << 1); - if (gSetting_set_met == 1) - tmp = tmp | (1 << 2); - if (gSetting_set_gui == 1) - tmp = tmp | (1 << 3); - + if (gSetting_set_inv) tmp |= 1 << 0; + if (gSetting_set_lck) tmp |= 1 << 1; + if (gSetting_set_met) tmp |= 1 << 2; + if (gSetting_set_gui) tmp |= 1 << 3; State[5] = ((tmp << 4) | (gSetting_set_ctr & 0x0F)); State[6] = ((gSetting_set_tot << 4) | (gSetting_set_eot & 0x0F)); State[7] = ((gSetting_set_low << 4) | (gSetting_set_ptt & 0x0F)); diff --git a/ui/main.c b/ui/main.c index 6b6fee089..aac9ae056 100644 --- a/ui/main.c +++ b/ui/main.c @@ -892,44 +892,24 @@ void UI_DisplayMain(void) if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num])) { // it's a channel - uint8_t countList = 0; //uint8_t shiftList = 0; - + uint8_t countList = 0; + // show the scan list assigment symbols const ChannelAttributes_t att = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; - - if (att.scanlists & 0b001) - countList++; - if (att.scanlists & 0b010) - countList++; - if (att.scanlists & 0b100) - countList++; - -/* - shiftList = countList; - - if (att.scanlists & 0b100) - { - memcpy(p_line0 + 128 - ((shiftList>2?2:shiftList) * 8), BITMAP_ScanList1, sizeof(BITMAP_ScanList1)); - shiftList--; - } - if (att.scanlists & 0b010) - { - memcpy(((shiftList%2==1)?p_line0:p_line1) + 128 - ((shiftList>2?2:shiftList) * 8), BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); - shiftList--; + if (gMR_ChannelExclude[gEeprom.ScreenChannel[vfo_num]]){ + memcpy(p_line0 + 129 - (1 * 8), BITMAP_ScanList4, sizeof(BITMAP_ScanList4)); + memcpy(p_line0 + 129 - (2 * 8), BITMAP_ScanList4, sizeof(BITMAP_ScanList4)); + memcpy(p_line1 + 129 - (2 * 8), BITMAP_ScanList4, sizeof(BITMAP_ScanList4)); + } else { + countList = __builtin_popcount(att.scanlists & 0b111); + if (att.scanlists & 0b001) + memcpy(p_line0 + 129 - (2 * 8), BITMAP_ScanList1, sizeof(BITMAP_ScanList1)); + if (att.scanlists & 0b010) + memcpy(p_line0 + 129 - (1 * 8), BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); + if (att.scanlists & 0b100) + memcpy(p_line1 + 129 - (2 * 8), BITMAP_ScanList3, sizeof(BITMAP_ScanList3)); } - if (att.scanlists & 0b001) - { - memcpy(((shiftList%2==1)?p_line0:p_line1) + 128 - ((shiftList>2?2:shiftList) * 8), BITMAP_ScanList3, sizeof(BITMAP_ScanList3)); - } -*/ - if (att.scanlists & 0b001) - memcpy(p_line0 + 129 - (2 * 8), BITMAP_ScanList1, sizeof(BITMAP_ScanList1)); - if (att.scanlists & 0b010) - memcpy(p_line0 + 129 - (1 * 8), BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); - if (att.scanlists & 0b100) - memcpy(p_line1 + 129 - (2 * 8), BITMAP_ScanList3, sizeof(BITMAP_ScanList3)); - if(countList == 0) {