diff --git a/app/action.c b/app/action.c index db0dc8c..e57da3e 100644 --- a/app/action.c +++ b/app/action.c @@ -74,6 +74,7 @@ static void ACTION_Monitor(void) RADIO_SetupRegisters(true); APP_StartListening(FUNCTION_MONITOR); + return; } @@ -88,7 +89,7 @@ static void ACTION_Monitor(void) if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode) { gNOAA_Countdown = 500; - gScheduleNOAA = false; + gScheduleNOAA = false; } #endif @@ -207,6 +208,7 @@ void ACTION_FM(void) if (gFmRadioMode) { FM_TurnOff(); + gInputBoxIndex = 0; gVoxResumeCountdown = 80; gFlagReconfigureVfos = true; @@ -216,7 +218,9 @@ void ACTION_FM(void) RADIO_SelectVfos(); RADIO_SetupRegisters(true); + FM_Start(); + gInputBoxIndex = 0; gRequestDisplayScreen = DISPLAY_FM; } @@ -246,6 +250,7 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) #ifndef DISABLE_VOICE gAnotherVoiceID = VOICE_ID_CANCEL; #endif + gRequestDisplayScreen = DISPLAY_MAIN; gDTMF_InputMode = false; } @@ -286,6 +291,7 @@ void ACTION_Handle(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) switch (Short) { default: + case ACTION_OPT_NONE: break; case ACTION_OPT_FLASHLIGHT: ACTION_FlashLight(); diff --git a/app/app.c b/app/app.c index d41462a..c6e06aa 100644 --- a/app/app.c +++ b/app/app.c @@ -421,7 +421,6 @@ void APP_StartListening(FUNCTION_Type_t Function) #ifndef DISABLE_VOICE if (gVoiceWriteIndex == 0) -// BK4819_SetAF(gRxVfo->IsAM ? BK4819_AF_AM : BK4819_AF_OPEN); #endif BK4819_SetAF(gRxVfo->IsAM ? BK4819_AF_AM : BK4819_AF_OPEN); @@ -685,7 +684,11 @@ static void APP_HandleVox(void) gVoxPauseCountdown = 0; } - if (gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_MONITOR && gScanState == SCAN_OFF && gCssScanMode == CSS_SCAN_MODE_OFF && !gFmRadioMode) + if (gCurrentFunction != FUNCTION_RECEIVE && + gCurrentFunction != FUNCTION_MONITOR && + gScanState == SCAN_OFF && + gCssScanMode == CSS_SCAN_MODE_OFF && + !gFmRadioMode) { if (gVOX_NoiseDetected) { @@ -704,6 +707,7 @@ static void APP_HandleVox(void) else { APP_EndTransmission(); + if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) FUNCTION_Select(FUNCTION_FOREGROUND); else @@ -727,7 +731,9 @@ static void APP_HandleVox(void) if (gCurrentFunction != FUNCTION_TRANSMIT) { gDTMF_ReplyState = DTMF_REPLY_NONE; + RADIO_PrepareTX(); + gUpdateDisplay = true; } } @@ -749,9 +755,13 @@ void APP_Update(void) { gTxTimeoutReached = false; gFlagEndTransmission = true; + APP_EndTransmission(); + AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP); + RADIO_SetVfoState(VFO_STATE_TIMEOUT); + GUI_DisplayScreen(); } @@ -809,6 +819,7 @@ void APP_Update(void) { NOAA_IncreaseChannel(); RADIO_SetupRegisters(false); + gScheduleNOAA = false; gNOAA_Countdown = 7; } @@ -840,7 +851,11 @@ void APP_Update(void) } } - if (gFM_ScanState != FM_SCAN_OFF && gScheduleFM && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_TRANSMIT) + if (gFM_ScanState != FM_SCAN_OFF && + gScheduleFM && + gCurrentFunction != FUNCTION_MONITOR && + gCurrentFunction != FUNCTION_RECEIVE && + gCurrentFunction != FUNCTION_TRANSMIT) { FM_Play(); gScheduleFM = false; @@ -852,7 +867,14 @@ void APP_Update(void) if (gSchedulePowerSave) { #ifndef DISABLE_NOAA - if (gEeprom.BATTERY_SAVE == 0 || gScanState != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF || gFmRadioMode || gPttIsPressed || gScreenToDisplay != DISPLAY_MAIN || gKeyBeingHeld || gDTMF_CallState != DTMF_CALL_STATE_NONE) + if (gEeprom.BATTERY_SAVE == 0 || + gScanState != SCAN_OFF || + gCssScanMode != CSS_SCAN_MODE_OFF || + gFmRadioMode || + gPttIsPressed || + gScreenToDisplay != DISPLAY_MAIN || + gKeyBeingHeld || + gDTMF_CallState != DTMF_CALL_STATE_NONE) gBatterySaveCountdown = 1000; else if ((IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) && IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) || !gIsNoaaMode) @@ -860,7 +882,14 @@ void APP_Update(void) else gBatterySaveCountdown = 1000; #else - if (gEeprom.BATTERY_SAVE == 0 || gScanState != SCAN_OFF || gCssScanMode != CSS_SCAN_MODE_OFF || gFmRadioMode || gPttIsPressed || gScreenToDisplay != DISPLAY_MAIN || gKeyBeingHeld || gDTMF_CallState != DTMF_CALL_STATE_NONE) + if (gEeprom.BATTERY_SAVE == 0 || + gScanState != SCAN_OFF || + gCssScanMode != CSS_SCAN_MODE_OFF || + gFmRadioMode || + gPttIsPressed || + gScreenToDisplay != DISPLAY_MAIN || + gKeyBeingHeld || + gDTMF_CallState != DTMF_CALL_STATE_NONE) gBatterySaveCountdown = 1000; else FUNCTION_Select(FUNCTION_POWER_SAVE); @@ -889,6 +918,7 @@ void APP_Update(void) } FUNCTION_Init(); + gBatterySave = 10; gRxIdleMode = false; } @@ -923,7 +953,7 @@ void APP_Update(void) // called every 10ms void APP_CheckKeys(void) { - const uint16_t key_repeat_delay = 70; // 700ms + const uint16_t key_repeat_delay = 60; // 600ms KEY_Code_t Key; #ifndef DISABLE_AIRCOPY diff --git a/firmware b/firmware index 3d80b94..d60bb5d 100644 Binary files a/firmware and b/firmware differ diff --git a/firmware.bin b/firmware.bin index fe3f4a4..f35bb52 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 664c119..63710d0 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/functions.c b/functions.c index d19189c..c1f7c49 100644 --- a/functions.c +++ b/functions.c @@ -42,12 +42,7 @@ void FUNCTION_Init(void) { gCurrentCodeType = gSelectedCodeType; if (gCssScanMode == CSS_SCAN_MODE_OFF) - { - if (gRxVfo->IsAM) - gCurrentCodeType = CODE_TYPE_OFF; - else - gCurrentCodeType = gRxVfo->pRX->CodeType; - } + gCurrentCodeType = gRxVfo->IsAM ? CODE_TYPE_OFF : gRxVfo->pRX->CodeType; } #ifndef DISABLE_NOAA else @@ -77,108 +72,119 @@ void FUNCTION_Init(void) void FUNCTION_Select(FUNCTION_Type_t Function) { FUNCTION_Type_t PreviousFunction; - bool bWasPowerSave; - uint16_t Countdown = 0; + bool bWasPowerSave; + uint16_t Countdown = 0; PreviousFunction = gCurrentFunction; - bWasPowerSave = (PreviousFunction == FUNCTION_POWER_SAVE); + bWasPowerSave = (PreviousFunction == FUNCTION_POWER_SAVE); gCurrentFunction = Function; - if (bWasPowerSave) { - if (Function != FUNCTION_POWER_SAVE) { + if (bWasPowerSave) + { + if (Function != FUNCTION_POWER_SAVE) + { BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable(); gRxIdleMode = false; UI_DisplayStatus(); } } - switch (Function) { - case FUNCTION_FOREGROUND: - if (gDTMF_ReplyState != DTMF_REPLY_NONE) { - RADIO_PrepareCssTX(); - } - if (PreviousFunction == FUNCTION_TRANSMIT) { - gVFO_RSSI_Level[0] = 0; - gVFO_RSSI_Level[1] = 0; - } else if (PreviousFunction == FUNCTION_RECEIVE) { - if (gFmRadioMode) { - Countdown = 500; - } - 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); - } - } - return; - - case FUNCTION_MONITOR: - case FUNCTION_INCOMING: - case FUNCTION_RECEIVE: - break; - - case FUNCTION_POWER_SAVE: - gBatterySave = gEeprom.BATTERY_SAVE * 10; - gRxIdleMode = true; - BK4819_DisableVox(); - BK4819_Sleep(); - BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, false); - gBatterySaveCountdownExpired = false; - gUpdateStatus = true; - GUI_SelectNextDisplay(DISPLAY_MAIN); - return; - - case FUNCTION_TRANSMIT: - if (gFmRadioMode) - BK1080_Init(0, false); - - #ifndef DISABLE_ALARM - if (gAlarmState == ALARM_STATE_TXALARM && gEeprom.ALARM_MODE != ALARM_MODE_TONE) - { - gAlarmState = ALARM_STATE_ALARM; - GUI_DisplayScreen(); - GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); - SYSTEM_DelayMs(20); - BK4819_PlayTone(500, 0); - SYSTEM_DelayMs(2); - GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); - gEnableSpeaker = true; - SYSTEM_DelayMs(60); - BK4819_ExitTxMute(); - gAlarmToneCounter = 0; - break; - } - #endif - - GUI_DisplayScreen(); - RADIO_SetTxParameters(); - BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_RED, true); - - DTMF_Reply(); - - #ifndef DISABLE_ALARM - if (gAlarmState != ALARM_STATE_OFF) - { - if (gAlarmState == ALARM_STATE_TX1750) - BK4819_TransmitTone(true, 1750); - else - BK4819_TransmitTone(true, 500); + switch (Function) + { + case FUNCTION_FOREGROUND: + if (gDTMF_ReplyState != DTMF_REPLY_NONE) + RADIO_PrepareCssTX(); - SYSTEM_DelayMs(2); - GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); - gAlarmToneCounter = 0; - gEnableSpeaker = true; - break; + if (PreviousFunction == FUNCTION_TRANSMIT) + { + gVFO_RSSI_Level[0] = 0; + gVFO_RSSI_Level[1] = 0; } - #endif + else + if (PreviousFunction == FUNCTION_RECEIVE) + { + if (gFmRadioMode) + Countdown = 500; + + 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); + } + + return; + + case FUNCTION_MONITOR: + case FUNCTION_INCOMING: + case FUNCTION_RECEIVE: + break; + + case FUNCTION_POWER_SAVE: + gBatterySave = gEeprom.BATTERY_SAVE * 10; + gRxIdleMode = true; + + BK4819_DisableVox(); + BK4819_Sleep(); + BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, false); + + gBatterySaveCountdownExpired = false; + gUpdateStatus = true; + + GUI_SelectNextDisplay(DISPLAY_MAIN); + return; + + case FUNCTION_TRANSMIT: + if (gFmRadioMode) + BK1080_Init(0, false); + + #ifndef DISABLE_ALARM + if (gAlarmState == ALARM_STATE_TXALARM && gEeprom.ALARM_MODE != ALARM_MODE_TONE) + { + gAlarmState = ALARM_STATE_ALARM; + GUI_DisplayScreen(); + GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); + SYSTEM_DelayMs(20); + BK4819_PlayTone(500, 0); + SYSTEM_DelayMs(2); + GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); + gEnableSpeaker = true; + SYSTEM_DelayMs(60); + BK4819_ExitTxMute(); + gAlarmToneCounter = 0; + break; + } + #endif + + GUI_DisplayScreen(); + + RADIO_SetTxParameters(); + + BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_RED, true); + + DTMF_Reply(); + + #ifndef DISABLE_ALARM + if (gAlarmState != ALARM_STATE_OFF) + { + BK4819_TransmitTone(true, (gAlarmState == ALARM_STATE_TX1750) ? 1750 : 500); - if (gCurrentVfo->SCRAMBLING_TYPE && gSetting_ScrambleEnable) - BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1U); - else - BK4819_DisableScramble(); + SYSTEM_DelayMs(2); - break; + GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); + + gAlarmToneCounter = 0; + gEnableSpeaker = true; + break; + } + #endif + + if (gCurrentVfo->SCRAMBLING_TYPE && gSetting_ScrambleEnable) + BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1U); + else + BK4819_DisableScramble(); + + break; } + gBatterySaveCountdown = 1000; - gSchedulePowerSave = false; - gFM_RestoreCountdown = Countdown; + gSchedulePowerSave = false; + gFM_RestoreCountdown = Countdown; } - diff --git a/helper/boot.c b/helper/boot.c index 5ffbfd0..f755bf0 100644 --- a/helper/boot.c +++ b/helper/boot.c @@ -74,6 +74,9 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode) #ifdef DISABLE_VOICE gMenuListCount--; #endif + #ifdef DISABLE_ALARM + gMenuListCount--; + #endif #ifdef DISABLE_NOAA gMenuListCount--; #endif diff --git a/ui/aircopy.c b/ui/aircopy.c index 85ba8ab..242769c 100644 --- a/ui/aircopy.c +++ b/ui/aircopy.c @@ -46,7 +46,7 @@ void UI_DisplayAircopy(void) { NUMBER_ToDigits(gRxVfo->ConfigRX.Frequency, String); UI_DisplayFrequency(String, 16, 2, 0, 0); - UI_DisplaySmallDigits(2, String + 6, 97, 3); + UI_DisplaySmallDigits(2, String + 6, 97, 3, true); } else UI_DisplayFrequency(gInputBox, 16, 2, 1, 0); diff --git a/ui/helper.c b/ui/helper.c index 6cc64f3..358e558 100644 --- a/ui/helper.c +++ b/ui/helper.c @@ -217,11 +217,21 @@ void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bD } } -void UI_DisplaySmallDigits(uint8_t Size, const char *pString, uint8_t X, uint8_t Y) +void UI_DisplaySmallDigits(const uint8_t size, const char *str, const uint8_t x, const uint8_t y, const bool display_leading_zeros) { const unsigned int char_width = 7; - unsigned int x = X; + bool display = display_leading_zeros; + unsigned int xx; unsigned int i; - for (i = 0; i < Size; i++, x += char_width) - memcpy(gFrameBuffer[Y] + x, gFontSmallDigits[(unsigned int)pString[i]], char_width); + for (i = 0, xx = x; i < size; i++) + { + const unsigned int c = (unsigned int)str[i]; + if (c > 0) + display = true; + if (display && c < ARRAY_SIZE(gFontSmallDigits)) + { + memcpy(gFrameBuffer[y] + xx, gFontSmallDigits[c], char_width); + xx += char_width; + } + } } diff --git a/ui/helper.h b/ui/helper.h index dbd4353..213b149 100644 --- a/ui/helper.h +++ b/ui/helper.h @@ -26,7 +26,7 @@ void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Lin void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_t Line); void UI_DisplayFrequency(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero, bool bFlag); void UI_DisplayFrequencySmall(const char *pDigits, uint8_t X, uint8_t Y, bool bDisplayLeadingZero); -void UI_DisplaySmallDigits(uint8_t Size, const char *pString, uint8_t X, uint8_t Y); +void UI_DisplaySmallDigits(const uint8_t size, const char *str, const uint8_t x, const uint8_t y, const bool display_leading_zeros); #endif diff --git a/ui/main.c b/ui/main.c index 1d86942..8fbc57c 100644 --- a/ui/main.c +++ b/ui/main.c @@ -116,8 +116,9 @@ void UI_DisplayMain(void) // highlight the selected/used VFO with a marker if (!single_vfo && bIsSameVfo) memcpy(pLine0 + 2, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); - //else - // memcpy(pLine0 + 2, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault)); + else + if (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) + memcpy(pLine0 + 2, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault)); } else if (!single_vfo) @@ -169,7 +170,7 @@ void UI_DisplayMain(void) NUMBER_ToDigits(gEeprom.ScreenChannel[vfo_num] + 1, String); else memcpy(String + 5, gInputBox, 3); - UI_DisplaySmallDigits(3, String + 5, x + sizeof(BITMAP_M), Line + 1); + UI_DisplaySmallDigits(3, String + 5, x + sizeof(BITMAP_M), Line + 1, false); } else if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num])) @@ -179,7 +180,7 @@ void UI_DisplayMain(void) char c; memcpy(pLine1 + x, BITMAP_FB, sizeof(BITMAP_FB)); c = (gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST) + 1; - UI_DisplaySmallDigits(1, &c, x + sizeof(BITMAP_FB), Line + 1); + UI_DisplaySmallDigits(1, &c, x + sizeof(BITMAP_FB), Line + 1, false); } else { @@ -195,7 +196,7 @@ void UI_DisplayMain(void) String[6] = gInputBox[0]; String[7] = gInputBox[1]; } - UI_DisplaySmallDigits(2, String + 6, 15, Line + 1); + UI_DisplaySmallDigits(2, String + 6, 15, Line + 1, true); } // ************ @@ -285,7 +286,7 @@ void UI_DisplayMain(void) // show the main large frequency digits UI_DisplayFrequency(String, 31, Line, false, false); // show the remaining 2 small frequency digits - UI_DisplaySmallDigits(2, String + 6, 112, Line + 1); + UI_DisplaySmallDigits(2, String + 6, 112, Line + 1, true); #else // show the frequency in the main font sprintf(String, "%9.5f", frequency_Hz * 0.00001); @@ -346,7 +347,7 @@ void UI_DisplayMain(void) // show the main large frequency digits UI_DisplayFrequency(String, 31, Line, false, false); // show the remaining 2 small frequency digits - UI_DisplaySmallDigits(2, String + 6, 112, Line + 1); + UI_DisplaySmallDigits(2, String + 6, 112, Line + 1, true); #else // show the frequency in the main font sprintf(String, "%9.5f", frequency_Hz * 0.00001); diff --git a/ui/menu.c b/ui/menu.c index b136962..d588895 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -34,22 +34,22 @@ static const char MenuList[][7] = { "SQL", "STEP", - "TX-PWR", - "R_DCS", - "R_CTCS", - "T_DCS", - "T_CTCS", + "TX-PWR", // was "TXP" + "R-DCS", // was "R_DCS" + "R-CTCS", // was "R_CTCS" + "T-DCS", // was "T_DCS" + "T-CTCS", // was "T_CTCS" "SFT-D", "OFFSET", "W/N", - "SCRAM", + "SCRAM", // was "SCR" "BCL", "MEM-CH", - "B-SAVE", + "B-SAVE", // was "SAVE" "VOX", - "BAK-LT", - "TDR", - "CROS-B", + "BAK-LT", // was "ABR" + "DUAL-W", // was "TDR" + "CROS-B", // was "WX" "BEEP", "TOT", #ifndef DISABLE_VOICE @@ -82,8 +82,8 @@ static const char MenuList[][7] = "D-LIST", "PONMSG", "ROGER", - "BATVOL", - "MODE", + "BATVOL", // was "VOL" + "MODE", // was "AM" #ifndef DISABLE_NOAA "NOAA_S", #endif @@ -93,12 +93,12 @@ static const char MenuList[][7] = // normally hidden menu items from here on. // enabled if pressing PTT and side button below PTT at power-on. - "350TX", + "350-TX", // was "350TX" "F-LOCK", - "200TX", - "500TX", - "350EN", - "SCREN" + "200-TX", // was "200TX" + "500-TX", // was "500TX" + "350-EN", // was "350EN" + "SCR-EN" // was "SCREN" }; #if 0 @@ -293,7 +293,7 @@ void UI_DisplayMenu(void) #endif NUMBER_ToDigits(gMenuCursor + 1, String); - UI_DisplaySmallDigits(2, String + 6, 33, 6); + UI_DisplaySmallDigits(2, String + 6, 33, 6, false); if (gIsInSubMenu) memcpy(gFrameBuffer[0] + 50, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator)); @@ -628,10 +628,10 @@ void UI_DisplayMenu(void) gMenuCursor == MENU_T_DCS || gMenuCursor == MENU_D_LIST) { - uint8_t Offset; + unsigned int Offset; NUMBER_ToDigits((uint8_t)gSubMenuSelection, String); Offset = (gMenuCursor == MENU_D_LIST) ? 2 : 3; - UI_DisplaySmallDigits(Offset, String + (8 - Offset), 105, 0); + UI_DisplaySmallDigits(Offset, String + (8 - Offset), 105, 0, false); } if (gMenuCursor == MENU_SLIST1 || gMenuCursor == MENU_SLIST2)