From f4ff2e604846217ddd5d259cea9c5c38bc19303c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Thu, 27 Feb 2025 16:49:04 +0100 Subject: [PATCH] Apply my changes v1 --- Makefile | 29 +- app/aircopy.c | 78 +- app/app.c | 1014 +++++++------- app/app.h | 18 +- app/dtmf.c | 94 +- app/main.c | 531 +++++--- app/menu.c | 998 +++++++------- app/spectrum.c | 1132 +++++++--------- driver/backlight.c | 6 - driver/bk4819-regs.h | 2 + driver/bk4819.c | 15 + driver/bk4819.h | 5 + driver/keyboard.c | 2 + driver/keyboard.h | 6 +- .../CMSIS/DoxyGen/Driver/src/General.txt | 4 +- font.c | 420 +++--- frequencies.c | 70 +- functions.c | 104 +- functions.h | 9 +- helper/battery.c | 4 - main.c | 190 ++- misc.c | 7 +- misc.h | 5 - radio.c | 11 +- settings.c | 808 ++++++------ settings.h | 234 ++-- ui/aircopy.c | 6 +- ui/fmradio.c | 16 +- ui/helper.c | 341 ++--- ui/helper.h | 2 +- ui/main.c | 847 ++++++------ ui/menu.c | 1168 ++++++++--------- ui/menu.h | 146 +-- ui/status.c | 7 - ui/welcome.c | 161 +-- version.c | 1 - version.h | 6 +- 37 files changed, 3890 insertions(+), 4607 deletions(-) diff --git a/Makefile b/Makefile index d55d9db..12a12a0 100644 --- a/Makefile +++ b/Makefile @@ -4,12 +4,12 @@ # 1 = enable # ---- STOCK QUANSHENG FEATURES ---- -ENABLE_FMRADIO ?= 0 +ENABLE_FMRADIO ?= 1 ENABLE_UART ?= 1 ENABLE_AIRCOPY ?= 0 ENABLE_NOAA ?= 0 ENABLE_VOICE ?= 0 -ENABLE_VOX ?= 1 +ENABLE_VOX ?= 0 ENABLE_ALARM ?= 0 ENABLE_TX1750 ?= 1 ENABLE_PWRON_PASSWORD ?= 0 @@ -17,15 +17,15 @@ ENABLE_DTMF_CALLING ?= 0 ENABLE_FLASHLIGHT ?= 1 # ---- CUSTOM MODS ---- -ENABLE_SPECTRUM ?= 0 -ENABLE_BIG_FREQ ?= 1 -ENABLE_SMALL_BOLD ?= 1 +ENABLE_SPECTRUM ?= 1 +ENABLE_BIG_FREQ ?= 0 +ENABLE_SMALL_BOLD ?= 0 ENABLE_CUSTOM_MENU_LAYOUT ?= 1 ENABLE_KEEP_MEM_NAME ?= 1 ENABLE_WIDE_RX ?= 1 ENABLE_TX_WHEN_AM ?= 0 -ENABLE_F_CAL_MENU ?= 0 -ENABLE_CTCSS_TAIL_PHASE_SHIFT ?= 0 +ENABLE_F_CAL_MENU ?= 1 +ENABLE_CTCSS_TAIL_PHASE_SHIFT ?= 1 ENABLE_BOOT_BEEPS ?= 0 ENABLE_SHOW_CHARGE_LEVEL ?= 0 ENABLE_REVERSE_BAT_SYMBOL ?= 0 @@ -36,26 +36,26 @@ ENABLE_FASTER_CHANNEL_SCAN ?= 1 ENABLE_RSSI_BAR ?= 1 ENABLE_AUDIO_BAR ?= 1 ENABLE_COPY_CHAN_TO_VFO ?= 1 -ENABLE_REDUCE_LOW_MID_TX_POWER ?= 0 -ENABLE_BYP_RAW_DEMODULATORS ?= 0 -ENABLE_BLMIN_TMP_OFF ?= 0 +ENABLE_REDUCE_LOW_MID_TX_POWER ?= 1 +ENABLE_BYP_RAW_DEMODULATORS ?= 1 +ENABLE_BLMIN_TMP_OFF ?= 1 ENABLE_SCAN_RANGES ?= 1 ENABLE_FEAT_F4HWN ?= 1 ENABLE_FEAT_F4HWN_SCREENSHOT ?= 0 ENABLE_FEAT_F4HWN_SPECTRUM ?= 1 -ENABLE_FEAT_F4HWN_RX_TX_TIMER ?= 1 +ENABLE_FEAT_F4HWN_RX_TX_TIMER ?= 0 ENABLE_FEAT_F4HWN_CHARGING_C ?= 0 ENABLE_FEAT_F4HWN_SLEEP ?= 1 ENABLE_FEAT_F4HWN_RESUME_STATE ?= 1 ENABLE_FEAT_F4HWN_NARROWER ?= 1 -ENABLE_FEAT_F4HWN_INV ?= 1 +ENABLE_FEAT_F4HWN_INV ?= 0 ENABLE_FEAT_F4HWN_CTR ?= 1 ENABLE_FEAT_F4HWN_RESCUE_OPS ?= 0 -ENABLE_FEAT_F4HWN_VOL ?= 0 +ENABLE_FEAT_F4HWN_VOL ?= 1 ENABLE_FEAT_F4HWN_RESET_CHANNEL ?= 0 ENABLE_FEAT_F4HWN_PMR ?= 0 ENABLE_FEAT_F4HWN_GMRS_FRS_MURS ?= 0 -ENABLE_FEAT_F4HWN_CA ?= 1 +ENABLE_FEAT_F4HWN_CA ?= 0 ENABLE_FEAT_F4HWN_DEBUG ?= 0 ENABLE_REGA ?= 0 @@ -138,6 +138,7 @@ OBJS += app/app.o OBJS += app/chFrScanner.o OBJS += app/common.o OBJS += app/dtmf.o +OBJS += app/fskmodem.o ifeq ($(ENABLE_REGA),1) OBJS += app/rega.o endif diff --git a/app/aircopy.c b/app/aircopy.c index bc844fe..cb4acc7 100644 --- a/app/aircopy.c +++ b/app/aircopy.c @@ -36,7 +36,7 @@ #include "screenshot.h" #endif -static const uint16_t Obfuscation[8] = { 0x6C16, 0xE614, 0x912E, 0x400D, 0x3521, 0x40D5, 0x0313, 0x80E9 }; +static const uint16_t Obfuscation[8] = {0x6C16, 0xE614, 0x912E, 0x400D, 0x3521, 0x40D5, 0x0313, 0x80E9}; AIRCOPY_State_t gAircopyState; uint16_t gAirCopyBlockNumber; @@ -45,16 +45,13 @@ uint8_t gAirCopyIsSendMode; uint16_t g_FSK_Buffer[36]; -static void AIRCOPY_clear() -{ - for (uint8_t i = 0; i < 15; i++) - { +static void AIRCOPY_clear() { + for (uint8_t i = 0; i < 15; i++) { crc[i] = 0; } } -bool AIRCOPY_SendMessage(void) -{ +bool AIRCOPY_SendMessage(void) { static uint8_t gAircopySendCountdown = 1; if (gAircopyState != AIRCOPY_TRANSFER) { @@ -77,9 +74,9 @@ bool AIRCOPY_SendMessage(void) if (++gAirCopyBlockNumber >= 0x78) { gAircopyState = AIRCOPY_COMPLETE; - #ifdef ENABLE_FEAT_F4HWN_SCREENSHOT - getScreenShot(); - #endif +#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT + getScreenShot(); +#endif //NVIC_SystemReset(); } @@ -94,8 +91,7 @@ bool AIRCOPY_SendMessage(void) return 0; } -void AIRCOPY_StorePacket(void) -{ +void AIRCOPY_StorePacket(void) { if (gFSKWriteIndex < 36) { return; } @@ -138,16 +134,15 @@ void AIRCOPY_StorePacket(void) if (Offset == 0x1E00) { gAircopyState = AIRCOPY_COMPLETE; - #ifdef ENABLE_FEAT_F4HWN_SCREENSHOT - getScreenShot(); - #endif +#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT + getScreenShot(); +#endif } gAirCopyBlockNumber++; } -static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) -{ +static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { if (bKeyHeld || !bKeyPressed) { return; } @@ -194,8 +189,7 @@ static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) gRequestDisplayScreen = DISPLAY_AIRCOPY; } -static void AIRCOPY_Key_EXIT(bool bKeyPressed, bool bKeyHeld) -{ +static void AIRCOPY_Key_EXIT(bool bKeyPressed, bool bKeyHeld) { if (bKeyHeld || !bKeyPressed) { return; } @@ -220,8 +214,7 @@ static void AIRCOPY_Key_EXIT(bool bKeyPressed, bool bKeyHeld) gRequestDisplayScreen = DISPLAY_AIRCOPY; } -static void AIRCOPY_Key_MENU(bool bKeyPressed, bool bKeyHeld) -{ +static void AIRCOPY_Key_MENU(bool bKeyPressed, bool bKeyHeld) { if (bKeyHeld || !bKeyPressed) { return; } @@ -242,29 +235,28 @@ static void AIRCOPY_Key_MENU(bool bKeyPressed, bool bKeyHeld) gAircopyState = AIRCOPY_TRANSFER; } -void AIRCOPY_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) -{ +void AIRCOPY_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { switch (Key) { - case KEY_0: - case KEY_1: - case KEY_2: - case KEY_3: - case KEY_4: - case KEY_5: - case KEY_6: - case KEY_7: - case KEY_8: - case KEY_9: - AIRCOPY_Key_DIGITS(Key, bKeyPressed, bKeyHeld); - break; - case KEY_MENU: - AIRCOPY_Key_MENU(bKeyPressed, bKeyHeld); - break; - case KEY_EXIT: - AIRCOPY_Key_EXIT(bKeyPressed, bKeyHeld); - break; - default: - break; + case KEY_0: + case KEY_1: + case KEY_2: + case KEY_3: + case KEY_4: + case KEY_5: + case KEY_6: + case KEY_7: + case KEY_8: + case KEY_9: + AIRCOPY_Key_DIGITS(Key, bKeyPressed, bKeyHeld); + break; + case KEY_MENU: + AIRCOPY_Key_MENU(bKeyPressed, bKeyHeld); + break; + case KEY_EXIT: + AIRCOPY_Key_EXIT(bKeyPressed, bKeyHeld); + break; + default: + break; } } diff --git a/app/app.c b/app/app.c index 3fa9e1f..ac938ee 100644 --- a/app/app.c +++ b/app/app.c @@ -22,35 +22,50 @@ #include "app/action.h" #ifdef ENABLE_AIRCOPY - #include "app/aircopy.h" +#include "app/aircopy.h" #endif + #include "app/app.h" #include "app/chFrScanner.h" #include "app/dtmf.h" + #ifdef ENABLE_FLASHLIGHT - #include "app/flashlight.h" + +#include "app/flashlight.h" + #endif #ifdef ENABLE_FMRADIO - #include "app/fm.h" +#include "app/fm.h" #endif + #include "app/generic.h" #include "app/main.h" #include "app/menu.h" #include "app/scanner.h" + #ifdef ENABLE_UART - #include "app/uart.h" + +#include "app/uart.h" + #endif + #include "ARMCM0.h" #include "audio.h" #include "board.h" #include "bsp/dp32g030/gpio.h" + #ifdef ENABLE_FEAT_F4HWN_SLEEP - #include "bsp/dp32g030/pwmplus.h" + +#include "bsp/dp32g030/pwmplus.h" + #endif + #include "driver/backlight.h" + #ifdef ENABLE_FMRADIO - #include "driver/bk1080.h" +#include "driver/bk1080.h" #endif + #include "driver/bk4819.h" #include "driver/gpio.h" #include "driver/keyboard.h" @@ -66,8 +81,9 @@ #include "settings.h" #if defined(ENABLE_OVERLAY) - #include "sram-overlay.h" +#include "sram-overlay.h" #endif + #include "ui/battery.h" #include "ui/inputbox.h" #include "ui/main.h" @@ -83,16 +99,16 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld); void (*ProcessKeysFunctions[])(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) = { - [DISPLAY_MAIN] = &MAIN_ProcessKeys, - [DISPLAY_MENU] = &MENU_ProcessKeys, - [DISPLAY_SCANNER] = &SCANNER_ProcessKeys, + [DISPLAY_MAIN] = &MAIN_ProcessKeys, + [DISPLAY_MENU] = &MENU_ProcessKeys, + [DISPLAY_SCANNER] = &SCANNER_ProcessKeys, #ifdef ENABLE_FMRADIO - [DISPLAY_FM] = &FM_ProcessKeys, + [DISPLAY_FM] = &FM_ProcessKeys, #endif #ifdef ENABLE_AIRCOPY - [DISPLAY_AIRCOPY] = &AIRCOPY_ProcessKeys, + [DISPLAY_AIRCOPY] = &AIRCOPY_ProcessKeys, #endif }; @@ -103,28 +119,24 @@ static_assert(ARRAY_SIZE(ProcessKeysFunctions) == DISPLAY_N_ELEM-1); static_assert(ARRAY_SIZE(ProcessKeysFunctions) == DISPLAY_N_ELEM); #endif -static void CheckForIncoming(void) -{ +static void CheckForIncoming(void) { if (!g_SquelchLost) return; // squelch is closed // squelch is open - if (gScanStateDir == SCAN_OFF) - { // not RF scanning - if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF) - { // dual watch is disabled + if (gScanStateDir == SCAN_OFF) { // not RF scanning + if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF) { // dual watch is disabled - #ifdef ENABLE_NOAA - if (gIsNoaaMode) - { - gNOAA_Countdown_10ms = NOAA_countdown_3_10ms; - gScheduleNOAA = false; - } - #endif - - if (gCurrentFunction != FUNCTION_INCOMING) +#ifdef ENABLE_NOAA + if (gIsNoaaMode) { + gNOAA_Countdown_10ms = NOAA_countdown_3_10ms; + gScheduleNOAA = false; + } +#endif + + if (gCurrentFunction != FUNCTION_INCOMING) { FUNCTION_Select(FUNCTION_INCOMING); //gUpdateDisplay = true; } @@ -134,10 +146,8 @@ static void CheckForIncoming(void) // dual watch is enabled and we're RX'ing a signal - if (gRxReceptionMode != RX_MODE_NONE) - { - if (gCurrentFunction != FUNCTION_INCOMING) - { + if (gRxReceptionMode != RX_MODE_NONE) { + if (gCurrentFunction != FUNCTION_INCOMING) { FUNCTION_Select(FUNCTION_INCOMING); //gUpdateDisplay = true; } @@ -145,18 +155,14 @@ static void CheckForIncoming(void) } gDualWatchCountdown_10ms = dual_watch_count_after_rx_10ms; - gScheduleDualWatch = false; + gScheduleDualWatch = false; // let the user see DW is not active gDualWatchActive = false; - gUpdateStatus = true; - } - else - { // RF scanning - if (gRxReceptionMode != RX_MODE_NONE) - { - if (gCurrentFunction != FUNCTION_INCOMING) - { + gUpdateStatus = true; + } else { // RF scanning + if (gRxReceptionMode != RX_MODE_NONE) { + if (gCurrentFunction != FUNCTION_INCOMING) { FUNCTION_Select(FUNCTION_INCOMING); //gUpdateDisplay = true; } @@ -164,20 +170,18 @@ static void CheckForIncoming(void) } gScanPauseDelayIn_10ms = scan_pause_delay_in_3_10ms; - gScheduleScanListen = false; + gScheduleScanListen = false; } gRxReceptionMode = RX_MODE_DETECTED; - if (gCurrentFunction != FUNCTION_INCOMING) - { + if (gCurrentFunction != FUNCTION_INCOMING) { FUNCTION_Select(FUNCTION_INCOMING); //gUpdateDisplay = true; } } -static void HandleIncoming(void) -{ +static void HandleIncoming(void) { if (!g_SquelchLost) { // squelch is closed #ifdef ENABLE_DTMF_CALLING if (gDTMF_RX_index > 0) @@ -200,20 +204,18 @@ static void HandleIncoming(void) #endif if (g_CTCSS_Lost && gCurrentCodeType == CODE_TYPE_CONTINUOUS_TONE) { - bFlag = true; + bFlag = true; gFoundCTCSS = false; } if (g_CDCSS_Lost && gCDCSSCodeType == CDCSS_POSITIVE_CODE - && (gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL)) - { + && (gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL)) { gFoundCDCSS = false; - } - else if (!bFlag) + } else if (!bFlag) return; #ifdef ENABLE_DTMF_CALLING - if (gScanStateDir == SCAN_OFF && (gRxVfo->DTMF_DECODING_ENABLE || gSetting_KILLED)) { + if (gScanStateDir == SCAN_OFF && (gRxVfo->DTMF_DECODING_ENABLE)) { // DTMF DCD is enabled DTMF_HandleRequest(); @@ -222,13 +224,13 @@ static void HandleIncoming(void) return; } gDualWatchCountdown_10ms = dual_watch_count_after_1_10ms; - gScheduleDualWatch = false; + gScheduleDualWatch = false; gRxReceptionMode = RX_MODE_LISTENING; // let the user see DW is not active gDualWatchActive = false; - gUpdateStatus = true; + gUpdateStatus = true; gUpdateDisplay = true; return; @@ -239,22 +241,19 @@ static void HandleIncoming(void) APP_StartListening(gMonitor ? FUNCTION_MONITOR : FUNCTION_RECEIVE); } -static void HandleReceive(void) -{ - #define END_OF_RX_MODE_SKIP 0 - #define END_OF_RX_MODE_END 1 - #define END_OF_RX_MODE_TTE 2 +static void HandleReceive(void) { +#define END_OF_RX_MODE_SKIP 0 +#define END_OF_RX_MODE_END 1 +#define END_OF_RX_MODE_TTE 2 uint8_t Mode = END_OF_RX_MODE_SKIP; - if (gFlagTailNoteEliminationComplete) - { + if (gFlagTailNoteEliminationComplete) { Mode = END_OF_RX_MODE_END; goto Skip; } - if (gScanStateDir != SCAN_OFF && IS_FREQ_CHANNEL(gNextMrChannel)) - { // we are scanning in the frequency mode + if (gScanStateDir != SCAN_OFF && IS_FREQ_CHANNEL(gNextMrChannel)) { // we are scanning in the frequency mode if (g_SquelchLost) return; @@ -262,89 +261,72 @@ static void HandleReceive(void) goto Skip; } - switch (gCurrentCodeType) - { + switch (gCurrentCodeType) { default: case CODE_TYPE_OFF: break; case CODE_TYPE_CONTINUOUS_TONE: - if (gFoundCTCSS && gFoundCTCSSCountdown_10ms == 0) - { + if (gFoundCTCSS && gFoundCTCSSCountdown_10ms == 0) { gFoundCTCSS = false; gFoundCDCSS = false; - Mode = END_OF_RX_MODE_END; + Mode = END_OF_RX_MODE_END; goto Skip; } break; case CODE_TYPE_DIGITAL: case CODE_TYPE_REVERSE_DIGITAL: - if (gFoundCDCSS && gFoundCDCSSCountdown_10ms == 0) - { + if (gFoundCDCSS && gFoundCDCSSCountdown_10ms == 0) { gFoundCTCSS = false; gFoundCDCSS = false; - Mode = END_OF_RX_MODE_END; + Mode = END_OF_RX_MODE_END; goto Skip; } break; } - if (g_SquelchLost) - { - #ifdef ENABLE_NOAA - if (!gEndOfRxDetectedMaybe && !IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) - #else - if (!gEndOfRxDetectedMaybe) - #endif + if (g_SquelchLost) { +#ifdef ENABLE_NOAA + if (!gEndOfRxDetectedMaybe && !IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) +#else + if (!gEndOfRxDetectedMaybe) +#endif { - switch (gCurrentCodeType) - { + switch (gCurrentCodeType) { case CODE_TYPE_OFF: - if (gEeprom.SQUELCH_LEVEL) - { - if (g_CxCSS_TAIL_Found) - { - Mode = END_OF_RX_MODE_TTE; + if (gEeprom.SQUELCH_LEVEL) { + if (g_CxCSS_TAIL_Found) { + Mode = END_OF_RX_MODE_TTE; g_CxCSS_TAIL_Found = false; } } break; case CODE_TYPE_CONTINUOUS_TONE: - if (g_CTCSS_Lost) - { + if (g_CTCSS_Lost) { gFoundCTCSS = false; - } - else - if (!gFoundCTCSS) - { - gFoundCTCSS = true; + } else if (!gFoundCTCSS) { + gFoundCTCSS = true; gFoundCTCSSCountdown_10ms = 100; // 1 sec } - if (g_CxCSS_TAIL_Found) - { - Mode = END_OF_RX_MODE_TTE; + if (g_CxCSS_TAIL_Found) { + Mode = END_OF_RX_MODE_TTE; g_CxCSS_TAIL_Found = false; } break; case CODE_TYPE_DIGITAL: case CODE_TYPE_REVERSE_DIGITAL: - if (g_CDCSS_Lost && gCDCSSCodeType == CDCSS_POSITIVE_CODE) - { + if (g_CDCSS_Lost && gCDCSSCodeType == CDCSS_POSITIVE_CODE) { gFoundCDCSS = false; - } - else - if (!gFoundCDCSS) - { - gFoundCDCSS = true; + } else if (!gFoundCDCSS) { + gFoundCDCSS = true; gFoundCDCSSCountdown_10ms = 100; // 1 sec } - if (g_CxCSS_TAIL_Found) - { + if (g_CxCSS_TAIL_Found) { if (BK4819_GetCTCType() == 1) Mode = END_OF_RX_MODE_TTE; @@ -354,38 +336,35 @@ static void HandleReceive(void) break; } } - } - else + } else Mode = END_OF_RX_MODE_END; - if (!gEndOfRxDetectedMaybe && - Mode == END_OF_RX_MODE_SKIP && - gNextTimeslice40ms && - gEeprom.TAIL_TONE_ELIMINATION && - (gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL) && - BK4819_GetCTCType() == 1) + if (!gEndOfRxDetectedMaybe && + Mode == END_OF_RX_MODE_SKIP && + gNextTimeslice40ms && + gEeprom.TAIL_TONE_ELIMINATION && + (gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL) && + BK4819_GetCTCType() == 1) Mode = END_OF_RX_MODE_TTE; else gNextTimeslice40ms = false; -Skip: - switch (Mode) - { + Skip: + switch (Mode) { case END_OF_RX_MODE_SKIP: break; case END_OF_RX_MODE_END: RADIO_SetupRegisters(true); - #ifdef ENABLE_NOAA - if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) - gNOAACountdown_10ms = 300; // 3 sec - #endif +#ifdef ENABLE_NOAA + if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) + gNOAACountdown_10ms = 300; // 3 sec +#endif gUpdateDisplay = true; - if (gScanStateDir != SCAN_OFF) - { + if (gScanStateDir != SCAN_OFF) { /* switch (gEeprom.SCAN_RESUME_MODE) @@ -404,16 +383,12 @@ Skip: } */ - if(gEeprom.SCAN_RESUME_MODE < 81) - { - if(gEeprom.SCAN_RESUME_MODE == 0) - { + if (gEeprom.SCAN_RESUME_MODE < 81) { + if (gEeprom.SCAN_RESUME_MODE == 0) { CHFRSCANNER_Stop(); - } - else - { + } else { gScanPauseDelayIn_10ms = gEeprom.SCAN_RESUME_MODE * (250 / 10); // 250ms - gScheduleScanListen = false; + gScheduleScanListen = false; } } @@ -461,51 +436,43 @@ Skip: AUDIO_AudioPathOff(); gTailNoteEliminationCountdown_10ms = 20; - gFlagTailNoteEliminationComplete = false; + gFlagTailNoteEliminationComplete = false; gEndOfRxDetectedMaybe = true; - gEnableSpeaker = false; + gEnableSpeaker = false; } break; } } -static void HandlePowerSave() -{ +static void HandlePowerSave() { if (!gRxIdleMode) { CheckForIncoming(); } } static void (*HandleFunction_fn_table[])(void) = { - [FUNCTION_FOREGROUND] = &CheckForIncoming, - [FUNCTION_TRANSMIT] = &FUNCTION_NOP, - [FUNCTION_MONITOR] = &FUNCTION_NOP, - [FUNCTION_INCOMING] = &HandleIncoming, - [FUNCTION_RECEIVE] = &HandleReceive, - [FUNCTION_POWER_SAVE] = &HandlePowerSave, - [FUNCTION_BAND_SCOPE] = &FUNCTION_NOP, + [FUNCTION_FOREGROUND] = &CheckForIncoming, + [FUNCTION_TRANSMIT] = &FUNCTION_NOP, + [FUNCTION_MONITOR] = &FUNCTION_NOP, + [FUNCTION_INCOMING] = &HandleIncoming, + [FUNCTION_RECEIVE] = &HandleReceive, + [FUNCTION_POWER_SAVE] = &HandlePowerSave, + [FUNCTION_BAND_SCOPE] = &FUNCTION_NOP, }; static_assert(ARRAY_SIZE(HandleFunction_fn_table) == FUNCTION_N_ELEM); -static void HandleFunction(void) -{ +static void HandleFunction(void) { HandleFunction_fn_table[gCurrentFunction](); } -void APP_StartListening(FUNCTION_Type_t function) -{ +void APP_StartListening(FUNCTION_Type_t function) { const unsigned int vfo = gEeprom.RX_VFO; #ifdef ENABLE_FEAT_F4HWN_RX_TX_TIMER gRxTimerCountdown_500ms = 7200; #endif -#ifdef ENABLE_DTMF_CALLING - if (gSetting_KILLED) - return; -#endif - #ifdef ENABLE_FMRADIO if (gFmRadioMode) BK1080_Init0(); @@ -537,31 +504,30 @@ void APP_StartListening(FUNCTION_Type_t function) #endif if (gScanStateDir == SCAN_OFF && - gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) - { // not scanning, dual watch is enabled + gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) { // not scanning, dual watch is enabled gDualWatchCountdown_10ms = dual_watch_count_after_2_10ms; - gScheduleDualWatch = false; + gScheduleDualWatch = false; // when crossband is active only the main VFO should be used for TX - if(gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) + if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) gRxVfoIsActive = true; // let the user see DW is not active gDualWatchActive = false; - gUpdateStatus = true; + gUpdateStatus = true; } BK4819_WriteRegister(BK4819_REG_48, - (11u << 12) | // ??? .. 0 to 15, doesn't seem to make any difference - ( 0u << 10) | // AF Rx Gain-1 - (gEeprom.VOLUME_GAIN << 4) | // AF Rx Gain-2 - (gEeprom.DAC_GAIN << 0)); // AF DAC Gain (after Gain-1 and Gain-2) + (11u << 12) | // ??? .. 0 to 15, doesn't seem to make any difference + (0u << 10) | // AF Rx Gain-1 + (gEeprom.VOLUME_GAIN << 4) | // AF Rx Gain-2 + (gEeprom.DAC_GAIN << 0)); // AF DAC Gain (after Gain-1 and Gain-2) #ifdef ENABLE_VOICE if (gVoiceWriteIndex == 0) // AM/FM RX mode will be set when the voice has finished #endif - RADIO_SetModulation(gRxVfo->Modulation); // no need, set it now + RADIO_SetModulation(gRxVfo->Modulation); // no need, set it now FUNCTION_Select(function); @@ -573,23 +539,22 @@ void APP_StartListening(FUNCTION_Type_t function) { // squelch is disabled if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu GUI_SelectNextDisplay(DISPLAY_MAIN); - } - else + } else gUpdateDisplay = true; gUpdateStatus = true; } -uint32_t APP_SetFreqByStepAndLimits(VFO_Info_t *pInfo, int8_t direction, uint32_t lower, uint32_t upper) -{ - uint32_t Frequency = FREQUENCY_RoundToStep(pInfo->freq_config_RX.Frequency + (direction * pInfo->StepFrequency), pInfo->StepFrequency); +uint32_t APP_SetFreqByStepAndLimits(VFO_Info_t *pInfo, int8_t direction, uint32_t lower, uint32_t upper) { + uint32_t Frequency = FREQUENCY_RoundToStep(pInfo->freq_config_RX.Frequency + (direction * pInfo->StepFrequency), + pInfo->StepFrequency); #ifdef ENABLE_FEAT_F4HWN if (Frequency > upper) #else - if (Frequency >= upper) + if (Frequency >= upper) #endif - Frequency = lower; + Frequency = lower; else if (Frequency < lower) Frequency = FREQUENCY_RoundToStep(upper - pInfo->StepFrequency, pInfo->StepFrequency); @@ -597,58 +562,55 @@ uint32_t APP_SetFreqByStepAndLimits(VFO_Info_t *pInfo, int8_t direction, uint32_ return Frequency; } -uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t direction) -{ - return APP_SetFreqByStepAndLimits(pInfo, direction, frequencyBandTable[pInfo->Band].lower, frequencyBandTable[pInfo->Band].upper); +uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t direction) { + return APP_SetFreqByStepAndLimits(pInfo, direction, frequencyBandTable[pInfo->Band].lower, + frequencyBandTable[pInfo->Band].upper); } #ifdef ENABLE_NOAA - static void NOAA_IncreaseChannel(void) - { - if (++gNoaaChannel > 9) - gNoaaChannel = 0; - } +static void NOAA_IncreaseChannel(void) +{ + if (++gNoaaChannel > 9) + gNoaaChannel = 0; +} #endif -static void DualwatchAlternate(void) -{ - #ifdef ENABLE_NOAA - if (gIsNoaaMode) - { - if (!IS_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) || !IS_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) - gEeprom.RX_VFO = (gEeprom.RX_VFO + 1) & 1; - else - gEeprom.RX_VFO = 0; - - gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_VFO]; - - if (IS_NOAA_CHANNEL(gEeprom.VfoInfo[0].CHANNEL_SAVE)) - NOAA_IncreaseChannel(); - } +static void DualwatchAlternate(void) { +#ifdef ENABLE_NOAA + if (gIsNoaaMode) + { + if (!IS_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) || !IS_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) + gEeprom.RX_VFO = (gEeprom.RX_VFO + 1) & 1; else - #endif + gEeprom.RX_VFO = 0; + + gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_VFO]; + + if (IS_NOAA_CHANNEL(gEeprom.VfoInfo[0].CHANNEL_SAVE)) + NOAA_IncreaseChannel(); + } + else +#endif { // toggle between VFO's gEeprom.RX_VFO = !gEeprom.RX_VFO; - gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_VFO]; + gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_VFO]; - if (!gDualWatchActive) - { // let the user see DW is active + if (!gDualWatchActive) { // let the user see DW is active gDualWatchActive = true; - gUpdateStatus = true; + gUpdateStatus = true; } } RADIO_SetupRegisters(false); - #ifdef ENABLE_NOAA - gDualWatchCountdown_10ms = gIsNoaaMode ? dual_watch_count_noaa_10ms : dual_watch_count_toggle_10ms; - #else - gDualWatchCountdown_10ms = dual_watch_count_toggle_10ms; - #endif +#ifdef ENABLE_NOAA + gDualWatchCountdown_10ms = gIsNoaaMode ? dual_watch_count_noaa_10ms : dual_watch_count_toggle_10ms; +#else + gDualWatchCountdown_10ms = dual_watch_count_toggle_10ms; +#endif } -static void CheckRadioInterrupts(void) -{ +static void CheckRadioInterrupts(void) { if (SCANNER_IsScanning()) return; @@ -659,22 +621,22 @@ static void CheckRadioInterrupts(void) union { struct { - uint16_t __UNUSED : 1; - uint16_t fskRxSync : 1; - uint16_t sqlLost : 1; - uint16_t sqlFound : 1; - uint16_t voxLost : 1; - uint16_t voxFound : 1; - uint16_t ctcssLost : 1; - uint16_t ctcssFound : 1; - uint16_t cdcssLost : 1; - uint16_t cdcssFound : 1; - uint16_t cssTailFound : 1; - uint16_t dtmf5ToneFound : 1; - uint16_t fskFifoAlmostFull : 1; - uint16_t fskRxFinied : 1; - uint16_t fskFifoAlmostEmpty : 1; - uint16_t fskTxFinied : 1; + uint16_t __UNUSED: 1; + uint16_t fskRxSync: 1; + uint16_t sqlLost: 1; + uint16_t sqlFound: 1; + uint16_t voxLost: 1; + uint16_t voxFound: 1; + uint16_t ctcssLost: 1; + uint16_t ctcssFound: 1; + uint16_t cdcssLost: 1; + uint16_t cdcssFound: 1; + uint16_t cssTailFound: 1; + uint16_t dtmf5ToneFound: 1; + uint16_t fskFifoAlmostFull: 1; + uint16_t fskRxFinied: 1; + uint16_t fskFifoAlmostEmpty: 1; + uint16_t fskTxFinied: 1; }; uint16_t __raw; } interrupts; @@ -689,7 +651,7 @@ static void CheckRadioInterrupts(void) // if (ctcss_shift > 0) // g_CTCSS_Lost = true; - if (interrupts.dtmf5ToneFound) { + if (interrupts.dtmf5ToneFound) { const char c = DTMF_GetCharacter(BK4819_GetDTMF_5TONE_Code()); // save the RX'ed DTMF character if (c != 0xff) { if (gCurrentFunction != FUNCTION_TRANSMIT) { @@ -699,23 +661,23 @@ static void CheckRadioInterrupts(void) memmove(&gDTMF_RX_live[0], &gDTMF_RX_live[1], sizeof(gDTMF_RX_live) - 1); len--; } - gDTMF_RX_live[len++] = c; - gDTMF_RX_live[len] = 0; + gDTMF_RX_live[len++] = c; + gDTMF_RX_live[len] = 0; gDTMF_RX_live_timeout = DTMF_RX_live_timeout_500ms; // time till we delete it - gUpdateDisplay = true; + gUpdateDisplay = true; } #ifdef ENABLE_DTMF_CALLING - if (gRxVfo->DTMF_DECODING_ENABLE || gSetting_KILLED) { + if (gRxVfo->DTMF_DECODING_ENABLE) { if (gDTMF_RX_index >= sizeof(gDTMF_RX) - 1) { // make room memmove(&gDTMF_RX[0], &gDTMF_RX[1], sizeof(gDTMF_RX) - 1); gDTMF_RX_index--; } gDTMF_RX[gDTMF_RX_index++] = c; - gDTMF_RX[gDTMF_RX_index] = 0; - gDTMF_RX_timeout = DTMF_RX_timeout_500ms; // time till we delete it - gDTMF_RX_pending = true; - + gDTMF_RX[gDTMF_RX_index] = 0; + gDTMF_RX_timeout = DTMF_RX_timeout_500ms; // time till we delete it + gDTMF_RX_pending = true; + SYSTEM_DelayMs(3);//fix DTMF not reply@Yurisu DTMF_HandleRequest(); } @@ -743,28 +705,29 @@ static void CheckRadioInterrupts(void) #ifdef ENABLE_VOX if (interrupts.voxLost) { - g_VOX_Lost = true; + g_VOX_Lost = true; gVoxPauseCountdown = 10; if (gEeprom.VOX_SWITCH) { if (gCurrentFunction == FUNCTION_POWER_SAVE && !gRxIdleMode) { - gPowerSave_10ms = power_save2_10ms; + gPowerSave_10ms = power_save2_10ms; gPowerSaveCountdownExpired = 0; } - if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && (gScheduleDualWatch || gDualWatchCountdown_10ms < dual_watch_count_after_vox_10ms)) { + if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && + (gScheduleDualWatch || gDualWatchCountdown_10ms < dual_watch_count_after_vox_10ms)) { gDualWatchCountdown_10ms = dual_watch_count_after_vox_10ms; gScheduleDualWatch = false; // let the user see DW is not active gDualWatchActive = false; - gUpdateStatus = true; + gUpdateStatus = true; } } } if (interrupts.voxFound) { - g_VOX_Lost = false; + g_VOX_Lost = false; gVoxPauseCountdown = 0; } #endif @@ -772,59 +735,53 @@ static void CheckRadioInterrupts(void) if (interrupts.sqlLost) { g_SquelchLost = true; BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2_GREEN, true); - #ifdef ENABLE_FEAT_F4HWN_RX_TX_TIMER - gRxTimerCountdown_500ms = 7200; - #endif +#ifdef ENABLE_FEAT_F4HWN_RX_TX_TIMER + gRxTimerCountdown_500ms = 7200; +#endif } if (interrupts.sqlFound) { g_SquelchLost = false; BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2_GREEN, false); } - + if (interrupts.fskFifoAlmostFull) { #ifdef ENABLE_AIRCOPY - if (interrupts.fskFifoAlmostFull && - gScreenToDisplay == DISPLAY_AIRCOPY && - gAircopyState == AIRCOPY_TRANSFER && - gAirCopyIsSendMode == 0) - { - for (unsigned int i = 0; i < 4; i++) { - g_FSK_Buffer[gFSKWriteIndex++] = BK4819_ReadRegister(BK4819_REG_5F); - } + if (gScreenToDisplay == DISPLAY_AIRCOPY && + gAircopyState == AIRCOPY_TRANSFER && + gAirCopyIsSendMode == 0) + { + for (unsigned int i = 0; i < 4; i++) { + g_FSK_Buffer[gFSKWriteIndex++] = BK4819_ReadRegister(BK4819_REG_5F); + } - AIRCOPY_StorePacket(); - } + AIRCOPY_StorePacket(); + } #endif + } } } -void APP_EndTransmission(void) -{ +void APP_EndTransmission(void) { // back to RX mode RADIO_SendEndOfTransmission(); gFlagEndTransmission = true; if (gMonitor) { - //turn the monitor back on + //turn the monitor back on gFlagReconfigureVfos = true; } } #ifdef ENABLE_VOX -static void HandleVox(void) -{ -#ifdef ENABLE_DTMF_CALLING - if (gSetting_KILLED) - return; -#endif + +static void HandleVox(void) { if (gVoxResumeCountdown == 0) { if (gVoxPauseCountdown) return; - } - else { - g_VOX_Lost = false; + } else { + g_VOX_Lost = false; gVoxPauseCountdown = 0; } @@ -848,21 +805,19 @@ static void HandleVox(void) if (gCurrentFunction == FUNCTION_TRANSMIT && !gPttIsPressed && !gVOX_NoiseDetected) { if (gFlagEndTransmission) { //if (gCurrentFunction != FUNCTION_FOREGROUND) - FUNCTION_Select(FUNCTION_FOREGROUND); - } - else { + FUNCTION_Select(FUNCTION_FOREGROUND); + } else { APP_EndTransmission(); if (gEeprom.REPEATER_TAIL_TONE_ELIMINATION == 0) { //if (gCurrentFunction != FUNCTION_FOREGROUND) - FUNCTION_Select(FUNCTION_FOREGROUND); - } - else + FUNCTION_Select(FUNCTION_FOREGROUND); + } else gRTTECountdown_10ms = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10; } - gUpdateStatus = true; - gUpdateDisplay = true; + gUpdateStatus = true; + gUpdateDisplay = true; gFlagEndTransmission = false; } return; @@ -883,10 +838,10 @@ static void HandleVox(void) } } } + #endif -void APP_Update(void) -{ +void APP_Update(void) { #ifdef ENABLE_VOICE if (gFlagPlayQueuedVoice) { AUDIO_PlayQueuedVoice(); @@ -895,25 +850,17 @@ void APP_Update(void) #endif #ifdef ENABLE_FEAT_F4HWN - if (gCurrentFunction == FUNCTION_TRANSMIT && (gTxTimeoutReachedAlert || SerialConfigInProgress())) - { - if(gSetting_set_tot >= 2) - { + if (gCurrentFunction == FUNCTION_TRANSMIT && (gTxTimeoutReachedAlert || SerialConfigInProgress())) { + if (gSetting_set_tot >= 2) { if (gEeprom.BACKLIGHT_TIME == 0) { - if (gBlinkCounter == 0 || gBlinkCounter == 250) - { + if (gBlinkCounter == 0 || gBlinkCounter == 250) { GPIO_FlipBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT); } - } - else - { - if (gBlinkCounter == 0) - { + } else { + if (gBlinkCounter == 0) { //BACKLIGHT_TurnOn(); BACKLIGHT_SetBrightness(gEeprom.BACKLIGHT_MAX); - } - else if(gBlinkCounter == 15000) - { + } else if (gBlinkCounter == 15000) { //BACKLIGHT_TurnOff(); BACKLIGHT_SetBrightness(gEeprom.BACKLIGHT_MIN); } @@ -922,16 +869,15 @@ void APP_Update(void) gBlinkCounter++; - if( - (gSetting_set_tot == 3 && gEeprom.BACKLIGHT_TIME != 0 && gBlinkCounter > 74000) || - (gSetting_set_tot == 3 && gEeprom.BACKLIGHT_TIME == 0 && gBlinkCounter > 79000) || - (gSetting_set_tot != 3 && gBlinkCounter > 76000) - ) // try to calibrate 10 times + if ( + (gSetting_set_tot == 3 && gEeprom.BACKLIGHT_TIME != 0 && gBlinkCounter > 74000) || + (gSetting_set_tot == 3 && gEeprom.BACKLIGHT_TIME == 0 && gBlinkCounter > 79000) || + (gSetting_set_tot != 3 && gBlinkCounter > 76000) + ) // try to calibrate 10 times { gBlinkCounter = 0; - if(gSetting_set_tot == 1 || gSetting_set_tot == 3) - { + if (gSetting_set_tot == 1 || gSetting_set_tot == 3) { BK4819_DisableScramble(); BK4819_PlaySingleTone(gTxTimeoutToneAlert, 30, 1, true); gTxTimeoutToneAlert += 100; @@ -940,13 +886,12 @@ void APP_Update(void) } #endif - if (gCurrentFunction == FUNCTION_TRANSMIT && (gTxTimeoutReached || SerialConfigInProgress())) - { // transmitter timed out or must de-key + if (gCurrentFunction == FUNCTION_TRANSMIT && + (gTxTimeoutReached || SerialConfigInProgress())) { // transmitter timed out or must de-key gTxTimeoutReached = false; #ifdef ENABLE_FEAT_F4HWN - if(gBacklightCountdown_500ms > 0 || gEeprom.BACKLIGHT_TIME == 61) - { + if (gBacklightCountdown_500ms > 0 || gEeprom.BACKLIGHT_TIME == 61) { //BACKLIGHT_TurnOn(); BACKLIGHT_SetBrightness(gEeprom.BACKLIGHT_MAX); } @@ -956,12 +901,9 @@ void APP_Update(void) if (gSetting_set_ptt_session) // Improve OnePush if TOT { - if(gPttOnePushCounter == 1) - { + if (gPttOnePushCounter == 1) { gPttOnePushCounter = 3; - } - else if(gPttOnePushCounter == 2) - { + } else if (gPttOnePushCounter == 2) { ProcessKey(KEY_PTT, false, false); gPttIsPressed = false; gPttOnePushCounter = 0; @@ -969,9 +911,9 @@ void APP_Update(void) //if (gKeyReading1 != KEY_INVALID) // gPttWasReleased = true; } - #if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV) +#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV) ST7565_ContrastAndInv(); - #endif +#endif } #endif @@ -991,9 +933,9 @@ void APP_Update(void) HandleFunction(); #ifdef ENABLE_FMRADIO -// if (gFmRadioCountdown_500ms > 0) - if (gFmRadioMode && gFmRadioCountdown_500ms > 0) // 1of11 - return; + // if (gFmRadioCountdown_500ms > 0) + if (gFmRadioMode && gFmRadioCountdown_500ms > 0) // 1of11 + return; #endif #ifdef ENABLE_VOICE @@ -1007,17 +949,17 @@ void APP_Update(void) #ifdef ENABLE_NOAA #ifdef ENABLE_VOICE - if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode && gScheduleNOAA && gVoiceWriteIndex == 0) + if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode && gScheduleNOAA && gVoiceWriteIndex == 0) #else - if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode && gScheduleNOAA) + if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF && gIsNoaaMode && gScheduleNOAA) #endif - { - NOAA_IncreaseChannel(); - RADIO_SetupRegisters(false); + { + NOAA_IncreaseChannel(); + RADIO_SetupRegisters(false); - gNOAA_Countdown_10ms = 7; // 70ms - gScheduleNOAA = false; - } + gNOAA_Countdown_10ms = 7; // 70ms + gScheduleNOAA = false; + } #endif // toggle between the VFO's if dual watch is enabled @@ -1027,25 +969,25 @@ void APP_Update(void) && gScanStateDir == SCAN_OFF && !gPttIsPressed && gCurrentFunction != FUNCTION_POWER_SAVE -#ifdef ENABLE_VOICE + #ifdef ENABLE_VOICE && gVoiceWriteIndex == 0 -#endif -#ifdef ENABLE_FMRADIO + #endif + #ifdef ENABLE_FMRADIO && !gFmRadioMode -#endif -#ifdef ENABLE_DTMF_CALLING + #endif + #ifdef ENABLE_DTMF_CALLING && gDTMF_CallState == DTMF_CALL_STATE_NONE #endif - ) { + ) { DualwatchAlternate(); // toggle between the two VFO's if (gRxVfoIsActive && gScreenToDisplay == DISPLAY_MAIN) { GUI_SelectNextDisplay(DISPLAY_MAIN); } - gRxVfoIsActive = false; - gScanPauseMode = false; - gRxReceptionMode = RX_MODE_NONE; + gRxVfoIsActive = false; + gScanPauseMode = false; + gRxReceptionMode = RX_MODE_NONE; gScheduleDualWatch = false; } @@ -1069,16 +1011,16 @@ void APP_Update(void) || gScanStateDir != SCAN_OFF || gCssBackgroundScan || gScreenToDisplay != DISPLAY_MAIN -#ifdef ENABLE_FMRADIO + #ifdef ENABLE_FMRADIO || gFmRadioMode -#endif -#ifdef ENABLE_DTMF_CALLING + #endif + #ifdef ENABLE_DTMF_CALLING || gDTMF_CallState != DTMF_CALL_STATE_NONE #endif #ifdef ENABLE_NOAA || (gIsNoaaMode && (IS_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) || IS_NOAA_CHANNEL(gEeprom.ScreenChannel[1]))) #endif - ) { + ) { gBatterySaveCountdown_10ms = battery_save_count_10ms; } else { FUNCTION_Select(FUNCTION_POWER_SAVE); @@ -1091,11 +1033,10 @@ void APP_Update(void) #ifdef ENABLE_VOICE && gVoiceWriteIndex == 0 #endif - ) { + ) { static bool goToSleep; // wake up, enable RX then go back to sleep - if (gRxIdleMode) - { + if (gRxIdleMode) { BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable(); #ifdef ENABLE_VOX @@ -1105,8 +1046,7 @@ void APP_Update(void) if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && gScanStateDir == SCAN_OFF && - !gCssBackgroundScan) - { // dual watch mode, toggle between the two VFO's + !gCssBackgroundScan) { // dual watch mode, toggle between the two VFO's DualwatchAlternate(); goToSleep = false; } @@ -1114,25 +1054,21 @@ void APP_Update(void) FUNCTION_Init(); gPowerSave_10ms = power_save1_10ms; // come back here in a bit - gRxIdleMode = false; // RX is awake - } - else if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF || gScanStateDir != SCAN_OFF || gCssBackgroundScan || goToSleep) - { // dual watch mode off or scanning or rssi update request + gRxIdleMode = false; // RX is awake + } else if (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF || gScanStateDir != SCAN_OFF || gCssBackgroundScan || + goToSleep) { // dual watch mode off or scanning or rssi update request // go back to sleep #ifdef ENABLE_FEAT_F4HWN_SLEEP - if(gWakeUp) - { + if (gWakeUp) { gPowerSave_10ms = gEeprom.BATTERY_SAVE * 200; // deep sleep now indexed on BatSav - } - else - { + } else { gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10; } #else gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10; #endif - gRxIdleMode = true; + gRxIdleMode = true; goToSleep = false; BK4819_DisableVox(); @@ -1141,11 +1077,10 @@ void APP_Update(void) // Authentic device checked removed - } - else { + } else { // toggle between the two VFO's DualwatchAlternate(); - gPowerSave_10ms = power_save1_10ms; + gPowerSave_10ms = power_save1_10ms; goToSleep = true; } @@ -1154,13 +1089,7 @@ void APP_Update(void) } // called every 10ms -static void CheckKeys(void) -{ -#ifdef ENABLE_DTMF_CALLING - if(gSetting_KILLED){ - return; - } -#endif +static void CheckKeys(void) { #ifdef ENABLE_AIRCOPY if (gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState != AIRCOPY_READY){ @@ -1170,36 +1099,32 @@ static void CheckKeys(void) // -------------------- PTT ------------------------ #ifdef ENABLE_FEAT_F4HWN - if (gSetting_set_ptt_session) - { - if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && !SerialConfigInProgress() && gPttOnePushCounter == 0) - { // PTT pressed + if (gSetting_set_ptt_session) { + if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && !SerialConfigInProgress() && + gPttOnePushCounter == 0) { // PTT pressed if (++gPttDebounceCounter >= 3) // 30ms { // start transmitting - boot_counter_10ms = 0; + boot_counter_10ms = 0; gPttDebounceCounter = 0; - gPttIsPressed = true; + gPttIsPressed = true; gPttOnePushCounter = 1; ProcessKey(KEY_PTT, true, false); } - } - else if ((GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || SerialConfigInProgress()) && gPttOnePushCounter == 1) - { + } else if ((GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || SerialConfigInProgress()) && + gPttOnePushCounter == 1) { // PTT released or serial comms config in progress if (++gPttDebounceCounter >= 3 || SerialConfigInProgress()) // 30ms { // stop transmitting gPttOnePushCounter = 2; } - } - else if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && !SerialConfigInProgress() && gPttOnePushCounter == 2) - { // PTT pressed again + } else if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && !SerialConfigInProgress() && + gPttOnePushCounter == 2) { // PTT pressed again if (++gPttDebounceCounter >= 3 || SerialConfigInProgress()) // 30ms { // stop transmitting gPttOnePushCounter = 3; } - } - else if ((GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || SerialConfigInProgress()) && gPttOnePushCounter == 3) - { // PTT released or serial comms config in progress + } else if ((GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || SerialConfigInProgress()) && + gPttOnePushCounter == 3) { // PTT released or serial comms config in progress if (++gPttDebounceCounter >= 3 || SerialConfigInProgress()) // 30ms { // stop transmitting ProcessKey(KEY_PTT, false, false); @@ -1207,48 +1132,40 @@ static void CheckKeys(void) if (gKeyReading1 != KEY_INVALID) gPttWasReleased = true; gPttOnePushCounter = 0; - #if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV) +#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV) ST7565_ContrastAndInv(); - #endif +#endif } - } - else + } else gPttDebounceCounter = 0; //gDebug = gPttOnePushCounter; - } - else - { - if (gPttIsPressed) - { - if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || SerialConfigInProgress()) - { // PTT released or serial comms config in progress + } else { + if (gPttIsPressed) { + if (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || + SerialConfigInProgress()) { // PTT released or serial comms config in progress if (++gPttDebounceCounter >= 3 || SerialConfigInProgress()) // 30ms { // stop transmitting ProcessKey(KEY_PTT, false, false); gPttIsPressed = false; if (gKeyReading1 != KEY_INVALID) gPttWasReleased = true; - #if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV) +#if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV) ST7565_ContrastAndInv(); - #endif +#endif } - } - else + } else gPttDebounceCounter = 0; - } - else if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && !SerialConfigInProgress()) - { // PTT pressed + } else if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && !SerialConfigInProgress()) { // PTT pressed if (++gPttDebounceCounter >= 3) // 30ms { // start transmitting - boot_counter_10ms = 0; + boot_counter_10ms = 0; gPttDebounceCounter = 0; - gPttIsPressed = true; + gPttIsPressed = true; ProcessKey(KEY_PTT, true, false); } - } - else - gPttDebounceCounter = 0; + } else + gPttDebounceCounter = 0; } #else if (gPttIsPressed) @@ -1294,7 +1211,7 @@ static void CheckKeys(void) if (gKeyReading0 != KEY_INVALID && Key != KEY_INVALID) ProcessKey(gKeyReading1, false, gKeyBeingHeld); // key pressed without releasing previous key - gKeyReading0 = Key; + gKeyReading0 = Key; gDebounceCounter = 0; return; } @@ -1310,8 +1227,7 @@ static void CheckKeys(void) ProcessKey(gKeyReading1, false, gKeyBeingHeld); // process last button released event gKeyReading1 = KEY_INVALID; } - } - else // process new key pressed + } else // process new key pressed { gKeyReading1 = Key; ProcessKey(Key, true, false); @@ -1321,18 +1237,17 @@ static void CheckKeys(void) return; } - if (gDebounceCounter < key_repeat_delay_10ms || Key == KEY_INVALID) // the button is not held long enough for repeat yet, or not really pressed + if (gDebounceCounter < key_repeat_delay_10ms || + Key == KEY_INVALID) // the button is not held long enough for repeat yet, or not really pressed return; if (gDebounceCounter == key_repeat_delay_10ms) //initial key repeat with longer delay { - if (Key != KEY_PTT) - { + if (Key != KEY_PTT) { gKeyBeingHeld = true; ProcessKey(Key, true, true); // key held event } - } - else //subsequent fast key repeats + } else //subsequent fast key repeats { if (Key == KEY_UP || Key == KEY_DOWN) // fast key repeats for up/down buttons { @@ -1344,12 +1259,11 @@ static void CheckKeys(void) if (gDebounceCounter < 0xFFFF) return; - gDebounceCounter = key_repeat_delay_10ms+1; + gDebounceCounter = key_repeat_delay_10ms + 1; } } -void APP_TimeSlice10ms(void) -{ +void APP_TimeSlice10ms(void) { gNextTimeslice = false; gFlashLightBlinkCounter++; @@ -1373,8 +1287,7 @@ void APP_TimeSlice10ms(void) if (gCurrentFunction != FUNCTION_POWER_SAVE || !gRxIdleMode) CheckRadioInterrupts(); - if (gCurrentFunction == FUNCTION_TRANSMIT) - { // transmitting + if (gCurrentFunction == FUNCTION_TRANSMIT) { // transmitting #ifdef ENABLE_AUDIO_BAR if (gSetting_mic_bar && (gFlashLightBlinkCounter % (150 / 10)) == 0) // once every 150ms UI_DisplayAudioBar(); @@ -1397,9 +1310,9 @@ void APP_TimeSlice10ms(void) #endif #if !defined(ENABLE_FEAT_F4HWN) || defined(ENABLE_FEAT_F4HWN_RESCUE_OPS) - #ifdef ENABLE_FLASHLIGHT - FlashlightTimeSlice(); - #endif +#ifdef ENABLE_FLASHLIGHT + FlashlightTimeSlice(); +#endif #endif #ifdef ENABLE_VOX @@ -1420,7 +1333,7 @@ void APP_TimeSlice10ms(void) Tone = 500 + (gAlarmToneCounter * 25); if (Tone > 1500) { - Tone = 500; + Tone = 500; gAlarmToneCounter = 0; } @@ -1432,7 +1345,7 @@ void APP_TimeSlice10ms(void) if (gAlarmState == ALARM_STATE_TXALARM) { gAlarmState = ALARM_STATE_SITE_ALARM; - if(gEeprom.TAIL_TONE_ELIMINATION) + if (gEeprom.TAIL_TONE_ELIMINATION) RADIO_SendCssTail(); BK4819_SetupPowerAmplifier(0, 0); BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_PA_ENABLE, false); @@ -1440,8 +1353,7 @@ void APP_TimeSlice10ms(void) BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, false); GUI_DisplayScreen(); - } - else { + } else { gAlarmState = ALARM_STATE_TXALARM; GUI_DisplayScreen(); @@ -1452,7 +1364,7 @@ void APP_TimeSlice10ms(void) SYSTEM_DelayMs(2); AUDIO_AudioPathOn(); - gEnableSpeaker = true; + gEnableSpeaker = true; gAlarmToneCounter = 0; } } @@ -1462,9 +1374,9 @@ void APP_TimeSlice10ms(void) if (gRTTECountdown_10ms > 0) { if (--gRTTECountdown_10ms == 0) { //if (gCurrentFunction != FUNCTION_FOREGROUND) - FUNCTION_Select(FUNCTION_FOREGROUND); + FUNCTION_Select(FUNCTION_FOREGROUND); - gUpdateStatus = true; + gUpdateStatus = true; gUpdateDisplay = true; } } @@ -1493,30 +1405,26 @@ void APP_TimeSlice10ms(void) CheckKeys(); } -void cancelUserInputModes(void) -{ - if (gDTMF_InputMode || gDTMF_InputBox_Index > 0) - { +void cancelUserInputModes(void) { + if (gDTMF_InputMode || gDTMF_InputBox_Index > 0) { DTMF_clear_input_box(); - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gRequestDisplayScreen = DISPLAY_MAIN; - gUpdateDisplay = true; + gUpdateDisplay = true; } - if (gWasFKeyPressed || gKeyInputCountdown > 0 || gInputBoxIndex > 0) - { - gWasFKeyPressed = false; - gInputBoxIndex = 0; - gKeyInputCountdown = 0; - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; - gUpdateStatus = true; - gUpdateDisplay = true; + if (gWasFKeyPressed || gKeyInputCountdown > 0 || gInputBoxIndex > 0) { + gWasFKeyPressed = false; + gInputBoxIndex = 0; + gKeyInputCountdown = 0; + gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + gUpdateStatus = true; + gUpdateDisplay = true; } } // this is called once every 500ms -void APP_TimeSlice500ms(void) -{ +void APP_TimeSlice500ms(void) { gNextTimeslice_500ms = false; bool exit_menu = false; @@ -1526,13 +1434,10 @@ void APP_TimeSlice500ms(void) if (--gKeypadLocked == 0) gUpdateDisplay = true; - if (gKeyInputCountdown > 0) - { - if (--gKeyInputCountdown == 0) - { + if (gKeyInputCountdown > 0) { + if (--gKeyInputCountdown == 0) { - if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE) && (gInputBoxIndex == 1 || gInputBoxIndex == 2)) - { + if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE) && (gInputBoxIndex == 1 || gInputBoxIndex == 2)) { channelMoveSwitch(); if (gBeepToPlay == BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL) { @@ -1546,19 +1451,16 @@ void APP_TimeSlice500ms(void) } } - if (gDTMF_RX_live_timeout > 0) - { - #ifdef ENABLE_RSSI_BAR - if (center_line == CENTER_LINE_DTMF_DEC || - center_line == CENTER_LINE_NONE) // wait till the center line is free for us to use before timing out - #endif + if (gDTMF_RX_live_timeout > 0) { +#ifdef ENABLE_RSSI_BAR + if (center_line == CENTER_LINE_DTMF_DEC || + center_line == CENTER_LINE_NONE) // wait till the center line is free for us to use before timing out +#endif { - if (--gDTMF_RX_live_timeout == 0) - { - if (gDTMF_RX_live[0] != 0) - { + if (--gDTMF_RX_live_timeout == 0) { + if (gDTMF_RX_live[0] != 0) { memset(gDTMF_RX_live, 0, sizeof(gDTMF_RX_live)); - gUpdateDisplay = true; + gUpdateDisplay = true; } } } @@ -1587,10 +1489,11 @@ void APP_TimeSlice500ms(void) if (gBacklightCountdown_500ms > 0 && !gAskToSave && !gCssBackgroundScan // don't turn off backlight if user is in backlight menu option - && !(gScreenToDisplay == DISPLAY_MENU && (UI_MENU_GetCurrentMenuId() == MENU_ABR || UI_MENU_GetCurrentMenuId() == MENU_ABR_MAX)) + && !(gScreenToDisplay == DISPLAY_MENU && + (UI_MENU_GetCurrentMenuId() == MENU_ABR || UI_MENU_GetCurrentMenuId() == MENU_ABR_MAX)) && --gBacklightCountdown_500ms == 0 && gEeprom.BACKLIGHT_TIME < 61 - ) { + ) { BACKLIGHT_TurnOff(); } @@ -1603,11 +1506,11 @@ void APP_TimeSlice500ms(void) gWakeUp = false; } - #ifdef ENABLE_AIRCOPY +#ifdef ENABLE_AIRCOPY if(gCurrentFunction != FUNCTION_TRANSMIT && !FUNCTION_IsRx() && gScreenToDisplay != DISPLAY_AIRCOPY) - #else - if(gCurrentFunction != FUNCTION_TRANSMIT && !FUNCTION_IsRx()) - #endif +#else + if (gCurrentFunction != FUNCTION_TRANSMIT && !FUNCTION_IsRx()) +#endif { if (gSleepModeCountdown_500ms > 0 && --gSleepModeCountdown_500ms == 0) { gBacklightCountdown_500ms = 0; @@ -1615,21 +1518,14 @@ void APP_TimeSlice500ms(void) gWakeUp = true; PWM_PLUS0_CH0_COMP = 0; ST7565_ShutDown(); - } - else if(gSleepModeCountdown_500ms != 0 && gSleepModeCountdown_500ms < 21 && gSetting_set_off != 0) - { - if(gSleepModeCountdown_500ms % 4 == 0) - { + } else if (gSleepModeCountdown_500ms != 0 && gSleepModeCountdown_500ms < 21 && gSetting_set_off != 0) { + if (gSleepModeCountdown_500ms % 4 == 0) { PWM_PLUS0_CH0_COMP = value[gEeprom.BACKLIGHT_MAX] * 4; // Max brightness - } - else - { + } else { PWM_PLUS0_CH0_COMP = 0; } } - } - else - { + } else { gSleepModeCountdown_500ms = gSetting_set_off * 120; } @@ -1640,17 +1536,15 @@ void APP_TimeSlice500ms(void) } #endif - if (gReducedService) - { + if (gReducedService) { BOARD_ADC_GetBatteryInfo(&gBatteryCurrentVoltage, &gBatteryCurrent); - if (gBatteryCurrent > 500 || gBatteryCalibration[3] < gBatteryCurrentVoltage) - { - #ifdef ENABLE_OVERLAY - overlay_FLASH_RebootToBootloader(); - #else - NVIC_SystemReset(); - #endif + if (gBatteryCurrent > 500 || gBatteryCalibration[3] < gBatteryCurrentVoltage) { +#ifdef ENABLE_OVERLAY + overlay_FLASH_RebootToBootloader(); +#else + NVIC_SystemReset(); +#endif } return; @@ -1660,11 +1554,9 @@ void APP_TimeSlice500ms(void) // Skipped authentic device check - if (gCurrentFunction != FUNCTION_TRANSMIT) - { + if (gCurrentFunction != FUNCTION_TRANSMIT) { - if ((gBatteryCheckCounter & 1) == 0) - { + if ((gBatteryCheckCounter & 1) == 0) { BOARD_ADC_GetBatteryInfo(&gBatteryVoltages[gBatteryVoltageIndex++], &gBatteryCurrent); if (gBatteryVoltageIndex > 3) gBatteryVoltageIndex = 0; @@ -1673,14 +1565,13 @@ void APP_TimeSlice500ms(void) } // regular display updates (once every 2 sec) - if need be - if ((gBatteryCheckCounter & 3) == 0) - { + if ((gBatteryCheckCounter & 3) == 0) { if (gChargingWithTypeC || gSetting_battery_text > 0) gUpdateStatus = true; - #ifdef ENABLE_SHOW_CHARGE_LEVEL - if (gChargingWithTypeC) - gUpdateDisplay = true; - #endif +#ifdef ENABLE_SHOW_CHARGE_LEVEL + if (gChargingWithTypeC) + gUpdateDisplay = true; +#endif } if (!gCssBackgroundScan && gScanStateDir == SCAN_OFF && !SCANNER_IsScanning() @@ -1690,10 +1581,9 @@ void APP_TimeSlice500ms(void) #ifdef ENABLE_AIRCOPY && gScreenToDisplay != DISPLAY_AIRCOPY #endif - ) { + ) { if (gEeprom.AUTO_KEYPAD_LOCK && gKeyLockCountdown > 0 && !gDTMF_InputMode - && gScreenToDisplay != DISPLAY_MENU && --gKeyLockCountdown == 0) - { + && gScreenToDisplay != DISPLAY_MENU && --gKeyLockCountdown == 0) { gEeprom.KEY_LOCK = true; // lock the keyboard gUpdateStatus = true; // lock symbol needs showing } @@ -1720,14 +1610,14 @@ void APP_TimeSlice500ms(void) */ DTMF_clear_input_box(); - gWasFKeyPressed = false; - gInputBoxIndex = 0; + gWasFKeyPressed = false; + gInputBoxIndex = 0; - gAskToSave = false; - gAskToDelete = false; + gAskToSave = false; + gAskToDelete = false; - gUpdateStatus = true; - gUpdateDisplay = true; + gUpdateStatus = true; + gUpdateDisplay = true; GUI_DisplayType_t disp = DISPLAY_INVALID; @@ -1738,10 +1628,10 @@ void APP_TimeSlice500ms(void) #endif if (disp == DISPLAY_INVALID -#ifdef ENABLE_NO_CODE_SCAN_TIMEOUT + #ifdef ENABLE_NO_CODE_SCAN_TIMEOUT && !SCANNER_IsScanning() #endif - ) { + ) { disp = DISPLAY_MAIN; } @@ -1752,7 +1642,7 @@ void APP_TimeSlice500ms(void) } if (!gPttIsPressed && gVFOStateResumeCountdown_500ms > 0 && --gVFOStateResumeCountdown_500ms == 0) { - RADIO_SetVfoState(VFO_STATE_NORMAL); + RADIO_SetVfoState(VFO_STATE_NORMAL); #ifdef ENABLE_FMRADIO if (gFmRadioMode && !FUNCTION_IsRx()) { // switch back to FM radio mode @@ -1777,11 +1667,10 @@ void APP_TimeSlice500ms(void) gDTMF_DecodeRingCountdown_500ms = 0; } - if (gDTMF_CallState != DTMF_CALL_STATE_NONE && gCurrentFunction != FUNCTION_TRANSMIT + if (gDTMF_CallState != DTMF_CALL_STATE_NONE && gCurrentFunction != FUNCTION_TRANSMIT && gCurrentFunction != FUNCTION_RECEIVE && gDTMF_auto_reset_time_500ms > 0 - && --gDTMF_auto_reset_time_500ms == 0) - { - gUpdateDisplay = true; + && --gDTMF_auto_reset_time_500ms == 0) { + gUpdateDisplay = true; if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED && gEeprom.DTMF_auto_reset_time >= DTMF_HOLD_MAX) { gDTMF_CallState = DTMF_CALL_STATE_RECEIVED_STAY; // keep message on-screen till a key is pressed } else { @@ -1790,15 +1679,15 @@ void APP_TimeSlice500ms(void) } if (gDTMF_IsTx && gDTMF_TxStopCountdown_500ms > 0 && --gDTMF_TxStopCountdown_500ms == 0) { - gDTMF_IsTx = false; + gDTMF_IsTx = false; gUpdateDisplay = true; } #endif } #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) -static void ALARM_Off(void) -{ + +static void ALARM_Off(void) { AUDIO_AudioPathOff(); gEnableSpeaker = false; @@ -1819,31 +1708,26 @@ static void ALARM_Off(void) if (gScreenToDisplay != DISPLAY_MENU) // 1of11 .. don't close the menu gRequestDisplayScreen = DISPLAY_MAIN; } + #endif -static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) -{ - #ifdef ENABLE_FEAT_F4HWN_SLEEP - if(gWakeUp) - { - if(!bKeyPressed || Key == KEY_PTT) - { +static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { +#ifdef ENABLE_FEAT_F4HWN_SLEEP + if (gWakeUp) { + if (!bKeyPressed || Key == KEY_PTT) { BACKLIGHT_TurnOn(); - if(Key != KEY_PTT) - { + if (Key != KEY_PTT) { Key = KEY_INVALID; } - } - else - { + } else { return; } } - #endif +#endif - if (Key == KEY_EXIT && !BACKLIGHT_IsOn() && gEeprom.BACKLIGHT_TIME > 0) - { // just turn the light on for now so the user can see what's what + if (Key == KEY_EXIT && !BACKLIGHT_IsOn() && + gEeprom.BACKLIGHT_TIME > 0) { // just turn the light on for now so the user can see what's what BACKLIGHT_TurnOn(); gBeepToPlay = BEEP_NONE; return; @@ -1883,15 +1767,13 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) // gVfoConfigureMode is so as we don't wipe out previously setting this variable elsewhere gVfoConfigureMode = VFO_CONFIGURE; } - } - else { // key pressed or held + } else { // key pressed or held const int m = UI_MENU_GetCurrentMenuId(); - if ( //not when PTT and the backlight shouldn't turn on on TX + if ( //not when PTT and the backlight shouldn't turn on on TX !(Key == KEY_PTT && !(gSetting_backlight_on_tx_rx & BACKLIGHT_ON_TR_TX)) // not in the backlight menu - && !(gScreenToDisplay == DISPLAY_MENU && ( m == MENU_ABR || m == MENU_ABR_MAX || m == MENU_ABR_MIN)) - ) - { + && !(gScreenToDisplay == DISPLAY_MENU && (m == MENU_ABR || m == MENU_ABR_MAX || m == MENU_ABR_MIN)) + ) { BACKLIGHT_TurnOn(); } @@ -1900,7 +1782,7 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (gDTMF_RX_live[0] != 0) { memset(gDTMF_RX_live, 0, sizeof(gDTMF_RX_live)); gDTMF_RX_live_timeout = 0; - gUpdateDisplay = true; + gUpdateDisplay = true; } // cancel user input @@ -1930,24 +1812,24 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) #endif } - bool lowBatPopup = gLowBattery && !gLowBatteryConfirmed && gScreenToDisplay == DISPLAY_MAIN; + bool lowBatPopup = gLowBattery && !gLowBatteryConfirmed && gScreenToDisplay == DISPLAY_MAIN; #ifdef ENABLE_FEAT_F4HWN // Disable PTT if KEY_LOCK bool lck_condition = false; - if(gSetting_set_lck) + if (gSetting_set_lck) lck_condition = (gEeprom.KEY_LOCK || lowBatPopup) && gCurrentFunction != FUNCTION_TRANSMIT; else lck_condition = (gEeprom.KEY_LOCK || lowBatPopup) && gCurrentFunction != FUNCTION_TRANSMIT && Key != KEY_PTT; if (lck_condition) #else - if ((gEeprom.KEY_LOCK || lowBatPopup) && gCurrentFunction != FUNCTION_TRANSMIT && Key != KEY_PTT) + if ((gEeprom.KEY_LOCK || lowBatPopup) && gCurrentFunction != FUNCTION_TRANSMIT && Key != KEY_PTT) #endif { // keyboard is locked or low battery popup // close low battery popup - if(Key == KEY_EXIT && bKeyPressed && lowBatPopup) { + if (Key == KEY_EXIT && bKeyPressed && lowBatPopup) { gLowBatteryConfirmed = true; gUpdateDisplay = true; AUDIO_PlayBeep(BEEP_1KHZ_60MS_OPTIONAL); @@ -1960,24 +1842,25 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (!bKeyHeld) { // keypad is locked, tell the user AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); - gKeypadLocked = 4; // 2 seconds + gKeypadLocked = 4; // 2 seconds gUpdateDisplay = true; return; } } - // KEY_MENU has a special treatment here, because we want to pass hold event to ACTION_Handle - // but we don't want it to complain when initial press happens - // we want to react on realese instead + // KEY_MENU has a special treatment here, because we want to pass hold event to ACTION_Handle + // but we don't want it to complain when initial press happens + // we want to react on realese instead else if (Key != KEY_SIDE1 && Key != KEY_SIDE2 && // pass side buttons !(Key == KEY_MENU && bKeyHeld)) // pass KEY_MENU held { - if ((!bKeyPressed || bKeyHeld || (Key == KEY_MENU && bKeyPressed)) && // prevent released or held, prevent KEY_MENU pressed + if ((!bKeyPressed || bKeyHeld || (Key == KEY_MENU && bKeyPressed)) && + // prevent released or held, prevent KEY_MENU pressed !(Key == KEY_MENU && !bKeyPressed)) // pass KEY_MENU released return; // keypad is locked, tell the user AUDIO_PlayBeep(BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL); - gKeypadLocked = 4; // 2 seconds + gKeypadLocked = 4; // 2 seconds gUpdateDisplay = true; return; } @@ -1997,28 +1880,27 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (gPttWasPressed) { bFlag = bKeyHeld; if (!bKeyPressed) { - bFlag = true; + bFlag = true; gPttWasPressed = false; } } - } - else if (gPttWasReleased) { + } else if (gPttWasReleased) { if (bKeyHeld) bFlag = true; if (!bKeyPressed) { - bFlag = true; + bFlag = true; gPttWasReleased = false; } } #ifdef ENABLE_FEAT_F4HWN // For F + SIDE1 or F + SIDE2 - if (gWasFKeyPressed && (Key == KEY_PTT || Key == KEY_EXIT)) { + if (gWasFKeyPressed && (Key == KEY_PTT || Key == KEY_EXIT)) { #else - if (gWasFKeyPressed && (Key == KEY_PTT || Key == KEY_EXIT || Key == KEY_SIDE1 || Key == KEY_SIDE2)) { + if (gWasFKeyPressed && (Key == KEY_PTT || Key == KEY_EXIT || Key == KEY_SIDE1 || Key == KEY_SIDE2)) { #endif // cancel the F-key gWasFKeyPressed = false; - gUpdateStatus = true; + gUpdateStatus = true; } if (bFlag) { @@ -2039,8 +1921,7 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (Key == KEY_SIDE2) { // transmit 1750Hz tone Code = 0xFE; - } - else { + } else { Code = DTMF_GetCharacter(Key - KEY_0); if (Code == 0xFF) goto Skip; @@ -2055,17 +1936,13 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) BK4819_ExitDTMF_TX(false); -#ifndef ENABLE_FEAT_F4HWN - if (gCurrentVfo->SCRAMBLING_TYPE == 0 || !gSetting_ScrambleEnable) + if (gCurrentVfo->SCRAMBLING_TYPE == 0) BK4819_DisableScramble(); else BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1); -#else - BK4819_DisableScramble(); -#endif + } - } - else { + } else { if (gEeprom.DTMF_SIDE_TONE) { // user will here the DTMF tones in speaker AUDIO_AudioPathOn(); gEnableSpeaker = true; @@ -2089,7 +1966,7 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) gRTTECountdown_10ms = gEeprom.REPEATER_TAIL_TONE_ELIMINATION * 10; if (Key == KEY_PTT) - gPttWasPressed = true; + gPttWasPressed = true; else if (!bKeyHeld) gPttWasReleased = true; } @@ -2098,27 +1975,25 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) #ifdef ENABLE_FEAT_F4HWN // For F + SIDE1 or F + SIDE2 else if (gWasFKeyPressed && (Key == KEY_SIDE1 || Key == KEY_SIDE2)) { ProcessKeysFunctions[gScreenToDisplay](Key, bKeyPressed, bKeyHeld); - } - else if (Key != KEY_SIDE1 && Key != KEY_SIDE2 && gScreenToDisplay != DISPLAY_INVALID) { + } else if (Key != KEY_SIDE1 && Key != KEY_SIDE2 && gScreenToDisplay != DISPLAY_INVALID) { ProcessKeysFunctions[gScreenToDisplay](Key, bKeyPressed, bKeyHeld); } #else - else if (Key != KEY_SIDE1 && Key != KEY_SIDE2 && gScreenToDisplay != DISPLAY_INVALID) { - ProcessKeysFunctions[gScreenToDisplay](Key, bKeyPressed, bKeyHeld); - } + else if (Key != KEY_SIDE1 && Key != KEY_SIDE2 && gScreenToDisplay != DISPLAY_INVALID) { + ProcessKeysFunctions[gScreenToDisplay](Key, bKeyPressed, bKeyHeld); + } #endif else if (!SCANNER_IsScanning() #ifdef ENABLE_AIRCOPY - && gScreenToDisplay != DISPLAY_AIRCOPY + && gScreenToDisplay != DISPLAY_AIRCOPY #endif - ) { + ) { ACTION_Handle(Key, bKeyPressed, bKeyHeld); - } - else if (!bKeyHeld && bKeyPressed) { + } else if (!bKeyHeld && bKeyPressed) { gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; } -Skip: + Skip: if (gBeepToPlay != BEEP_NONE) { AUDIO_PlayBeep(gBeepToPlay); gBeepToPlay = BEEP_NONE; @@ -2130,7 +2005,7 @@ Skip: MENU_AcceptSetting(); gFlagRefreshSetting = true; - gFlagAcceptSetting = false; + gFlagAcceptSetting = false; } if (gRequestSaveSettings) { @@ -2139,7 +2014,7 @@ Skip: else flagSaveSettings = 1; gRequestSaveSettings = false; - gUpdateStatus = true; + gUpdateStatus = true; } #ifdef ENABLE_FMRADIO @@ -2161,15 +2036,13 @@ Skip: } if (gRequestSaveChannel > 0) { // TODO: remove the gRequestSaveChannel, why use global variable for that?? - if ((!bKeyHeld && !bKeyPressed) || UI_MENU_GetCurrentMenuId()) - { + if ((!bKeyHeld && !bKeyPressed) || UI_MENU_GetCurrentMenuId()) { SETTINGS_SaveChannel(gTxVfo->CHANNEL_SAVE, gEeprom.TX_VFO, gTxVfo, gRequestSaveChannel); if (!SCANNER_IsScanning() && gVfoConfigureMode == VFO_CONFIGURE_NONE) // gVfoConfigureMode is so as we don't wipe out previously setting this variable elsewhere gVfoConfigureMode = VFO_CONFIGURE; - } - else { // this is probably so settings are not saved when up/down button is held and save is postponed to btn release + } else { // this is probably so settings are not saved when up/down button is held and save is postponed to btn release flagSaveChannel = gRequestSaveChannel; if (gRequestDisplayScreen == DISPLAY_INVALID) @@ -2183,16 +2056,15 @@ Skip: if (gFlagResetVfos) { RADIO_ConfigureChannel(0, gVfoConfigureMode); RADIO_ConfigureChannel(1, gVfoConfigureMode); - } - else + } else RADIO_ConfigureChannel(gEeprom.TX_VFO, gVfoConfigureMode); if (gRequestDisplayScreen == DISPLAY_INVALID) gRequestDisplayScreen = DISPLAY_MAIN; gFlagReconfigureVfos = true; - gVfoConfigureMode = VFO_CONFIGURE_NONE; - gFlagResetVfos = false; + gVfoConfigureMode = VFO_CONFIGURE_NONE; + gFlagResetVfos = false; } if (gFlagReconfigureVfos) { @@ -2206,15 +2078,15 @@ Skip: #ifdef ENABLE_DTMF_CALLING gDTMF_auto_reset_time_500ms = 0; - gDTMF_CallState = DTMF_CALL_STATE_NONE; + gDTMF_CallState = DTMF_CALL_STATE_NONE; gDTMF_TxStopCountdown_500ms = 0; - gDTMF_IsTx = false; + gDTMF_IsTx = false; #endif - gVFO_RSSI_bar_level[0] = 0; - gVFO_RSSI_bar_level[1] = 0; + gVFO_RSSI_bar_level[0] = 0; + gVFO_RSSI_bar_level[1] = 0; - gFlagReconfigureVfos = false; + gFlagReconfigureVfos = false; if (gMonitor) ACTION_Monitor(); // 1of11 @@ -2222,7 +2094,7 @@ Skip: if (gFlagRefreshSetting) { gFlagRefreshSetting = false; - gMenuCountdown = menu_timeout_500ms; + gMenuCountdown = menu_timeout_500ms; MENU_ShowCurrentSetting(); } diff --git a/app/app.h b/app/app.h index 20b7c85..da3b63c 100644 --- a/app/app.h +++ b/app/app.h @@ -23,13 +23,21 @@ #include "frequencies.h" #include "radio.h" -void APP_EndTransmission(void); -void APP_StartListening(FUNCTION_Type_t function); +void APP_EndTransmission(void); + +void APP_StartListening(FUNCTION_Type_t function); + uint32_t APP_SetFreqByStepAndLimits(VFO_Info_t *pInfo, int8_t direction, uint32_t lower, uint32_t upper); + uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t direction); -void APP_Update(void); -void APP_TimeSlice10ms(void); -void APP_TimeSlice500ms(void); + +void APP_Update(void); + +void APP_TimeSlice10ms(void); + +void APP_TimeSlice500ms(void); + +void APP_EndTransmission(void); #endif diff --git a/app/dtmf.c b/app/dtmf.c index 91b5868..15ef6c8 100644 --- a/app/dtmf.c +++ b/app/dtmf.c @@ -248,7 +248,7 @@ void DTMF_HandleRequest(void) return; } - if (!gRxVfo->DTMF_DECODING_ENABLE && !gSetting_KILLED) + if (!gRxVfo->DTMF_DECODING_ENABLE) { // D-DCD is disabled or we're alive DTMF_clear_RX(); return; @@ -266,28 +266,28 @@ void DTMF_HandleRequest(void) if (CompareMessage(gDTMF_RX + Offset, String, strlen(String), true)) { // bugger - if (gEeprom.PERMIT_REMOTE_KILL) - { - gSetting_KILLED = true; // oooerr ! - - DTMF_clear_RX(); - - SETTINGS_SaveSettings(); - - gDTMF_ReplyState = DTMF_REPLY_AB; - - #ifdef ENABLE_FMRADIO - if (gFmRadioMode) - { - FM_TurnOff(); - GUI_SelectNextDisplay(DISPLAY_MAIN); - } - #endif - } - else - { +// if (gEeprom.PERMIT_REMOTE_KILL) +// { +// gSetting_KILLED = true; // oooerr ! +// +// DTMF_clear_RX(); +// +// SETTINGS_SaveSettings(); +// +// gDTMF_ReplyState = DTMF_REPLY_AB; +// +// #ifdef ENABLE_FMRADIO +// if (gFmRadioMode) +// { +// FM_TurnOff(); +// GUI_SelectNextDisplay(DISPLAY_MAIN); +// } +// #endif +// } +// else +// { gDTMF_ReplyState = DTMF_REPLY_NONE; - } +// } gDTMF_CallState = DTMF_CALL_STATE_NONE; @@ -297,30 +297,30 @@ void DTMF_HandleRequest(void) } } - if (gDTMF_RX_index >= 9) - { // look for the REVIVE code - - sprintf(String, "%s%c%s", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE, gEeprom.REVIVE_CODE); - - Offset = gDTMF_RX_index - strlen(String); - - if (CompareMessage(gDTMF_RX + Offset, String, strlen(String), true)) - { // shit, we're back ! - - gSetting_KILLED = false; - - DTMF_clear_RX(); - - SETTINGS_SaveSettings(); - - gDTMF_ReplyState = DTMF_REPLY_AB; - gDTMF_CallState = DTMF_CALL_STATE_NONE; - - gUpdateDisplay = true; - gUpdateStatus = true; - return; - } - } +// if (gDTMF_RX_index >= 9) +// { // look for the REVIVE code +// +// sprintf(String, "%s%c%s", gEeprom.ANI_DTMF_ID, gEeprom.DTMF_SEPARATE_CODE, gEeprom.REVIVE_CODE); +// +// Offset = gDTMF_RX_index - strlen(String); +// +// if (CompareMessage(gDTMF_RX + Offset, String, strlen(String), true)) +// { // shit, we're back ! +// +// gSetting_KILLED = false; +// +// DTMF_clear_RX(); +// +// SETTINGS_SaveSettings(); +// +// gDTMF_ReplyState = DTMF_REPLY_AB; +// gDTMF_CallState = DTMF_CALL_STATE_NONE; +// +// gUpdateDisplay = true; +// gUpdateStatus = true; +// return; +// } +// } if (gDTMF_RX_index >= 2) { // look for ACK reply @@ -360,7 +360,7 @@ void DTMF_HandleRequest(void) } } - if (gSetting_KILLED || gDTMF_CallState != DTMF_CALL_STATE_NONE) + if (gDTMF_CallState != DTMF_CALL_STATE_NONE) { // we've been killed or expecting a reply return; } diff --git a/app/main.c b/app/main.c index 2de8caa..42f040b 100644 --- a/app/main.c +++ b/app/main.c @@ -20,15 +20,21 @@ #include "app/app.h" #include "app/chFrScanner.h" #include "app/common.h" + #ifdef ENABLE_FMRADIO - #include "app/fm.h" + +#include "app/fm.h" + #endif + #include "app/generic.h" #include "app/main.h" #include "app/scanner.h" #ifdef ENABLE_SPECTRUM + #include "app/spectrum.h" + #endif #include "audio.h" @@ -43,32 +49,46 @@ #include "ui/ui.h" #include -static void toggle_chan_scanlist(void) -{ // toggle the selected channels scanlist setting +#define T9Count 9 + +const char T9Table[10][T9Count] = { + {'#', '(', ')', ';', ':', '<', '>', '/', '0'}, + {',', '.', '?', '&', '!', ' ', '-', '_', '1'}, + {'a', 'b', 'c', 'A', 'B', 'C', '[', ']', '2'}, + {'d', 'e', 'f', 'D', 'E', 'F', '@', '%', '3'}, + {'g', 'h', 'i', 'G', 'H', 'I', '~', '$', '4'}, + {'j', 'k', 'l', 'J', 'K', 'L', '|', '*', '5'}, + {'m', 'n', 'o', 'M', 'N', 'O', '{', '}', '6'}, + {'p', 'q', 'r', 's', 'P', 'Q', 'R', 'S', '7'}, + {'t', 'u', 'v', 'T', 'U', 'V', '"', '\'', '8'}, + {'w', 'x', 'y', 'z', 'W', 'X', 'Y', 'Z', '9'} +}; + +static void toggle_chan_scanlist(void) { // toggle the selected channels scanlist setting if (SCANNER_IsScanning()) return; - if(!IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) { + if (!IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) { #ifdef ENABLE_SCAN_RANGES gScanRangeStart = gScanRangeStart ? 0 : gTxVfo->pRX->Frequency; gScanRangeStop = gEeprom.VfoInfo[!gEeprom.TX_VFO].freq_config_RX.Frequency; - if(gScanRangeStart > gScanRangeStop) + if (gScanRangeStart > gScanRangeStop) SWAP(gScanRangeStart, gScanRangeStop); #endif return; } - + // Remove exclude - if(gMR_ChannelExclude[gTxVfo->CHANNEL_SAVE] == true) - { + if (gMR_ChannelExclude[gTxVfo->CHANNEL_SAVE] == true) { gMR_ChannelExclude[gTxVfo->CHANNEL_SAVE] = false; return; } - uint8_t scanTmp = gTxVfo->SCANLIST1_PARTICIPATION | (gTxVfo->SCANLIST2_PARTICIPATION << 1) | (gTxVfo->SCANLIST3_PARTICIPATION << 2); + uint8_t scanTmp = gTxVfo->SCANLIST1_PARTICIPATION | (gTxVfo->SCANLIST2_PARTICIPATION << 1) | + (gTxVfo->SCANLIST3_PARTICIPATION << 2); - scanTmp = (scanTmp++ < 7) ? scanTmp: 0; + scanTmp = (scanTmp++ < 7) ? scanTmp : 0; gTxVfo->SCANLIST1_PARTICIPATION = (scanTmp >> 0) & 0x01; gTxVfo->SCANLIST2_PARTICIPATION = (scanTmp >> 1) & 0x01; @@ -77,11 +97,10 @@ static void toggle_chan_scanlist(void) SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true, true, true); gVfoConfigureMode = VFO_CONFIGURE; - gFlagResetVfos = true; + gFlagResetVfos = true; } -static void processFKeyFunction(const KEY_Code_t Key, const bool beep) -{ +static void processFKeyFunction(const KEY_Code_t Key, const bool beep) { uint8_t Vfo = gEeprom.TX_VFO; #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS @@ -101,21 +120,21 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } - + gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; switch (Key) { case KEY_0: - #ifdef ENABLE_FMRADIO - ACTION_FM(); - #endif +#ifdef ENABLE_FMRADIO + ACTION_FM(); +#endif break; case KEY_1: if (!IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) { gWasFKeyPressed = false; - gUpdateStatus = true; - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + gUpdateStatus = true; + gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; #ifdef ENABLE_COPY_CHAN_TO_VFO if (!gEeprom.VFO_OPEN || gCssBackgroundScan) { @@ -125,17 +144,15 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) if (gScanStateDir != SCAN_OFF) { if (gCurrentFunction != FUNCTION_INCOMING || - gRxReceptionMode == RX_MODE_NONE || - gScanPauseDelayIn_10ms == 0) - { // scan is running (not paused) + gRxReceptionMode == RX_MODE_NONE || + gScanPauseDelayIn_10ms == 0) { // scan is running (not paused) return; } } const uint8_t vfo = gEeprom.TX_VFO; - if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo])) - { // copy channel to VFO, then swap to the VFO + if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo])) { // copy channel to VFO, then swap to the VFO gEeprom.ScreenChannel[vfo] = FREQ_CHANNEL_FIRST + gEeprom.VfoInfo[vfo].Band; gEeprom.VfoInfo[vfo].CHANNEL_SAVE = gEeprom.ScreenChannel[vfo]; @@ -156,9 +173,9 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) } #ifdef ENABLE_WIDE_RX - if(gTxVfo->Band == BAND7_470MHz && gTxVfo->pRX->Frequency < _1GHz_in_KHz) { - gTxVfo->pRX->Frequency = _1GHz_in_KHz; - return; + if (gTxVfo->Band == BAND7_470MHz && gTxVfo->pRX->Frequency < _1GHz_in_KHz) { + gTxVfo->pRX->Frequency = _1GHz_in_KHz; + return; } #endif gTxVfo->Band += 1; @@ -166,18 +183,18 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) if (gTxVfo->Band == BAND5_350MHz && !gSetting_350EN) { // skip if not enabled gTxVfo->Band += 1; - } else if (gTxVfo->Band >= BAND_N_ELEM){ + } else if (gTxVfo->Band >= BAND_N_ELEM) { // go arround if overflowed gTxVfo->Band = BAND1_50MHz; } gEeprom.ScreenChannel[Vfo] = FREQ_CHANNEL_FIRST + gTxVfo->Band; - gEeprom.FreqChannel[Vfo] = FREQ_CHANNEL_FIRST + gTxVfo->Band; + gEeprom.FreqChannel[Vfo] = FREQ_CHANNEL_FIRST + gTxVfo->Band; - gRequestSaveVFO = true; - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; + gRequestSaveVFO = true; + gVfoConfigureMode = VFO_CONFIGURE_RELOAD; - gRequestDisplayScreen = DISPLAY_MAIN; + gRequestDisplayScreen = DISPLAY_MAIN; if (beep) gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; @@ -185,18 +202,18 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) break; case KEY_2: - #ifdef ENABLE_FEAT_F4HWN - gVfoConfigureMode = VFO_CONFIGURE; - #endif +#ifdef ENABLE_FEAT_F4HWN + gVfoConfigureMode = VFO_CONFIGURE; +#endif COMMON_SwitchVFOs(); if (beep) gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; break; case KEY_3: - #ifdef ENABLE_FEAT_F4HWN - gVfoConfigureMode = VFO_CONFIGURE; - #endif +#ifdef ENABLE_FEAT_F4HWN + gVfoConfigureMode = VFO_CONFIGURE; +#endif COMMON_SwitchVFOMode(); if (beep) gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; @@ -204,11 +221,11 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) break; case KEY_4: - gWasFKeyPressed = false; + gWasFKeyPressed = false; - gBackup_CROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX; + gBackup_CROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX; gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF; - gUpdateStatus = true; + gUpdateStatus = true; if (beep) gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; @@ -217,7 +234,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) break; case KEY_5: - if(beep) { + if (beep) { #ifdef ENABLE_NOAA if (!IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) { gEeprom.ScreenChannel[Vfo] = gEeprom.NoaaChannel[gEeprom.TX_VFO]; @@ -234,8 +251,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) APP_RunSpectrum(); gRequestDisplayScreen = DISPLAY_MAIN; #endif - } - else { + } else { toggle_chan_scanlist(); } @@ -260,15 +276,15 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) case KEY_9: if (RADIO_CheckValidChannel(gEeprom.CHAN_1_CALL, false, 0)) { - gEeprom.MrChannel[Vfo] = gEeprom.CHAN_1_CALL; + gEeprom.MrChannel[Vfo] = gEeprom.CHAN_1_CALL; gEeprom.ScreenChannel[Vfo] = gEeprom.CHAN_1_CALL; #ifdef ENABLE_VOICE AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE); AUDIO_SetDigitVoice(1, gEeprom.CHAN_1_CALL + 1); gAnotherVoiceID = (VOICE_ID_t)0xFE; #endif - gRequestSaveVFO = true; - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; + gRequestSaveVFO = true; + gVfoConfigureMode = VFO_CONFIGURE_RELOAD; break; } @@ -278,46 +294,42 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) #ifdef ENABLE_FEAT_F4HWN // Set Squelch F + UP or Down and Step F + SIDE1 or F + SIDE2 case KEY_UP: - gEeprom.SQUELCH_LEVEL = (gEeprom.SQUELCH_LEVEL < 9) ? gEeprom.SQUELCH_LEVEL + 1: 9; - gVfoConfigureMode = VFO_CONFIGURE; + gEeprom.SQUELCH_LEVEL = (gEeprom.SQUELCH_LEVEL < 9) ? gEeprom.SQUELCH_LEVEL + 1 : 9; + gVfoConfigureMode = VFO_CONFIGURE; gWasFKeyPressed = false; break; case KEY_DOWN: - gEeprom.SQUELCH_LEVEL = (gEeprom.SQUELCH_LEVEL > 0) ? gEeprom.SQUELCH_LEVEL - 1: 0; - gVfoConfigureMode = VFO_CONFIGURE; + gEeprom.SQUELCH_LEVEL = (gEeprom.SQUELCH_LEVEL > 0) ? gEeprom.SQUELCH_LEVEL - 1 : 0; + gVfoConfigureMode = VFO_CONFIGURE; gWasFKeyPressed = false; break; case KEY_SIDE1: uint8_t a = FREQUENCY_GetSortedIdxFromStepIdx(gTxVfo->STEP_SETTING); - if (a < STEP_N_ELEM - 1) - { + if (a < STEP_N_ELEM - 1) { gTxVfo->STEP_SETTING = FREQUENCY_GetStepIdxFromSortedIdx(a + 1); } - if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) - { + if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) { gRequestSaveChannel = 1; } - gVfoConfigureMode = VFO_CONFIGURE; + gVfoConfigureMode = VFO_CONFIGURE; gWasFKeyPressed = false; break; case KEY_SIDE2: uint8_t b = FREQUENCY_GetSortedIdxFromStepIdx(gTxVfo->STEP_SETTING); - if (b > 0) - { + if (b > 0) { gTxVfo->STEP_SETTING = FREQUENCY_GetStepIdxFromSortedIdx(b - 1); } - if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) - { + if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) { gRequestSaveChannel = 1; } - gVfoConfigureMode = VFO_CONFIGURE; + gVfoConfigureMode = VFO_CONFIGURE; gWasFKeyPressed = false; break; #endif default: - gUpdateStatus = true; + gUpdateStatus = true; gWasFKeyPressed = false; if (beep) @@ -326,8 +338,7 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) } } -void channelMove(uint16_t Channel) -{ +void channelMove(uint16_t Channel) { const uint8_t Vfo = gEeprom.TX_VFO; if (!RADIO_CheckValidChannel(Channel, false, 0)) { @@ -340,14 +351,14 @@ void channelMove(uint16_t Channel) gBeepToPlay = BEEP_NONE; - #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; - #endif +#ifdef ENABLE_VOICE + gAnotherVoiceID = (VOICE_ID_t)Key; +#endif - gEeprom.MrChannel[Vfo] = (uint8_t)Channel; - gEeprom.ScreenChannel[Vfo] = (uint8_t)Channel; + gEeprom.MrChannel[Vfo] = (uint8_t) Channel; + gEeprom.ScreenChannel[Vfo] = (uint8_t) Channel; //gRequestSaveVFO = true; - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; + gVfoConfigureMode = VFO_CONFIGURE_RELOAD; #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS gRemoveOffset = false; @@ -355,7 +366,7 @@ void channelMove(uint16_t Channel) #endif RADIO_ConfigureChannel(gEeprom.TX_VFO, gVfoConfigureMode); - + return; } @@ -392,7 +403,7 @@ void channelMoveSwitch(void) { channelMove(Channel - 1); SETTINGS_SaveVfoIndices(); - + return; } @@ -400,18 +411,17 @@ void channelMoveSwitch(void) { } } -static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) -{ +static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { if (bKeyHeld) { // key held down if (bKeyPressed) { if (gScreenToDisplay == DISPLAY_MAIN) { if (gInputBoxIndex > 0) { // delete any inputted chars - gInputBoxIndex = 0; + gInputBoxIndex = 0; gRequestDisplayScreen = DISPLAY_MAIN; } gWasFKeyPressed = false; - gUpdateStatus = true; + gUpdateStatus = true; processFKeyFunction(Key, false); } @@ -419,21 +429,20 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) return; } - if (bKeyPressed) - { // key is pressed + if (bKeyPressed) { // key is pressed gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; // beep when key is pressed return; // don't use the key till it's released } if (!gWasFKeyPressed) { // F-key wasn't pressed - if (gScanStateDir != SCAN_OFF){ - switch(Key) { + if (gScanStateDir != SCAN_OFF) { + switch (Key) { case KEY_0...KEY_5: gEeprom.SCAN_LIST_DEFAULT = Key; - #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE - SETTINGS_WriteCurrentState(); - #endif +#ifdef ENABLE_FEAT_F4HWN_RESUME_STATE + SETTINGS_WriteCurrentState(); +#endif break; default: break; @@ -453,18 +462,17 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) gKeyInputCountdown = (key_input_timeout_500ms / 4); // short time... - #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; - #endif - +#ifdef ENABLE_VOICE + gAnotherVoiceID = (VOICE_ID_t)Key; +#endif + return; } // #ifdef ENABLE_NOAA // if (!IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) // #endif - if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) - { // user is entering a frequency + if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) { // user is entering a frequency #ifdef ENABLE_VOICE gAnotherVoiceID = (VOICE_ID_t)Key; @@ -478,8 +486,9 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) // do nothing return; } - - gKeyInputCountdown = (gInputBoxIndex == totalDigits) ? (key_input_timeout_500ms / 16) : (key_input_timeout_500ms / 3); + + gKeyInputCountdown = (gInputBoxIndex == totalDigits) ? (key_input_timeout_500ms / 16) : ( + key_input_timeout_500ms / 3); const char *inputStr = INPUTBOX_GetAscii(); uint8_t inputLength = gInputBoxIndex; @@ -500,21 +509,19 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) // clamp the frequency entered to some valid value if (Frequency < frequencyBandTable[0].lower) { Frequency = frequencyBandTable[0].lower; - } - else if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower) { + } else if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower) { const uint32_t center = (BX4819_band1.upper + BX4819_band2.lower) / 2; Frequency = (Frequency < center) ? BX4819_band1.upper : BX4819_band2.lower; - } - else if (Frequency > frequencyBandTable[BAND_N_ELEM - 1].upper) { + } else if (Frequency > frequencyBandTable[BAND_N_ELEM - 1].upper) { Frequency = frequencyBandTable[BAND_N_ELEM - 1].upper; } const FREQUENCY_Band_t band = FREQUENCY_GetBand(Frequency); if (gTxVfo->Band != band) { - gTxVfo->Band = band; + gTxVfo->Band = band; gEeprom.ScreenChannel[Vfo] = band + FREQ_CHANNEL_FIRST; - gEeprom.FreqChannel[Vfo] = band + FREQ_CHANNEL_FIRST; + gEeprom.FreqChannel[Vfo] = band + FREQ_CHANNEL_FIRST; SETTINGS_SaveVfoIndices(); @@ -523,8 +530,8 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) Frequency = FREQUENCY_RoundToStep(Frequency, gTxVfo->StepFrequency); - if (Frequency >= BX4819_band1.upper && Frequency < BX4819_band2.lower) - { // clamp the frequency to the limit + if (Frequency >= BX4819_band1.upper && + Frequency < BX4819_band2.lower) { // clamp the frequency to the limit const uint32_t center = (BX4819_band1.upper + BX4819_band2.lower) / 2; Frequency = (Frequency < center) ? BX4819_band1.upper - gTxVfo->StepFrequency : BX4819_band2.lower; } @@ -535,50 +542,47 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) return; } - #ifdef ENABLE_NOAA - else - if (IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) - { // user is entering NOAA channel - if (gInputBoxIndex != 2) { - #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; - #endif - gRequestDisplayScreen = DISPLAY_MAIN; - return; - } - - gInputBoxIndex = 0; - - uint8_t Channel = (gInputBox[0] * 10) + gInputBox[1]; - if (Channel >= 1 && Channel <= ARRAY_SIZE(NoaaFrequencyTable)) { - Channel += NOAA_CHANNEL_FIRST; - #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; - #endif - gEeprom.NoaaChannel[Vfo] = Channel; - gEeprom.ScreenChannel[Vfo] = Channel; - gRequestSaveVFO = true; - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; - return; - } +#ifdef ENABLE_NOAA + else + if (IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) + { // user is entering NOAA channel + if (gInputBoxIndex != 2) { +#ifdef ENABLE_VOICE + gAnotherVoiceID = (VOICE_ID_t)Key; +#endif + gRequestDisplayScreen = DISPLAY_MAIN; + return; } - #endif + + gInputBoxIndex = 0; + + uint8_t Channel = (gInputBox[0] * 10) + gInputBox[1]; + if (Channel >= 1 && Channel <= ARRAY_SIZE(NoaaFrequencyTable)) { + Channel += NOAA_CHANNEL_FIRST; +#ifdef ENABLE_VOICE + gAnotherVoiceID = (VOICE_ID_t)Key; +#endif + gEeprom.NoaaChannel[Vfo] = Channel; + gEeprom.ScreenChannel[Vfo] = Channel; + gRequestSaveVFO = true; + gVfoConfigureMode = VFO_CONFIGURE_RELOAD; + return; + } + } +#endif gRequestDisplayScreen = DISPLAY_MAIN; - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } gWasFKeyPressed = false; - gUpdateStatus = true; + gUpdateStatus = true; - if(Key == 8) - { + if (Key == 8) { ACTION_BackLightOnDemand(); return; - } - else if(Key == 9) - { + } else if (Key == 9) { ACTION_BackLight(); return; } @@ -586,8 +590,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) processFKeyFunction(Key, true); } -static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld) -{ +static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld) { if (!bKeyHeld && bKeyPressed) { // exit key pressed gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; @@ -615,8 +618,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld) if (gInputBoxIndex == 0) gAnotherVoiceID = VOICE_ID_CANCEL; #endif - } - else { + } else { gScanKeepResult = false; CHFRSCANNER_Stop(); @@ -636,36 +638,33 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld) } if (bKeyHeld && bKeyPressed) { // exit key held down - if (gInputBoxIndex > 0 || gDTMF_InputBox_Index > 0 || gDTMF_InputMode) - { // cancel key input mode (channel/frequency entry) - gDTMF_InputMode = false; - gDTMF_InputBox_Index = 0; + if (gInputBoxIndex > 0 || gDTMF_InputBox_Index > 0 || + gDTMF_InputMode) { // cancel key input mode (channel/frequency entry) + gDTMF_InputMode = false; + gDTMF_InputBox_Index = 0; memset(gDTMF_String, 0, sizeof(gDTMF_String)); - gInputBoxIndex = 0; + gInputBoxIndex = 0; gRequestDisplayScreen = DISPLAY_MAIN; - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; } } } -static void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld) -{ +static void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld) { if (bKeyPressed && !bKeyHeld) // menu key pressed gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; if (bKeyHeld) { // menu key held down (long press) if (bKeyPressed) { // long press MENU key - #ifdef ENABLE_FEAT_F4HWN +#ifdef ENABLE_FEAT_F4HWN // Exclude work with list 1, 2, 3 or all list - if(gScanStateDir != SCAN_OFF) - { - if(FUNCTION_IsRx()) - { + if (gScanStateDir != SCAN_OFF) { + if (FUNCTION_IsRx()) { gMR_ChannelExclude[gTxVfo->CHANNEL_SAVE] = true; gVfoConfigureMode = VFO_CONFIGURE; - gFlagResetVfos = true; + gFlagResetVfos = true; lastFoundFrqOrChan = lastFoundFrqOrChanOld; @@ -674,18 +673,18 @@ static void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld) return; } - #endif - +#endif + gWasFKeyPressed = false; if (gScreenToDisplay == DISPLAY_MAIN) { if (gInputBoxIndex > 0) { // delete any inputted chars - gInputBoxIndex = 0; + gInputBoxIndex = 0; gRequestDisplayScreen = DISPLAY_MAIN; } gWasFKeyPressed = false; - gUpdateStatus = true; + gUpdateStatus = true; ACTION_Handle(KEY_MENU, bKeyPressed, bKeyHeld); } @@ -696,7 +695,7 @@ static void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld) if (!bKeyPressed && !gDTMF_InputMode) { // menu key released const bool bFlag = !gInputBoxIndex; - gInputBoxIndex = 0; + gInputBoxIndex = 0; if (bFlag) { if (gScanStateDir != SCAN_OFF) { @@ -704,28 +703,26 @@ static void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld) return; } - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS +#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS if(gEeprom.MENU_LOCK == false) { - #endif +#endif gFlagRefreshSetting = true; gRequestDisplayScreen = DISPLAY_MENU; - #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_MENU; - #endif +#ifdef ENABLE_VOICE + gAnotherVoiceID = VOICE_ID_MENU; +#endif - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS +#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS } - #endif - } - else { +#endif + } else { gRequestDisplayScreen = DISPLAY_MAIN; } } } -static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld) -{ +static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld) { #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS if(gEeprom.MENU_LOCK == true) { @@ -735,16 +732,16 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld) if (gCurrentFunction == FUNCTION_TRANSMIT) return; - + if (gInputBoxIndex) { if (!bKeyHeld && bKeyPressed) gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } - if (bKeyHeld && !gWasFKeyPressed){ // long press + if (bKeyHeld && !gWasFKeyPressed) { // long press if (!bKeyPressed) // released - return; + return; /* #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE @@ -768,61 +765,55 @@ static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld) if (bKeyPressed) { // just pressed return; } - + // just released - + if (!gWasFKeyPressed) // pressed without the F-key - { - if (gScanStateDir == SCAN_OFF -#ifdef ENABLE_NOAA + { + if (gScanStateDir == SCAN_OFF + #ifdef ENABLE_NOAA && !IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE) -#endif -#ifdef ENABLE_SCAN_RANGES + #endif + #ifdef ENABLE_SCAN_RANGES && gScanRangeStart == 0 -#endif - ) - { // start entering a DTMF string +#endif + ) { // start entering a DTMF string gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; memcpy(gDTMF_InputBox, gDTMF_String, MIN(sizeof(gDTMF_InputBox), sizeof(gDTMF_String) - 1)); - gDTMF_InputBox_Index = 0; - gDTMF_InputMode = true; + gDTMF_InputBox_Index = 0; + gDTMF_InputMode = true; - gKeyInputCountdown = key_input_timeout_500ms; + gKeyInputCountdown = key_input_timeout_500ms; gRequestDisplayScreen = DISPLAY_MAIN; - } - else + } else gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; - } - else - { // with the F-key + } else { // with the F-key gWasFKeyPressed = false; #ifdef ENABLE_NOAA if (IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) { gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; - } + } #endif // scan the CTCSS/DCS code - gBackup_CROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX; + gBackup_CROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX; gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF; SCANNER_Start(true); gRequestDisplayScreen = DISPLAY_SCANNER; } - + //gPttWasReleased = true; Fixed issue #138 - gUpdateStatus = true; + gUpdateStatus = true; } -static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) -{ +static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) { #ifdef ENABLE_FEAT_F4HWN // Set Squelch F + UP or Down - if(gWasFKeyPressed) { - switch(Direction) - { + if (gWasFKeyPressed) { + switch (Direction) { case 1: processFKeyFunction(KEY_UP, false); break; @@ -855,8 +846,7 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) #endif return; } - } - else { // short pressed + } else { // short pressed if (gInputBoxIndex > 0) { gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; @@ -907,7 +897,7 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) } #endif - gRequestSaveVFO = true; + gRequestSaveVFO = true; gVfoConfigureMode = VFO_CONFIGURE_RELOAD; return; } @@ -920,8 +910,13 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) gPttWasReleased = true; } -void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) -{ +void updatePrevChar(KEY_Code_t Key) { + if (Key != prevKey) { + prevKey = Key; + } +} + +void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { #ifdef ENABLE_FMRADIO if (gFmRadioMode && Key != KEY_PTT && Key != KEY_EXIT) { if (!bKeyHeld && bKeyPressed) @@ -932,13 +927,12 @@ void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (gDTMF_InputMode && bKeyPressed && !bKeyHeld) { const char Character = DTMF_GetCharacter(Key); - if (Character != 0xFF) - { // add key to DTMF string + if (Character != 0xFF) { // add key to DTMF string DTMF_Append(Character); - gKeyInputCountdown = key_input_timeout_500ms; + gKeyInputCountdown = key_input_timeout_500ms; gRequestDisplayScreen = DISPLAY_MAIN; - gPttWasReleased = true; - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + gPttWasReleased = true; + gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; return; } } @@ -949,31 +943,138 @@ void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) // Key = KEY_SIDE2; // what's this doing ??? // } + if (Key == KEY_9 && bKeyHeld) { + if (bKeyPressed) { + if (gEnteringSMS == SMS_NOT_ENTERING) { + gEnteringSMS = SMS_ENTERING_DEST; + updatePrevChar(Key); + return; + } + } + } + if (Key == KEY_MENU) { + if (gEnteringSMS == SMS_ENTERING_DEST) { + if (bKeyPressed) { + memset(dataPacket.data, 0, DataPacketDataSize); + prepareDataPacket(); + dataPacket.flags = 126; + gEnteringSMS = SMS_ENTERING_MESSAGE; + } + return; + } + if (gEnteringSMS == SMS_ENTERING_MESSAGE) { + if (bKeyPressed) { + if (strlen((char *) dataPacket.data)) { + BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, true); + AUDIO_AudioPathOff(); + gEnableSpeaker = false; + RADIO_PrepareTX(); + if (gCurrentVfo->SCRAMBLING_TYPE > 0) + BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1); + else + BK4819_DisableScramble(); + MSG_FSKSendData(); + AUDIO_AudioPathOn(); + gEnableSpeaker = true; + BK4819_ExitTxMute(); + MSG_EnableRX(true); + gVfoConfigureMode = VFO_CONFIGURE; + BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, false); + dataPTR = dataPacket.data; + memset(dataPacket.data, 0, DataPacketDataSize); + gEnteringSMS = SMS_NOT_ENTERING; + } + } + return; + } + } + if (Key == KEY_EXIT && gEnteringSMS != SMS_NOT_ENTERING) { + if (bKeyHeld) { + if (bKeyPressed) { + gEnteringSMS = SMS_NOT_ENTERING; + dataPTR = dataPacket.data; + memset(dataPacket.data, 0, DataPacketDataSize); + } + } else { + if (bKeyPressed) { + if (gEnteringSMS == SMS_ENTERING_MESSAGE) { + if (dataPacket.data <= dataPTR) { + *dataPTR = '\0'; + if (dataPacket.data < dataPTR) { + dataPTR--; + } + *dataPTR = '\0'; + } + } else if (gEnteringSMS == SMS_ENTERING_DEST) { + dataPacket.dest /= 10; + } + } + } + updatePrevChar(Key); + return; + } + + if (gEnteringSMS != SMS_NOT_ENTERING && !bKeyHeld) { + if (!dataPTR) { + dataPTR = dataPacket.data; + } + if (gEnteringSMS == SMS_ENTERING_MESSAGE) { + if (bKeyPressed) { + if (prevKey != Key) { + dataPTR++; + if (dataPTR - dataPacket.data >= DataPacketDataSize) { + dataPTR = dataPacket.data; + } + prevLetter = 0; + } + *(dataPTR - 1) = T9Table[Key][(prevLetter++) % T9Count]; + updatePrevChar(Key); + } + return; + } else if (gEnteringSMS == SMS_ENTERING_DEST) { + if (bKeyPressed) { + dataPacket.dest *= 10; + dataPacket.dest += Key; + prevLetter = 0; + } + return; + } + } + switch (Key) { #ifdef ENABLE_FEAT_F4HWN case KEY_SIDE1: case KEY_SIDE2: #endif - case KEY_0...KEY_9: - MAIN_Key_DIGITS(Key, bKeyPressed, bKeyHeld); + case + KEY_0...KEY_9 + : + MAIN_Key_DIGITS(Key, bKeyPressed, bKeyHeld + ); break; case KEY_MENU: - MAIN_Key_MENU(bKeyPressed, bKeyHeld); + MAIN_Key_MENU(bKeyPressed, bKeyHeld + ); break; case KEY_UP: - MAIN_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1); + MAIN_Key_UP_DOWN(bKeyPressed, bKeyHeld, + 1); break; case KEY_DOWN: - MAIN_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1); + MAIN_Key_UP_DOWN(bKeyPressed, bKeyHeld, + -1); break; case KEY_EXIT: - MAIN_Key_EXIT(bKeyPressed, bKeyHeld); + MAIN_Key_EXIT(bKeyPressed, bKeyHeld + ); break; case KEY_STAR: - MAIN_Key_STAR(bKeyPressed, bKeyHeld); + MAIN_Key_STAR(bKeyPressed, bKeyHeld + ); break; case KEY_F: - GENERIC_Key_F(bKeyPressed, bKeyHeld); + GENERIC_Key_F(bKeyPressed, bKeyHeld + ); break; case KEY_PTT: GENERIC_Key_PTT(bKeyPressed); diff --git a/app/menu.c b/app/menu.c index 5983dff..7b30c3d 100644 --- a/app/menu.c +++ b/app/menu.c @@ -17,8 +17,11 @@ #include #if !defined(ENABLE_OVERLAY) - #include "ARMCM0.h" + +#include "ARMCM0.h" + #endif + #include "app/dtmf.h" #include "app/generic.h" #include "app/menu.h" @@ -35,49 +38,50 @@ #include "helper/battery.h" #include "misc.h" #include "settings.h" + #if defined(ENABLE_OVERLAY) - #include "sram-overlay.h" +#include "sram-overlay.h" #endif + #include "ui/inputbox.h" #include "ui/menu.h" #include "ui/ui.h" #ifndef ARRAY_SIZE - #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) #endif uint8_t gUnlockAllTxConfCnt; #ifdef ENABLE_F_CAL_MENU - void writeXtalFreqCal(const int32_t value, const bool update_eeprom) +void writeXtalFreqCal(const int32_t value, const bool update_eeprom) +{ + BK4819_WriteRegister(BK4819_REG_3B, 22656 + value); + + if (update_eeprom) { - BK4819_WriteRegister(BK4819_REG_3B, 22656 + value); - - if (update_eeprom) + struct { - struct - { - int16_t BK4819_XtalFreqLow; - uint16_t EEPROM_1F8A; - uint16_t EEPROM_1F8C; - uint8_t VOLUME_GAIN; - uint8_t DAC_GAIN; - } __attribute__((packed)) misc; + int16_t BK4819_XtalFreqLow; + uint16_t EEPROM_1F8A; + uint16_t EEPROM_1F8C; + uint8_t VOLUME_GAIN; + uint8_t DAC_GAIN; + } __attribute__((packed)) misc; - gEeprom.BK4819_XTAL_FREQ_LOW = value; + gEeprom.BK4819_XTAL_FREQ_LOW = value; - // radio 1 .. 04 00 46 00 50 00 2C 0E - // radio 2 .. 05 00 46 00 50 00 2C 0E - // - EEPROM_ReadBuffer(0x1F88, &misc, 8); - misc.BK4819_XtalFreqLow = value; - EEPROM_WriteBuffer(0x1F88, &misc); - } + // radio 1 .. 04 00 46 00 50 00 2C 0E + // radio 2 .. 05 00 46 00 50 00 2C 0E + // + EEPROM_ReadBuffer(0x1F88, &misc, 8); + misc.BK4819_XtalFreqLow = value; + EEPROM_WriteBuffer(0x1F88, &misc); } +} #endif -void MENU_StartCssScan(void) -{ +void MENU_StartCssScan(void) { SCANNER_Start(true); gUpdateStatus = true; gCssBackgroundScan = true; @@ -85,12 +89,10 @@ void MENU_StartCssScan(void) gRequestDisplayScreen = DISPLAY_MENU; } -void MENU_CssScanFound(void) -{ - if(gScanCssResultType == CODE_TYPE_DIGITAL || gScanCssResultType == CODE_TYPE_REVERSE_DIGITAL) { +void MENU_CssScanFound(void) { + if (gScanCssResultType == CODE_TYPE_DIGITAL || gScanCssResultType == CODE_TYPE_REVERSE_DIGITAL) { gMenuCursor = UI_MENU_GetMenuIdx(MENU_R_DCS); - } - else if(gScanCssResultType == CODE_TYPE_CONTINUOUS_TONE) { + } else if (gScanCssResultType == CODE_TYPE_CONTINUOUS_TONE) { gMenuCursor = UI_MENU_GetMenuIdx(MENU_R_CTCS); } @@ -100,8 +102,7 @@ void MENU_CssScanFound(void) gUpdateDisplay = true; } -void MENU_StopCssScan(void) -{ +void MENU_StopCssScan(void) { gCssBackgroundScan = false; #ifdef ENABLE_VOICE @@ -111,12 +112,10 @@ void MENU_StopCssScan(void) gUpdateStatus = true; } -int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) -{ +int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) { *pMin = 0; - switch (menu_id) - { + switch (menu_id) { case MENU_SQL: //*pMin = 0; *pMax = 9; @@ -167,12 +166,12 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) *pMax = ARRAY_SIZE(gSubMenu_RXMode) - 1; break; - #ifdef ENABLE_VOICE +#ifdef ENABLE_VOICE case MENU_VOICE: //*pMin = 0; *pMax = ARRAY_SIZE(gSubMenu_VOICE) - 1; break; - #endif +#endif case MENU_SC_REV: //*pMin = 0; @@ -184,9 +183,9 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) *pMax = ARRAY_SIZE(gSubMenu_ROGER) - 1; break; - case MENU_PONMSG: + case MENU_FSKMOD: //*pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_PONMSG) - 1; + *pMax = ARRAY_SIZE(gSubMenu_FSKMod) - 1; break; case MENU_R_DCS: @@ -207,12 +206,12 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) *pMax = ARRAY_SIZE(gSubMenu_W_N) - 1; break; - #ifdef ENABLE_ALARM - case MENU_AL_MOD: - //*pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_AL_MOD) - 1; - break; - #endif +#ifdef ENABLE_ALARM + case MENU_AL_MOD: + //*pMin = 0; + *pMax = ARRAY_SIZE(gSubMenu_AL_MOD) - 1; + break; +#endif case MENU_RESET: //*pMin = 0; @@ -225,14 +224,14 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) *pMax = ARRAY_SIZE(gSubMenu_RX_TX) - 1; break; - #ifndef ENABLE_FEAT_F4HWN - #ifdef ENABLE_AM_FIX - case MENU_AM_FIX: - #endif - #endif - #ifdef ENABLE_AUDIO_BAR - case MENU_MIC_BAR: - #endif +#ifndef ENABLE_FEAT_F4HWN +#ifdef ENABLE_AM_FIX + case MENU_AM_FIX: +#endif +#endif +#ifdef ENABLE_AUDIO_BAR + case MENU_MIC_BAR: +#endif case MENU_BCL: case MENU_BEEP: case MENU_S_ADD1: @@ -244,18 +243,15 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) case MENU_D_DCD: #endif case MENU_D_LIVE_DEC: - #ifdef ENABLE_NOAA +#ifdef ENABLE_NOAA case MENU_NOAA_S: - #endif +#endif #ifndef ENABLE_FEAT_F4HWN - case MENU_350TX: - case MENU_200TX: - case MENU_500TX: + case MENU_350TX: + case MENU_200TX: + case MENU_500TX: #endif case MENU_350EN: -#ifndef ENABLE_FEAT_F4HWN - case MENU_SCREN: -#endif #ifdef ENABLE_FEAT_F4HWN case MENU_SET_TMR: #endif @@ -267,26 +263,29 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) *pMax = ARRAY_SIZE(gModulationStr) - 1; break; -#ifndef ENABLE_FEAT_F4HWN case MENU_SCR: //*pMin = 0; *pMax = ARRAY_SIZE(gSubMenu_SCRAMBLER) - 1; break; -#endif case MENU_AUTOLK: *pMax = 40; break; + case MENU_FSKSRC: + *pMax = INT32_MAX; + *pMin = 0; + break; + case MENU_TOT: //*pMin = 0; *pMin = 5; *pMax = 179; break; - #ifdef ENABLE_VOX - case MENU_VOX: - #endif +#ifdef ENABLE_VOX + case MENU_VOX: +#endif case MENU_RP_STE: //*pMin = 0; *pMax = 10; @@ -355,12 +354,12 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) *pMax = 16; break; #endif - #ifdef ENABLE_F_CAL_MENU +#ifdef ENABLE_F_CAL_MENU case MENU_F_CALI: *pMin = -50; *pMax = +50; break; - #endif +#endif case MENU_BATCAL: *pMin = 1600; @@ -378,7 +377,7 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) case MENU_F2LONG: case MENU_MLONG: //*pMin = 0; - *pMax = gSubMenu_SIDEFUNCTIONS_size-1; + *pMax = gSubMenu_SIDEFUNCTIONS_size - 1; break; #ifdef ENABLE_FEAT_F4HWN_SLEEP @@ -422,24 +421,24 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) //*pMin = 0; *pMax = ARRAY_SIZE(gSubMenu_SET_MET) - 1; break; - #ifdef ENABLE_FEAT_F4HWN_NARROWER - case MENU_SET_NFM: - //*pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_SET_NFM) - 1; - break; - #endif - #ifdef ENABLE_FEAT_F4HWN_VOL - case MENU_SET_VOL: - //*pMin = 0; - *pMax = 63; - break; - #endif - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS +#ifdef ENABLE_FEAT_F4HWN_NARROWER + case MENU_SET_NFM: + //*pMin = 0; + *pMax = ARRAY_SIZE(gSubMenu_SET_NFM) - 1; + break; +#endif +#ifdef ENABLE_FEAT_F4HWN_VOL + case MENU_SET_VOL: + //*pMin = 0; + *pMax = 63; + break; +#endif +#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS case MENU_SET_KEY: //*pMin = 0; *pMax = 4; break; - #endif +#endif #endif default: @@ -449,33 +448,28 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) return 0; } -void MENU_AcceptSetting(void) -{ - int32_t Min; - int32_t Max; +void MENU_AcceptSetting(void) { + int32_t Min; + int32_t Max; FREQ_Config_t *pConfig = &gTxVfo->freq_config_RX; - if (!MENU_GetLimits(UI_MENU_GetCurrentMenuId(), &Min, &Max)) - { + if (!MENU_GetLimits(UI_MENU_GetCurrentMenuId(), &Min, &Max)) { if (gSubMenuSelection < Min) gSubMenuSelection = Min; - else - if (gSubMenuSelection > Max) gSubMenuSelection = Max; + else if (gSubMenuSelection > Max) gSubMenuSelection = Max; } - switch (UI_MENU_GetCurrentMenuId()) - { + switch (UI_MENU_GetCurrentMenuId()) { default: return; case MENU_SQL: gEeprom.SQUELCH_LEVEL = gSubMenuSelection; - gVfoConfigureMode = VFO_CONFIGURE; + gVfoConfigureMode = VFO_CONFIGURE; break; case MENU_STEP: gTxVfo->STEP_SETTING = FREQUENCY_GetStepIdxFromSortedIdx(gSubMenuSelection); - if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) - { + if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) { gRequestSaveChannel = 1; } return; @@ -497,12 +491,10 @@ void MENU_AcceptSetting(void) } pConfig->Code = 0; pConfig->CodeType = CODE_TYPE_OFF; - } - else if (gSubMenuSelection < 105) { + } else if (gSubMenuSelection < 105) { pConfig->CodeType = CODE_TYPE_DIGITAL; pConfig->Code = gSubMenuSelection - 1; - } - else { + } else { pConfig->CodeType = CODE_TYPE_REVERSE_DIGITAL; pConfig->Code = gSubMenuSelection - 105; } @@ -518,11 +510,10 @@ void MENU_AcceptSetting(void) if (pConfig->CodeType != CODE_TYPE_CONTINUOUS_TONE) { return; } - pConfig->Code = 0; + pConfig->Code = 0; pConfig->CodeType = CODE_TYPE_OFF; - } - else { - pConfig->Code = gSubMenuSelection - 1; + } else { + pConfig->Code = gSubMenuSelection - 1; pConfig->CodeType = CODE_TYPE_CONTINUOUS_TONE; } @@ -531,47 +522,43 @@ void MENU_AcceptSetting(void) } case MENU_SFT_D: gTxVfo->TX_OFFSET_FREQUENCY_DIRECTION = gSubMenuSelection; - gRequestSaveChannel = 1; + gRequestSaveChannel = 1; return; case MENU_OFFSET: gTxVfo->TX_OFFSET_FREQUENCY = gSubMenuSelection; - gRequestSaveChannel = 1; + gRequestSaveChannel = 1; return; case MENU_W_N: gTxVfo->CHANNEL_BANDWIDTH = gSubMenuSelection; - gRequestSaveChannel = 1; + gRequestSaveChannel = 1; return; -#ifndef ENABLE_FEAT_F4HWN case MENU_SCR: gTxVfo->SCRAMBLING_TYPE = gSubMenuSelection; - #if 0 - if (gSubMenuSelection > 0 && gSetting_ScrambleEnable) - BK4819_EnableScramble(gSubMenuSelection - 1); - else - BK4819_DisableScramble(); - #endif - gRequestSaveChannel = 1; + if (gSubMenuSelection > 0) + BK4819_EnableScramble(gSubMenuSelection - 1); + else + BK4819_DisableScramble(); + gRequestSaveChannel = 1; return; -#endif case MENU_BCL: gTxVfo->BUSY_CHANNEL_LOCK = gSubMenuSelection; - gRequestSaveChannel = 1; + gRequestSaveChannel = 1; return; case MENU_MEM_CH: gTxVfo->CHANNEL_SAVE = gSubMenuSelection; - #if 0 - gEeprom.MrChannel[0] = gSubMenuSelection; - #else - gEeprom.MrChannel[gEeprom.TX_VFO] = gSubMenuSelection; - #endif +#if 0 + gEeprom.MrChannel[0] = gSubMenuSelection; +#else + gEeprom.MrChannel[gEeprom.TX_VFO] = gSubMenuSelection; +#endif gRequestSaveChannel = 2; - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; - gFlagResetVfos = true; + gVfoConfigureMode = VFO_CONFIGURE_RELOAD; + gFlagResetVfos = true; return; case MENU_MEM_NAME: @@ -588,27 +575,27 @@ void MENU_AcceptSetting(void) gEeprom.BATTERY_SAVE = gSubMenuSelection; break; - #ifdef ENABLE_VOX - case MENU_VOX: - gEeprom.VOX_SWITCH = gSubMenuSelection != 0; - if (gEeprom.VOX_SWITCH) - gEeprom.VOX_LEVEL = gSubMenuSelection - 1; - SETTINGS_LoadCalibration(); - gFlagReconfigureVfos = true; - gUpdateStatus = true; - break; - #endif +#ifdef ENABLE_VOX + case MENU_VOX: + gEeprom.VOX_SWITCH = gSubMenuSelection != 0; + if (gEeprom.VOX_SWITCH) + gEeprom.VOX_LEVEL = gSubMenuSelection - 1; + SETTINGS_LoadCalibration(); + gFlagReconfigureVfos = true; + gUpdateStatus = true; + break; +#endif case MENU_ABR: gEeprom.BACKLIGHT_TIME = gSubMenuSelection; - #ifdef ENABLE_FEAT_F4HWN - gBackLight = false; - #endif +#ifdef ENABLE_FEAT_F4HWN + gBackLight = false; +#endif break; case MENU_ABR_MIN: gEeprom.BACKLIGHT_MIN = gSubMenuSelection; - gEeprom.BACKLIGHT_MAX = MAX(gSubMenuSelection + 1 , gEeprom.BACKLIGHT_MAX); + gEeprom.BACKLIGHT_MAX = MAX(gSubMenuSelection + 1, gEeprom.BACKLIGHT_MAX); break; case MENU_ABR_MAX: @@ -624,14 +611,14 @@ void MENU_AcceptSetting(void) gEeprom.DUAL_WATCH = (gEeprom.TX_VFO + 1) * (gSubMenuSelection & 1); gEeprom.CROSS_BAND_RX_TX = (gEeprom.TX_VFO + 1) * ((gSubMenuSelection & 2) > 0); - #ifdef ENABLE_FEAT_F4HWN - gDW = gEeprom.DUAL_WATCH; - gCB = gEeprom.CROSS_BAND_RX_TX; - gSaveRxMode = true; - #endif +#ifdef ENABLE_FEAT_F4HWN + gDW = gEeprom.DUAL_WATCH; + gCB = gEeprom.CROSS_BAND_RX_TX; + gSaveRxMode = true; +#endif gFlagReconfigureVfos = true; - gUpdateStatus = true; + gUpdateStatus = true; break; case MENU_BEEP: @@ -642,12 +629,12 @@ void MENU_AcceptSetting(void) gEeprom.TX_TIMEOUT_TIMER = gSubMenuSelection; break; - #ifdef ENABLE_VOICE +#ifdef ENABLE_VOICE case MENU_VOICE: gEeprom.VOICE_PROMPT = gSubMenuSelection; gUpdateStatus = true; break; - #endif +#endif case MENU_SC_REV: gEeprom.SCAN_RESUME_MODE = gSubMenuSelection; @@ -659,28 +646,28 @@ void MENU_AcceptSetting(void) case MENU_AUTOLK: gEeprom.AUTO_KEYPAD_LOCK = gSubMenuSelection; - gKeyLockCountdown = gEeprom.AUTO_KEYPAD_LOCK * 30; // 15 seconds step + gKeyLockCountdown = gEeprom.AUTO_KEYPAD_LOCK * 30; // 15 seconds step break; case MENU_S_ADD1: gTxVfo->SCANLIST1_PARTICIPATION = gSubMenuSelection; SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true, false, true); gVfoConfigureMode = VFO_CONFIGURE; - gFlagResetVfos = true; + gFlagResetVfos = true; return; case MENU_S_ADD2: gTxVfo->SCANLIST2_PARTICIPATION = gSubMenuSelection; SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true, false, true); gVfoConfigureMode = VFO_CONFIGURE; - gFlagResetVfos = true; + gFlagResetVfos = true; return; case MENU_S_ADD3: gTxVfo->SCANLIST3_PARTICIPATION = gSubMenuSelection; SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true, false, true); gVfoConfigureMode = VFO_CONFIGURE; - gFlagResetVfos = true; + gFlagResetVfos = true; return; case MENU_STE: @@ -697,17 +684,17 @@ void MENU_AcceptSetting(void) gFlagReconfigureVfos = true; break; - #ifdef ENABLE_AUDIO_BAR - case MENU_MIC_BAR: - gSetting_mic_bar = gSubMenuSelection; - break; - #endif +#ifdef ENABLE_AUDIO_BAR + case MENU_MIC_BAR: + gSetting_mic_bar = gSubMenuSelection; + break; +#endif case MENU_COMPAND: gTxVfo->Compander = gSubMenuSelection; SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true, false, true); gVfoConfigureMode = VFO_CONFIGURE; - gFlagResetVfos = true; + gFlagResetVfos = true; // gRequestSaveChannel = 1; return; @@ -719,11 +706,11 @@ void MENU_AcceptSetting(void) gEeprom.SCAN_LIST_DEFAULT = gSubMenuSelection; break; - #ifdef ENABLE_ALARM - case MENU_AL_MOD: - gEeprom.ALARM_MODE = gSubMenuSelection; - break; - #endif +#ifdef ENABLE_ALARM + case MENU_AL_MOD: + gEeprom.ALARM_MODE = gSubMenuSelection; + break; +#endif case MENU_D_ST: gEeprom.DTMF_SIDE_TONE = gSubMenuSelection; @@ -744,7 +731,7 @@ void MENU_AcceptSetting(void) case MENU_PTT_ID: gTxVfo->DTMF_PTT_ID_TX_MODE = gSubMenuSelection; - gRequestSaveChannel = 1; + gRequestSaveChannel = 1; return; case MENU_BAT_TXT: @@ -765,25 +752,28 @@ void MENU_AcceptSetting(void) memset(gDTMF_RX_live, 0, sizeof(gDTMF_RX_live)); if (!gSetting_live_DTMF_decoder) BK4819_DisableDTMF(); - gFlagReconfigureVfos = true; - gUpdateStatus = true; + gFlagReconfigureVfos = true; + gUpdateStatus = true; break; #ifdef ENABLE_DTMF_CALLING case MENU_D_LIST: gDTMF_chosen_contact = gSubMenuSelection - 1; - if (gIsDtmfContactValid) - { + if (gIsDtmfContactValid) { GUI_SelectNextDisplay(DISPLAY_MAIN); - gDTMF_InputMode = true; - gDTMF_InputBox_Index = 3; + gDTMF_InputMode = true; + gDTMF_InputBox_Index = 3; memcpy(gDTMF_InputBox, gDTMF_ID, 4); gRequestDisplayScreen = DISPLAY_INVALID; } return; #endif - case MENU_PONMSG: - gEeprom.POWER_ON_DISPLAY_MODE = gSubMenuSelection; + case MENU_FSKMOD: + gEeprom.FSKMode = gSubMenuSelection; + break; + + case MENU_FSKSRC: + gEeprom.FSKSRCAddress = gSubMenuSelection; break; case MENU_ROGER: @@ -791,31 +781,31 @@ void MENU_AcceptSetting(void) break; case MENU_AM: - gTxVfo->Modulation = gSubMenuSelection; + gTxVfo->Modulation = gSubMenuSelection; gRequestSaveChannel = 1; return; - #ifndef ENABLE_FEAT_F4HWN - #ifdef ENABLE_AM_FIX - case MENU_AM_FIX: - gSetting_AM_fix = gSubMenuSelection; - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; - gFlagResetVfos = true; - break; - #endif - #endif +#ifndef ENABLE_FEAT_F4HWN +#ifdef ENABLE_AM_FIX + case MENU_AM_FIX: + gSetting_AM_fix = gSubMenuSelection; + gVfoConfigureMode = VFO_CONFIGURE_RELOAD; + gFlagResetVfos = true; + break; +#endif +#endif - #ifdef ENABLE_NOAA +#ifdef ENABLE_NOAA case MENU_NOAA_S: gEeprom.NOAA_AUTO_SCAN = gSubMenuSelection; gFlagReconfigureVfos = true; break; - #endif +#endif case MENU_DEL_CH: SETTINGS_UpdateChannel(gSubMenuSelection, NULL, false, false, true); gVfoConfigureMode = VFO_CONFIGURE_RELOAD; - gFlagResetVfos = true; + gFlagResetVfos = true; return; case MENU_RESET: @@ -823,66 +813,51 @@ void MENU_AcceptSetting(void) return; #ifndef ENABLE_FEAT_F4HWN - case MENU_350TX: - gSetting_350TX = gSubMenuSelection; - break; + case MENU_350TX: + gSetting_350TX = gSubMenuSelection; + break; #endif case MENU_F_LOCK: { - if(gSubMenuSelection == F_LOCK_NONE) { // select 10 times to enable - gUnlockAllTxConfCnt++; -#ifdef ENABLE_FEAT_F4HWN - if(gUnlockAllTxConfCnt < 3) -#else - if(gUnlockAllTxConfCnt < 10) -#endif - return; - } - else - gUnlockAllTxConfCnt = 0; - gSetting_F_LOCK = gSubMenuSelection; - #ifdef ENABLE_FEAT_F4HWN - if(gSetting_F_LOCK == F_LOCK_ALL) { +#ifdef ENABLE_FEAT_F4HWN + if (gSetting_F_LOCK == F_LOCK_ALL) { SETTINGS_ResetTxLock(); } - #endif +#endif break; } #ifndef ENABLE_FEAT_F4HWN - case MENU_200TX: - gSetting_200TX = gSubMenuSelection; - break; + case MENU_200TX: + gSetting_200TX = gSubMenuSelection; + break; - case MENU_500TX: - gSetting_500TX = gSubMenuSelection; - break; + case MENU_500TX: + gSetting_500TX = gSubMenuSelection; + break; #endif case MENU_350EN: - gSetting_350EN = gSubMenuSelection; - gVfoConfigureMode = VFO_CONFIGURE_RELOAD; - gFlagResetVfos = true; + gSetting_350EN = gSubMenuSelection; + gVfoConfigureMode = VFO_CONFIGURE_RELOAD; + gFlagResetVfos = true; break; -#ifndef ENABLE_FEAT_F4HWN - case MENU_SCREN: - gSetting_ScrambleEnable = gSubMenuSelection; - gFlagReconfigureVfos = true; - break; -#endif +// case MENU_SCREN: +// gSetting_ScrambleEnable = gSubMenuSelection; +// gFlagReconfigureVfos = true; +// break; - #ifdef ENABLE_F_CAL_MENU +#ifdef ENABLE_F_CAL_MENU case MENU_F_CALI: writeXtalFreqCal(gSubMenuSelection, true); return; - #endif +#endif - case MENU_BATCAL: - { // voltages are averages between discharge curves of 1600 and 2200 mAh + case MENU_BATCAL: { // voltages are averages between discharge curves of 1600 and 2200 mAh // gBatteryCalibration[0] = (520ul * gSubMenuSelection) / 760; // 5.20V empty, blinking above this value, reduced functionality below // gBatteryCalibration[1] = (689ul * gSubMenuSelection) / 760; // 6.89V, ~5%, 1 bars above this value // gBatteryCalibration[2] = (724ul * gSubMenuSelection) / 760; // 7.24V, ~17%, 2 bars above this value - gBatteryCalibration[3] = gSubMenuSelection; // 7.6V, ~29%, 3 bars above this value + gBatteryCalibration[3] = gSubMenuSelection; // 7.6V, ~29%, 3 bars above this value // gBatteryCalibration[4] = (771ul * gSubMenuSelection) / 760; // 7.71V, ~65%, 4 bars above this value // gBatteryCalibration[5] = 2300; SETTINGS_SaveBatteryCalibration(gBatteryCalibration); @@ -897,19 +872,18 @@ void MENU_AcceptSetting(void) case MENU_F1LONG: case MENU_F2SHRT: case MENU_F2LONG: - case MENU_MLONG: - { - uint8_t * fun[]= { + case MENU_MLONG: { + uint8_t *fun[] = { &gEeprom.KEY_1_SHORT_PRESS_ACTION, &gEeprom.KEY_1_LONG_PRESS_ACTION, &gEeprom.KEY_2_SHORT_PRESS_ACTION, &gEeprom.KEY_2_LONG_PRESS_ACTION, &gEeprom.KEY_M_LONG_PRESS_ACTION}; - *fun[UI_MENU_GetCurrentMenuId()-MENU_F1SHRT] = gSubMenu_SIDEFUNCTIONS[gSubMenuSelection].id; - } + *fun[UI_MENU_GetCurrentMenuId() - MENU_F1SHRT] = gSubMenu_SIDEFUNCTIONS[gSubMenuSelection].id; + } break; -#ifdef ENABLE_FEAT_F4HWN_SLEEP +#ifdef ENABLE_FEAT_F4HWN_SLEEP case MENU_SET_OFF: gSetting_set_off = gSubMenuSelection; break; @@ -947,29 +921,29 @@ void MENU_AcceptSetting(void) case MENU_SET_GUI: gSetting_set_gui = gSubMenuSelection; break; - #ifdef ENABLE_FEAT_F4HWN_NARROWER - case MENU_SET_NFM: - gSetting_set_nfm = gSubMenuSelection; - RADIO_SetTxParameters(); - RADIO_SetupRegisters(true); - break; - #endif - #ifdef ENABLE_FEAT_F4HWN_VOL - case MENU_SET_VOL: - gEeprom.VOLUME_GAIN = gSubMenuSelection; - break; - #endif - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS +#ifdef ENABLE_FEAT_F4HWN_NARROWER + case MENU_SET_NFM: + gSetting_set_nfm = gSubMenuSelection; + RADIO_SetTxParameters(); + RADIO_SetupRegisters(true); + break; +#endif +#ifdef ENABLE_FEAT_F4HWN_VOL + case MENU_SET_VOL: + gEeprom.VOLUME_GAIN = gSubMenuSelection; + break; +#endif +#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS case MENU_SET_KEY: gEeprom.SET_KEY = gSubMenuSelection; break; - #endif +#endif case MENU_SET_TMR: gSetting_set_tmr = gSubMenuSelection; break; case MENU_TX_LOCK: gTxVfo->TX_LOCK = gSubMenuSelection; - gRequestSaveChannel = 1; + gRequestSaveChannel = 1; return; #endif } @@ -977,25 +951,20 @@ void MENU_AcceptSetting(void) gRequestSaveSettings = true; } -static void MENU_ClampSelection(int8_t Direction) -{ +static void MENU_ClampSelection(int8_t Direction) { int32_t Min; int32_t Max; - if (!MENU_GetLimits(UI_MENU_GetCurrentMenuId(), &Min, &Max)) - { + if (!MENU_GetLimits(UI_MENU_GetCurrentMenuId(), &Min, &Max)) { int32_t Selection = gSubMenuSelection; if (Selection < Min) Selection = Min; - else - if (Selection > Max) Selection = Max; + else if (Selection > Max) Selection = Max; gSubMenuSelection = NUMBER_AddWithWraparound(Selection, Direction, Min, Max); } } -void MENU_ShowCurrentSetting(void) -{ - switch (UI_MENU_GetCurrentMenuId()) - { +void MENU_ShowCurrentSetting(void) { + switch (UI_MENU_GetCurrentMenuId()) { case MENU_SQL: gSubMenuSelection = gEeprom.SQUELCH_LEVEL; break; @@ -1013,18 +982,17 @@ void MENU_ShowCurrentSetting(void) break; case MENU_R_DCS: - case MENU_R_CTCS: - { + case MENU_R_CTCS: { DCS_CodeType_t type = gTxVfo->freq_config_RX.CodeType; uint8_t code = gTxVfo->freq_config_RX.Code; int menuid = UI_MENU_GetCurrentMenuId(); - if(gScanUseCssResult) { + if (gScanUseCssResult) { gScanUseCssResult = false; type = gScanCssResultType; code = gScanCssResultCode; } - if((menuid==MENU_R_CTCS) ^ (type==CODE_TYPE_CONTINUOUS_TONE)) { //not the same type + if ((menuid == MENU_R_CTCS) ^ (type == CODE_TYPE_CONTINUOUS_TONE)) { //not the same type gSubMenuSelection = 0; break; } @@ -1041,12 +1009,11 @@ void MENU_ShowCurrentSetting(void) gSubMenuSelection = 0; break; } - break; + break; } case MENU_T_DCS: - switch (gTxVfo->freq_config_TX.CodeType) - { + switch (gTxVfo->freq_config_TX.CodeType) { case CODE_TYPE_DIGITAL: gSubMenuSelection = gTxVfo->freq_config_TX.Code + 1; break; @@ -1060,7 +1027,8 @@ void MENU_ShowCurrentSetting(void) break; case MENU_T_CTCS: - gSubMenuSelection = (gTxVfo->freq_config_TX.CodeType == CODE_TYPE_CONTINUOUS_TONE) ? gTxVfo->freq_config_TX.Code + 1 : 0; + gSubMenuSelection = (gTxVfo->freq_config_TX.CodeType == CODE_TYPE_CONTINUOUS_TONE) ? + gTxVfo->freq_config_TX.Code + 1 : 0; break; case MENU_SFT_D: @@ -1075,22 +1043,20 @@ void MENU_ShowCurrentSetting(void) gSubMenuSelection = gTxVfo->CHANNEL_BANDWIDTH; break; -#ifndef ENABLE_FEAT_F4HWN case MENU_SCR: gSubMenuSelection = gTxVfo->SCRAMBLING_TYPE; break; -#endif case MENU_BCL: gSubMenuSelection = gTxVfo->BUSY_CHANNEL_LOCK; break; case MENU_MEM_CH: - #if 0 - gSubMenuSelection = gEeprom.MrChannel[0]; - #else - gSubMenuSelection = gEeprom.MrChannel[gEeprom.TX_VFO]; - #endif +#if 0 + gSubMenuSelection = gEeprom.MrChannel[0]; +#else + gSubMenuSelection = gEeprom.MrChannel[gEeprom.TX_VFO]; +#endif break; case MENU_MEM_NAME: @@ -1108,18 +1074,15 @@ void MENU_ShowCurrentSetting(void) #endif case MENU_ABR: - #ifdef ENABLE_FEAT_F4HWN - if(gBackLight) - { - gSubMenuSelection = gBacklightTimeOriginal; - } - else - { - gSubMenuSelection = gEeprom.BACKLIGHT_TIME; - } - #else +#ifdef ENABLE_FEAT_F4HWN + if (gBackLight) { + gSubMenuSelection = gBacklightTimeOriginal; + } else { gSubMenuSelection = gEeprom.BACKLIGHT_TIME; - #endif + } +#else + gSubMenuSelection = gEeprom.BACKLIGHT_TIME; +#endif break; case MENU_ABR_MIN: @@ -1135,7 +1098,8 @@ void MENU_ShowCurrentSetting(void) break; case MENU_TDR: - gSubMenuSelection = (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2; + gSubMenuSelection = + (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF) + (gEeprom.CROSS_BAND_RX_TX != CROSS_BAND_OFF) * 2; break; case MENU_BEEP: @@ -1147,9 +1111,9 @@ void MENU_ShowCurrentSetting(void) break; #ifdef ENABLE_VOICE - case MENU_VOICE: - gSubMenuSelection = gEeprom.VOICE_PROMPT; - break; + case MENU_VOICE: + gSubMenuSelection = gEeprom.VOICE_PROMPT; + break; #endif case MENU_SC_REV: @@ -1212,11 +1176,11 @@ void MENU_ShowCurrentSetting(void) gSubMenuSelection = RADIO_FindNextChannel(0, 1, true, UI_MENU_GetCurrentMenuId() - MENU_SLIST1 + 1); break; - #ifdef ENABLE_ALARM - case MENU_AL_MOD: - gSubMenuSelection = gEeprom.ALARM_MODE; - break; - #endif +#ifdef ENABLE_ALARM + case MENU_AL_MOD: + gSubMenuSelection = gEeprom.ALARM_MODE; + break; +#endif case MENU_D_ST: gSubMenuSelection = gEeprom.DTMF_SIDE_TONE; @@ -1256,8 +1220,12 @@ void MENU_ShowCurrentSetting(void) gSubMenuSelection = gSetting_live_DTMF_decoder; break; - case MENU_PONMSG: - gSubMenuSelection = gEeprom.POWER_ON_DISPLAY_MODE; + case MENU_FSKMOD: + gSubMenuSelection = gEeprom.FSKMode; + break; + + case MENU_FSKSRC: + gSubMenuSelection = (int32_t) gEeprom.FSKSRCAddress; break; case MENU_ROGER: @@ -1269,31 +1237,31 @@ void MENU_ShowCurrentSetting(void) break; #ifndef ENABLE_FEAT_F4HWN - #ifdef ENABLE_AM_FIX +#ifdef ENABLE_AM_FIX case MENU_AM_FIX: gSubMenuSelection = gSetting_AM_fix; break; - #endif #endif - - #ifdef ENABLE_NOAA +#endif + +#ifdef ENABLE_NOAA case MENU_NOAA_S: gSubMenuSelection = gEeprom.NOAA_AUTO_SCAN; break; - #endif +#endif case MENU_DEL_CH: - #if 0 - gSubMenuSelection = RADIO_FindNextChannel(gEeprom.MrChannel[0], 1, false, 1); - #else - gSubMenuSelection = RADIO_FindNextChannel(gEeprom.MrChannel[gEeprom.TX_VFO], 1, false, 1); - #endif +#if 0 + gSubMenuSelection = RADIO_FindNextChannel(gEeprom.MrChannel[0], 1, false, 1); +#else + gSubMenuSelection = RADIO_FindNextChannel(gEeprom.MrChannel[gEeprom.TX_VFO], 1, false, 1); +#endif break; #ifndef ENABLE_FEAT_F4HWN - case MENU_350TX: - gSubMenuSelection = gSetting_350TX; - break; + case MENU_350TX: + gSubMenuSelection = gSetting_350TX; + break; #endif case MENU_F_LOCK: @@ -1301,30 +1269,21 @@ void MENU_ShowCurrentSetting(void) break; #ifndef ENABLE_FEAT_F4HWN - case MENU_200TX: - gSubMenuSelection = gSetting_200TX; - break; + case MENU_200TX: + gSubMenuSelection = gSetting_200TX; + break; - case MENU_500TX: - gSubMenuSelection = gSetting_500TX; - break; + case MENU_500TX: + gSubMenuSelection = gSetting_500TX; + break; #endif - case MENU_350EN: - gSubMenuSelection = gSetting_350EN; - break; -#ifndef ENABLE_FEAT_F4HWN - case MENU_SCREN: - gSubMenuSelection = gSetting_ScrambleEnable; - break; -#endif - - #ifdef ENABLE_F_CAL_MENU +#ifdef ENABLE_F_CAL_MENU case MENU_F_CALI: gSubMenuSelection = gEeprom.BK4819_XTAL_FREQ_LOW; break; - #endif +#endif case MENU_BATCAL: gSubMenuSelection = gBatteryCalibration[3]; @@ -1338,18 +1297,17 @@ void MENU_ShowCurrentSetting(void) case MENU_F1LONG: case MENU_F2SHRT: case MENU_F2LONG: - case MENU_MLONG: - { - uint8_t * fun[]= { - &gEeprom.KEY_1_SHORT_PRESS_ACTION, - &gEeprom.KEY_1_LONG_PRESS_ACTION, - &gEeprom.KEY_2_SHORT_PRESS_ACTION, - &gEeprom.KEY_2_LONG_PRESS_ACTION, - &gEeprom.KEY_M_LONG_PRESS_ACTION}; - uint8_t id = *fun[UI_MENU_GetCurrentMenuId()-MENU_F1SHRT]; + case MENU_MLONG: { + uint8_t *fun[] = { + &gEeprom.KEY_1_SHORT_PRESS_ACTION, + &gEeprom.KEY_1_LONG_PRESS_ACTION, + &gEeprom.KEY_2_SHORT_PRESS_ACTION, + &gEeprom.KEY_2_LONG_PRESS_ACTION, + &gEeprom.KEY_M_LONG_PRESS_ACTION}; + uint8_t id = *fun[UI_MENU_GetCurrentMenuId() - MENU_F1SHRT]; - for(int i = 0; i < gSubMenu_SIDEFUNCTIONS_size; i++) { - if(gSubMenu_SIDEFUNCTIONS[i].id==id) { + for (int i = 0; i < gSubMenu_SIDEFUNCTIONS_size; i++) { + if (gSubMenu_SIDEFUNCTIONS[i].id == id) { gSubMenuSelection = i; break; } @@ -1358,7 +1316,7 @@ void MENU_ShowCurrentSetting(void) break; } -#ifdef ENABLE_FEAT_F4HWN_SLEEP +#ifdef ENABLE_FEAT_F4HWN_SLEEP case MENU_SET_OFF: gSubMenuSelection = gSetting_set_off; break; @@ -1394,21 +1352,21 @@ void MENU_ShowCurrentSetting(void) case MENU_SET_GUI: gSubMenuSelection = gSetting_set_gui; break; - #ifdef ENABLE_FEAT_F4HWN_NARROWER - case MENU_SET_NFM: - gSubMenuSelection = gSetting_set_nfm; - break; - #endif - #ifdef ENABLE_FEAT_F4HWN_VOL - case MENU_SET_VOL: - gSubMenuSelection = gEeprom.VOLUME_GAIN; - break; - #endif - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS +#ifdef ENABLE_FEAT_F4HWN_NARROWER + case MENU_SET_NFM: + gSubMenuSelection = gSetting_set_nfm; + break; +#endif +#ifdef ENABLE_FEAT_F4HWN_VOL + case MENU_SET_VOL: + gSubMenuSelection = gEeprom.VOLUME_GAIN; + break; +#endif +#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS case MENU_SET_KEY: gSubMenuSelection = gEeprom.SET_KEY; break; - #endif +#endif case MENU_SET_TMR: gSubMenuSelection = gSetting_set_tmr; break; @@ -1422,11 +1380,10 @@ void MENU_ShowCurrentSetting(void) } } -static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) -{ - uint8_t Offset; - int32_t Min; - int32_t Max; +static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { + uint8_t Offset; + int32_t Min; + int32_t Max; uint16_t Value = 0; if (bKeyHeld || !bKeyPressed) @@ -1434,18 +1391,14 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; - if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && edit_index >= 0) - { // currently editing the channel name + if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && edit_index >= 0) { // currently editing the channel name - if (edit_index < 10) - { - if (Key <= KEY_9) - { + if (edit_index < 10) { + if (Key <= KEY_9) { edit[edit_index] = '0' + Key - KEY_0; - if (++edit_index >= 10) - { // exit edit - gFlagAcceptSetting = false; + if (++edit_index >= 10) { // exit edit + gFlagAcceptSetting = false; gAskForConfirmation = 1; } @@ -1460,18 +1413,15 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) gRequestDisplayScreen = DISPLAY_MENU; - if (!gIsInSubMenu) - { - switch (gInputBoxIndex) - { + if (!gIsInSubMenu) { + switch (gInputBoxIndex) { case 2: gInputBoxIndex = 0; Value = (gInputBox[0] * 10) + gInputBox[1]; - if (Value > 0 && Value <= gMenuListCount) - { - gMenuCursor = Value - 1; + if (Value > 0 && Value <= gMenuListCount) { + gMenuCursor = Value - 1; gFlagRefreshSetting = true; return; } @@ -1479,14 +1429,13 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (Value <= gMenuListCount) break; - gInputBox[0] = gInputBox[1]; + gInputBox[0] = gInputBox[1]; gInputBoxIndex = 1; [[fallthrough]]; case 1: Value = gInputBox[0]; - if (Value > 0 && Value <= gMenuListCount) - { - gMenuCursor = Value - 1; + if (Value > 0 && Value <= gMenuListCount) { + gMenuCursor = Value - 1; gFlagRefreshSetting = true; return; } @@ -1499,23 +1448,21 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) return; } - if (UI_MENU_GetCurrentMenuId() == MENU_OFFSET) - { + if (UI_MENU_GetCurrentMenuId() == MENU_OFFSET) { uint32_t Frequency; - if (gInputBoxIndex < 6) - { // invalid frequency - #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; - #endif + if (gInputBoxIndex < 6) { // invalid frequency +#ifdef ENABLE_VOICE + gAnotherVoiceID = (VOICE_ID_t)Key; +#endif return; } - #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; - #endif +#ifdef ENABLE_VOICE + gAnotherVoiceID = (VOICE_ID_t)Key; +#endif - Frequency = StrToUL(INPUTBOX_GetAscii())*100; + Frequency = StrToUL(INPUTBOX_GetAscii()) * 100; gSubMenuSelection = FREQUENCY_RoundToStep(Frequency, gTxVfo->StepFrequency); gInputBoxIndex = 0; @@ -1525,14 +1472,12 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (UI_MENU_GetCurrentMenuId() == MENU_MEM_CH || UI_MENU_GetCurrentMenuId() == MENU_DEL_CH || UI_MENU_GetCurrentMenuId() == MENU_1_CALL || - UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME) - { // enter 3-digit channel number + UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME) { // enter 3-digit channel number - if (gInputBoxIndex < 3) - { - #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; - #endif + if (gInputBoxIndex < 3) { +#ifdef ENABLE_VOICE + gAnotherVoiceID = (VOICE_ID_t)Key; +#endif gRequestDisplayScreen = DISPLAY_MENU; return; } @@ -1541,11 +1486,10 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) Value = ((gInputBox[0] * 100) + (gInputBox[1] * 10) + gInputBox[2]) - 1; - if (IS_MR_CHANNEL(Value)) - { - #ifdef ENABLE_VOICE - gAnotherVoiceID = (VOICE_ID_t)Key; - #endif + if (IS_MR_CHANNEL(Value)) { +#ifdef ENABLE_VOICE + gAnotherVoiceID = (VOICE_ID_t)Key; +#endif gSubMenuSelection = Value; return; } @@ -1554,8 +1498,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) return; } - if (MENU_GetLimits(UI_MENU_GetCurrentMenuId(), &Min, &Max)) - { + if (MENU_GetLimits(UI_MENU_GetCurrentMenuId(), &Min, &Max)) { gInputBoxIndex = 0; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; @@ -1585,8 +1528,7 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) if (Offset == gInputBoxIndex) gInputBoxIndex = 0; - if (Value <= Max) - { + if (Value <= Max) { gSubMenuSelection = Value; return; } @@ -1594,33 +1536,28 @@ static void MENU_Key_0_to_9(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; } -static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld) -{ +static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld) { if (bKeyHeld || !bKeyPressed) return; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; - if (!gCssBackgroundScan) - { + if (!gCssBackgroundScan) { /* Backlight related menus set full brightness. Set it back to the configured value, just in case we are exiting from one of them. */ BACKLIGHT_TurnOn(); - if (gIsInSubMenu) - { - if (gInputBoxIndex == 0 || UI_MENU_GetCurrentMenuId() != MENU_OFFSET) - { + if (gIsInSubMenu) { + if (gInputBoxIndex == 0 || UI_MENU_GetCurrentMenuId() != MENU_OFFSET) { gAskForConfirmation = 0; - gIsInSubMenu = false; - gInputBoxIndex = 0; + gIsInSubMenu = false; + gInputBoxIndex = 0; gFlagRefreshSetting = true; - #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_CANCEL; - #endif - } - else +#ifdef ENABLE_VOICE + gAnotherVoiceID = VOICE_ID_CANCEL; +#endif + } else gInputBox[--gInputBoxIndex] = 10; // *********************** @@ -1629,9 +1566,9 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld) return; } - #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_CANCEL; - #endif +#ifdef ENABLE_VOICE + gAnotherVoiceID = VOICE_ID_CANCEL; +#endif gRequestDisplayScreen = DISPLAY_MAIN; @@ -1639,14 +1576,12 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld) { BACKLIGHT_TurnOff(); // turn the backlight OFF } - } - else - { + } else { MENU_StopCssScan(); - #ifdef ENABLE_VOICE - gAnotherVoiceID = VOICE_ID_SCANNING_STOP; - #endif +#ifdef ENABLE_VOICE + gAnotherVoiceID = VOICE_ID_SCANNING_STOP; +#endif gRequestDisplayScreen = DISPLAY_MENU; } @@ -1654,49 +1589,45 @@ static void MENU_Key_EXIT(bool bKeyPressed, bool bKeyHeld) gPttWasReleased = true; } -static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) -{ +static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) { if (bKeyHeld || !bKeyPressed) return; - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gRequestDisplayScreen = DISPLAY_MENU; - if (!gIsInSubMenu) - { - #ifdef ENABLE_VOICE - if (UI_MENU_GetCurrentMenuId() != MENU_SCR) - gAnotherVoiceID = MenuList[gMenuCursor].voice_id; - #endif - if (UI_MENU_GetCurrentMenuId() == MENU_UPCODE - || UI_MENU_GetCurrentMenuId() == MENU_DWCODE -#ifdef ENABLE_DTMF_CALLING + if (!gIsInSubMenu) { +#ifdef ENABLE_VOICE + if (UI_MENU_GetCurrentMenuId() != MENU_SCR) + gAnotherVoiceID = MenuList[gMenuCursor].voice_id; +#endif + if (UI_MENU_GetCurrentMenuId() == MENU_UPCODE + || UI_MENU_GetCurrentMenuId() == MENU_DWCODE + #ifdef ENABLE_DTMF_CALLING || UI_MENU_GetCurrentMenuId() == MENU_ANI_ID #endif - ) + ) return; - #if 1 - if (UI_MENU_GetCurrentMenuId() == MENU_DEL_CH || UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME) - if (!RADIO_CheckValidChannel(gSubMenuSelection, false, 0)) - return; // invalid channel - #endif +#if 1 + if (UI_MENU_GetCurrentMenuId() == MENU_DEL_CH || UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME) + if (!RADIO_CheckValidChannel(gSubMenuSelection, false, 0)) + return; // invalid channel +#endif gAskForConfirmation = 0; - gIsInSubMenu = true; + gIsInSubMenu = true; // if (UI_MENU_GetCurrentMenuId() != MENU_D_LIST) { - gInputBoxIndex = 0; - edit_index = -1; + gInputBoxIndex = 0; + edit_index = -1; } return; } - if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME) - { - if (edit_index < 0) - { // enter channel name edit mode + if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME) { + if (edit_index < 0) { // enter channel name edit mode if (!RADIO_CheckValidChannel(gSubMenuSelection, false, 0)) return; @@ -1713,16 +1644,13 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) memcpy(edit_original, edit, sizeof(edit_original)); return; - } - else - if (edit_index >= 0 && edit_index < 10) - { // editing the channel name characters + } else if (edit_index >= 0 && edit_index < 10) { // editing the channel name characters if (++edit_index < 10) return; // next char // exit - gFlagAcceptSetting = false; + gFlagAcceptSetting = false; gAskForConfirmation = 0; if (memcmp(edit_original, edit, sizeof(edit_original)) == 0) { // no change - drop it @@ -1733,15 +1661,12 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) // exiting the sub menu - if (gIsInSubMenu) - { - if (UI_MENU_GetCurrentMenuId() == MENU_RESET || + if (gIsInSubMenu) { + if (UI_MENU_GetCurrentMenuId() == MENU_RESET || UI_MENU_GetCurrentMenuId() == MENU_MEM_CH || UI_MENU_GetCurrentMenuId() == MENU_DEL_CH || - UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME) - { - switch (gAskForConfirmation) - { + UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME) { + switch (gAskForConfirmation) { case 0: gAskForConfirmation = 1; break; @@ -1751,63 +1676,56 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) UI_DisplayMenu(); - if (UI_MENU_GetCurrentMenuId() == MENU_RESET) - { - #ifdef ENABLE_VOICE - AUDIO_SetVoiceID(0, VOICE_ID_CONFIRM); - AUDIO_PlaySingleVoice(true); - #endif + if (UI_MENU_GetCurrentMenuId() == MENU_RESET) { +#ifdef ENABLE_VOICE + AUDIO_SetVoiceID(0, VOICE_ID_CONFIRM); + AUDIO_PlaySingleVoice(true); +#endif MENU_AcceptSetting(); - #if defined(ENABLE_OVERLAY) - overlay_FLASH_RebootToBootloader(); - #else - NVIC_SystemReset(); - #endif +#if defined(ENABLE_OVERLAY) + overlay_FLASH_RebootToBootloader(); +#else + NVIC_SystemReset(); +#endif } - gFlagAcceptSetting = true; - gIsInSubMenu = false; + gFlagAcceptSetting = true; + gIsInSubMenu = false; gAskForConfirmation = 0; } - } - else - { + } else { gFlagAcceptSetting = true; - gIsInSubMenu = false; + gIsInSubMenu = false; } } SCANNER_Stop(); - #ifdef ENABLE_VOICE - if (UI_MENU_GetCurrentMenuId() == MENU_SCR) - gAnotherVoiceID = (gSubMenuSelection == 0) ? VOICE_ID_SCRAMBLER_OFF : VOICE_ID_SCRAMBLER_ON; - else - gAnotherVoiceID = VOICE_ID_CONFIRM; - #endif +#ifdef ENABLE_VOICE + if (UI_MENU_GetCurrentMenuId() == MENU_SCR) + gAnotherVoiceID = (gSubMenuSelection == 0) ? VOICE_ID_SCRAMBLER_OFF : VOICE_ID_SCRAMBLER_ON; + else + gAnotherVoiceID = VOICE_ID_CONFIRM; +#endif gInputBoxIndex = 0; } -static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld) -{ +static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld) { if (bKeyHeld || !bKeyPressed) return; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; - if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && edit_index >= 0) - { // currently editing the channel name + if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && edit_index >= 0) { // currently editing the channel name - if (edit_index < 10) - { + if (edit_index < 10) { edit[edit_index] = '-'; - if (++edit_index >= 10) - { // exit edit - gFlagAcceptSetting = false; + if (++edit_index >= 10) { // exit edit + gFlagAcceptSetting = false; gAskForConfirmation = 1; } @@ -1819,14 +1737,14 @@ static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld) RADIO_SelectVfos(); - #ifdef ENABLE_NOAA - if (!IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gRxVfo->Modulation == MODULATION_FM) - #else - if (gRxVfo->Modulation == MODULATION_FM) - #endif +#ifdef ENABLE_NOAA + if (!IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gRxVfo->Modulation == MODULATION_FM) +#else + if (gRxVfo->Modulation == MODULATION_FM) +#endif { - if ((UI_MENU_GetCurrentMenuId() == MENU_R_CTCS || UI_MENU_GetCurrentMenuId() == MENU_R_DCS) && gIsInSubMenu) - { // scan CTCSS or DCS to find the tone/code of the incoming signal + if ((UI_MENU_GetCurrentMenuId() == MENU_R_CTCS || UI_MENU_GetCurrentMenuId() == MENU_R_DCS) && + gIsInSubMenu) { // scan CTCSS or DCS to find the tone/code of the incoming signal if (!SCANNER_IsScanning()) MENU_StartCssScan(); else @@ -1840,23 +1758,18 @@ static void MENU_Key_STAR(const bool bKeyPressed, const bool bKeyHeld) gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; } -static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) -{ +static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) { uint8_t VFO; uint8_t Channel; - bool bCheckScanList; + bool bCheckScanList; - if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && gIsInSubMenu && edit_index >= 0) - { // change the character - if (bKeyPressed && edit_index < 10 && Direction != 0) - { - const char unwanted[] = "$%&!\"':;?^`|{}"; - char c = edit[edit_index] + Direction; - unsigned int i = 0; - while (i < sizeof(unwanted) && c >= 32 && c <= 126) - { - if (c == unwanted[i++]) - { // choose next character + if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && gIsInSubMenu && edit_index >= 0) { // change the character + if (bKeyPressed && edit_index < 10 && Direction != 0) { + const char unwanted[] = "$%&!\"':;?^`|{}"; + char c = edit[edit_index] + Direction; + unsigned int i = 0; + while (i < sizeof(unwanted) && c >= 32 && c <= 126) { + if (c == unwanted[i++]) { // choose next character c += Direction; i = 0; } @@ -1868,25 +1781,21 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) return; } - if (!bKeyHeld) - { + if (!bKeyHeld) { if (!bKeyPressed) return; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gInputBoxIndex = 0; - } - else - if (!bKeyPressed) + } else if (!bKeyPressed) return; if (SCANNER_IsScanning()) { return; } - if (!gIsInSubMenu) - { + if (!gIsInSubMenu) { gMenuCursor = NUMBER_AddWithWraparound(gMenuCursor, -Direction, 0, gMenuListCount - 1); gFlagRefreshSetting = true; @@ -1904,26 +1813,22 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) return; } - if (UI_MENU_GetCurrentMenuId() == MENU_OFFSET) - { + if (UI_MENU_GetCurrentMenuId() == MENU_OFFSET) { int32_t Offset = (Direction * gTxVfo->StepFrequency) + gSubMenuSelection; - if (Offset < 99999990) - { + if (Offset < 99999990) { if (Offset < 0) Offset = 99999990; - } - else + } else Offset = 0; - gSubMenuSelection = FREQUENCY_RoundToStep(Offset, gTxVfo->StepFrequency); + gSubMenuSelection = FREQUENCY_RoundToStep(Offset, gTxVfo->StepFrequency); gRequestDisplayScreen = DISPLAY_MENU; return; } VFO = 0; - switch (UI_MENU_GetCurrentMenuId()) - { + switch (UI_MENU_GetCurrentMenuId()) { case MENU_DEL_CH: case MENU_1_CALL: case MENU_MEM_NAME: @@ -1956,10 +1861,8 @@ static void MENU_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) gRequestDisplayScreen = DISPLAY_MENU; } -void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) -{ - switch (Key) - { +void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { + switch (Key) { case KEY_0: case KEY_1: case KEY_2: @@ -1976,7 +1879,7 @@ void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) MENU_Key_MENU(bKeyPressed, bKeyHeld); break; case KEY_UP: - MENU_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1); + MENU_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1); break; case KEY_DOWN: MENU_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1); @@ -1988,17 +1891,14 @@ void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) MENU_Key_STAR(bKeyPressed, bKeyHeld); break; case KEY_F: - if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && edit_index >= 0) - { // currently editing the channel name - if (!bKeyHeld && bKeyPressed) - { + if (UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME && + edit_index >= 0) { // currently editing the channel name + if (!bKeyHeld && bKeyPressed) { gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; - if (edit_index < 10) - { + if (edit_index < 10) { edit[edit_index] = ' '; - if (++edit_index >= 10) - { // exit edit - gFlagAcceptSetting = false; + if (++edit_index >= 10) { // exit edit + gFlagAcceptSetting = false; gAskForConfirmation = 1; } gRequestDisplayScreen = DISPLAY_MENU; @@ -2018,18 +1918,14 @@ void MENU_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) break; } - if (gScreenToDisplay == DISPLAY_MENU) - { - if (UI_MENU_GetCurrentMenuId() == MENU_VOL || - #ifdef ENABLE_F_CAL_MENU - UI_MENU_GetCurrentMenuId() == MENU_F_CALI || - #endif - UI_MENU_GetCurrentMenuId() == MENU_BATCAL) - { + if (gScreenToDisplay == DISPLAY_MENU) { + if ( +#ifdef ENABLE_F_CAL_MENU +UI_MENU_GetCurrentMenuId() == MENU_F_CALI || +#endif +UI_MENU_GetCurrentMenuId() == MENU_BATCAL) { gMenuCountdown = menu_timeout_long_500ms; - } - else - { + } else { gMenuCountdown = menu_timeout_500ms; } } diff --git a/app/spectrum.c b/app/spectrum.c index 418b73c..9f5ab1f 100644 --- a/app/spectrum.c +++ b/app/spectrum.c @@ -19,7 +19,9 @@ #include "misc.h" #ifdef ENABLE_SCAN_RANGES + #include "chFrScanner.h" + #endif #include "driver/backlight.h" @@ -32,11 +34,12 @@ #endif #ifdef ENABLE_FEAT_F4HWN_SPECTRUM + #include "driver/eeprom.h" + #endif -struct FrequencyBandInfo -{ +struct FrequencyBandInfo { uint32_t lower; uint32_t upper; uint32_t middle; @@ -76,16 +79,16 @@ const uint8_t modulationTypeTuneSteps[] = {100, 50, 10}; const uint8_t modTypeReg47Values[] = {1, 7, 5}; SpectrumSettings settings = {.stepsCount = STEPS_64, - .scanStepIndex = S_STEP_25_0kHz, - .frequencyChangeStep = 80000, - .scanDelay = 3200, - .rssiTriggerLevel = 150, - .backlightState = true, - .bw = BK4819_FILTER_BW_WIDE, - .listenBw = BK4819_FILTER_BW_WIDE, - .modulationType = false, - .dbMin = -130, - .dbMax = -50}; + .scanStepIndex = S_STEP_25_0kHz, + .frequencyChangeStep = 80000, + .scanDelay = 3200, + .rssiTriggerLevel = 150, + .backlightState = true, + .bw = BK4819_FILTER_BW_WIDE, + .listenBw = BK4819_FILTER_BW_WIDE, + .modulationType = false, + .dbMin = -130, + .dbMax = -50}; uint32_t fMeasure = 0; uint32_t currentFreq, tempFreq; @@ -100,47 +103,43 @@ uint8_t menuState = 0; uint16_t listenT = 0; RegisterSpec registerSpecs[] = { - {}, - {"LNAs", BK4819_REG_13, 8, 0b11, 1}, - {"LNA", BK4819_REG_13, 5, 0b111, 1}, - {"PGA", BK4819_REG_13, 0, 0b111, 1}, - {"IF", BK4819_REG_3D, 0, 0xFFFF, 0x2aaa}, - // {"MIX", 0x13, 3, 0b11, 1}, // TODO: hidden + {}, + {"LNAs", BK4819_REG_13, 8, 0b11, 1}, + {"LNA", BK4819_REG_13, 5, 0b111, 1}, + {"PGA", BK4819_REG_13, 0, 0b111, 1}, + {"IF", BK4819_REG_3D, 0, 0xFFFF, 0x2aaa}, + // {"MIX", 0x13, 3, 0b11, 1}, // TODO: hidden }; uint16_t statuslineUpdateTimer = 0; #ifdef ENABLE_FEAT_F4HWN_SPECTRUM -static void LoadSettings() -{ + +static void LoadSettings() { uint8_t Data[8] = {0}; // 1FF0..0x1FF7 EEPROM_ReadBuffer(0x1FF0, Data, 8); settings.scanStepIndex = ((Data[3] & 0xF0) >> 4); - if (settings.scanStepIndex > 14) - { + if (settings.scanStepIndex > 14) { settings.scanStepIndex = S_STEP_25_0kHz; } settings.stepsCount = ((Data[3] & 0x0F) & 0b1100) >> 2; - if (settings.stepsCount > 3) - { + if (settings.stepsCount > 3) { settings.stepsCount = STEPS_64; } settings.listenBw = ((Data[3] & 0x0F) & 0b0011); - if (settings.listenBw > 2) - { + if (settings.listenBw > 2) { settings.listenBw = BK4819_FILTER_BW_WIDE; } } -static void SaveSettings() -{ +static void SaveSettings() { uint8_t Data[8] = {0}; // 1FF0..0x1FF7 EEPROM_ReadBuffer(0x1FF0, Data, 8); @@ -149,41 +148,35 @@ static void SaveSettings() EEPROM_WriteBuffer(0x1FF0, Data); } + #endif -static uint8_t DBm2S(int dbm) -{ +static uint8_t DBm2S(int dbm) { uint8_t i = 0; dbm *= -1; - for (i = 0; i < ARRAY_SIZE(U8RssiMap); i++) - { - if (dbm >= U8RssiMap[i]) - { + for (i = 0; i < ARRAY_SIZE(U8RssiMap); i++) { + if (dbm >= U8RssiMap[i]) { return i; } } return i; } -static int Rssi2DBm(uint16_t rssi) -{ +static int Rssi2DBm(uint16_t rssi) { return (rssi / 2) - 160 + dBmCorrTable[gRxVfo->Band]; } -static uint16_t GetRegMenuValue(uint8_t st) -{ +static uint16_t GetRegMenuValue(uint8_t st) { RegisterSpec s = registerSpecs[st]; return (BK4819_ReadRegister(s.num) >> s.offset) & s.mask; } -void LockAGC() -{ +void LockAGC() { RADIO_SetupAGC(settings.modulationType == MODULATION_AM, lockAGC); lockAGC = true; } -static void SetRegMenuValue(uint8_t st, bool add) -{ +static void SetRegMenuValue(uint8_t st, bool add) { uint16_t v = GetRegMenuValue(st); RegisterSpec s = registerSpecs[st]; @@ -191,12 +184,9 @@ static void SetRegMenuValue(uint8_t st, bool add) LockAGC(); uint16_t reg = BK4819_ReadRegister(s.num); - if (add && v <= s.mask - s.inc) - { + if (add && v <= s.mask - s.inc) { v += s.inc; - } - else if (!add && v >= 0 + s.inc) - { + } else if (!add && v >= 0 + s.inc) { v -= s.inc; } // TODO: use max value for bits count in max value, or reset by additional @@ -219,12 +209,9 @@ static void PutPixelStatus(uint8_t x, uint8_t y, bool fill) } #endif -static void DrawVLine(int sy, int ey, int nx, bool fill) -{ - for (int i = sy; i <= ey; i++) - { - if (i < 56 && nx < 128) - { +static void DrawVLine(int sy, int ey, int nx, bool fill) { + for (int i = sy; i <= ey; i++) { + if (i < 56 && nx < 128) { PutPixel(nx, i, fill); } } @@ -263,25 +250,21 @@ static void GUI_DisplaySmallest(const char *pString, uint8_t x, uint8_t y, // Utility functions -KEY_Code_t GetKey() -{ +KEY_Code_t GetKey() { KEY_Code_t btn = KEYBOARD_Poll(); - if (btn == KEY_INVALID && !GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT)) - { + if (btn == KEY_INVALID && !GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT)) { btn = KEY_PTT; } return btn; } -static int clamp(int v, int min, int max) -{ +static int clamp(int v, int min, int max) { return v <= min ? min : (v >= max ? max : v); } static uint8_t my_abs(signed v) { return v > 0 ? v : -v; } -void SetState(State state) -{ +void SetState(State state) { previousState = currentState; currentState = state; redrawScreen = true; @@ -290,8 +273,7 @@ void SetState(State state) // Radio functions -static void ToggleAFBit(bool on) -{ +static void ToggleAFBit(bool on) { uint16_t reg = BK4819_ReadRegister(BK4819_REG_47); reg &= ~(1 << 8); if (on) @@ -300,30 +282,26 @@ static void ToggleAFBit(bool on) } static const BK4819_REGISTER_t registers_to_save[] = { - BK4819_REG_30, - BK4819_REG_37, - BK4819_REG_3D, - BK4819_REG_43, - BK4819_REG_47, - BK4819_REG_48, - BK4819_REG_7E, + BK4819_REG_30, + BK4819_REG_37, + BK4819_REG_3D, + BK4819_REG_43, + BK4819_REG_47, + BK4819_REG_48, + BK4819_REG_7E, }; static uint16_t registers_stack[sizeof(registers_to_save)]; -static void BackupRegisters() -{ - for (uint32_t i = 0; i < ARRAY_SIZE(registers_to_save); i++) - { +static void BackupRegisters() { + for (uint32_t i = 0; i < ARRAY_SIZE(registers_to_save); i++) { registers_stack[i] = BK4819_ReadRegister(registers_to_save[i]); } } -static void RestoreRegisters() -{ +static void RestoreRegisters() { - for (uint32_t i = 0; i < ARRAY_SIZE(registers_to_save); i++) - { + for (uint32_t i = 0; i < ARRAY_SIZE(registers_to_save); i++) { BK4819_WriteRegister(registers_to_save[i], registers_stack[i]); } @@ -332,8 +310,7 @@ static void RestoreRegisters() #endif } -static void ToggleAFDAC(bool on) -{ +static void ToggleAFDAC(bool on) { uint32_t Reg = BK4819_ReadRegister(BK4819_REG_30); Reg &= ~(1 << 9); if (on) @@ -341,8 +318,7 @@ static void ToggleAFDAC(bool on) BK4819_WriteRegister(BK4819_REG_30, Reg); } -static void SetF(uint32_t f) -{ +static void SetF(uint32_t f) { fMeasure = f; BK4819_SetFrequency(fMeasure); @@ -356,21 +332,19 @@ static void SetF(uint32_t f) bool IsPeakOverLevel() { return peak.rssi >= settings.rssiTriggerLevel; } -static void ResetPeak() -{ +static void ResetPeak() { peak.t = 0; peak.rssi = 0; } bool IsCenterMode() { return settings.scanStepIndex < S_STEP_2_5kHz; } + // scan step in 0.01khz uint16_t GetScanStep() { return scanStepValues[settings.scanStepIndex]; } -uint16_t GetStepsCount() -{ +uint16_t GetStepsCount() { #ifdef ENABLE_SCAN_RANGES - if (gScanRangeStart) - { + if (gScanRangeStart) { return (gScanRangeStop - gScanRangeStart) / GetScanStep(); } #endif @@ -378,39 +352,34 @@ uint16_t GetStepsCount() } uint32_t GetBW() { return GetStepsCount() * GetScanStep(); } -uint32_t GetFStart() -{ + +uint32_t GetFStart() { return IsCenterMode() ? currentFreq - (GetBW() >> 1) : currentFreq; } uint32_t GetFEnd() { return currentFreq + GetBW(); } -static void TuneToPeak() -{ +static void TuneToPeak() { scanInfo.f = peak.f; scanInfo.rssi = peak.rssi; scanInfo.i = peak.i; SetF(scanInfo.f); } -static void DeInitSpectrum() -{ +static void DeInitSpectrum() { SetF(initialFreq); RestoreRegisters(); isInitialized = false; } -uint8_t GetBWRegValueForScan() -{ +uint8_t GetBWRegValueForScan() { return scanStepBWRegValues[settings.scanStepIndex]; } -uint16_t GetRssi() -{ +uint16_t GetRssi() { // SYSTICK_DelayUs(800); // testing autodelay based on Glitch value - while ((BK4819_ReadRegister(0x63) & 0b11111111) >= 255) - { + while ((BK4819_ReadRegister(0x63) & 0b11111111) >= 255) { SYSTICK_DelayUs(100); } uint16_t rssi = BK4819_GetRSSI(); @@ -421,25 +390,19 @@ uint16_t GetRssi() return rssi; } -static void ToggleAudio(bool on) -{ - if (on == audioState) - { +static void ToggleAudio(bool on) { + if (on == audioState) { return; } audioState = on; - if (on) - { + if (on) { AUDIO_AudioPathOn(); - } - else - { + } else { AUDIO_AudioPathOff(); } } -static void ToggleRX(bool on) -{ +static void ToggleRX(bool on) { isListening = on; RADIO_SetupAGC(on, lockAGC); @@ -449,29 +412,24 @@ static void ToggleRX(bool on) ToggleAFDAC(on); ToggleAFBit(on); - if (on) - { + if (on) { listenT = 1000; BK4819_WriteRegister(0x43, listenBWRegValues[settings.listenBw]); - } - else - { + } else { BK4819_WriteRegister(0x43, GetBWRegValueForScan()); } } // Scan info -static void ResetScanStats() -{ +static void ResetScanStats() { scanInfo.rssi = 0; scanInfo.rssiMax = 0; scanInfo.iPeak = 0; scanInfo.fPeak = 0; } -static void InitScan() -{ +static void InitScan() { ResetScanStats(); scanInfo.i = 0; scanInfo.f = GetFStart(); @@ -480,10 +438,8 @@ static void InitScan() scanInfo.measurementsCount = GetStepsCount(); } -static void ResetBlacklist() -{ - for (int i = 0; i < 128; ++i) - { +static void ResetBlacklist() { + for (int i = 0; i < 128; ++i) { if (rssiHistory[i] == RSSI_MAX_VALUE) rssiHistory[i] = 0; } @@ -493,8 +449,7 @@ static void ResetBlacklist() #endif } -static void RelaunchScan() -{ +static void RelaunchScan() { InitScan(); ResetPeak(); ToggleRX(false); @@ -505,33 +460,27 @@ static void RelaunchScan() scanInfo.rssiMin = RSSI_MAX_VALUE; } -static void UpdateScanInfo() -{ - if (scanInfo.rssi > scanInfo.rssiMax) - { +static void UpdateScanInfo() { + if (scanInfo.rssi > scanInfo.rssiMax) { scanInfo.rssiMax = scanInfo.rssi; scanInfo.fPeak = scanInfo.f; scanInfo.iPeak = scanInfo.i; } - if (scanInfo.rssi < scanInfo.rssiMin) - { + if (scanInfo.rssi < scanInfo.rssiMin) { scanInfo.rssiMin = scanInfo.rssi; settings.dbMin = Rssi2DBm(scanInfo.rssiMin); redrawStatus = true; } } -static void AutoTriggerLevel() -{ - if (settings.rssiTriggerLevel == RSSI_MAX_VALUE) - { +static void AutoTriggerLevel() { + if (settings.rssiTriggerLevel == RSSI_MAX_VALUE) { settings.rssiTriggerLevel = clamp(scanInfo.rssiMax + 8, 0, RSSI_MAX_VALUE); } } -static void UpdatePeakInfoForce() -{ +static void UpdatePeakInfoForce() { peak.t = 0; peak.rssi = scanInfo.rssiMax; peak.f = scanInfo.fPeak; @@ -539,18 +488,15 @@ static void UpdatePeakInfoForce() AutoTriggerLevel(); } -static void UpdatePeakInfo() -{ +static void UpdatePeakInfo() { if (peak.f == 0 || peak.t >= 1024 || peak.rssi < scanInfo.rssiMax) UpdatePeakInfoForce(); } -static void SetRssiHistory(uint16_t idx, uint16_t rssi) -{ +static void SetRssiHistory(uint16_t idx, uint16_t rssi) { #ifdef ENABLE_SCAN_RANGES - if (scanInfo.measurementsCount > 128) - { - uint8_t i = (uint32_t)ARRAY_SIZE(rssiHistory) * 1000 / scanInfo.measurementsCount * idx / 1000; + if (scanInfo.measurementsCount > 128) { + uint8_t i = (uint32_t) ARRAY_SIZE(rssiHistory) * 1000 / scanInfo.measurementsCount * idx / 1000; if (rssiHistory[i] < rssi || isListening) rssiHistory[i] = rssi; rssiHistory[(i + 1) % 128] = 0; @@ -560,28 +506,24 @@ static void SetRssiHistory(uint16_t idx, uint16_t rssi) rssiHistory[idx] = rssi; } -static void Measure() -{ +static void Measure() { uint16_t rssi = scanInfo.rssi = GetRssi(); SetRssiHistory(scanInfo.i, rssi); } // Update things by keypress -static uint16_t dbm2rssi(int dBm) -{ +static uint16_t dbm2rssi(int dBm) { return (dBm + 160 - dBmCorrTable[gRxVfo->Band]) * 2; } -static void ClampRssiTriggerLevel() -{ +static void ClampRssiTriggerLevel() { settings.rssiTriggerLevel = - clamp(settings.rssiTriggerLevel, dbm2rssi(settings.dbMin), - dbm2rssi(settings.dbMax)); + clamp(settings.rssiTriggerLevel, dbm2rssi(settings.dbMin), + dbm2rssi(settings.dbMax)); } -static void UpdateRssiTriggerLevel(bool inc) -{ +static void UpdateRssiTriggerLevel(bool inc) { if (inc) settings.rssiTriggerLevel += 2; else @@ -593,18 +535,12 @@ static void UpdateRssiTriggerLevel(bool inc) redrawStatus = true; } -static void UpdateDBMax(bool inc) -{ - if (inc && settings.dbMax < 10) - { +static void UpdateDBMax(bool inc) { + if (inc && settings.dbMax < 10) { settings.dbMax += 1; - } - else if (!inc && settings.dbMax > settings.dbMin) - { + } else if (!inc && settings.dbMax > settings.dbMin) { settings.dbMax -= 1; - } - else - { + } else { return; } @@ -614,14 +550,10 @@ static void UpdateDBMax(bool inc) SYSTEM_DelayMs(20); } -static void UpdateScanStep(bool inc) -{ - if (inc) - { +static void UpdateScanStep(bool inc) { + if (inc) { settings.scanStepIndex = settings.scanStepIndex != S_STEP_100_0kHz ? settings.scanStepIndex + 1 : 0; - } - else - { + } else { settings.scanStepIndex = settings.scanStepIndex != 0 ? settings.scanStepIndex - 1 : S_STEP_100_0kHz; } @@ -631,18 +563,12 @@ static void UpdateScanStep(bool inc) redrawScreen = true; } -static void UpdateCurrentFreq(bool inc) -{ - if (inc && currentFreq < F_MAX) - { +static void UpdateCurrentFreq(bool inc) { + if (inc && currentFreq < F_MAX) { currentFreq += settings.frequencyChangeStep; - } - else if (!inc && currentFreq > F_MIN) - { + } else if (!inc && currentFreq > F_MIN) { currentFreq -= settings.frequencyChangeStep; - } - else - { + } else { return; } RelaunchScan(); @@ -650,45 +576,33 @@ static void UpdateCurrentFreq(bool inc) redrawScreen = true; } -static void UpdateCurrentFreqStill(bool inc) -{ +static void UpdateCurrentFreqStill(bool inc) { uint8_t offset = modulationTypeTuneSteps[settings.modulationType]; uint32_t f = fMeasure; - if (inc && f < F_MAX) - { + if (inc && f < F_MAX) { f += offset; - } - else if (!inc && f > F_MIN) - { + } else if (!inc && f > F_MIN) { f -= offset; } SetF(f); redrawScreen = true; } -static void UpdateFreqChangeStep(bool inc) -{ +static void UpdateFreqChangeStep(bool inc) { uint16_t diff = GetScanStep() * 4; - if (inc && settings.frequencyChangeStep < 200000) - { + if (inc && settings.frequencyChangeStep < 200000) { settings.frequencyChangeStep += diff; - } - else if (!inc && settings.frequencyChangeStep > 10000) - { + } else if (!inc && settings.frequencyChangeStep > 10000) { settings.frequencyChangeStep -= diff; } SYSTEM_DelayMs(100); redrawScreen = true; } -static void ToggleModulation() -{ - if (settings.modulationType < MODULATION_UKNOWN - 1) - { +static void ToggleModulation() { + if (settings.modulationType < MODULATION_UKNOWN - 1) { settings.modulationType++; - } - else - { + } else { settings.modulationType = MODULATION_FM; } RADIO_SetModulation(settings.modulationType); @@ -697,28 +611,20 @@ static void ToggleModulation() redrawScreen = true; } -static void ToggleListeningBW() -{ - if (settings.listenBw == BK4819_FILTER_BW_NARROWER) - { +static void ToggleListeningBW() { + if (settings.listenBw == BK4819_FILTER_BW_NARROWER) { settings.listenBw = BK4819_FILTER_BW_WIDE; - } - else - { + } else { settings.listenBw++; } redrawScreen = true; } -static void ToggleBacklight() -{ +static void ToggleBacklight() { settings.backlightState = !settings.backlightState; - if (settings.backlightState) - { + if (settings.backlightState) { BACKLIGHT_TurnOn(); - } - else - { + } else { BACKLIGHT_TurnOff(); } // For screenshot @@ -727,14 +633,10 @@ static void ToggleBacklight() #endif } -static void ToggleStepsCount() -{ - if (settings.stepsCount == STEPS_128) - { +static void ToggleStepsCount() { + if (settings.stepsCount == STEPS_128) { settings.stepsCount = STEPS_16; - } - else - { + } else { settings.stepsCount--; } settings.frequencyChangeStep = GetBW() >> 1; @@ -743,79 +645,62 @@ static void ToggleStepsCount() redrawScreen = true; } -static void ResetFreqInput() -{ +static void ResetFreqInput() { tempFreq = 0; - for (int i = 0; i < 10; ++i) - { + for (int i = 0; i < 10; ++i) { freqInputString[i] = '-'; } } -static void FreqInput() -{ +static void FreqInput() { freqInputIndex = 0; freqInputDotIndex = 0; ResetFreqInput(); SetState(FREQ_INPUT); } -static void UpdateFreqInput(KEY_Code_t key) -{ - if (key != KEY_EXIT && freqInputIndex >= 10) - { +static void UpdateFreqInput(KEY_Code_t key) { + if (key != KEY_EXIT && freqInputIndex >= 10) { return; } - if (key == KEY_STAR) - { - if (freqInputIndex == 0 || freqInputDotIndex) - { + if (key == KEY_STAR) { + if (freqInputIndex == 0 || freqInputDotIndex) { return; } freqInputDotIndex = freqInputIndex; } - if (key == KEY_EXIT) - { + if (key == KEY_EXIT) { freqInputIndex--; if (freqInputDotIndex == freqInputIndex) freqInputDotIndex = 0; - } - else - { + } else { freqInputArr[freqInputIndex++] = key; } ResetFreqInput(); uint8_t dotIndex = - freqInputDotIndex == 0 ? freqInputIndex : freqInputDotIndex; + freqInputDotIndex == 0 ? freqInputIndex : freqInputDotIndex; KEY_Code_t digitKey; - for (int i = 0; i < 10; ++i) - { - if (i < freqInputIndex) - { + for (int i = 0; i < 10; ++i) { + if (i < freqInputIndex) { digitKey = freqInputArr[i]; freqInputString[i] = digitKey <= KEY_9 ? '0' + digitKey - KEY_0 : '.'; - } - else - { + } else { freqInputString[i] = '-'; } } uint32_t base = 100000; // 1MHz in BK units - for (int i = dotIndex - 1; i >= 0; --i) - { + for (int i = dotIndex - 1; i >= 0; --i) { tempFreq += (freqInputArr[i] - KEY_0) * base; base *= 10; } base = 10000; // 0.1MHz in BK units - if (dotIndex < freqInputIndex) - { - for (int i = dotIndex + 1; i < freqInputIndex; ++i) - { + if (dotIndex < freqInputIndex) { + for (int i = dotIndex + 1; i < freqInputIndex; ++i) { tempFreq += (freqInputArr[i] - KEY_0) * base; base /= 10; } @@ -823,8 +708,7 @@ static void UpdateFreqInput(KEY_Code_t key) redrawScreen = true; } -static void Blacklist() -{ +static void Blacklist() { #ifdef ENABLE_SCAN_RANGES blacklistFreqs[blacklistFreqsIdx++ % ARRAY_SIZE(blacklistFreqs)] = peak.i; #endif @@ -836,21 +720,21 @@ static void Blacklist() } #ifdef ENABLE_SCAN_RANGES -static bool IsBlacklisted(uint16_t idx) -{ + +static bool IsBlacklisted(uint16_t idx) { if (blacklistFreqsIdx) for (uint8_t i = 0; i < ARRAY_SIZE(blacklistFreqs); i++) if (blacklistFreqs[i] == idx) return true; return false; } + #endif // Draw things // applied x2 to prevent initial rounding -uint8_t Rssi2PX(uint16_t rssi, uint8_t pxMin, uint8_t pxMax) -{ +uint8_t Rssi2PX(uint16_t rssi, uint8_t pxMin, uint8_t pxMax) { const int DB_MIN = settings.dbMin << 1; const int DB_MAX = settings.dbMax << 1; const int DB_RANGE = DB_MAX - DB_MIN; @@ -862,52 +746,48 @@ uint8_t Rssi2PX(uint16_t rssi, uint8_t pxMin, uint8_t pxMax) return ((dbm - DB_MIN) * PX_RANGE + DB_RANGE / 2) / DB_RANGE + pxMin; } -uint8_t Rssi2Y(uint16_t rssi) -{ +uint8_t Rssi2Y(uint16_t rssi) { return DrawingEndY - Rssi2PX(rssi, 0, DrawingEndY); } #ifdef ENABLE_FEAT_F4HWN - static void DrawSpectrum() - { - uint16_t steps = GetStepsCount(); - // max bars at 128 to correctly draw larger numbers of samples - uint8_t bars = (steps > 128) ? 128 : steps; - // shift to center bar on freq marker - uint8_t shift_graph = 64 / steps + 1; - uint8_t ox = 0; - for (uint8_t i = 0; i < 128; ++i) - { - uint16_t rssi = rssiHistory[i >> settings.stepsCount]; - if (rssi != RSSI_MAX_VALUE) - { - // stretch bars to fill the screen width - uint8_t x = i * 128 / bars + shift_graph; - for (uint8_t xx = ox; xx < x; xx++) - { - DrawVLine(Rssi2Y(rssi), DrawingEndY, xx, true); - } - ox = x; +static void DrawSpectrum() { + uint16_t steps = GetStepsCount(); + // max bars at 128 to correctly draw larger numbers of samples + uint8_t bars = (steps > 128) ? 128 : steps; + // shift to center bar on freq marker + uint8_t shift_graph = 64 / steps + 1; + + uint8_t ox = 0; + for (uint8_t i = 0; i < 128; ++i) { + uint16_t rssi = rssiHistory[i >> settings.stepsCount]; + if (rssi != RSSI_MAX_VALUE) { + // stretch bars to fill the screen width + uint8_t x = i * 128 / bars + shift_graph; + for (uint8_t xx = ox; xx < x; xx++) { + DrawVLine(Rssi2Y(rssi), DrawingEndY, xx, true); } + ox = x; } } +} + #else - static void DrawSpectrum() +static void DrawSpectrum() +{ + for (uint8_t x = 0; x < 128; ++x) { - for (uint8_t x = 0; x < 128; ++x) + uint16_t rssi = rssiHistory[x >> settings.stepsCount]; + if (rssi != RSSI_MAX_VALUE) { - uint16_t rssi = rssiHistory[x >> settings.stepsCount]; - if (rssi != RSSI_MAX_VALUE) - { - DrawVLine(Rssi2Y(rssi), DrawingEndY, x, true); - } + DrawVLine(Rssi2Y(rssi), DrawingEndY, x, true); } } +} #endif -static void DrawStatus() -{ +static void DrawStatus() { #ifdef SPECTRUM_EXTRA_VALUES sprintf(String, "%d/%d P:%d T:%d", settings.dbMin, settings.dbMax, Rssi2DBm(peak.rssi), Rssi2DBm(settings.rssiTriggerLevel)); @@ -930,35 +810,28 @@ static void DrawStatus() gStatusLine[116] = 0b00011100; gStatusLine[117] = 0b00111110; - for (int i = 118; i <= 126; i++) - { + for (int i = 118; i <= 126; i++) { gStatusLine[i] = 0b00100010; } - for (unsigned i = 127; i >= 118; i--) - { - if (127 - i <= (perc + 5) * 9 / 100) - { + for (unsigned i = 127; i >= 118; i--) { + if (127 - i <= (perc + 5) * 9 / 100) { gStatusLine[i] = 0b00111110; } } } #ifdef ENABLE_FEAT_F4HWN_SPECTRUM -static void ShowChannelName(uint32_t f) -{ + +static void ShowChannelName(uint32_t f) { unsigned int i; char String[12]; memset(String, 0, sizeof(String)); - if (isListening) - { - for (i = 0; IS_MR_CHANNEL(i); i++) - { - if (RADIO_CheckValidChannel(i, false, 0)) - { - if (SETTINGS_FetchChannelFrequency(i) == f) - { + if (isListening) { + for (i = 0; IS_MR_CHANNEL(i); i++) { + if (RADIO_CheckValidChannel(i, false, 0)) { + if (SETTINGS_FetchChannelFrequency(i) == f) { SETTINGS_FetchChannelName(String, i); if (String[0] != 0) { UI_PrintStringSmallBufferNormal(String, gStatusLine + 36); @@ -968,9 +841,7 @@ static void ShowChannelName(uint32_t f) } } } - } - else - { + } else { /* for (int i = 36; i < 100; i++) { @@ -981,10 +852,10 @@ static void ShowChannelName(uint32_t f) } ST7565_BlitStatusLine(); } + #endif -static void DrawF(uint32_t f) -{ +static void DrawF(uint32_t f) { sprintf(String, "%u.%05u", f / 100000, f % 100000); UI_PrintStringSmallNormal(String, 8, 127, 0); @@ -998,26 +869,21 @@ static void DrawF(uint32_t f) #endif } -static void DrawNums() -{ +static void DrawNums() { - if (currentState == SPECTRUM) - { + if (currentState == SPECTRUM) { sprintf(String, "%ux", GetStepsCount()); GUI_DisplaySmallest(String, 0, 1, false, true); sprintf(String, "%u.%02uk", GetScanStep() / 100, GetScanStep() % 100); GUI_DisplaySmallest(String, 0, 7, false, true); } - if (IsCenterMode()) - { + if (IsCenterMode()) { sprintf(String, "%u.%05u \x7F%u.%02uk", currentFreq / 100000, currentFreq % 100000, settings.frequencyChangeStep / 100, settings.frequencyChangeStep % 100); GUI_DisplaySmallest(String, 36, 49, false, true); - } - else - { + } else { sprintf(String, "%u.%05u", GetFStart() / 100000, GetFStart() % 100000); GUI_DisplaySmallest(String, 0, 49, false, true); @@ -1030,24 +896,20 @@ static void DrawNums() } } -static void DrawRssiTriggerLevel() -{ +static void DrawRssiTriggerLevel() { if (settings.rssiTriggerLevel == RSSI_MAX_VALUE || monitorMode) return; uint8_t y = Rssi2Y(settings.rssiTriggerLevel); - for (uint8_t x = 0; x < 128; x += 2) - { + for (uint8_t x = 0; x < 128; x += 2) { PutPixel(x, y, true); } } -static void DrawTicks() -{ +static void DrawTicks() { uint32_t f = GetFStart(); uint32_t span = GetFEnd() - GetFStart(); uint32_t step = span / 128; - for (uint8_t i = 0; i < 128; i += (1 << settings.stepsCount)) - { + for (uint8_t i = 0; i < 128; i += (1 << settings.stepsCount)) { f = GetFStart() + span * i / 128; uint8_t barValue = 0b00000001; (f % 10000) < step && (barValue |= 0b00000010); @@ -1058,13 +920,10 @@ static void DrawTicks() } // center - if (IsCenterMode()) - { + if (IsCenterMode()) { memset(gFrameBuffer[5] + 62, 0x80, 5); gFrameBuffer[5][64] = 0xff; - } - else - { + } else { memset(gFrameBuffer[5] + 1, 0x80, 3); memset(gFrameBuffer[5] + 124, 0x80, 3); @@ -1073,238 +932,216 @@ static void DrawTicks() } } -static void DrawArrow(uint8_t x) -{ - for (signed i = -2; i <= 2; ++i) - { +static void DrawArrow(uint8_t x) { + for (signed i = -2; i <= 2; ++i) { signed v = x + i; - if (!(v & 128)) - { + if (!(v & 128)) { gFrameBuffer[5][v] |= (0b01111000 << my_abs(i)) & 0b01111000; } } } -static void OnKeyDown(uint8_t key) -{ - switch (key) - { - case KEY_3: - UpdateDBMax(true); - break; - case KEY_9: - UpdateDBMax(false); - break; - case KEY_1: - UpdateScanStep(true); - break; - case KEY_7: - UpdateScanStep(false); - break; - case KEY_2: - UpdateFreqChangeStep(true); - break; - case KEY_8: - UpdateFreqChangeStep(false); - break; - case KEY_UP: -#ifdef ENABLE_SCAN_RANGES - if (!gScanRangeStart) -#endif - UpdateCurrentFreq(true); - break; - case KEY_DOWN: -#ifdef ENABLE_SCAN_RANGES - if (!gScanRangeStart) -#endif - UpdateCurrentFreq(false); - break; - case KEY_SIDE1: - Blacklist(); - break; - case KEY_STAR: - UpdateRssiTriggerLevel(true); - break; - case KEY_F: - UpdateRssiTriggerLevel(false); - break; - case KEY_5: -#ifdef ENABLE_SCAN_RANGES - if (!gScanRangeStart) -#endif - FreqInput(); - break; - case KEY_0: - ToggleModulation(); - break; - case KEY_6: - ToggleListeningBW(); - break; - case KEY_4: -#ifdef ENABLE_SCAN_RANGES - if (!gScanRangeStart) -#endif - ToggleStepsCount(); - break; - case KEY_SIDE2: - ToggleBacklight(); - break; - case KEY_PTT: - SetState(STILL); - TuneToPeak(); - break; - case KEY_MENU: - break; - case KEY_EXIT: - if (menuState) - { - menuState = 0; +static void OnKeyDown(uint8_t key) { + switch (key) { + case KEY_3: + UpdateDBMax(true); break; - } + case KEY_9: + UpdateDBMax(false); + break; + case KEY_1: + UpdateScanStep(true); + break; + case KEY_7: + UpdateScanStep(false); + break; + case KEY_2: + UpdateFreqChangeStep(true); + break; + case KEY_8: + UpdateFreqChangeStep(false); + break; + case KEY_UP: +#ifdef ENABLE_SCAN_RANGES + if (!gScanRangeStart || gEnteringSMS == SMS_NOT_ENTERING) +#endif + UpdateCurrentFreq(true); + break; + case KEY_DOWN: +#ifdef ENABLE_SCAN_RANGES + if (!gScanRangeStart || gEnteringSMS == SMS_NOT_ENTERING) +#endif + UpdateCurrentFreq(false); + break; + case KEY_SIDE1: + Blacklist(); + break; + case KEY_STAR: + UpdateRssiTriggerLevel(true); + break; + case KEY_F: + UpdateRssiTriggerLevel(false); + break; + case KEY_5: +#ifdef ENABLE_SCAN_RANGES + if (!gScanRangeStart || gEnteringSMS == SMS_NOT_ENTERING) +#endif + FreqInput(); + break; + case KEY_0: + ToggleModulation(); + break; + case KEY_6: + ToggleListeningBW(); + break; + case KEY_4: +#ifdef ENABLE_SCAN_RANGES + if (!gScanRangeStart || gEnteringSMS == SMS_NOT_ENTERING) +#endif + ToggleStepsCount(); + break; + case KEY_SIDE2: + ToggleBacklight(); + break; + case KEY_PTT: + SetState(STILL); + TuneToPeak(); + break; + case KEY_MENU: + break; + case KEY_EXIT: + if (menuState) { + menuState = 0; + break; + } #ifdef ENABLE_FEAT_F4HWN_SPECTRUM - SaveSettings(); + SaveSettings(); #endif #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE - gEeprom.CURRENT_STATE = 0; - SETTINGS_WriteCurrentState(); + gEeprom.CURRENT_STATE = 0; + SETTINGS_WriteCurrentState(); #endif - DeInitSpectrum(); - break; - default: - break; + DeInitSpectrum(); + break; + default: + break; } } -static void OnKeyDownFreqInput(uint8_t key) -{ - switch (key) - { - case KEY_0: - case KEY_1: - case KEY_2: - case KEY_3: - case KEY_4: - case KEY_5: - case KEY_6: - case KEY_7: - case KEY_8: - case KEY_9: - case KEY_STAR: - UpdateFreqInput(key); - break; - case KEY_EXIT: - if (freqInputIndex == 0) - { +static void OnKeyDownFreqInput(uint8_t key) { + switch (key) { + case KEY_0: + case KEY_1: + case KEY_2: + case KEY_3: + case KEY_4: + case KEY_5: + case KEY_6: + case KEY_7: + case KEY_8: + case KEY_9: + case KEY_STAR: + UpdateFreqInput(key); + break; + case KEY_EXIT: + if (freqInputIndex == 0) { + SetState(previousState); + break; + } + UpdateFreqInput(key); + break; + case KEY_MENU: + if (tempFreq < F_MIN || tempFreq > F_MAX) { + break; + } SetState(previousState); + currentFreq = tempFreq; + if (currentState == SPECTRUM) { + ResetBlacklist(); + RelaunchScan(); + } else { + SetF(currentFreq); + } break; - } - UpdateFreqInput(key); - break; - case KEY_MENU: - if (tempFreq < F_MIN || tempFreq > F_MAX) - { + default: break; - } - SetState(previousState); - currentFreq = tempFreq; - if (currentState == SPECTRUM) - { - ResetBlacklist(); - RelaunchScan(); - } - else - { - SetF(currentFreq); - } - break; - default: - break; } } -void OnKeyDownStill(KEY_Code_t key) -{ - switch (key) - { - case KEY_3: - UpdateDBMax(true); - break; - case KEY_9: - UpdateDBMax(false); - break; - case KEY_UP: - if (menuState) - { - SetRegMenuValue(menuState, true); +void OnKeyDownStill(KEY_Code_t key) { + switch (key) { + case KEY_3: + UpdateDBMax(true); break; - } - UpdateCurrentFreqStill(true); - break; - case KEY_DOWN: - if (menuState) - { - SetRegMenuValue(menuState, false); + case KEY_9: + UpdateDBMax(false); break; - } - UpdateCurrentFreqStill(false); - break; - case KEY_STAR: - UpdateRssiTriggerLevel(true); - break; - case KEY_F: - UpdateRssiTriggerLevel(false); - break; - case KEY_5: - FreqInput(); - break; - case KEY_0: - ToggleModulation(); - break; - case KEY_6: - ToggleListeningBW(); - break; - case KEY_SIDE1: - monitorMode = !monitorMode; - break; - case KEY_SIDE2: - ToggleBacklight(); - break; - case KEY_PTT: - // TODO: start transmit - /* BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2_GREEN, false); - BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, true); */ - break; - case KEY_MENU: - if (menuState == ARRAY_SIZE(registerSpecs) - 1) - { - menuState = 1; - } - else - { - menuState++; - } - redrawScreen = true; - break; - case KEY_EXIT: - if (!menuState) - { - SetState(SPECTRUM); - lockAGC = false; - monitorMode = false; - RelaunchScan(); + case KEY_UP: + if (menuState) { + SetRegMenuValue(menuState, true); + break; + } + UpdateCurrentFreqStill(true); + break; + case KEY_DOWN: + if (menuState) { + SetRegMenuValue(menuState, false); + break; + } + UpdateCurrentFreqStill(false); + break; + case KEY_STAR: + UpdateRssiTriggerLevel(true); + break; + case KEY_F: + UpdateRssiTriggerLevel(false); + break; + case KEY_5: + FreqInput(); + break; + case KEY_0: + ToggleModulation(); + break; + case KEY_6: + ToggleListeningBW(); + break; + case KEY_SIDE1: + monitorMode = !monitorMode; + break; + case KEY_SIDE2: + ToggleBacklight(); + break; + case KEY_PTT: + // TODO: start transmit + /* BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2_GREEN, false); + BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1_RED, true); */ + break; + case KEY_MENU: + if (menuState == ARRAY_SIZE(registerSpecs) - 1) { + menuState = 1; + } else { + menuState++; + } + redrawScreen = true; + break; + case KEY_EXIT: + if (!menuState) { + SetState(SPECTRUM); + lockAGC = false; + monitorMode = false; + RelaunchScan(); + break; + } + menuState = 0; + break; + default: break; - } - menuState = 0; - break; - default: - break; } } static void RenderFreqInput() { UI_PrintString(freqInputString, 2, 127, 0, 8); } -static void RenderStatus() -{ +static void RenderStatus() { memset(gStatusLine, 0, sizeof(gStatusLine)); DrawStatus(); #ifdef ENABLE_FEAT_F4HWN_SPECTRUM @@ -1313,8 +1150,7 @@ static void RenderStatus() ST7565_BlitStatusLine(); } -static void RenderSpectrum() -{ +static void RenderSpectrum() { DrawTicks(); DrawArrow(128u * peak.i / GetStepsCount()); DrawSpectrum(); @@ -1323,29 +1159,24 @@ static void RenderSpectrum() DrawNums(); } -static void RenderStill() -{ +static void RenderStill() { DrawF(fMeasure); const uint8_t METER_PAD_LEFT = 3; memset(&gFrameBuffer[2][METER_PAD_LEFT], 0b00010000, 121); - for (int i = 0; i < 121; i += 5) - { + for (int i = 0; i < 121; i += 5) { gFrameBuffer[2][i + METER_PAD_LEFT] = 0b00110000; } - for (int i = 0; i < 121; i += 10) - { + for (int i = 0; i < 121; i += 10) { gFrameBuffer[2][i + METER_PAD_LEFT] = 0b01110000; } uint8_t x = Rssi2PX(scanInfo.rssi, 0, 121); - for (int i = 0; i < x; ++i) - { - if (i % 5) - { + for (int i = 0; i < x; ++i) { + if (i % 5) { gFrameBuffer[2][i + METER_PAD_LEFT] |= 0b00000111; } } @@ -1357,8 +1188,7 @@ static void RenderStill() sprintf(String, "%d dBm", dbm); GUI_DisplaySmallest(String, 28, 25, false, true); - if (!monitorMode) - { + if (!monitorMode) { uint8_t x = Rssi2PX(settings.rssiTriggerLevel, 0, 121); gFrameBuffer[2][METER_PAD_LEFT + x] = 0b11111111; } @@ -1368,18 +1198,14 @@ static void RenderStill() uint8_t offset = PAD_LEFT; uint8_t row = 4; - for (int i = 0, idx = 1; idx <= 4; ++i, ++idx) - { - if (idx == 5) - { + for (int i = 0, idx = 1; idx <= 4; ++i, ++idx) { + if (idx == 5) { row += 2; i = 0; } offset = PAD_LEFT + i * CELL_WIDTH; - if (menuState == idx) - { - for (int j = 0; j < CELL_WIDTH; ++j) - { + if (menuState == idx) { + for (int j = 0; j < CELL_WIDTH; ++j) { gFrameBuffer[row][j + offset] = 0xFF; gFrameBuffer[row + 1][j + offset] = 0xFF; } @@ -1393,90 +1219,77 @@ static void RenderStill() } } -static void Render() -{ +static void Render() { UI_DisplayClear(); - switch (currentState) - { - case SPECTRUM: - RenderSpectrum(); - break; - case FREQ_INPUT: - RenderFreqInput(); - break; - case STILL: - RenderStill(); - break; + switch (currentState) { + case SPECTRUM: + RenderSpectrum(); + break; + case FREQ_INPUT: + RenderFreqInput(); + break; + case STILL: + RenderStill(); + break; } ST7565_BlitFullScreen(); } -bool HandleUserInput() -{ +bool HandleUserInput() { kbd.prev = kbd.current; kbd.current = GetKey(); - if (kbd.current != KEY_INVALID && kbd.current == kbd.prev) - { + if (kbd.current != KEY_INVALID && kbd.current == kbd.prev) { if (kbd.counter < 16) kbd.counter++; else kbd.counter -= 3; SYSTEM_DelayMs(20); - } - else - { + } else { kbd.counter = 0; } - if (kbd.counter == 3 || kbd.counter == 16) - { - switch (currentState) - { - case SPECTRUM: - OnKeyDown(kbd.current); - break; - case FREQ_INPUT: - OnKeyDownFreqInput(kbd.current); - break; - case STILL: - OnKeyDownStill(kbd.current); - break; + if (kbd.counter == 3 || kbd.counter == 16) { + switch (currentState) { + case SPECTRUM: + OnKeyDown(kbd.current); + break; + case FREQ_INPUT: + OnKeyDownFreqInput(kbd.current); + break; + case STILL: + OnKeyDownStill(kbd.current); + break; } } return true; } -static void Scan() -{ +static void Scan() { if (rssiHistory[scanInfo.i] != RSSI_MAX_VALUE -#ifdef ENABLE_SCAN_RANGES + #ifdef ENABLE_SCAN_RANGES && !IsBlacklisted(scanInfo.i) #endif - ) - { + ) { SetF(scanInfo.f); Measure(); UpdateScanInfo(); } } -static void NextScanStep() -{ +static void NextScanStep() { ++peak.t; ++scanInfo.i; scanInfo.f += scanInfo.scanStep; } -static void UpdateScan() -{ +static void UpdateScan() { Scan(); - if (scanInfo.i < scanInfo.measurementsCount) - { + if (scanInfo.i < scanInfo.measurementsCount) { NextScanStep(); return; } @@ -1489,8 +1302,7 @@ static void UpdateScan() preventKeypress = false; UpdatePeakInfo(); - if (IsPeakOverLevel()) - { + if (IsPeakOverLevel()) { ToggleRX(true); TuneToPeak(); return; @@ -1499,8 +1311,7 @@ static void UpdateScan() newScanStart = true; } -static void UpdateStill() -{ +static void UpdateStill() { Measure(); redrawScreen = true; preventKeypress = false; @@ -1511,36 +1322,29 @@ static void UpdateStill() ToggleRX(IsPeakOverLevel() || monitorMode); } -static void UpdateListening() -{ +static void UpdateListening() { preventKeypress = false; - if (currentState == STILL) - { + if (currentState == STILL) { listenT = 0; } - if (listenT) - { + if (listenT) { listenT--; SYSTEM_DelayMs(1); return; } - if (currentState == SPECTRUM) - { + if (currentState == SPECTRUM) { BK4819_WriteRegister(0x43, GetBWRegValueForScan()); Measure(); BK4819_WriteRegister(0x43, listenBWRegValues[settings.listenBw]); - } - else - { + } else { Measure(); } peak.rssi = scanInfo.rssi; redrawScreen = true; - if (IsPeakOverLevel() || monitorMode) - { + if (IsPeakOverLevel() || monitorMode) { listenT = 1000; return; } @@ -1549,32 +1353,26 @@ static void UpdateListening() ResetScanStats(); } -static void Tick() -{ +static void Tick() { #ifdef ENABLE_AM_FIX - if (gNextTimeslice) - { + if (gNextTimeslice) { gNextTimeslice = false; - if (settings.modulationType == MODULATION_AM && !lockAGC) - { + if (settings.modulationType == MODULATION_AM && !lockAGC) { AM_fix_10ms(vfo); // allow AM_Fix to apply its AGC action } } #endif #ifdef ENABLE_SCAN_RANGES - if (gNextTimeslice_500ms) - { + if (gNextTimeslice_500ms) { gNextTimeslice_500ms = false; // if a lot of steps then it takes long time // we don't want to wait for whole scan // listening has it's own timer - if (GetStepsCount() > 128 && !isListening) - { + if (GetStepsCount() > 128 && !isListening) { UpdatePeakInfo(); - if (IsPeakOverLevel()) - { + if (IsPeakOverLevel()) { ToggleRX(true); TuneToPeak(); return; @@ -1585,45 +1383,34 @@ static void Tick() } #endif - if (!preventKeypress) - { + if (!preventKeypress) { HandleUserInput(); } - if (newScanStart) - { + if (newScanStart) { InitScan(); newScanStart = false; } - if (isListening && currentState != FREQ_INPUT) - { + if (isListening && currentState != FREQ_INPUT) { UpdateListening(); - } - else - { - if (currentState == SPECTRUM) - { + } else { + if (currentState == SPECTRUM) { UpdateScan(); - } - else if (currentState == STILL) - { + } else if (currentState == STILL) { UpdateStill(); } } - if (redrawStatus || ++statuslineUpdateTimer > 4096) - { + if (redrawStatus || ++statuslineUpdateTimer > 4096) { RenderStatus(); redrawStatus = false; statuslineUpdateTimer = 0; } - if (redrawScreen) - { + if (redrawScreen) { Render(); redrawScreen = false; } } -void APP_RunSpectrum() -{ +void APP_RunSpectrum() { // TX here coz it always? set to active VFO vfo = gEeprom.TX_VFO; #ifdef ENABLE_FEAT_F4HWN_SPECTRUM @@ -1631,34 +1418,30 @@ void APP_RunSpectrum() #endif // set the current frequency in the middle of the display #ifdef ENABLE_SCAN_RANGES - if (gScanRangeStart) - { + if (gScanRangeStart) { currentFreq = initialFreq = gScanRangeStart; - for (uint8_t i = 0; i < ARRAY_SIZE(scanStepValues); i++) - { - if (scanStepValues[i] >= gTxVfo->StepFrequency) - { + for (uint8_t i = 0; i < ARRAY_SIZE(scanStepValues); i++) { + if (scanStepValues[i] >= gTxVfo->StepFrequency) { settings.scanStepIndex = i; break; } } settings.stepsCount = STEPS_128; - #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE - gEeprom.CURRENT_STATE = 5; - #endif - } - else { +#ifdef ENABLE_FEAT_F4HWN_RESUME_STATE + gEeprom.CURRENT_STATE = 5; +#endif + } else { #endif currentFreq = initialFreq = gTxVfo->pRX->Frequency - ((GetStepsCount() / 2) * GetScanStep()); - #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE - gEeprom.CURRENT_STATE = 4; - #endif +#ifdef ENABLE_FEAT_F4HWN_RESUME_STATE + gEeprom.CURRENT_STATE = 4; +#endif } - #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE - SETTINGS_WriteCurrentState(); - #endif +#ifdef ENABLE_FEAT_F4HWN_RESUME_STATE + SETTINGS_WriteCurrentState(); +#endif BackupRegisters(); @@ -1682,8 +1465,7 @@ void APP_RunSpectrum() isInitialized = true; - while (isInitialized) - { + while (isInitialized) { Tick(); } } diff --git a/driver/backlight.c b/driver/backlight.c index 4830ea6..a6dc7eb 100644 --- a/driver/backlight.c +++ b/driver/backlight.c @@ -68,12 +68,6 @@ void BACKLIGHT_InitHardware() static void BACKLIGHT_Sound(void) { - if (gEeprom.POWER_ON_DISPLAY_MODE == POWER_ON_DISPLAY_MODE_SOUND || gEeprom.POWER_ON_DISPLAY_MODE == POWER_ON_DISPLAY_MODE_ALL) - { - AUDIO_PlayBeep(BEEP_880HZ_60MS_DOUBLE_BEEP); - AUDIO_PlayBeep(BEEP_880HZ_60MS_DOUBLE_BEEP); - } - gK5startup = false; } diff --git a/driver/bk4819-regs.h b/driver/bk4819-regs.h index 7c33371..c5755ca 100644 --- a/driver/bk4819-regs.h +++ b/driver/bk4819-regs.h @@ -74,6 +74,7 @@ enum BK4819_REGISTER_t { BK4819_REG_3D = 0x3DU, BK4819_REG_3E = 0x3EU, BK4819_REG_3F = 0x3FU, + BK4819_REG_40 = 0x40U, BK4819_REG_43 = 0x43U, BK4819_REG_46 = 0x46U, BK4819_REG_47 = 0x47U, @@ -96,6 +97,7 @@ enum BK4819_REGISTER_t { BK4819_REG_5A = 0x5AU, BK4819_REG_5B = 0x5BU, BK4819_REG_5C = 0x5CU, + BK4819_REG_5E = 0x5EU, BK4819_REG_5D = 0x5DU, BK4819_REG_5F = 0x5FU, BK4819_REG_63 = 0x63U, diff --git a/driver/bk4819.c b/driver/bk4819.c index ae3b8db..45800e8 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -48,6 +48,21 @@ __inline uint16_t scale_freq(const uint16_t freq) return (((uint32_t)freq * 1353245u) + (1u << 16)) >> 17; // with rounding } +void BK4819_FskEnableTx(void){ + const uint16_t fsk_reg59 = BK4819_ReadRegister(BK4819_REG_59); + BK4819_WriteRegister(BK4819_REG_59, (1u << 11) | fsk_reg59); +} + +void BK4819_FskClearFifo(void){ + const uint16_t fsk_reg59 = BK4819_ReadRegister(BK4819_REG_59); + BK4819_WriteRegister(BK4819_REG_59, (1u << 15) | (1u << 14) | fsk_reg59); +} + +void BK4819_FskEnableRx(void){ + const uint16_t fsk_reg59 = BK4819_ReadRegister(BK4819_REG_59); + BK4819_WriteRegister(BK4819_REG_59, (1u << 12) | fsk_reg59); +} + void BK4819_Init(void) { GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCN); diff --git a/driver/bk4819.h b/driver/bk4819.h index b700377..b7e3de4 100644 --- a/driver/bk4819.h +++ b/driver/bk4819.h @@ -77,6 +77,11 @@ void BK4819_InitAGC(bool amModulation); void BK4819_ToggleGpioOut(BK4819_GPIO_PIN_t Pin, bool bSet); +void BK4819_ResetFSK(void); +void BK4819_FskClearFifo(void); +void BK4819_FskEnableRx(void); +void BK4819_FskEnableTx(void); + void BK4819_SetCDCSSCodeWord(uint32_t CodeWord); void BK4819_SetCTCSSFrequency(uint32_t BaudRate); void BK4819_SetTailDetection(const uint32_t freq_10Hz); diff --git a/driver/keyboard.c b/driver/keyboard.c index bc55381..41806f2 100644 --- a/driver/keyboard.c +++ b/driver/keyboard.c @@ -26,6 +26,8 @@ KEY_Code_t gKeyReading0 = KEY_INVALID; KEY_Code_t gKeyReading1 = KEY_INVALID; uint16_t gDebounceCounter = 0; bool gWasFKeyPressed = false; +uint8_t prevLetter = 0; +KEY_Code_t prevKey = KEY_INVALID; static const struct { diff --git a/driver/keyboard.h b/driver/keyboard.h index 5a01844..c7f5f0b 100644 --- a/driver/keyboard.h +++ b/driver/keyboard.h @@ -47,8 +47,10 @@ typedef enum KEY_Code_e KEY_Code_t; extern KEY_Code_t gKeyReading0; extern KEY_Code_t gKeyReading1; -extern uint16_t gDebounceCounter; -extern bool gWasFKeyPressed; +extern uint16_t gDebounceCounter; +extern bool gWasFKeyPressed; +extern uint8_t prevLetter; +extern KEY_Code_t prevKey; KEY_Code_t KEYBOARD_Poll(void); diff --git a/external/CMSIS_5/CMSIS/DoxyGen/Driver/src/General.txt b/external/CMSIS_5/CMSIS/DoxyGen/Driver/src/General.txt index 459f295..f282229 100644 --- a/external/CMSIS_5/CMSIS/DoxyGen/Driver/src/General.txt +++ b/external/CMSIS_5/CMSIS/DoxyGen/Driver/src/General.txt @@ -4084,9 +4084,9 @@ called in the following order: a=>b [label="GetVersion ()", textcolor="gray", linecolor="gray"]; --- [label="Obtain driver features"]; a=>b [label="GetCapabilities (...)", textcolor="gray", linecolor="gray"]; - --- [label="Setup software resources"]; + --- [label="Sup software resources"]; a=>b [label="Initialize (...)", textcolor="red", linecolor="red"]; - --- [label="Setup the peripheral"]; + --- [label="Sup the peripheral"]; a=>b [label="PowerControl (ARM_POWER_FULL)", textcolor="red", linecolor="red"]; --- [label="Operate with the peripheral"]; a=>b [label="Data Transfer Functions"]; diff --git a/font.c b/font.c index 4b2732f..e4fe9a9 100644 --- a/font.c +++ b/font.c @@ -18,202 +18,202 @@ // removed last and middle column which was all 0x00 // also the space char is not needed -const uint8_t gFontBig[95 - 1][16 - 2] = -{ -#if 0 -// {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // , 0x00}, // ' ' - {0x00, 0x00, 0x70, 0xF8, 0xF8, 0x70, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x1B, 0x1B, 0x00, 0x00}, // , 0x00}, // '!' - {0x00, 0x1E, 0x3E, 0x00, 0x00, 0x3E, 0x1E, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // , 0x00}, // '"' - {0x40, 0xF0, 0xF0, 0x40, 0xF0, 0xF0, 0x40, /*0x00,*/ 0x04, 0x1F, 0x1F, 0x04, 0x1F, 0x1F, 0x04}, // , 0x00}, // '#' - {0x70, 0xF8, 0x88, 0x8F, 0x8F, 0x98, 0x30, /*0x00,*/ 0x06, 0x0C, 0x08, 0x38, 0x38, 0x0F, 0x07}, // , 0x00}, // '$' - {0x60, 0x60, 0x00, 0x00, 0x80, 0xC0, 0x60, /*0x00,*/ 0x18, 0x0C, 0x06, 0x03, 0x01, 0x18, 0x18}, // , 0x00}, // '%' - {0x00, 0xB0, 0xF8, 0xC8, 0x78, 0xB0, 0x80, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x11, 0x0F, 0x1F, 0x10}, // , 0x00}, // '&' - {0x00, 0x20, 0x3E, 0x1E, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // , 0x00}, // ''' - {0x00, 0x00, 0xE0, 0xF0, 0x18, 0x08, 0x00, /*0x00,*/ 0x00, 0x00, 0x07, 0x0F, 0x18, 0x10, 0x00}, // , 0x00}, // '(' - {0x00, 0x00, 0x08, 0x18, 0xF0, 0xE0, 0x00, /*0x00,*/ 0x00, 0x00, 0x10, 0x18, 0x0F, 0x07, 0x00}, // , 0x00}, // ')' - {0x00, 0x40, 0xC0, 0x80, 0x80, 0xC0, 0x40, /*0x00,*/ 0x01, 0x05, 0x07, 0x03, 0x03, 0x07, 0x05}, // , 0x01}, // '*' - {0x00, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, /*0x00,*/ 0x00, 0x01, 0x01, 0x07, 0x07, 0x01, 0x01}, // , 0x00}, // '+' - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x20, 0x3C, 0x1C, 0x00, 0x00}, // , 0x00}, // ',' - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}, // , 0x00}, // '-' - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00}, // , 0x00}, // '.' - {0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x60, /*0x00,*/ 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00, 0x00}, // , 0x00}, // '/' - {0xF0, 0xF8, 0x08, 0x88, 0x48, 0xF8, 0xF0, /*0x00,*/ 0x0F, 0x1F, 0x12, 0x11, 0x10, 0x1F, 0x0F}, // , 0x00}, // '0' - {0x00, 0x20, 0x30, 0xF8, 0xF8, 0x00, 0x00, /*0x00,*/ 0x00, 0x10, 0x10, 0x1F, 0x1F, 0x10, 0x10}, // , 0x00}, // '1' - {0x10, 0x18, 0x08, 0x88, 0xC8, 0x78, 0x30, /*0x00,*/ 0x1C, 0x1E, 0x13, 0x11, 0x10, 0x18, 0x18}, // , 0x00}, // '2' - {0x10, 0x18, 0x88, 0x88, 0x88, 0xF8, 0x70, /*0x00,*/ 0x08, 0x18, 0x10, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // '3' - {0x80, 0xC0, 0x60, 0x30, 0xF8, 0xF8, 0x00, /*0x00,*/ 0x01, 0x01, 0x01, 0x11, 0x1F, 0x1F, 0x11}, // , 0x00}, // '4' - {0xF8, 0xF8, 0x88, 0x88, 0x88, 0x88, 0x08, /*0x00,*/ 0x08, 0x18, 0x10, 0x10, 0x11, 0x1F, 0x0F}, // , 0x00}, // '5' - {0xE0, 0xF0, 0x98, 0x88, 0x88, 0x80, 0x00, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // '6' - {0x18, 0x18, 0x08, 0x08, 0x88, 0xF8, 0x78, /*0x00,*/ 0x00, 0x00, 0x1E, 0x1F, 0x01, 0x00, 0x00}, // , 0x00}, // '7' - {0x70, 0xF8, 0x88, 0x88, 0x88, 0xF8, 0x70, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // '8' - {0x70, 0xF8, 0x88, 0x88, 0x88, 0xF8, 0xF0, /*0x00,*/ 0x00, 0x10, 0x10, 0x10, 0x18, 0x0F, 0x07}, // , 0x00}, // '9' - {0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x00}, // , 0x00}, // ':' - {0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x10, 0x1C, 0x0C, 0x00, 0x00}, // , 0x00}, // ';' - {0x00, 0x00, 0x80, 0xC0, 0x60, 0x30, 0x10, /*0x00,*/ 0x00, 0x01, 0x03, 0x06, 0x0C, 0x18, 0x10}, // , 0x00}, // '<' - {0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, /*0x00,*/ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04}, // , 0x00}, // '=' - {0x00, 0x10, 0x30, 0x60, 0xC0, 0x80, 0x00, /*0x00,*/ 0x00, 0x10, 0x18, 0x0C, 0x06, 0x03, 0x01}, // , 0x00}, // '>' - {0x30, 0x38, 0x08, 0x88, 0xC8, 0x78, 0x30, /*0x00,*/ 0x00, 0x00, 0x00, 0x1B, 0x1B, 0x00, 0x00}, // , 0x00}, // '?' - {0xE0, 0xF0, 0x10, 0x90, 0x90, 0xF0, 0xE0, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x17, 0x17, 0x17, 0x03}, // , 0x00}, // '@' - {0xC0, 0xE0, 0x30, 0x18, 0x30, 0xE0, 0xC0, /*0x00,*/ 0x1F, 0x1F, 0x01, 0x01, 0x01, 0x1F, 0x1F}, // , 0x00}, // 'A' - {0x08, 0xF8, 0xF8, 0x88, 0x88, 0xF8, 0x70, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // 'B' - {0xE0, 0xF0, 0x18, 0x08, 0x08, 0x18, 0x30, /*0x00,*/ 0x07, 0x0F, 0x18, 0x10, 0x10, 0x18, 0x0C}, // , 0x00}, // 'C' - {0x08, 0xF8, 0xF8, 0x08, 0x18, 0xF0, 0xE0, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x18, 0x0F, 0x07}, // , 0x00}, // 'D' - {0x08, 0xF8, 0xF8, 0x88, 0xC8, 0x18, 0x38, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x11, 0x18, 0x1C}, // , 0x00}, // 'E' - {0x08, 0xF8, 0xF8, 0x88, 0xC8, 0x18, 0x38, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x01, 0x00, 0x00}, // , 0x00}, // 'F' - {0xE0, 0xF0, 0x18, 0x08, 0x08, 0x18, 0x30, /*0x00,*/ 0x07, 0x0F, 0x18, 0x11, 0x11, 0x0F, 0x1F}, // , 0x00}, // 'G' - {0xF8, 0xF8, 0x80, 0x80, 0x80, 0xF8, 0xF8, /*0x00,*/ 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x1F}, // , 0x00}, // 'H' - {0x00, 0x00, 0x08, 0xF8, 0xF8, 0x08, 0x00, /*0x00,*/ 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00}, // , 0x00}, // 'I' - {0x00, 0x00, 0x00, 0x08, 0xF8, 0xF8, 0x08, /*0x00,*/ 0x0E, 0x1E, 0x10, 0x10, 0x1F, 0x0F, 0x00}, // , 0x00}, // 'J' - {0x08, 0xF8, 0xF8, 0x80, 0xE0, 0x78, 0x18, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x01, 0x03, 0x1E, 0x1C}, // , 0x00}, // 'K' - {0x08, 0xF8, 0xF8, 0x08, 0x00, 0x00, 0x00, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x10, 0x18, 0x1C}, // , 0x00}, // 'L' - {0xF8, 0xF8, 0x70, 0xE0, 0x70, 0xF8, 0xF8, /*0x00,*/ 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x1F}, // , 0x00}, // 'M' - {0xF8, 0xF8, 0x70, 0xE0, 0xC0, 0xF8, 0xF8, /*0x00,*/ 0x1F, 0x1F, 0x00, 0x00, 0x01, 0x1F, 0x1F}, // , 0x00}, // 'N' - {0xE0, 0xF0, 0x18, 0x08, 0x18, 0xF0, 0xE0, /*0x00,*/ 0x07, 0x0F, 0x18, 0x10, 0x18, 0x0F, 0x07}, // , 0x00}, // 'O' - {0x08, 0xF8, 0xF8, 0x88, 0x88, 0xF8, 0x70, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00, 0x00}, // , 0x00}, // 'P' - {0xF0, 0xF8, 0x08, 0x08, 0x08, 0xF8, 0xF0, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x1C, 0x78, 0x7F, 0x4F}, // , 0x00}, // 'Q' - {0x08, 0xF8, 0xF8, 0x88, 0x88, 0xF8, 0x70, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x00, 0x01, 0x1F, 0x1E}, // , 0x00}, // 'R' - {0x30, 0x78, 0xC8, 0x88, 0x88, 0x38, 0x30, /*0x00,*/ 0x0C, 0x1C, 0x10, 0x10, 0x11, 0x1F, 0x0E}, // , 0x00}, // 'S' - {0x00, 0x38, 0x18, 0xF8, 0xF8, 0x18, 0x38, /*0x00,*/ 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00}, // , 0x00}, // 'T' - {0xF8, 0xF8, 0x00, 0x00, 0x00, 0xF8, 0xF8, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // 'U' - {0xF8, 0xF8, 0x00, 0x00, 0x00, 0xF8, 0xF8, /*0x00,*/ 0x03, 0x07, 0x0C, 0x18, 0x0C, 0x07, 0x03}, // , 0x00}, // 'V' - {0xF8, 0xF8, 0x00, 0x00, 0x00, 0xF8, 0xF8, /*0x00,*/ 0x07, 0x1F, 0x1C, 0x07, 0x1C, 0x1F, 0x07}, // , 0x00}, // 'W' - {0x18, 0x78, 0xE0, 0x80, 0xE0, 0x78, 0x18, /*0x00,*/ 0x18, 0x1E, 0x07, 0x01, 0x07, 0x1E, 0x18}, // , 0x00}, // 'X' - {0x00, 0x78, 0xF8, 0x80, 0x80, 0xF8, 0x78, /*0x00,*/ 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00}, // , 0x00}, // 'Y' - {0x38, 0x18, 0x08, 0x88, 0xC8, 0x78, 0x38, /*0x00,*/ 0x1C, 0x1E, 0x13, 0x11, 0x10, 0x18, 0x1C}, // , 0x00}, // 'Z' - {0x00, 0x00, 0xF8, 0xF8, 0x08, 0x08, 0x00, /*0x00,*/ 0x00, 0x00, 0x1F, 0x1F, 0x10, 0x10, 0x00}, // , 0x00}, // '[' - {0x70, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x01, 0x03, 0x07, 0x0E, 0x1C}, // , 0x00}, // '"\' - {0x00, 0x00, 0x08, 0x08, 0xF8, 0xF8, 0x00, /*0x00,*/ 0x00, 0x00, 0x10, 0x10, 0x1F, 0x1F, 0x00}, // , 0x00}, // ']' - {0x10, 0x18, 0x0E, 0x07, 0x0E, 0x18, 0x10, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // , 0x00}, // '^' - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40}, // , 0x40}, // '_' - {0x00, 0x00, 0x07, 0x0F, 0x08, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // , 0x00}, // '`' - {0x00, 0x40, 0x40, 0x40, 0xC0, 0x80, 0x00, /*0x00,*/ 0x0E, 0x1F, 0x11, 0x11, 0x0F, 0x1F, 0x10}, // , 0x00}, // 'a' - {0x08, 0xF8, 0xF8, 0x40, 0xC0, 0x80, 0x00, /*0x00,*/ 0x10, 0x1F, 0x0F, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // 'b' - {0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x18, 0x08}, // , 0x00}, // 'c' - {0x00, 0x80, 0xC0, 0x48, 0xF8, 0xF8, 0x00, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x10, 0x0F, 0x1F, 0x10}, // , 0x00}, // 'd' - {0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, /*0x00,*/ 0x0F, 0x1F, 0x11, 0x11, 0x11, 0x19, 0x09}, // , 0x00}, // 'e' - {0x80, 0xF0, 0xF8, 0x88, 0x18, 0x30, 0x00, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00, 0x00}, // , 0x00}, // 'f' - {0x80, 0xC0, 0x40, 0x40, 0x80, 0xC0, 0x40, /*0x00,*/ 0x4F, 0xDF, 0x90, 0x90, 0xFF, 0x7F, 0x00}, // , 0x00}, // 'g' - {0x08, 0xF8, 0xF8, 0x80, 0x40, 0xC0, 0x80, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x00, 0x00, 0x1F, 0x1F}, // , 0x00}, // 'h' - {0x00, 0x00, 0x40, 0xD8, 0xD8, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00}, // , 0x00}, // 'i' - {0x00, 0x00, 0x00, 0x00, 0x40, 0xD8, 0xD8, /*0x00,*/ 0x00, 0x60, 0xE0, 0x80, 0x80, 0xFF, 0x7F}, // , 0x00}, // 'j' - {0x08, 0xF8, 0xF8, 0x00, 0x80, 0xC0, 0x40, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x03, 0x07, 0x1C, 0x18}, // , 0x00}, // 'k' - {0x00, 0x00, 0x08, 0xF8, 0xF8, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00}, // , 0x00}, // 'l' - {0xC0, 0xC0, 0xC0, 0x80, 0xC0, 0xC0, 0x80, /*0x00,*/ 0x1F, 0x1F, 0x00, 0x1F, 0x00, 0x1F, 0x1F}, // , 0x00}, // 'm' - {0x40, 0xC0, 0x80, 0x40, 0x40, 0xC0, 0x80, /*0x00,*/ 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x1F, 0x1F}, // , 0x00}, // 'n' - {0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // 'o' - {0x40, 0xC0, 0x80, 0x40, 0x40, 0xC0, 0x80, /*0x00,*/ 0x80, 0xFF, 0xFF, 0x90, 0x10, 0x1F, 0x0F}, // , 0x00}, // 'p' - {0x80, 0xC0, 0x40, 0x40, 0x80, 0xC0, 0x40, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x90, 0xFF, 0xFF, 0x80}, // , 0x00}, // 'q' - {0x40, 0xC0, 0x80, 0xC0, 0x40, 0xC0, 0x80, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00, 0x01}, // , 0x00}, // 'r' - {0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, /*0x00,*/ 0x08, 0x19, 0x13, 0x12, 0x16, 0x1C, 0x08}, // , 0x00}, // 's' - {0x40, 0x40, 0xF0, 0xF8, 0x40, 0x40, 0x00, /*0x00,*/ 0x00, 0x00, 0x0F, 0x1F, 0x10, 0x18, 0x08}, // , 0x00}, // 't' - {0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x10, 0x0F, 0x1F, 0x10}, // , 0x00}, // 'u' - {0x00, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, /*0x00,*/ 0x00, 0x07, 0x0F, 0x18, 0x18, 0x0F, 0x07}, // , 0x00}, // 'v' - {0xC0, 0xC0, 0x00, 0x00, 0x00, 0xC0, 0xC0, /*0x00,*/ 0x0F, 0x1F, 0x18, 0x0E, 0x18, 0x1F, 0x0F}, // , 0x00}, // 'w' - {0x40, 0xC0, 0x80, 0x00, 0x80, 0xC0, 0x40, /*0x00,*/ 0x10, 0x18, 0x0F, 0x07, 0x0F, 0x18, 0x10}, // , 0x00}, // 'x' - {0xC0, 0xC0, 0x00, 0x00, 0x00, 0xC0, 0xC0, /*0x00,*/ 0x8F, 0x9F, 0x90, 0x90, 0xD0, 0x7F, 0x3F}, // , 0x00}, // 'y' - {0xC0, 0xC0, 0x40, 0x40, 0xC0, 0xC0, 0x40, /*0x00,*/ 0x18, 0x1C, 0x16, 0x13, 0x11, 0x18, 0x18}, // , 0x00}, // 'z' - {0x00, 0x80, 0x80, 0xF0, 0x78, 0x08, 0x08, /*0x00,*/ 0x00, 0x00, 0x00, 0x0F, 0x1F, 0x10, 0x10}, // , 0x00}, // '{' - {0x00, 0x00, 0x00, 0x78, 0x78, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x00, 0x00}, // , 0x00}, // '|' - {0x00, 0x08, 0x08, 0x78, 0xF0, 0x80, 0x80, /*0x00,*/ 0x00, 0x10, 0x10, 0x1F, 0x0F, 0x00, 0x00}, // , 0x00}, // '}' - {0x10, 0x18, 0x08, 0x18, 0x10, 0x18, 0x08, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // , 0x00} // '->' -#else - // {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // ' ' - {0x00, 0x00, 0x00, 0xFC, 0xFC, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00}, // '!' - {0x00, 0x0F, 0x1F, 0x00, 0x00, 0x1F, 0x0F, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // '"' - {0x20, 0xF8, 0xF8, 0x20, 0xF8, 0xF8, 0x20, /*0x00,*/ 0x02, 0x0F, 0x0F, 0x02, 0x0F, 0x0F, 0x02}, // '#' - {0x70, 0xF8, 0x88, 0x8E, 0x8E, 0x98, 0x10, /*0x00,*/ 0x04, 0x0C, 0x08, 0x38, 0x38, 0x0F, 0x07}, // '$' - {0x30, 0x30, 0x00, 0x80, 0xC0, 0x60, 0x30, /*0x00,*/ 0x0C, 0x06, 0x03, 0x01, 0x00, 0x0C, 0x0C}, // '%' - {0x80, 0xD8, 0x7C, 0xE4, 0xBC, 0xD8, 0x40, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x07, 0x0F, 0x08}, // '&' - {0x00, 0x10, 0x1F, 0x0F, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // ''' - {0x00, 0x00, 0xF0, 0xF8, 0x0C, 0x04, 0x00, /*0x00,*/ 0x00, 0x00, 0x03, 0x07, 0x0C, 0x08, 0x00}, // '(' - {0x00, 0x00, 0x04, 0x0C, 0xF8, 0xF0, 0x00, /*0x00,*/ 0x00, 0x00, 0x08, 0x0C, 0x07, 0x03, 0x00}, // ')' - {0x00, 0x80, 0xA0, 0xE0, 0xC0, 0xE0, 0xA0, /*0x80,*/ 0x00, 0x00, 0x02, 0x03, 0x01, 0x03, 0x02}, // '*' - {0x00, 0x80, 0x80, 0xE0, 0xE0, 0x80, 0x80, /*0x00,*/ 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00}, // '+' - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x10, 0x1E, 0x0E, 0x00, 0x00}, // ',' - {0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // '-' - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x00}, // '.' - {0x00, 0x00, 0x00, 0x80, 0xC0, 0x60, 0x30, /*0x00,*/ 0x0C, 0x06, 0x03, 0x01, 0x00, 0x00, 0x00}, // '/' - {0xF8, 0xFC, 0x04, 0x04, 0x04, 0xFC, 0xF8, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // '0' - {0x00, 0x10, 0x18, 0xFC, 0xFC, 0x00, 0x00, /*0x00,*/ 0x00, 0x08, 0x08, 0x0F, 0x0F, 0x08, 0x08}, // '1' - {0x18, 0x1C, 0x04, 0x84, 0xC4, 0x7C, 0x38, /*0x00,*/ 0x0C, 0x0E, 0x0B, 0x09, 0x08, 0x08, 0x08}, // '2' - {0x18, 0x1C, 0x44, 0x44, 0x44, 0xFC, 0xB8, /*0x00,*/ 0x06, 0x0E, 0x08, 0x08, 0x08, 0x0F, 0x07}, // '3' - {0x80, 0xC0, 0x60, 0x30, 0x18, 0xFC, 0xFC, /*0x00,*/ 0x01, 0x01, 0x01, 0x01, 0x01, 0x0F, 0x0F}, // '4' - {0x7C, 0x7C, 0x44, 0x44, 0x44, 0xC4, 0x84, /*0x00,*/ 0x04, 0x0C, 0x08, 0x08, 0x08, 0x0F, 0x07}, // '5' - {0xF0, 0xF8, 0x4C, 0x44, 0x44, 0xC4, 0x80, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // '6' - {0x04, 0x04, 0x04, 0x84, 0xE4, 0x7C, 0x1C, /*0x00,*/ 0x00, 0x00, 0x0E, 0x0F, 0x01, 0x00, 0x00}, // '7' - {0xB8, 0xFC, 0x44, 0x44, 0x44, 0xFC, 0xB8, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // '8' - {0x78, 0xFC, 0x84, 0x84, 0x84, 0xFC, 0xF8, /*0x00,*/ 0x00, 0x08, 0x08, 0x08, 0x0C, 0x07, 0x03}, // '9' - {0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00}, // ':' - {0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x08, 0x0E, 0x06, 0x00, 0x00}, // ';' - {0x00, 0x80, 0xC0, 0x60, 0x30, 0x18, 0x08, /*0x00,*/ 0x00, 0x00, 0x01, 0x03, 0x06, 0x0C, 0x08}, // '<' - {0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, /*0x00,*/ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}, // '=' - {0x00, 0x08, 0x18, 0x30, 0x60, 0xC0, 0x80, /*0x00,*/ 0x00, 0x08, 0x0C, 0x06, 0x03, 0x01, 0x00}, // '>' - {0x38, 0x3C, 0x04, 0x84, 0xC4, 0x7C, 0x38, /*0x00,*/ 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00}, // '?' - {0xF0, 0xF8, 0x08, 0xC8, 0xC8, 0xF8, 0xF0, /*0x00,*/ 0x07, 0x0F, 0x08, 0x0B, 0x0B, 0x0B, 0x01}, // '@' - {0xF8, 0xFC, 0x84, 0x84, 0x84, 0xFC, 0xF8, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F}, // 'A' - {0xFC, 0xFC, 0x44, 0x44, 0x44, 0xFC, 0xB8, /*0x00,*/ 0x0F, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'B' - {0xF8, 0xFC, 0x04, 0x04, 0x04, 0x1C, 0x18, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0E, 0x06}, // 'C' - {0xFC, 0xFC, 0x04, 0x04, 0x0C, 0xF8, 0xF0, /*0x00,*/ 0x0F, 0x0F, 0x08, 0x08, 0x0C, 0x07, 0x03}, // 'D' - {0xFC, 0xFC, 0x44, 0x44, 0x44, 0x04, 0x04, /*0x00,*/ 0x0F, 0x0F, 0x08, 0x08, 0x08, 0x08, 0x08}, // 'E' - {0xFC, 0xFC, 0x44, 0x44, 0x44, 0x04, 0x04, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00}, // 'F' - {0xF8, 0xFC, 0x04, 0x84, 0x84, 0x9C, 0x98, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'G' - {0xFC, 0xFC, 0x40, 0x40, 0x40, 0xFC, 0xFC, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F}, // 'H' - {0x00, 0x00, 0x04, 0xFC, 0xFC, 0x04, 0x00, /*0x00,*/ 0x00, 0x00, 0x08, 0x0F, 0x0F, 0x08, 0x00}, // 'I' - {0x00, 0x00, 0x00, 0x04, 0xFC, 0xFC, 0x04, /*0x00,*/ 0x06, 0x0E, 0x08, 0x08, 0x0F, 0x07, 0x00}, // 'J' - {0xFC, 0xFC, 0xE0, 0x30, 0x18, 0x0C, 0x04, /*0x00,*/ 0x0F, 0x0F, 0x01, 0x03, 0x06, 0x0C, 0x08}, // 'K' - {0xFC, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x0F, 0x0F, 0x08, 0x08, 0x08, 0x08, 0x08}, // 'L' - {0xFC, 0xFC, 0x18, 0x70, 0x18, 0xFC, 0xFC, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F}, // 'M' - {0xFC, 0xFC, 0x60, 0xC0, 0x80, 0xFC, 0xFC, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x01, 0x0F, 0x0F}, // 'N' - {0xF8, 0xFC, 0x04, 0x04, 0x04, 0xFC, 0xF8, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'O' - {0xFC, 0xFC, 0x84, 0x84, 0x84, 0xFC, 0x78, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00}, // 'P' - {0xF8, 0xFC, 0x04, 0x04, 0x04, 0xFC, 0xF8, /*0x00,*/ 0x07, 0x0F, 0x08, 0x0C, 0x0C, 0x1F, 0x17}, // 'Q' - {0xFC, 0xFC, 0x84, 0x84, 0x84, 0xFC, 0x78, /*0x00,*/ 0x0F, 0x0F, 0x01, 0x03, 0x06, 0x0C, 0x08}, // 'R' - {0x38, 0x7C, 0x44, 0x44, 0x44, 0xCC, 0x88, /*0x00,*/ 0x06, 0x0E, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'S' - {0x00, 0x04, 0x04, 0xFC, 0xFC, 0x04, 0x04, /*0x00,*/ 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00}, // 'T' - {0xFC, 0xFC, 0x00, 0x00, 0x00, 0xFC, 0xFC, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'U' - {0x7C, 0xFC, 0x80, 0x00, 0x80, 0xFC, 0x7C, /*0x00,*/ 0x00, 0x03, 0x0F, 0x0C, 0x0F, 0x03, 0x00}, // 'V' - {0xFC, 0xFC, 0x00, 0x80, 0x00, 0xFC, 0xFC, /*0x00,*/ 0x0F, 0x0F, 0x06, 0x03, 0x06, 0x0F, 0x0F}, // 'W' - {0x0C, 0x3C, 0xF0, 0xC0, 0xF0, 0x3C, 0x0C, /*0x00,*/ 0x0C, 0x0F, 0x03, 0x00, 0x03, 0x0F, 0x0C}, // 'X' - {0x00, 0x3C, 0x7C, 0xC0, 0xC0, 0x7C, 0x3C, /*0x00,*/ 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00}, // 'Y' - {0x04, 0x04, 0x84, 0xC4, 0x64, 0x3C, 0x1C, /*0x00,*/ 0x0E, 0x0F, 0x09, 0x08, 0x08, 0x08, 0x08}, // 'Z' - {0x00, 0x00, 0xFC, 0xFC, 0x04, 0x04, 0x00, /*0x00,*/ 0x00, 0x00, 0x0F, 0x0F, 0x08, 0x08, 0x00}, // '[' - {0x38, 0x70, 0xE0, 0xC0, 0x80, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0E}, // '"\' - {0x00, 0x00, 0x04, 0x04, 0xFC, 0xFC, 0x00, /*0x00,*/ 0x00, 0x00, 0x08, 0x08, 0x0F, 0x0F, 0x00}, // ']' - {0x08, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x08, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // '^' - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20}, // '_' - {0x00, 0x00, 0x03, 0x07, 0x04, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // '`' - {0x00, 0xA0, 0xA0, 0xA0, 0xA0, 0xE0, 0xC0, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x0F}, // 'a' - {0xFC, 0xFC, 0x20, 0x20, 0x20, 0xE0, 0xC0, /*0x00,*/ 0x0F, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'b' - {0xC0, 0xE0, 0x20, 0x20, 0x20, 0x60, 0x40, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0C, 0x04}, // 'c' - {0xC0, 0xE0, 0x20, 0x20, 0x20, 0xFC, 0xFC, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x0F}, // 'd' - {0xC0, 0xE0, 0x20, 0x20, 0x20, 0xE0, 0xC0, /*0x00,*/ 0x07, 0x0F, 0x09, 0x09, 0x09, 0x09, 0x01}, // 'e' - {0x20, 0x20, 0xF8, 0xFC, 0x24, 0x24, 0x04, /*0x00,*/ 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00}, // 'f' - {0xC0, 0xE0, 0x20, 0x20, 0x20, 0xE0, 0xE0, /*0x00,*/ 0x07, 0x4F, 0x48, 0x48, 0x48, 0x7F, 0x3F}, // 'g' - {0xFC, 0xFC, 0x20, 0x20, 0x20, 0xE0, 0xC0, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F}, // 'h' - {0x00, 0x00, 0x20, 0xEC, 0xEC, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x08, 0x0F, 0x0F, 0x08, 0x00}, // 'i' - {0x00, 0x00, 0x00, 0x00, 0x20, 0xEC, 0xEC, /*0x00,*/ 0x00, 0x30, 0x70, 0x40, 0x40, 0x7F, 0x3F}, // 'j' - {0xFC, 0xFC, 0x00, 0x80, 0xC0, 0x60, 0x20, /*0x00,*/ 0x0F, 0x0F, 0x01, 0x03, 0x06, 0x0C, 0x08}, // 'k' - {0x00, 0x00, 0x04, 0xFC, 0xFC, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x08, 0x0F, 0x0F, 0x08, 0x00}, // 'l' - {0xE0, 0xE0, 0x20, 0xE0, 0x20, 0xE0, 0xC0, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x0F, 0x00, 0x0F, 0x0F}, // 'm' - {0xE0, 0xE0, 0x20, 0x20, 0x20, 0xE0, 0xC0, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F}, // 'n' - {0xC0, 0xE0, 0x20, 0x20, 0x20, 0xE0, 0xC0, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'o' - {0xE0, 0xE0, 0x20, 0x20, 0x20, 0xE0, 0xC0, /*0x00,*/ 0x7F, 0x7F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'p' - {0xC0, 0xE0, 0x20, 0x20, 0x20, 0xE0, 0xE0, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x7F, 0x7F}, // 'q' - {0xE0, 0xE0, 0x60, 0x20, 0x20, 0x20, 0x20, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00}, // 'r' - {0xC0, 0xE0, 0x20, 0x20, 0x20, 0x20, 0x20, /*0x00,*/ 0x08, 0x09, 0x09, 0x09, 0x09, 0x0F, 0x06}, // 's' - {0x20, 0x20, 0xFC, 0xFC, 0x20, 0x20, 0x00, /*0x00,*/ 0x00, 0x00, 0x07, 0x0F, 0x08, 0x08, 0x08}, // 't' - {0xE0, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0xE0, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x0F}, // 'u' - {0xE0, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0xE0, /*0x00,*/ 0x00, 0x03, 0x0F, 0x0C, 0x0F, 0x03, 0x00}, // 'v' - {0xE0, 0xE0, 0x00, 0x80, 0x00, 0xE0, 0xE0, /*0x00,*/ 0x07, 0x0F, 0x08, 0x0F, 0x08, 0x0F, 0x07}, // 'w' - {0x60, 0xE0, 0x80, 0x00, 0x80, 0xE0, 0x60, /*0x00,*/ 0x0C, 0x0E, 0x03, 0x01, 0x03, 0x0E, 0x0C}, // 'x' - {0xE0, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0xE0, /*0x00,*/ 0x07, 0x4F, 0x48, 0x48, 0x48, 0x7F, 0x3F}, // 'y' - {0x20, 0x20, 0x20, 0xA0, 0xE0, 0x60, 0x20, /*0x00,*/ 0x0C, 0x0E, 0x0B, 0x09, 0x08, 0x08, 0x08}, // 'z' - {0x00, 0x00, 0x40, 0xF8, 0xBC, 0x04, 0x04, /*0x00,*/ 0x00, 0x00, 0x00, 0x07, 0x0F, 0x08, 0x08}, // '{' - {0x00, 0x00, 0x00, 0xBC, 0xBC, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00}, // '|' - {0x00, 0x04, 0x04, 0xBC, 0xF8, 0x40, 0x00, /*0x00,*/ 0x00, 0x08, 0x08, 0x0F, 0x07, 0x00, 0x00}, // '}' - {0x08, 0x0C, 0x04, 0x0C, 0x08, 0x0C, 0x04, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // '->' -#endif -}; +//const uint8_t gFontBig[95 - 1][16 - 2] = +//{ +//#if 0 +//// {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // , 0x00}, // ' ' +// {0x00, 0x00, 0x70, 0xF8, 0xF8, 0x70, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x1B, 0x1B, 0x00, 0x00}, // , 0x00}, // '!' +// {0x00, 0x1E, 0x3E, 0x00, 0x00, 0x3E, 0x1E, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // , 0x00}, // '"' +// {0x40, 0xF0, 0xF0, 0x40, 0xF0, 0xF0, 0x40, /*0x00,*/ 0x04, 0x1F, 0x1F, 0x04, 0x1F, 0x1F, 0x04}, // , 0x00}, // '#' +// {0x70, 0xF8, 0x88, 0x8F, 0x8F, 0x98, 0x30, /*0x00,*/ 0x06, 0x0C, 0x08, 0x38, 0x38, 0x0F, 0x07}, // , 0x00}, // '$' +// {0x60, 0x60, 0x00, 0x00, 0x80, 0xC0, 0x60, /*0x00,*/ 0x18, 0x0C, 0x06, 0x03, 0x01, 0x18, 0x18}, // , 0x00}, // '%' +// {0x00, 0xB0, 0xF8, 0xC8, 0x78, 0xB0, 0x80, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x11, 0x0F, 0x1F, 0x10}, // , 0x00}, // '&' +// {0x00, 0x20, 0x3E, 0x1E, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // , 0x00}, // ''' +// {0x00, 0x00, 0xE0, 0xF0, 0x18, 0x08, 0x00, /*0x00,*/ 0x00, 0x00, 0x07, 0x0F, 0x18, 0x10, 0x00}, // , 0x00}, // '(' +// {0x00, 0x00, 0x08, 0x18, 0xF0, 0xE0, 0x00, /*0x00,*/ 0x00, 0x00, 0x10, 0x18, 0x0F, 0x07, 0x00}, // , 0x00}, // ')' +// {0x00, 0x40, 0xC0, 0x80, 0x80, 0xC0, 0x40, /*0x00,*/ 0x01, 0x05, 0x07, 0x03, 0x03, 0x07, 0x05}, // , 0x01}, // '*' +// {0x00, 0x00, 0x00, 0xC0, 0xC0, 0x00, 0x00, /*0x00,*/ 0x00, 0x01, 0x01, 0x07, 0x07, 0x01, 0x01}, // , 0x00}, // '+' +// {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x20, 0x3C, 0x1C, 0x00, 0x00}, // , 0x00}, // ',' +// {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}, // , 0x00}, // '-' +// {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00}, // , 0x00}, // '.' +// {0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x60, /*0x00,*/ 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00, 0x00}, // , 0x00}, // '/' +// {0xF0, 0xF8, 0x08, 0x88, 0x48, 0xF8, 0xF0, /*0x00,*/ 0x0F, 0x1F, 0x12, 0x11, 0x10, 0x1F, 0x0F}, // , 0x00}, // '0' +// {0x00, 0x20, 0x30, 0xF8, 0xF8, 0x00, 0x00, /*0x00,*/ 0x00, 0x10, 0x10, 0x1F, 0x1F, 0x10, 0x10}, // , 0x00}, // '1' +// {0x10, 0x18, 0x08, 0x88, 0xC8, 0x78, 0x30, /*0x00,*/ 0x1C, 0x1E, 0x13, 0x11, 0x10, 0x18, 0x18}, // , 0x00}, // '2' +// {0x10, 0x18, 0x88, 0x88, 0x88, 0xF8, 0x70, /*0x00,*/ 0x08, 0x18, 0x10, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // '3' +// {0x80, 0xC0, 0x60, 0x30, 0xF8, 0xF8, 0x00, /*0x00,*/ 0x01, 0x01, 0x01, 0x11, 0x1F, 0x1F, 0x11}, // , 0x00}, // '4' +// {0xF8, 0xF8, 0x88, 0x88, 0x88, 0x88, 0x08, /*0x00,*/ 0x08, 0x18, 0x10, 0x10, 0x11, 0x1F, 0x0F}, // , 0x00}, // '5' +// {0xE0, 0xF0, 0x98, 0x88, 0x88, 0x80, 0x00, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // '6' +// {0x18, 0x18, 0x08, 0x08, 0x88, 0xF8, 0x78, /*0x00,*/ 0x00, 0x00, 0x1E, 0x1F, 0x01, 0x00, 0x00}, // , 0x00}, // '7' +// {0x70, 0xF8, 0x88, 0x88, 0x88, 0xF8, 0x70, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // '8' +// {0x70, 0xF8, 0x88, 0x88, 0x88, 0xF8, 0xF0, /*0x00,*/ 0x00, 0x10, 0x10, 0x10, 0x18, 0x0F, 0x07}, // , 0x00}, // '9' +// {0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x00}, // , 0x00}, // ':' +// {0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x10, 0x1C, 0x0C, 0x00, 0x00}, // , 0x00}, // ';' +// {0x00, 0x00, 0x80, 0xC0, 0x60, 0x30, 0x10, /*0x00,*/ 0x00, 0x01, 0x03, 0x06, 0x0C, 0x18, 0x10}, // , 0x00}, // '<' +// {0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, /*0x00,*/ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04}, // , 0x00}, // '=' +// {0x00, 0x10, 0x30, 0x60, 0xC0, 0x80, 0x00, /*0x00,*/ 0x00, 0x10, 0x18, 0x0C, 0x06, 0x03, 0x01}, // , 0x00}, // '>' +// {0x30, 0x38, 0x08, 0x88, 0xC8, 0x78, 0x30, /*0x00,*/ 0x00, 0x00, 0x00, 0x1B, 0x1B, 0x00, 0x00}, // , 0x00}, // '?' +// {0xE0, 0xF0, 0x10, 0x90, 0x90, 0xF0, 0xE0, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x17, 0x17, 0x17, 0x03}, // , 0x00}, // '@' +// {0xC0, 0xE0, 0x30, 0x18, 0x30, 0xE0, 0xC0, /*0x00,*/ 0x1F, 0x1F, 0x01, 0x01, 0x01, 0x1F, 0x1F}, // , 0x00}, // 'A' +// {0x08, 0xF8, 0xF8, 0x88, 0x88, 0xF8, 0x70, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // 'B' +// {0xE0, 0xF0, 0x18, 0x08, 0x08, 0x18, 0x30, /*0x00,*/ 0x07, 0x0F, 0x18, 0x10, 0x10, 0x18, 0x0C}, // , 0x00}, // 'C' +// {0x08, 0xF8, 0xF8, 0x08, 0x18, 0xF0, 0xE0, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x18, 0x0F, 0x07}, // , 0x00}, // 'D' +// {0x08, 0xF8, 0xF8, 0x88, 0xC8, 0x18, 0x38, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x11, 0x18, 0x1C}, // , 0x00}, // 'E' +// {0x08, 0xF8, 0xF8, 0x88, 0xC8, 0x18, 0x38, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x01, 0x00, 0x00}, // , 0x00}, // 'F' +// {0xE0, 0xF0, 0x18, 0x08, 0x08, 0x18, 0x30, /*0x00,*/ 0x07, 0x0F, 0x18, 0x11, 0x11, 0x0F, 0x1F}, // , 0x00}, // 'G' +// {0xF8, 0xF8, 0x80, 0x80, 0x80, 0xF8, 0xF8, /*0x00,*/ 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x1F}, // , 0x00}, // 'H' +// {0x00, 0x00, 0x08, 0xF8, 0xF8, 0x08, 0x00, /*0x00,*/ 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00}, // , 0x00}, // 'I' +// {0x00, 0x00, 0x00, 0x08, 0xF8, 0xF8, 0x08, /*0x00,*/ 0x0E, 0x1E, 0x10, 0x10, 0x1F, 0x0F, 0x00}, // , 0x00}, // 'J' +// {0x08, 0xF8, 0xF8, 0x80, 0xE0, 0x78, 0x18, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x01, 0x03, 0x1E, 0x1C}, // , 0x00}, // 'K' +// {0x08, 0xF8, 0xF8, 0x08, 0x00, 0x00, 0x00, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x10, 0x18, 0x1C}, // , 0x00}, // 'L' +// {0xF8, 0xF8, 0x70, 0xE0, 0x70, 0xF8, 0xF8, /*0x00,*/ 0x1F, 0x1F, 0x00, 0x00, 0x00, 0x1F, 0x1F}, // , 0x00}, // 'M' +// {0xF8, 0xF8, 0x70, 0xE0, 0xC0, 0xF8, 0xF8, /*0x00,*/ 0x1F, 0x1F, 0x00, 0x00, 0x01, 0x1F, 0x1F}, // , 0x00}, // 'N' +// {0xE0, 0xF0, 0x18, 0x08, 0x18, 0xF0, 0xE0, /*0x00,*/ 0x07, 0x0F, 0x18, 0x10, 0x18, 0x0F, 0x07}, // , 0x00}, // 'O' +// {0x08, 0xF8, 0xF8, 0x88, 0x88, 0xF8, 0x70, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00, 0x00}, // , 0x00}, // 'P' +// {0xF0, 0xF8, 0x08, 0x08, 0x08, 0xF8, 0xF0, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x1C, 0x78, 0x7F, 0x4F}, // , 0x00}, // 'Q' +// {0x08, 0xF8, 0xF8, 0x88, 0x88, 0xF8, 0x70, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x00, 0x01, 0x1F, 0x1E}, // , 0x00}, // 'R' +// {0x30, 0x78, 0xC8, 0x88, 0x88, 0x38, 0x30, /*0x00,*/ 0x0C, 0x1C, 0x10, 0x10, 0x11, 0x1F, 0x0E}, // , 0x00}, // 'S' +// {0x00, 0x38, 0x18, 0xF8, 0xF8, 0x18, 0x38, /*0x00,*/ 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00}, // , 0x00}, // 'T' +// {0xF8, 0xF8, 0x00, 0x00, 0x00, 0xF8, 0xF8, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // 'U' +// {0xF8, 0xF8, 0x00, 0x00, 0x00, 0xF8, 0xF8, /*0x00,*/ 0x03, 0x07, 0x0C, 0x18, 0x0C, 0x07, 0x03}, // , 0x00}, // 'V' +// {0xF8, 0xF8, 0x00, 0x00, 0x00, 0xF8, 0xF8, /*0x00,*/ 0x07, 0x1F, 0x1C, 0x07, 0x1C, 0x1F, 0x07}, // , 0x00}, // 'W' +// {0x18, 0x78, 0xE0, 0x80, 0xE0, 0x78, 0x18, /*0x00,*/ 0x18, 0x1E, 0x07, 0x01, 0x07, 0x1E, 0x18}, // , 0x00}, // 'X' +// {0x00, 0x78, 0xF8, 0x80, 0x80, 0xF8, 0x78, /*0x00,*/ 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00}, // , 0x00}, // 'Y' +// {0x38, 0x18, 0x08, 0x88, 0xC8, 0x78, 0x38, /*0x00,*/ 0x1C, 0x1E, 0x13, 0x11, 0x10, 0x18, 0x1C}, // , 0x00}, // 'Z' +// {0x00, 0x00, 0xF8, 0xF8, 0x08, 0x08, 0x00, /*0x00,*/ 0x00, 0x00, 0x1F, 0x1F, 0x10, 0x10, 0x00}, // , 0x00}, // '[' +// {0x70, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x01, 0x03, 0x07, 0x0E, 0x1C}, // , 0x00}, // '"\' +// {0x00, 0x00, 0x08, 0x08, 0xF8, 0xF8, 0x00, /*0x00,*/ 0x00, 0x00, 0x10, 0x10, 0x1F, 0x1F, 0x00}, // , 0x00}, // ']' +// {0x10, 0x18, 0x0E, 0x07, 0x0E, 0x18, 0x10, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // , 0x00}, // '^' +// {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40}, // , 0x40}, // '_' +// {0x00, 0x00, 0x07, 0x0F, 0x08, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // , 0x00}, // '`' +// {0x00, 0x40, 0x40, 0x40, 0xC0, 0x80, 0x00, /*0x00,*/ 0x0E, 0x1F, 0x11, 0x11, 0x0F, 0x1F, 0x10}, // , 0x00}, // 'a' +// {0x08, 0xF8, 0xF8, 0x40, 0xC0, 0x80, 0x00, /*0x00,*/ 0x10, 0x1F, 0x0F, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // 'b' +// {0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x18, 0x08}, // , 0x00}, // 'c' +// {0x00, 0x80, 0xC0, 0x48, 0xF8, 0xF8, 0x00, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x10, 0x0F, 0x1F, 0x10}, // , 0x00}, // 'd' +// {0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, /*0x00,*/ 0x0F, 0x1F, 0x11, 0x11, 0x11, 0x19, 0x09}, // , 0x00}, // 'e' +// {0x80, 0xF0, 0xF8, 0x88, 0x18, 0x30, 0x00, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00, 0x00}, // , 0x00}, // 'f' +// {0x80, 0xC0, 0x40, 0x40, 0x80, 0xC0, 0x40, /*0x00,*/ 0x4F, 0xDF, 0x90, 0x90, 0xFF, 0x7F, 0x00}, // , 0x00}, // 'g' +// {0x08, 0xF8, 0xF8, 0x80, 0x40, 0xC0, 0x80, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x00, 0x00, 0x1F, 0x1F}, // , 0x00}, // 'h' +// {0x00, 0x00, 0x40, 0xD8, 0xD8, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00}, // , 0x00}, // 'i' +// {0x00, 0x00, 0x00, 0x00, 0x40, 0xD8, 0xD8, /*0x00,*/ 0x00, 0x60, 0xE0, 0x80, 0x80, 0xFF, 0x7F}, // , 0x00}, // 'j' +// {0x08, 0xF8, 0xF8, 0x00, 0x80, 0xC0, 0x40, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x03, 0x07, 0x1C, 0x18}, // , 0x00}, // 'k' +// {0x00, 0x00, 0x08, 0xF8, 0xF8, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x10, 0x1F, 0x1F, 0x10, 0x00}, // , 0x00}, // 'l' +// {0xC0, 0xC0, 0xC0, 0x80, 0xC0, 0xC0, 0x80, /*0x00,*/ 0x1F, 0x1F, 0x00, 0x1F, 0x00, 0x1F, 0x1F}, // , 0x00}, // 'm' +// {0x40, 0xC0, 0x80, 0x40, 0x40, 0xC0, 0x80, /*0x00,*/ 0x00, 0x1F, 0x1F, 0x00, 0x00, 0x1F, 0x1F}, // , 0x00}, // 'n' +// {0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x10, 0x10, 0x1F, 0x0F}, // , 0x00}, // 'o' +// {0x40, 0xC0, 0x80, 0x40, 0x40, 0xC0, 0x80, /*0x00,*/ 0x80, 0xFF, 0xFF, 0x90, 0x10, 0x1F, 0x0F}, // , 0x00}, // 'p' +// {0x80, 0xC0, 0x40, 0x40, 0x80, 0xC0, 0x40, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x90, 0xFF, 0xFF, 0x80}, // , 0x00}, // 'q' +// {0x40, 0xC0, 0x80, 0xC0, 0x40, 0xC0, 0x80, /*0x00,*/ 0x10, 0x1F, 0x1F, 0x10, 0x00, 0x00, 0x01}, // , 0x00}, // 'r' +// {0x80, 0xC0, 0x40, 0x40, 0x40, 0xC0, 0x80, /*0x00,*/ 0x08, 0x19, 0x13, 0x12, 0x16, 0x1C, 0x08}, // , 0x00}, // 's' +// {0x40, 0x40, 0xF0, 0xF8, 0x40, 0x40, 0x00, /*0x00,*/ 0x00, 0x00, 0x0F, 0x1F, 0x10, 0x18, 0x08}, // , 0x00}, // 't' +// {0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, 0x00, /*0x00,*/ 0x0F, 0x1F, 0x10, 0x10, 0x0F, 0x1F, 0x10}, // , 0x00}, // 'u' +// {0x00, 0xC0, 0xC0, 0x00, 0x00, 0xC0, 0xC0, /*0x00,*/ 0x00, 0x07, 0x0F, 0x18, 0x18, 0x0F, 0x07}, // , 0x00}, // 'v' +// {0xC0, 0xC0, 0x00, 0x00, 0x00, 0xC0, 0xC0, /*0x00,*/ 0x0F, 0x1F, 0x18, 0x0E, 0x18, 0x1F, 0x0F}, // , 0x00}, // 'w' +// {0x40, 0xC0, 0x80, 0x00, 0x80, 0xC0, 0x40, /*0x00,*/ 0x10, 0x18, 0x0F, 0x07, 0x0F, 0x18, 0x10}, // , 0x00}, // 'x' +// {0xC0, 0xC0, 0x00, 0x00, 0x00, 0xC0, 0xC0, /*0x00,*/ 0x8F, 0x9F, 0x90, 0x90, 0xD0, 0x7F, 0x3F}, // , 0x00}, // 'y' +// {0xC0, 0xC0, 0x40, 0x40, 0xC0, 0xC0, 0x40, /*0x00,*/ 0x18, 0x1C, 0x16, 0x13, 0x11, 0x18, 0x18}, // , 0x00}, // 'z' +// {0x00, 0x80, 0x80, 0xF0, 0x78, 0x08, 0x08, /*0x00,*/ 0x00, 0x00, 0x00, 0x0F, 0x1F, 0x10, 0x10}, // , 0x00}, // '{' +// {0x00, 0x00, 0x00, 0x78, 0x78, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x1F, 0x1F, 0x00, 0x00}, // , 0x00}, // '|' +// {0x00, 0x08, 0x08, 0x78, 0xF0, 0x80, 0x80, /*0x00,*/ 0x00, 0x10, 0x10, 0x1F, 0x0F, 0x00, 0x00}, // , 0x00}, // '}' +// {0x10, 0x18, 0x08, 0x18, 0x10, 0x18, 0x08, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // , 0x00} // '->' +//#else +// // {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // ' ' +// {0x00, 0x00, 0x00, 0xFC, 0xFC, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00}, // '!' +// {0x00, 0x0F, 0x1F, 0x00, 0x00, 0x1F, 0x0F, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // '"' +// {0x20, 0xF8, 0xF8, 0x20, 0xF8, 0xF8, 0x20, /*0x00,*/ 0x02, 0x0F, 0x0F, 0x02, 0x0F, 0x0F, 0x02}, // '#' +// {0x70, 0xF8, 0x88, 0x8E, 0x8E, 0x98, 0x10, /*0x00,*/ 0x04, 0x0C, 0x08, 0x38, 0x38, 0x0F, 0x07}, // '$' +// {0x30, 0x30, 0x00, 0x80, 0xC0, 0x60, 0x30, /*0x00,*/ 0x0C, 0x06, 0x03, 0x01, 0x00, 0x0C, 0x0C}, // '%' +// {0x80, 0xD8, 0x7C, 0xE4, 0xBC, 0xD8, 0x40, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x07, 0x0F, 0x08}, // '&' +// {0x00, 0x10, 0x1F, 0x0F, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // ''' +// {0x00, 0x00, 0xF0, 0xF8, 0x0C, 0x04, 0x00, /*0x00,*/ 0x00, 0x00, 0x03, 0x07, 0x0C, 0x08, 0x00}, // '(' +// {0x00, 0x00, 0x04, 0x0C, 0xF8, 0xF0, 0x00, /*0x00,*/ 0x00, 0x00, 0x08, 0x0C, 0x07, 0x03, 0x00}, // ')' +// {0x00, 0x80, 0xA0, 0xE0, 0xC0, 0xE0, 0xA0, /*0x80,*/ 0x00, 0x00, 0x02, 0x03, 0x01, 0x03, 0x02}, // '*' +// {0x00, 0x80, 0x80, 0xE0, 0xE0, 0x80, 0x80, /*0x00,*/ 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00}, // '+' +// {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x10, 0x1E, 0x0E, 0x00, 0x00}, // ',' +// {0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // '-' +// {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x00}, // '.' +// {0x00, 0x00, 0x00, 0x80, 0xC0, 0x60, 0x30, /*0x00,*/ 0x0C, 0x06, 0x03, 0x01, 0x00, 0x00, 0x00}, // '/' +// {0xF8, 0xFC, 0x04, 0x04, 0x04, 0xFC, 0xF8, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // '0' +// {0x00, 0x10, 0x18, 0xFC, 0xFC, 0x00, 0x00, /*0x00,*/ 0x00, 0x08, 0x08, 0x0F, 0x0F, 0x08, 0x08}, // '1' +// {0x18, 0x1C, 0x04, 0x84, 0xC4, 0x7C, 0x38, /*0x00,*/ 0x0C, 0x0E, 0x0B, 0x09, 0x08, 0x08, 0x08}, // '2' +// {0x18, 0x1C, 0x44, 0x44, 0x44, 0xFC, 0xB8, /*0x00,*/ 0x06, 0x0E, 0x08, 0x08, 0x08, 0x0F, 0x07}, // '3' +// {0x80, 0xC0, 0x60, 0x30, 0x18, 0xFC, 0xFC, /*0x00,*/ 0x01, 0x01, 0x01, 0x01, 0x01, 0x0F, 0x0F}, // '4' +// {0x7C, 0x7C, 0x44, 0x44, 0x44, 0xC4, 0x84, /*0x00,*/ 0x04, 0x0C, 0x08, 0x08, 0x08, 0x0F, 0x07}, // '5' +// {0xF0, 0xF8, 0x4C, 0x44, 0x44, 0xC4, 0x80, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // '6' +// {0x04, 0x04, 0x04, 0x84, 0xE4, 0x7C, 0x1C, /*0x00,*/ 0x00, 0x00, 0x0E, 0x0F, 0x01, 0x00, 0x00}, // '7' +// {0xB8, 0xFC, 0x44, 0x44, 0x44, 0xFC, 0xB8, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // '8' +// {0x78, 0xFC, 0x84, 0x84, 0x84, 0xFC, 0xF8, /*0x00,*/ 0x00, 0x08, 0x08, 0x08, 0x0C, 0x07, 0x03}, // '9' +// {0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00}, // ':' +// {0x00, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x08, 0x0E, 0x06, 0x00, 0x00}, // ';' +// {0x00, 0x80, 0xC0, 0x60, 0x30, 0x18, 0x08, /*0x00,*/ 0x00, 0x00, 0x01, 0x03, 0x06, 0x0C, 0x08}, // '<' +// {0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, /*0x00,*/ 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}, // '=' +// {0x00, 0x08, 0x18, 0x30, 0x60, 0xC0, 0x80, /*0x00,*/ 0x00, 0x08, 0x0C, 0x06, 0x03, 0x01, 0x00}, // '>' +// {0x38, 0x3C, 0x04, 0x84, 0xC4, 0x7C, 0x38, /*0x00,*/ 0x00, 0x00, 0x00, 0x0D, 0x0D, 0x00, 0x00}, // '?' +// {0xF0, 0xF8, 0x08, 0xC8, 0xC8, 0xF8, 0xF0, /*0x00,*/ 0x07, 0x0F, 0x08, 0x0B, 0x0B, 0x0B, 0x01}, // '@' +// {0xF8, 0xFC, 0x84, 0x84, 0x84, 0xFC, 0xF8, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F}, // 'A' +// {0xFC, 0xFC, 0x44, 0x44, 0x44, 0xFC, 0xB8, /*0x00,*/ 0x0F, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'B' +// {0xF8, 0xFC, 0x04, 0x04, 0x04, 0x1C, 0x18, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0E, 0x06}, // 'C' +// {0xFC, 0xFC, 0x04, 0x04, 0x0C, 0xF8, 0xF0, /*0x00,*/ 0x0F, 0x0F, 0x08, 0x08, 0x0C, 0x07, 0x03}, // 'D' +// {0xFC, 0xFC, 0x44, 0x44, 0x44, 0x04, 0x04, /*0x00,*/ 0x0F, 0x0F, 0x08, 0x08, 0x08, 0x08, 0x08}, // 'E' +// {0xFC, 0xFC, 0x44, 0x44, 0x44, 0x04, 0x04, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00}, // 'F' +// {0xF8, 0xFC, 0x04, 0x84, 0x84, 0x9C, 0x98, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'G' +// {0xFC, 0xFC, 0x40, 0x40, 0x40, 0xFC, 0xFC, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F}, // 'H' +// {0x00, 0x00, 0x04, 0xFC, 0xFC, 0x04, 0x00, /*0x00,*/ 0x00, 0x00, 0x08, 0x0F, 0x0F, 0x08, 0x00}, // 'I' +// {0x00, 0x00, 0x00, 0x04, 0xFC, 0xFC, 0x04, /*0x00,*/ 0x06, 0x0E, 0x08, 0x08, 0x0F, 0x07, 0x00}, // 'J' +// {0xFC, 0xFC, 0xE0, 0x30, 0x18, 0x0C, 0x04, /*0x00,*/ 0x0F, 0x0F, 0x01, 0x03, 0x06, 0x0C, 0x08}, // 'K' +// {0xFC, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x0F, 0x0F, 0x08, 0x08, 0x08, 0x08, 0x08}, // 'L' +// {0xFC, 0xFC, 0x18, 0x70, 0x18, 0xFC, 0xFC, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F}, // 'M' +// {0xFC, 0xFC, 0x60, 0xC0, 0x80, 0xFC, 0xFC, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x01, 0x0F, 0x0F}, // 'N' +// {0xF8, 0xFC, 0x04, 0x04, 0x04, 0xFC, 0xF8, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'O' +// {0xFC, 0xFC, 0x84, 0x84, 0x84, 0xFC, 0x78, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00}, // 'P' +// {0xF8, 0xFC, 0x04, 0x04, 0x04, 0xFC, 0xF8, /*0x00,*/ 0x07, 0x0F, 0x08, 0x0C, 0x0C, 0x1F, 0x17}, // 'Q' +// {0xFC, 0xFC, 0x84, 0x84, 0x84, 0xFC, 0x78, /*0x00,*/ 0x0F, 0x0F, 0x01, 0x03, 0x06, 0x0C, 0x08}, // 'R' +// {0x38, 0x7C, 0x44, 0x44, 0x44, 0xCC, 0x88, /*0x00,*/ 0x06, 0x0E, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'S' +// {0x00, 0x04, 0x04, 0xFC, 0xFC, 0x04, 0x04, /*0x00,*/ 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00}, // 'T' +// {0xFC, 0xFC, 0x00, 0x00, 0x00, 0xFC, 0xFC, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'U' +// {0x7C, 0xFC, 0x80, 0x00, 0x80, 0xFC, 0x7C, /*0x00,*/ 0x00, 0x03, 0x0F, 0x0C, 0x0F, 0x03, 0x00}, // 'V' +// {0xFC, 0xFC, 0x00, 0x80, 0x00, 0xFC, 0xFC, /*0x00,*/ 0x0F, 0x0F, 0x06, 0x03, 0x06, 0x0F, 0x0F}, // 'W' +// {0x0C, 0x3C, 0xF0, 0xC0, 0xF0, 0x3C, 0x0C, /*0x00,*/ 0x0C, 0x0F, 0x03, 0x00, 0x03, 0x0F, 0x0C}, // 'X' +// {0x00, 0x3C, 0x7C, 0xC0, 0xC0, 0x7C, 0x3C, /*0x00,*/ 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00}, // 'Y' +// {0x04, 0x04, 0x84, 0xC4, 0x64, 0x3C, 0x1C, /*0x00,*/ 0x0E, 0x0F, 0x09, 0x08, 0x08, 0x08, 0x08}, // 'Z' +// {0x00, 0x00, 0xFC, 0xFC, 0x04, 0x04, 0x00, /*0x00,*/ 0x00, 0x00, 0x0F, 0x0F, 0x08, 0x08, 0x00}, // '[' +// {0x38, 0x70, 0xE0, 0xC0, 0x80, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0E}, // '"\' +// {0x00, 0x00, 0x04, 0x04, 0xFC, 0xFC, 0x00, /*0x00,*/ 0x00, 0x00, 0x08, 0x08, 0x0F, 0x0F, 0x00}, // ']' +// {0x08, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x08, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // '^' +// {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*0x00,*/ 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20}, // '_' +// {0x00, 0x00, 0x03, 0x07, 0x04, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // '`' +// {0x00, 0xA0, 0xA0, 0xA0, 0xA0, 0xE0, 0xC0, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x0F}, // 'a' +// {0xFC, 0xFC, 0x20, 0x20, 0x20, 0xE0, 0xC0, /*0x00,*/ 0x0F, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'b' +// {0xC0, 0xE0, 0x20, 0x20, 0x20, 0x60, 0x40, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0C, 0x04}, // 'c' +// {0xC0, 0xE0, 0x20, 0x20, 0x20, 0xFC, 0xFC, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x0F}, // 'd' +// {0xC0, 0xE0, 0x20, 0x20, 0x20, 0xE0, 0xC0, /*0x00,*/ 0x07, 0x0F, 0x09, 0x09, 0x09, 0x09, 0x01}, // 'e' +// {0x20, 0x20, 0xF8, 0xFC, 0x24, 0x24, 0x04, /*0x00,*/ 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00, 0x00}, // 'f' +// {0xC0, 0xE0, 0x20, 0x20, 0x20, 0xE0, 0xE0, /*0x00,*/ 0x07, 0x4F, 0x48, 0x48, 0x48, 0x7F, 0x3F}, // 'g' +// {0xFC, 0xFC, 0x20, 0x20, 0x20, 0xE0, 0xC0, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F}, // 'h' +// {0x00, 0x00, 0x20, 0xEC, 0xEC, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x08, 0x0F, 0x0F, 0x08, 0x00}, // 'i' +// {0x00, 0x00, 0x00, 0x00, 0x20, 0xEC, 0xEC, /*0x00,*/ 0x00, 0x30, 0x70, 0x40, 0x40, 0x7F, 0x3F}, // 'j' +// {0xFC, 0xFC, 0x00, 0x80, 0xC0, 0x60, 0x20, /*0x00,*/ 0x0F, 0x0F, 0x01, 0x03, 0x06, 0x0C, 0x08}, // 'k' +// {0x00, 0x00, 0x04, 0xFC, 0xFC, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x08, 0x0F, 0x0F, 0x08, 0x00}, // 'l' +// {0xE0, 0xE0, 0x20, 0xE0, 0x20, 0xE0, 0xC0, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x0F, 0x00, 0x0F, 0x0F}, // 'm' +// {0xE0, 0xE0, 0x20, 0x20, 0x20, 0xE0, 0xC0, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x0F, 0x0F}, // 'n' +// {0xC0, 0xE0, 0x20, 0x20, 0x20, 0xE0, 0xC0, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'o' +// {0xE0, 0xE0, 0x20, 0x20, 0x20, 0xE0, 0xC0, /*0x00,*/ 0x7F, 0x7F, 0x08, 0x08, 0x08, 0x0F, 0x07}, // 'p' +// {0xC0, 0xE0, 0x20, 0x20, 0x20, 0xE0, 0xE0, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x7F, 0x7F}, // 'q' +// {0xE0, 0xE0, 0x60, 0x20, 0x20, 0x20, 0x20, /*0x00,*/ 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00}, // 'r' +// {0xC0, 0xE0, 0x20, 0x20, 0x20, 0x20, 0x20, /*0x00,*/ 0x08, 0x09, 0x09, 0x09, 0x09, 0x0F, 0x06}, // 's' +// {0x20, 0x20, 0xFC, 0xFC, 0x20, 0x20, 0x00, /*0x00,*/ 0x00, 0x00, 0x07, 0x0F, 0x08, 0x08, 0x08}, // 't' +// {0xE0, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0xE0, /*0x00,*/ 0x07, 0x0F, 0x08, 0x08, 0x08, 0x0F, 0x0F}, // 'u' +// {0xE0, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0xE0, /*0x00,*/ 0x00, 0x03, 0x0F, 0x0C, 0x0F, 0x03, 0x00}, // 'v' +// {0xE0, 0xE0, 0x00, 0x80, 0x00, 0xE0, 0xE0, /*0x00,*/ 0x07, 0x0F, 0x08, 0x0F, 0x08, 0x0F, 0x07}, // 'w' +// {0x60, 0xE0, 0x80, 0x00, 0x80, 0xE0, 0x60, /*0x00,*/ 0x0C, 0x0E, 0x03, 0x01, 0x03, 0x0E, 0x0C}, // 'x' +// {0xE0, 0xE0, 0x00, 0x00, 0x00, 0xE0, 0xE0, /*0x00,*/ 0x07, 0x4F, 0x48, 0x48, 0x48, 0x7F, 0x3F}, // 'y' +// {0x20, 0x20, 0x20, 0xA0, 0xE0, 0x60, 0x20, /*0x00,*/ 0x0C, 0x0E, 0x0B, 0x09, 0x08, 0x08, 0x08}, // 'z' +// {0x00, 0x00, 0x40, 0xF8, 0xBC, 0x04, 0x04, /*0x00,*/ 0x00, 0x00, 0x00, 0x07, 0x0F, 0x08, 0x08}, // '{' +// {0x00, 0x00, 0x00, 0xBC, 0xBC, 0x00, 0x00, /*0x00,*/ 0x00, 0x00, 0x00, 0x0F, 0x0F, 0x00, 0x00}, // '|' +// {0x00, 0x04, 0x04, 0xBC, 0xF8, 0x40, 0x00, /*0x00,*/ 0x00, 0x08, 0x08, 0x0F, 0x07, 0x00, 0x00}, // '}' +// {0x08, 0x0C, 0x04, 0x0C, 0x08, 0x0C, 0x04, /*0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} // '->' +//#endif +//}; #if 0 // original font @@ -252,20 +252,20 @@ const uint8_t gFontBig[95 - 1][16 - 2] = #else // Terminus font - const uint8_t gFontBigDigits[11][26 - 6] = - { - {/*0x00, 0x00,*/ 0xFC, 0xFE, 0xFE, 0x06, 0x06, 0x06, 0x06, 0xFE, 0xFE, 0xFC, /*0x00,*/ /*0x00, 0x00,*/ 0x3F, 0x7F, 0x7F, 0x60, 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x3F, /*0x00*/}, - {/*0x00, 0x00,*/ 0x00, 0x00, 0x18, 0x1C, 0xFE, 0xFE, 0xFE, 0x00, 0x00, 0x00, /*0x00,*/ /*0x00, 0x00,*/ 0x00, 0x00, 0x60, 0x60, 0x7F, 0x7F, 0x7F, 0x60, 0x60, 0x00, /*0x00*/}, - {/*0x00, 0x00,*/ 0x1C, 0x1E, 0x1E, 0x06, 0x06, 0x06, 0x86, 0xFE, 0xFE, 0x7C, /*0x00,*/ /*0x00, 0x00,*/ 0x60, 0x70, 0x78, 0x7C, 0x6E, 0x67, 0x63, 0x61, 0x60, 0x60, /*0x00*/}, - {/*0x00, 0x00,*/ 0x0C, 0x0E, 0x0E, 0x86, 0x86, 0x86, 0x86, 0xFE, 0xFE, 0x7C, /*0x00,*/ /*0x00, 0x00,*/ 0x30, 0x70, 0x70, 0x61, 0x61, 0x61, 0x61, 0x7F, 0x7F, 0x3E, /*0x00*/}, - {/*0x00, 0x00,*/ 0x80, 0xC0, 0xE0, 0x70, 0x38, 0x1C, 0x0E, 0xFE, 0xFE, 0xFE, /*0x00,*/ /*0x00, 0x00,*/ 0x0F, 0x0F, 0x0F, 0x0C, 0x0C, 0x0C, 0x0C, 0x7F, 0x7F, 0x7F, /*0x00*/}, - {/*0x00, 0x00,*/ 0xFE, 0xFE, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x86, /*0x00,*/ /*0x00, 0x00,*/ 0x30, 0x70, 0x70, 0x60, 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x3F, /*0x00*/}, - {/*0x00, 0x00,*/ 0xF8, 0xFC, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x80, /*0x00,*/ /*0x00, 0x00,*/ 0x3F, 0x7F, 0x7F, 0x60, 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x3F, /*0x00*/}, - {/*0x00, 0x00,*/ 0x0E, 0x0E, 0x0E, 0x06, 0x06, 0x86, 0xE6, 0xFE, 0x7E, 0x1E, /*0x00,*/ /*0x00, 0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x7C, 0x7F, 0x7F, 0x03, 0x00, 0x00, /*0x00*/}, - {/*0x00, 0x00,*/ 0x7C, 0xFE, 0xFE, 0x86, 0x86, 0x86, 0x86, 0xFE, 0xFE, 0x7C, /*0x00,*/ /*0x00, 0x00,*/ 0x3F, 0x7F, 0x7F, 0x61, 0x61, 0x61, 0x61, 0x7F, 0x7F, 0x3F, /*0x00*/}, - {/*0x00, 0x00,*/ 0xFC, 0xFE, 0xFE, 0x06, 0x06, 0x06, 0x06, 0xFE, 0xFE, 0xFC, /*0x00,*/ /*0x00, 0x00,*/ 0x01, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x7F, 0x3F, 0x1F, /*0x00*/}, - {/*0x00, 0x00,*/ 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, /*0x00,*/ /*0x00, 0x00,*/ 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, /*0x00*/} - }; +// const uint8_t gFontBigDigits[11][26 - 6] = +// { +// {/*0x00, 0x00,*/ 0xFC, 0xFE, 0xFE, 0x06, 0x06, 0x06, 0x06, 0xFE, 0xFE, 0xFC, /*0x00,*/ /*0x00, 0x00,*/ 0x3F, 0x7F, 0x7F, 0x60, 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x3F, /*0x00*/}, +// {/*0x00, 0x00,*/ 0x00, 0x00, 0x18, 0x1C, 0xFE, 0xFE, 0xFE, 0x00, 0x00, 0x00, /*0x00,*/ /*0x00, 0x00,*/ 0x00, 0x00, 0x60, 0x60, 0x7F, 0x7F, 0x7F, 0x60, 0x60, 0x00, /*0x00*/}, +// {/*0x00, 0x00,*/ 0x1C, 0x1E, 0x1E, 0x06, 0x06, 0x06, 0x86, 0xFE, 0xFE, 0x7C, /*0x00,*/ /*0x00, 0x00,*/ 0x60, 0x70, 0x78, 0x7C, 0x6E, 0x67, 0x63, 0x61, 0x60, 0x60, /*0x00*/}, +// {/*0x00, 0x00,*/ 0x0C, 0x0E, 0x0E, 0x86, 0x86, 0x86, 0x86, 0xFE, 0xFE, 0x7C, /*0x00,*/ /*0x00, 0x00,*/ 0x30, 0x70, 0x70, 0x61, 0x61, 0x61, 0x61, 0x7F, 0x7F, 0x3E, /*0x00*/}, +// {/*0x00, 0x00,*/ 0x80, 0xC0, 0xE0, 0x70, 0x38, 0x1C, 0x0E, 0xFE, 0xFE, 0xFE, /*0x00,*/ /*0x00, 0x00,*/ 0x0F, 0x0F, 0x0F, 0x0C, 0x0C, 0x0C, 0x0C, 0x7F, 0x7F, 0x7F, /*0x00*/}, +// {/*0x00, 0x00,*/ 0xFE, 0xFE, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x86, /*0x00,*/ /*0x00, 0x00,*/ 0x30, 0x70, 0x70, 0x60, 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x3F, /*0x00*/}, +// {/*0x00, 0x00,*/ 0xF8, 0xFC, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x80, /*0x00,*/ /*0x00, 0x00,*/ 0x3F, 0x7F, 0x7F, 0x60, 0x60, 0x60, 0x60, 0x7F, 0x7F, 0x3F, /*0x00*/}, +// {/*0x00, 0x00,*/ 0x0E, 0x0E, 0x0E, 0x06, 0x06, 0x86, 0xE6, 0xFE, 0x7E, 0x1E, /*0x00,*/ /*0x00, 0x00,*/ 0x00, 0x00, 0x00, 0x00, 0x7C, 0x7F, 0x7F, 0x03, 0x00, 0x00, /*0x00*/}, +// {/*0x00, 0x00,*/ 0x7C, 0xFE, 0xFE, 0x86, 0x86, 0x86, 0x86, 0xFE, 0xFE, 0x7C, /*0x00,*/ /*0x00, 0x00,*/ 0x3F, 0x7F, 0x7F, 0x61, 0x61, 0x61, 0x61, 0x7F, 0x7F, 0x3F, /*0x00*/}, +// {/*0x00, 0x00,*/ 0xFC, 0xFE, 0xFE, 0x06, 0x06, 0x06, 0x06, 0xFE, 0xFE, 0xFC, /*0x00,*/ /*0x00, 0x00,*/ 0x01, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x7F, 0x3F, 0x1F, /*0x00*/}, +// {/*0x00, 0x00,*/ 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, /*0x00,*/ /*0x00, 0x00,*/ 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, /*0x00*/} +// }; #endif /* const uint8_t gFontSmallDigits[11][7] = diff --git a/frequencies.c b/frequencies.c index ac9953d..e9d78d5 100644 --- a/frequencies.c +++ b/frequencies.c @@ -183,7 +183,7 @@ int32_t TX_freq_check(const uint32_t Frequency) #ifndef ENABLE_FEAT_F4HWN if (gSetting_350TX && gSetting_350EN) #else - if (gSetting_350EN) + if (gSetting_350EN) #endif return 0; if (Frequency >= frequencyBandTable[BAND6_400MHz].lower && Frequency < frequencyBandTable[BAND6_400MHz].upper) @@ -195,40 +195,40 @@ int32_t TX_freq_check(const uint32_t Frequency) return 0; break; - case F_LOCK_FCC: - if (Frequency >= 14400000 && Frequency < 14800000) - return 0; - if (Frequency >= 42000000 && Frequency < 45000000) - return 0; - break; - - case F_LOCK_CE: - if (Frequency >= 14400000 && Frequency < 14600000) - return 0; - if (Frequency >= 43000000 && Frequency < 44000000) - return 0; - break; - - case F_LOCK_GB: - if (Frequency >= 14400000 && Frequency < 14800000) - return 0; - if (Frequency >= 43000000 && Frequency < 44000000) - return 0; - break; - - case F_LOCK_430: - if (Frequency >= frequencyBandTable[BAND3_137MHz].lower && Frequency < 17400000) - return 0; - if (Frequency >= 40000000 && Frequency < 43000000) - return 0; - break; - - case F_LOCK_438: - if (Frequency >= frequencyBandTable[BAND3_137MHz].lower && Frequency < 17400000) - return 0; - if (Frequency >= 40000000 && Frequency < 43800000) - return 0; - break; +// case F_LOCK_FCC: +// if (Frequency >= 14400000 && Frequency < 14800000) +// return 0; +// if (Frequency >= 42000000 && Frequency < 45000000) +// return 0; +// break; +// +// case F_LOCK_CE: +// if (Frequency >= 14400000 && Frequency < 14600000) +// return 0; +// if (Frequency >= 43000000 && Frequency < 44000000) +// return 0; +// break; +// +// case F_LOCK_GB: +// if (Frequency >= 14400000 && Frequency < 14800000) +// return 0; +// if (Frequency >= 43000000 && Frequency < 44000000) +// return 0; +// break; +// +// case F_LOCK_430: +// if (Frequency >= frequencyBandTable[BAND3_137MHz].lower && Frequency < 17400000) +// return 0; +// if (Frequency >= 40000000 && Frequency < 43000000) +// return 0; +// break; +// +// case F_LOCK_438: +// if (Frequency >= frequencyBandTable[BAND3_137MHz].lower && Frequency < 17400000) +// return 0; +// if (Frequency >= 40000000 && Frequency < 43800000) +// return 0; +// break; #ifdef ENABLE_FEAT_F4HWN_PMR case F_LOCK_PMR: diff --git a/functions.c b/functions.c index d09abbd..06bf4b9 100644 --- a/functions.c +++ b/functions.c @@ -17,16 +17,24 @@ #include #include "app/dtmf.h" + #if defined(ENABLE_FMRADIO) - #include "app/fm.h" + +#include "app/fm.h" + #endif + #include "audio.h" #include "bsp/dp32g030/gpio.h" #include "dcs.h" #include "driver/backlight.h" + #if defined(ENABLE_FMRADIO) - #include "driver/bk1080.h" + +#include "driver/bk1080.h" + #endif + #include "driver/bk4819.h" #include "driver/gpio.h" #include "driver/system.h" @@ -39,36 +47,36 @@ #include "settings.h" #include "ui/status.h" #include "ui/ui.h" +#include "app/app.h" + FUNCTION_Type_t gCurrentFunction; -bool FUNCTION_IsRx() -{ +bool FUNCTION_IsRx() { return gCurrentFunction == FUNCTION_MONITOR || gCurrentFunction == FUNCTION_INCOMING || gCurrentFunction == FUNCTION_RECEIVE; } -void FUNCTION_Init(void) -{ +void FUNCTION_Init(void) { g_CxCSS_TAIL_Found = false; - g_CDCSS_Lost = false; - g_CTCSS_Lost = false; + g_CDCSS_Lost = false; + g_CTCSS_Lost = false; - g_SquelchLost = false; + g_SquelchLost = false; - gFlagTailNoteEliminationComplete = false; + gFlagTailNoteEliminationComplete = false; gTailNoteEliminationCountdown_10ms = 0; - gFoundCTCSS = false; - gFoundCDCSS = false; - gFoundCTCSSCountdown_10ms = 0; - gFoundCDCSSCountdown_10ms = 0; - gEndOfRxDetectedMaybe = false; + gFoundCTCSS = false; + gFoundCDCSS = false; + gFoundCTCSSCountdown_10ms = 0; + gFoundCDCSSCountdown_10ms = 0; + gEndOfRxDetectedMaybe = false; gCurrentCodeType = (gRxVfo->Modulation != MODULATION_FM) ? CODE_TYPE_OFF : gRxVfo->pRX->CodeType; #ifdef ENABLE_VOX - g_VOX_Lost = false; + g_VOX_Lost = false; #endif #ifdef ENABLE_DTMF_CALLING @@ -86,8 +94,7 @@ void FUNCTION_Init(void) gUpdateStatus = true; } -void FUNCTION_Foreground(const FUNCTION_Type_t PreviousFunction) -{ +void FUNCTION_Foreground(const FUNCTION_Type_t PreviousFunction) { #ifdef ENABLE_DTMF_CALLING if (gDTMF_ReplyState != DTMF_REPLY_NONE) RADIO_PrepareCssTX(); @@ -109,8 +116,7 @@ void FUNCTION_Foreground(const FUNCTION_Type_t PreviousFunction) #ifdef ENABLE_DTMF_CALLING if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED || - gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY) - { + gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY) { gDTMF_auto_reset_time_500ms = gEeprom.DTMF_auto_reset_time * 2; } #endif @@ -118,18 +124,15 @@ void FUNCTION_Foreground(const FUNCTION_Type_t PreviousFunction) } void FUNCTION_PowerSave() { - #ifdef ENABLE_FEAT_F4HWN_SLEEP - if(gWakeUp) - { - gPowerSave_10ms = gEeprom.BATTERY_SAVE * 200; // deep sleep now indexed on BatSav - } - else - { - gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10; - } - #else +#ifdef ENABLE_FEAT_F4HWN_SLEEP + if (gWakeUp) { + gPowerSave_10ms = gEeprom.BATTERY_SAVE * 200; // deep sleep now indexed on BatSav + } else { gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10; - #endif + } +#else + gPowerSave_10ms = gEeprom.BATTERY_SAVE * 10; +#endif gPowerSaveCountdownExpired = false; gRxIdleMode = true; @@ -147,9 +150,11 @@ void FUNCTION_PowerSave() { GUI_SelectNextDisplay(DISPLAY_MAIN); } -void FUNCTION_Transmit() -{ +void FUNCTION_Transmit() { // if DTMF is enabled when TX'ing, it changes the TX audio filtering !! .. 1of11 + + MSG_EnableRX(false); + BK4819_DisableDTMF(); #ifdef ENABLE_DTMF_CALLING @@ -167,8 +172,7 @@ void FUNCTION_Transmit() #endif #ifdef ENABLE_ALARM - if (gAlarmState == ALARM_STATE_SITE_ALARM) - { + if (gAlarmState == ALARM_STATE_SITE_ALARM) { GUI_DisplayScreen(); AUDIO_AudioPathOff(); @@ -205,35 +209,35 @@ void FUNCTION_Transmit() #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) if (gAlarmState != ALARM_STATE_OFF) { - #ifdef ENABLE_TX1750 - if (gAlarmState == ALARM_STATE_TX1750) - BK4819_TransmitTone(true, 1750); - #endif +#ifdef ENABLE_TX1750 + if (gAlarmState == ALARM_STATE_TX1750) { + BK4819_TransmitTone(false, 1750); + gAlarmState = ALARM_STATE_OFF; + } +#endif - #ifdef ENABLE_ALARM +#ifdef ENABLE_ALARM if (gAlarmState == ALARM_STATE_TXALARM) BK4819_TransmitTone(true, 500); gAlarmToneCounter = 0; - #endif +#endif SYSTEM_DelayMs(2); AUDIO_AudioPathOn(); gEnableSpeaker = true; + BK4819_ExitTxMute(); gVfoConfigureMode = VFO_CONFIGURE; return; } #endif -#ifdef ENABLE_FEAT_F4HWN - BK4819_DisableScramble(); -#else - if (gCurrentVfo->SCRAMBLING_TYPE > 0 && gSetting_ScrambleEnable) + + if (gCurrentVfo->SCRAMBLING_TYPE > 0) BK4819_EnableScramble(gCurrentVfo->SCRAMBLING_TYPE - 1); else BK4819_DisableScramble(); -#endif if (gSetting_backlight_on_tx_rx & BACKLIGHT_ON_TR_TX) { BACKLIGHT_TurnOn(); @@ -241,9 +245,7 @@ void FUNCTION_Transmit() } - -void FUNCTION_Select(FUNCTION_Type_t Function) -{ +void FUNCTION_Select(FUNCTION_Type_t Function) { const FUNCTION_Type_t PreviousFunction = gCurrentFunction; const bool bWasPowerSave = PreviousFunction == FUNCTION_POWER_SAVE; @@ -298,10 +300,10 @@ void FUNCTION_Select(FUNCTION_Type_t Function) } gBatterySaveCountdown_10ms = battery_save_count_10ms; - gSchedulePowerSave = false; + gSchedulePowerSave = false; #if defined(ENABLE_FMRADIO) - if(Function != FUNCTION_INCOMING) + if (Function != FUNCTION_INCOMING) gFM_RestoreCountdown_10ms = 0; #endif } diff --git a/functions.h b/functions.h index ec1d983..27e3334 100644 --- a/functions.h +++ b/functions.h @@ -14,13 +14,13 @@ * limitations under the License. */ + #ifndef FUNCTIONS_H #define FUNCTIONS_H #include -enum FUNCTION_Type_t -{ +enum FUNCTION_Type_t { FUNCTION_FOREGROUND = 0, // ??? FUNCTION_TRANSMIT, // transmitting FUNCTION_MONITOR, // receiving with squelch forced open @@ -32,11 +32,12 @@ enum FUNCTION_Type_t }; typedef enum FUNCTION_Type_t FUNCTION_Type_t; - -extern FUNCTION_Type_t gCurrentFunction; +extern FUNCTION_Type_t gCurrentFunction; void FUNCTION_Init(void); + void FUNCTION_Select(FUNCTION_Type_t Function); + bool FUNCTION_IsRx(); #endif diff --git a/helper/battery.c b/helper/battery.c index f61974a..ff000e4 100644 --- a/helper/battery.c +++ b/helper/battery.c @@ -137,10 +137,6 @@ void BATTERY_GetReadings(const bool bDisplayBatteryLevel) } } - - if ((gScreenToDisplay == DISPLAY_MENU) && UI_MENU_GetCurrentMenuId() == MENU_VOL) - gUpdateDisplay = true; - if (gBatteryCurrent < 501) { if (gChargingWithTypeC) diff --git a/main.c b/main.c index 9786321..aebecdf 100644 --- a/main.c +++ b/main.c @@ -19,7 +19,9 @@ #include // NULL #ifdef ENABLE_AM_FIX - #include "am_fix.h" + +#include "am_fix.h" + #endif #include "audio.h" @@ -30,14 +32,20 @@ #include "version.h" #ifdef ENABLE_FEAT_F4HWN - #ifdef ENABLE_FMRADIO - #include "app/action.h" - #include "ui/ui.h" - #endif - #ifdef ENABLE_SPECTRUM - #include "app/spectrum.h" - #endif - #include "app/chFrScanner.h" +#ifdef ENABLE_FMRADIO + +#include "app/action.h" +#include "ui/ui.h" + +#endif +#ifdef ENABLE_SPECTRUM + +#include "app/spectrum.h" + +#endif + +#include "app/chFrScanner.h" + #endif #include "app/app.h" @@ -51,8 +59,11 @@ #include "driver/system.h" #include "driver/systick.h" #include "driver/eeprom.h" + #ifdef ENABLE_UART - #include "driver/uart.h" + +#include "driver/uart.h" + #endif #include "helper/battery.h" @@ -61,28 +72,27 @@ #include "ui/lock.h" #include "ui/welcome.h" #include "ui/menu.h" -void _putchar(__attribute__((unused)) char c) -{ + +void _putchar(__attribute__((unused)) char c) { #ifdef ENABLE_UART - UART_Send((uint8_t *)&c, 1); + UART_Send((uint8_t *) &c, 1); #endif } -void Main(void) -{ +void Main(void) { // Enable clock gating of blocks we need SYSCON_DEV_CLK_GATE = 0 - | SYSCON_DEV_CLK_GATE_GPIOA_BITS_ENABLE - | SYSCON_DEV_CLK_GATE_GPIOB_BITS_ENABLE - | SYSCON_DEV_CLK_GATE_GPIOC_BITS_ENABLE - | SYSCON_DEV_CLK_GATE_UART1_BITS_ENABLE - | SYSCON_DEV_CLK_GATE_SPI0_BITS_ENABLE - | SYSCON_DEV_CLK_GATE_SARADC_BITS_ENABLE - | SYSCON_DEV_CLK_GATE_CRC_BITS_ENABLE - | SYSCON_DEV_CLK_GATE_AES_BITS_ENABLE - | SYSCON_DEV_CLK_GATE_PWM_PLUS0_BITS_ENABLE; + | SYSCON_DEV_CLK_GATE_GPIOA_BITS_ENABLE + | SYSCON_DEV_CLK_GATE_GPIOB_BITS_ENABLE + | SYSCON_DEV_CLK_GATE_GPIOC_BITS_ENABLE + | SYSCON_DEV_CLK_GATE_UART1_BITS_ENABLE + | SYSCON_DEV_CLK_GATE_SPI0_BITS_ENABLE + | SYSCON_DEV_CLK_GATE_SARADC_BITS_ENABLE + | SYSCON_DEV_CLK_GATE_CRC_BITS_ENABLE + | SYSCON_DEV_CLK_GATE_AES_BITS_ENABLE + | SYSCON_DEV_CLK_GATE_PWM_PLUS0_BITS_ENABLE; SYSTICK_Init(); @@ -106,10 +116,10 @@ void Main(void) SETTINGS_InitEEPROM(); - #ifdef ENABLE_FEAT_F4HWN - gDW = gEeprom.DUAL_WATCH; - gCB = gEeprom.CROSS_BAND_RX_TX; - #endif +#ifdef ENABLE_FEAT_F4HWN + gDW = gEeprom.DUAL_WATCH; + gCB = gEeprom.CROSS_BAND_RX_TX; +#endif SETTINGS_WriteBuildOptions(); SETTINGS_LoadCalibration(); @@ -130,7 +140,7 @@ void Main(void) AM_fix_init(); #endif - BOOT_Mode_t BootMode = BOOT_GetMode(); + BOOT_Mode_t BootMode = BOOT_GetMode(); #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS if (BootMode == BOOT_MODE_RESCUE_OPS) @@ -157,33 +167,32 @@ void Main(void) } #endif - if (BootMode == BOOT_MODE_F_LOCK) - { + if (BootMode == BOOT_MODE_F_LOCK) { gF_LOCK = true; // flag to say include the hidden menu items - #ifdef ENABLE_FEAT_F4HWN - gEeprom.KEY_LOCK = 0; - SETTINGS_SaveSettings(); - #ifndef ENABLE_VOX - gMenuCursor = 67; // move to hidden section, fix me if change... !!! Remove VOX and Mic Bar - #else - gMenuCursor = 68; // move to hidden section, fix me if change... !!! - #endif +#ifdef ENABLE_FEAT_F4HWN + gEeprom.KEY_LOCK = 0; + SETTINGS_SaveSettings(); +#ifndef ENABLE_VOX + gMenuCursor = 67; // move to hidden section, fix me if change... !!! Remove VOX and Mic Bar +#else + gMenuCursor = 68; // move to hidden section, fix me if change... !!! +#endif - #ifdef ENABLE_NOAA - gMenuCursor += 1; // move to hidden section, fix me if change... !!! - #endif - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS - gMenuCursor += 1; // move to hidden section, fix me if change... !!! - #endif - gSubMenuSelection = gSetting_F_LOCK; - #endif +#ifdef ENABLE_NOAA + gMenuCursor += 1; // move to hidden section, fix me if change... !!! +#endif +#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS + gMenuCursor += 1; // move to hidden section, fix me if change... !!! +#endif + gSubMenuSelection = gSetting_F_LOCK; +#endif } // count the number of menu items gMenuListCount = 0; while (MenuList[gMenuListCount].name[0] != '\0') { - if(!gF_LOCK && MenuList[gMenuListCount].menu_id == FIRST_HIDDEN_MENU_ITEM) + if (!gF_LOCK && MenuList[gMenuListCount].menu_id == FIRST_HIDDEN_MENU_ITEM) break; gMenuListCount++; @@ -191,15 +200,13 @@ void Main(void) // wait for user to release all butts before moving on if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) || - KEYBOARD_Poll() != KEY_INVALID || - BootMode != BOOT_MODE_NORMAL) - { // keys are pressed + KEYBOARD_Poll() != KEY_INVALID || + BootMode != BOOT_MODE_NORMAL) { // keys are pressed UI_DisplayReleaseKeys(); BACKLIGHT_TurnOn(); // 500ms - for (int i = 0; i < 50;) - { + for (int i = 0; i < 50;) { i = (GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && KEYBOARD_Poll() == KEY_INVALID) ? i + 1 : 0; SYSTEM_DelayMs(10); } @@ -208,8 +215,7 @@ void Main(void) gDebounceCounter = 0; } - if (!gChargingWithTypeC && gBatteryDisplayLevel == 0) - { + if (!gChargingWithTypeC && gBatteryDisplayLevel == 0) { FUNCTION_Select(FUNCTION_POWER_SAVE); if (gEeprom.BACKLIGHT_TIME < 61) // backlight is not set to be always on @@ -218,29 +224,11 @@ void Main(void) BACKLIGHT_TurnOn(); // turn the backlight ON gReducedService = true; - } - else - { + } else { UI_DisplayWelcome(); BACKLIGHT_TurnOn(); - -#ifdef ENABLE_FEAT_F4HWN - if (gEeprom.POWER_ON_DISPLAY_MODE != POWER_ON_DISPLAY_MODE_NONE && gEeprom.POWER_ON_DISPLAY_MODE != POWER_ON_DISPLAY_MODE_SOUND) -#else - if (gEeprom.POWER_ON_DISPLAY_MODE != POWER_ON_DISPLAY_MODE_NONE) -#endif - { // 2.55 second boot-up screen - while (boot_counter_10ms > 0) - { - if (KEYBOARD_Poll() != KEY_INVALID) - { // halt boot beeps - boot_counter_10ms = 0; - break; - } - } - RADIO_SetupRegisters(true); - } + RADIO_SetupRegisters(true); #ifdef ENABLE_PWRON_PASSWORD if (gEeprom.POWER_ON_PASSWORD < 1000000) @@ -335,35 +323,35 @@ void Main(void) #endif */ - #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE - if (gEeprom.CURRENT_STATE == 2 || gEeprom.CURRENT_STATE == 5) { - gScanRangeStart = gScanRangeStart ? 0 : gTxVfo->pRX->Frequency; - gScanRangeStop = gEeprom.VfoInfo[!gEeprom.TX_VFO].freq_config_RX.Frequency; - if (gScanRangeStart > gScanRangeStop) { - SWAP(gScanRangeStart, gScanRangeStop); - } +#ifdef ENABLE_FEAT_F4HWN_RESUME_STATE + if (gEeprom.CURRENT_STATE == 2 || gEeprom.CURRENT_STATE == 5) { + gScanRangeStart = gScanRangeStart ? 0 : gTxVfo->pRX->Frequency; + gScanRangeStop = gEeprom.VfoInfo[!gEeprom.TX_VFO].freq_config_RX.Frequency; + if (gScanRangeStart > gScanRangeStop) { + SWAP(gScanRangeStart, gScanRangeStop); } + } - if (gEeprom.CURRENT_STATE == 1) { - gEeprom.SCAN_LIST_DEFAULT = gEeprom.CURRENT_LIST; - } + if (gEeprom.CURRENT_STATE == 1) { + gEeprom.SCAN_LIST_DEFAULT = gEeprom.CURRENT_LIST; + } + + if (gEeprom.CURRENT_STATE == 1 || gEeprom.CURRENT_STATE == 2) { + CHFRSCANNER_Start(true, SCAN_FWD); + } +#ifdef ENABLE_FMRADIO + else if (gEeprom.CURRENT_STATE == 3) { + ACTION_FM(); + GUI_SelectNextDisplay(gRequestDisplayScreen); + } +#endif +#ifdef ENABLE_SPECTRUM + else if (gEeprom.CURRENT_STATE == 4 || gEeprom.CURRENT_STATE == 5) { + APP_RunSpectrum(); + } +#endif +#endif - if (gEeprom.CURRENT_STATE == 1 || gEeprom.CURRENT_STATE == 2) { - CHFRSCANNER_Start(true, SCAN_FWD); - } - #ifdef ENABLE_FMRADIO - else if (gEeprom.CURRENT_STATE == 3) { - ACTION_FM(); - GUI_SelectNextDisplay(gRequestDisplayScreen); - } - #endif - #ifdef ENABLE_SPECTRUM - else if (gEeprom.CURRENT_STATE == 4 || gEeprom.CURRENT_STATE == 5) { - APP_RunSpectrum(); - } - #endif - #endif - while (true) { APP_Update(); diff --git a/misc.c b/misc.c index 82243f5..c59eeef 100644 --- a/misc.c +++ b/misc.c @@ -91,16 +91,11 @@ const uint8_t gMicGain_dB2[5] = {3, 8, 16, 24, 31}; #ifndef ENABLE_FEAT_F4HWN bool gSetting_350TX; #endif - -#ifdef ENABLE_DTMF_CALLING -bool gSetting_KILLED; -#endif - #ifndef ENABLE_FEAT_F4HWN bool gSetting_200TX; bool gSetting_500TX; #endif -bool gSetting_350EN; +bool gSetting_350EN = true; uint8_t gSetting_F_LOCK; bool gSetting_ScrambleEnable; diff --git a/misc.h b/misc.h index 6b65c0d..402f73f 100644 --- a/misc.h +++ b/misc.h @@ -143,11 +143,6 @@ extern const uint8_t gMicGain_dB2[5]; #ifndef ENABLE_FEAT_F4HWN extern bool gSetting_350TX; #endif - -#ifdef ENABLE_DTMF_CALLING -extern bool gSetting_KILLED; -#endif - #ifndef ENABLE_FEAT_F4HWN extern bool gSetting_200TX; extern bool gSetting_500TX; diff --git a/radio.c b/radio.c index d4c16b9..117a910 100644 --- a/radio.c +++ b/radio.c @@ -272,13 +272,10 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure pVfo->StepFrequency = gStepFrequencyTable[tmp]; tmp = data[7]; -#ifndef ENABLE_FEAT_F4HWN if (tmp > (ARRAY_SIZE(gSubMenu_SCRAMBLER) - 1)) tmp = 0; pVfo->SCRAMBLING_TYPE = tmp; -#else - pVfo->SCRAMBLING_TYPE = 0; -#endif + //pVfo->SCRAMBLING_TYPE = 0; pVfo->freq_config_RX.CodeType = (data[2] >> 0) & 0x0F; pVfo->freq_config_TX.CodeType = (data[2] >> 4) & 0x0F; @@ -817,14 +814,10 @@ void RADIO_SetupRegisters(bool switchToForeground) break; } -#ifndef ENABLE_FEAT_F4HWN - if (gRxVfo->SCRAMBLING_TYPE > 0 && gSetting_ScrambleEnable) + if (gRxVfo->SCRAMBLING_TYPE > 0) BK4819_EnableScramble(gRxVfo->SCRAMBLING_TYPE - 1); else BK4819_DisableScramble(); -#else - BK4819_DisableScramble(); -#endif } } #ifdef ENABLE_NOAA diff --git a/settings.c b/settings.c index c79fcb3..5487f7b 100644 --- a/settings.c +++ b/settings.c @@ -17,9 +17,11 @@ #include #include "app/dtmf.h" + #ifdef ENABLE_FMRADIO - #include "app/fm.h" +#include "app/fm.h" #endif + #include "driver/bk1080.h" #include "driver/bk4819.h" #include "driver/eeprom.h" @@ -38,67 +40,66 @@ static const uint32_t gDefaultFrequencyTable[] = }; #endif -EEPROM_Config_t gEeprom = { 0 }; +EEPROM_Config_t gEeprom = {0}; -void SETTINGS_InitEEPROM(void) -{ +void SETTINGS_InitEEPROM(void) { uint8_t Data[16] = {0}; // 0E70..0E77 EEPROM_ReadBuffer(0x0E70, Data, 8); - gEeprom.CHAN_1_CALL = IS_MR_CHANNEL(Data[0]) ? Data[0] : MR_CHANNEL_FIRST; - gEeprom.SQUELCH_LEVEL = (Data[1] < 10) ? Data[1] : 1; - gEeprom.TX_TIMEOUT_TIMER = (Data[2] > 4 && Data[2] < 180) ? Data[2] : 11; - #ifdef ENABLE_NOAA - gEeprom.NOAA_AUTO_SCAN = (Data[3] < 2) ? Data[3] : false; - #endif - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS - gEeprom.KEY_LOCK = (Data[4] & 0x01) != 0; - gEeprom.MENU_LOCK = (Data[4] & 0x02) != 0; - gEeprom.SET_KEY = ((Data[4] >> 2) & 0x0F) > 4 ? 0 : (Data[4] >> 2) & 0x0F; - #else - gEeprom.KEY_LOCK = (Data[4] < 2) ? Data[4] : false; - #endif - #ifdef ENABLE_VOX - gEeprom.VOX_SWITCH = (Data[5] < 2) ? Data[5] : false; - gEeprom.VOX_LEVEL = (Data[6] < 10) ? Data[6] : 1; - #endif - gEeprom.MIC_SENSITIVITY = (Data[7] < 5) ? Data[7] : 4; + gEeprom.CHAN_1_CALL = IS_MR_CHANNEL(Data[0]) ? Data[0] : MR_CHANNEL_FIRST; + gEeprom.SQUELCH_LEVEL = (Data[1] < 10) ? Data[1] : 1; + gEeprom.TX_TIMEOUT_TIMER = (Data[2] > 4 && Data[2] < 180) ? Data[2] : 11; +#ifdef ENABLE_NOAA + gEeprom.NOAA_AUTO_SCAN = (Data[3] < 2) ? Data[3] : false; +#endif +#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS + gEeprom.KEY_LOCK = (Data[4] & 0x01) != 0; + gEeprom.MENU_LOCK = (Data[4] & 0x02) != 0; + gEeprom.SET_KEY = ((Data[4] >> 2) & 0x0F) > 4 ? 0 : (Data[4] >> 2) & 0x0F; +#else + gEeprom.KEY_LOCK = (Data[4] < 2) ? Data[4] : false; +#endif +#ifdef ENABLE_VOX + gEeprom.VOX_SWITCH = (Data[5] < 2) ? Data[5] : false; + gEeprom.VOX_LEVEL = (Data[6] < 10) ? Data[6] : 1; +#endif + gEeprom.MIC_SENSITIVITY = (Data[7] < 5) ? Data[7] : 4; // 0E78..0E7F EEPROM_ReadBuffer(0x0E78, Data, 8); - gEeprom.BACKLIGHT_MAX = (Data[0] & 0xF) <= 10 ? (Data[0] & 0xF) : 10; - gEeprom.BACKLIGHT_MIN = (Data[0] >> 4) < gEeprom.BACKLIGHT_MAX ? (Data[0] >> 4) : 0; + gEeprom.BACKLIGHT_MAX = (Data[0] & 0xF) <= 10 ? (Data[0] & 0xF) : 10; + gEeprom.BACKLIGHT_MIN = (Data[0] >> 4) < gEeprom.BACKLIGHT_MAX ? (Data[0] >> 4) : 0; #ifdef ENABLE_BLMIN_TMP_OFF - gEeprom.BACKLIGHT_MIN_STAT = BLMIN_STAT_ON; + gEeprom.BACKLIGHT_MIN_STAT = BLMIN_STAT_ON; +#endif + gEeprom.CHANNEL_DISPLAY_MODE = (Data[1] < 4) ? Data[1] : MDF_FREQUENCY; // 4 instead of 3 - extra display mode + gEeprom.CROSS_BAND_RX_TX = (Data[2] < 3) ? Data[2] : CROSS_BAND_OFF; + gEeprom.BATTERY_SAVE = (Data[3] < 6) ? Data[3] : 4; + gEeprom.DUAL_WATCH = (Data[4] < 3) ? Data[4] : DUAL_WATCH_CHAN_A; + gEeprom.BACKLIGHT_TIME = (Data[5] < 62) ? Data[5] : 12; +#ifdef ENABLE_FEAT_F4HWN_NARROWER + gEeprom.TAIL_TONE_ELIMINATION = Data[6] & 0x01; + gSetting_set_nfm = (Data[6] >> 1) & 0x01; +#else + gEeprom.TAIL_TONE_ELIMINATION = (Data[6] < 2) ? Data[6] : false; #endif - gEeprom.CHANNEL_DISPLAY_MODE = (Data[1] < 4) ? Data[1] : MDF_FREQUENCY; // 4 instead of 3 - extra display mode - gEeprom.CROSS_BAND_RX_TX = (Data[2] < 3) ? Data[2] : CROSS_BAND_OFF; - gEeprom.BATTERY_SAVE = (Data[3] < 6) ? Data[3] : 4; - gEeprom.DUAL_WATCH = (Data[4] < 3) ? Data[4] : DUAL_WATCH_CHAN_A; - gEeprom.BACKLIGHT_TIME = (Data[5] < 62) ? Data[5] : 12; - #ifdef ENABLE_FEAT_F4HWN_NARROWER - gEeprom.TAIL_TONE_ELIMINATION = Data[6] & 0x01; - gSetting_set_nfm = (Data[6] >> 1) & 0x01; - #else - gEeprom.TAIL_TONE_ELIMINATION = (Data[6] < 2) ? Data[6] : false; - #endif - #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE - gEeprom.VFO_OPEN = Data[7] & 0x01; - gEeprom.CURRENT_STATE = (Data[7] >> 1) & 0x07; - gEeprom.CURRENT_LIST = (Data[7] >> 4) & 0x07; - #else - gEeprom.VFO_OPEN = (Data[7] < 2) ? Data[7] : true; - #endif +#ifdef ENABLE_FEAT_F4HWN_RESUME_STATE + gEeprom.VFO_OPEN = Data[7] & 0x01; + gEeprom.CURRENT_STATE = (Data[7] >> 1) & 0x07; + gEeprom.CURRENT_LIST = (Data[7] >> 4) & 0x07; +#else + gEeprom.VFO_OPEN = (Data[7] < 2) ? Data[7] : true; +#endif // 0E80..0E87 EEPROM_ReadBuffer(0x0E80, Data, 8); - gEeprom.ScreenChannel[0] = IS_VALID_CHANNEL(Data[0]) ? Data[0] : (FREQ_CHANNEL_FIRST + BAND6_400MHz); - gEeprom.ScreenChannel[1] = IS_VALID_CHANNEL(Data[3]) ? Data[3] : (FREQ_CHANNEL_FIRST + BAND6_400MHz); - gEeprom.MrChannel[0] = IS_MR_CHANNEL(Data[1]) ? Data[1] : MR_CHANNEL_FIRST; - gEeprom.MrChannel[1] = IS_MR_CHANNEL(Data[4]) ? Data[4] : MR_CHANNEL_FIRST; - gEeprom.FreqChannel[0] = IS_FREQ_CHANNEL(Data[2]) ? Data[2] : (FREQ_CHANNEL_FIRST + BAND6_400MHz); - gEeprom.FreqChannel[1] = IS_FREQ_CHANNEL(Data[5]) ? Data[5] : (FREQ_CHANNEL_FIRST + BAND6_400MHz); + gEeprom.ScreenChannel[0] = IS_VALID_CHANNEL(Data[0]) ? Data[0] : (FREQ_CHANNEL_FIRST + BAND6_400MHz); + gEeprom.ScreenChannel[1] = IS_VALID_CHANNEL(Data[3]) ? Data[3] : (FREQ_CHANNEL_FIRST + BAND6_400MHz); + gEeprom.MrChannel[0] = IS_MR_CHANNEL(Data[1]) ? Data[1] : MR_CHANNEL_FIRST; + gEeprom.MrChannel[1] = IS_MR_CHANNEL(Data[4]) ? Data[4] : MR_CHANNEL_FIRST; + gEeprom.FreqChannel[0] = IS_FREQ_CHANNEL(Data[2]) ? Data[2] : (FREQ_CHANNEL_FIRST + BAND6_400MHz); + gEeprom.FreqChannel[1] = IS_FREQ_CHANNEL(Data[5]) ? Data[5] : (FREQ_CHANNEL_FIRST + BAND6_400MHz); #ifdef ENABLE_NOAA gEeprom.NoaaChannel[0] = IS_NOAA_CHANNEL(Data[6]) ? Data[6] : NOAA_CHANNEL_FIRST; gEeprom.NoaaChannel[1] = IS_NOAA_CHANNEL(Data[7]) ? Data[7] : NOAA_CHANNEL_FIRST; @@ -133,55 +134,49 @@ void SETTINGS_InitEEPROM(void) // 0E90..0E97 EEPROM_ReadBuffer(0x0E90, Data, 8); - gEeprom.BEEP_CONTROL = Data[0] & 1; - gEeprom.KEY_M_LONG_PRESS_ACTION = ((Data[0] >> 1) < ACTION_OPT_LEN) ? (Data[0] >> 1) : ACTION_OPT_NONE; - gEeprom.KEY_1_SHORT_PRESS_ACTION = (Data[1] < ACTION_OPT_LEN) ? Data[1] : ACTION_OPT_MONITOR; - gEeprom.KEY_1_LONG_PRESS_ACTION = (Data[2] < ACTION_OPT_LEN) ? Data[2] : ACTION_OPT_NONE; - gEeprom.KEY_2_SHORT_PRESS_ACTION = (Data[3] < ACTION_OPT_LEN) ? Data[3] : ACTION_OPT_SCAN; - gEeprom.KEY_2_LONG_PRESS_ACTION = (Data[4] < ACTION_OPT_LEN) ? Data[4] : ACTION_OPT_NONE; - gEeprom.SCAN_RESUME_MODE = (Data[5] < 105) ? Data[5] : 14; - gEeprom.AUTO_KEYPAD_LOCK = (Data[6] < 41) ? Data[6] : 0; -#ifdef ENABLE_FEAT_F4HWN - gEeprom.POWER_ON_DISPLAY_MODE = (Data[7] < 6) ? Data[7] : POWER_ON_DISPLAY_MODE_VOLTAGE; -#else - gEeprom.POWER_ON_DISPLAY_MODE = (Data[7] < 4) ? Data[7] : POWER_ON_DISPLAY_MODE_VOLTAGE; -#endif - + gEeprom.BEEP_CONTROL = Data[0] & 1; + gEeprom.KEY_M_LONG_PRESS_ACTION = ((Data[0] >> 1) < ACTION_OPT_LEN) ? (Data[0] >> 1) : ACTION_OPT_NONE; + gEeprom.KEY_1_SHORT_PRESS_ACTION = (Data[1] < ACTION_OPT_LEN) ? Data[1] : ACTION_OPT_MONITOR; + gEeprom.KEY_1_LONG_PRESS_ACTION = (Data[2] < ACTION_OPT_LEN) ? Data[2] : ACTION_OPT_NONE; + gEeprom.KEY_2_SHORT_PRESS_ACTION = (Data[3] < ACTION_OPT_LEN) ? Data[3] : ACTION_OPT_SCAN; + gEeprom.KEY_2_LONG_PRESS_ACTION = (Data[4] < ACTION_OPT_LEN) ? Data[4] : ACTION_OPT_NONE; + gEeprom.SCAN_RESUME_MODE = (Data[5] < 105) ? Data[5] : 14; + gEeprom.AUTO_KEYPAD_LOCK = (Data[6] < 41) ? Data[6] : 0; + gEeprom.FSKMode = Data[7]; // 0E98..0E9F - #ifdef ENABLE_PWRON_PASSWORD - EEPROM_ReadBuffer(0x0E98, Data, 8); - memcpy(&gEeprom.POWER_ON_PASSWORD, Data, 4); - #endif +#ifdef ENABLE_PWRON_PASSWORD + EEPROM_ReadBuffer(0x0E98, Data, 8); + memcpy(&gEeprom.POWER_ON_PASSWORD, Data, 4); +#endif // 0EA0..0EA7 EEPROM_ReadBuffer(0x0EA0, Data, 8); - #ifdef ENABLE_VOICE +#ifdef ENABLE_VOICE gEeprom.VOICE_PROMPT = (Data[0] < 3) ? Data[0] : VOICE_PROMPT_ENGLISH; - #endif - #ifdef ENABLE_RSSI_BAR - if((Data[1] < 200 && Data[1] > 90) && (Data[2] < Data[1]-9 && Data[1] < 160 && Data[2] > 50)) { - gEeprom.S0_LEVEL = Data[1]; - gEeprom.S9_LEVEL = Data[2]; - } - else { - gEeprom.S0_LEVEL = 130; - gEeprom.S9_LEVEL = 76; - } - #endif +#endif +#ifdef ENABLE_RSSI_BAR + if ((Data[1] < 200 && Data[1] > 90) && (Data[2] < Data[1] - 9 && Data[1] < 160 && Data[2] > 50)) { + gEeprom.S0_LEVEL = Data[1]; + gEeprom.S9_LEVEL = Data[2]; + } else { + gEeprom.S0_LEVEL = 130; + gEeprom.S9_LEVEL = 76; + } +#endif // 0EA8..0EAF EEPROM_ReadBuffer(0x0EA8, Data, 8); - #ifdef ENABLE_ALARM - gEeprom.ALARM_MODE = (Data[0] < 2) ? Data[0] : true; - #endif - gEeprom.ROGER = (Data[1] < 3) ? Data[1] : ROGER_MODE_OFF; +#ifdef ENABLE_ALARM + gEeprom.ALARM_MODE = (Data[0] < 2) ? Data[0] : true; +#endif + gEeprom.ROGER = (Data[1] < 3) ? Data[1] : ROGER_MODE_OFF; gEeprom.REPEATER_TAIL_TONE_ELIMINATION = (Data[2] < 11) ? Data[2] : 0; - gEeprom.TX_VFO = (Data[3] < 2) ? Data[3] : 0; - gEeprom.BATTERY_TYPE = (Data[4] < BATTERY_TYPE_UNKNOWN) ? Data[4] : BATTERY_TYPE_1600_MAH; + gEeprom.TX_VFO = (Data[3] < 2) ? Data[3] : 0; + gEeprom.BATTERY_TYPE = (Data[4] < BATTERY_TYPE_UNKNOWN) ? Data[4] : BATTERY_TYPE_1600_MAH; // 0ED0..0ED7 EEPROM_ReadBuffer(0x0ED0, Data, 8); - gEeprom.DTMF_SIDE_TONE = (Data[0] < 2) ? Data[0] : true; + gEeprom.DTMF_SIDE_TONE = (Data[0] < 2) ? Data[0] : true; #ifdef ENABLE_DTMF_CALLING gEeprom.DTMF_SEPARATE_CODE = DTMF_ValidateCodes((char *)(Data + 1), 1) ? Data[1] : '*'; @@ -189,13 +184,13 @@ void SETTINGS_InitEEPROM(void) gEeprom.DTMF_DECODE_RESPONSE = (Data[3] < 4) ? Data[3] : 0; gEeprom.DTMF_auto_reset_time = (Data[4] < 61) ? Data[4] : (Data[4] >= 5) ? Data[4] : 10; #endif - gEeprom.DTMF_PRELOAD_TIME = (Data[5] < 101) ? Data[5] * 10 : 300; + gEeprom.DTMF_PRELOAD_TIME = (Data[5] < 101) ? Data[5] * 10 : 300; gEeprom.DTMF_FIRST_CODE_PERSIST_TIME = (Data[6] < 101) ? Data[6] * 10 : 100; - gEeprom.DTMF_HASH_CODE_PERSIST_TIME = (Data[7] < 101) ? Data[7] * 10 : 100; + gEeprom.DTMF_HASH_CODE_PERSIST_TIME = (Data[7] < 101) ? Data[7] * 10 : 100; // 0ED8..0EDF EEPROM_ReadBuffer(0x0ED8, Data, 8); - gEeprom.DTMF_CODE_PERSIST_TIME = (Data[0] < 101) ? Data[0] * 10 : 100; + gEeprom.DTMF_CODE_PERSIST_TIME = (Data[0] < 101) ? Data[0] * 10 : 100; gEeprom.DTMF_CODE_INTERVAL_TIME = (Data[1] < 101) ? Data[1] * 10 : 100; #ifdef ENABLE_DTMF_CALLING gEeprom.PERMIT_REMOTE_KILL = (Data[2] < 2) ? Data[2] : true; @@ -229,7 +224,7 @@ void SETTINGS_InitEEPROM(void) // 0EF8..0F07 EEPROM_ReadBuffer(0x0EF8, Data, sizeof(gEeprom.DTMF_UP_CODE)); - if (DTMF_ValidateCodes((char *)Data, sizeof(gEeprom.DTMF_UP_CODE))) { + if (DTMF_ValidateCodes((char *) Data, sizeof(gEeprom.DTMF_UP_CODE))) { memcpy(gEeprom.DTMF_UP_CODE, Data, sizeof(gEeprom.DTMF_UP_CODE)); } else { strcpy(gEeprom.DTMF_UP_CODE, "12345"); @@ -237,7 +232,7 @@ void SETTINGS_InitEEPROM(void) // 0F08..0F17 EEPROM_ReadBuffer(0x0F08, Data, sizeof(gEeprom.DTMF_DOWN_CODE)); - if (DTMF_ValidateCodes((char *)Data, sizeof(gEeprom.DTMF_DOWN_CODE))) { + if (DTMF_ValidateCodes((char *) Data, sizeof(gEeprom.DTMF_DOWN_CODE))) { memcpy(gEeprom.DTMF_DOWN_CODE, Data, sizeof(gEeprom.DTMF_DOWN_CODE)); } else { strcpy(gEeprom.DTMF_DOWN_CODE, "54321"); @@ -264,138 +259,136 @@ void SETTINGS_InitEEPROM(void) */ // Fix me probably after Chirp update... - for (unsigned int i = 0; i < 3; i++) - { + for (unsigned int i = 0; i < 3; i++) { gEeprom.SCAN_LIST_ENABLED[i] = (Data[1] >> i) & 1; } - for (unsigned int i = 0; i < 3; i++) - { + for (unsigned int i = 0; i < 3; i++) { const unsigned int j = 1 + (i * 2); - gEeprom.SCANLIST_PRIORITY_CH1[i] = Data[j + 1]; - gEeprom.SCANLIST_PRIORITY_CH2[i] = Data[j + 2]; + gEeprom.SCANLIST_PRIORITY_CH1[i] = Data[j + 1]; + gEeprom.SCANLIST_PRIORITY_CH2[i] = Data[j + 2]; } + EEPROM_ReadBuffer(0x0F20, Data, 8); + gEeprom.FSKSRCAddress = Data[0]; + gEeprom.FSKSRCAddress |= Data[1] << 8; + gEeprom.FSKSRCAddress |= Data[2] << 16; + gEeprom.FSKSRCAddress |= Data[3] << 24; + // 0F40..0F47 EEPROM_ReadBuffer(0x0F40, Data, 8); - gSetting_F_LOCK = (Data[0] < F_LOCK_LEN) ? Data[0] : F_LOCK_DEF; + gSetting_F_LOCK = (Data[0] < F_LOCK_LEN) ? Data[0] : F_LOCK_DEF; #ifndef ENABLE_FEAT_F4HWN gSetting_350TX = (Data[1] < 2) ? Data[1] : false; // was true #endif -#ifdef ENABLE_DTMF_CALLING - gSetting_KILLED = (Data[2] < 2) ? Data[2] : false; -#endif #ifndef ENABLE_FEAT_F4HWN gSetting_200TX = (Data[3] < 2) ? Data[3] : false; gSetting_500TX = (Data[4] < 2) ? Data[4] : false; -#endif gSetting_350EN = (Data[5] < 2) ? Data[5] : true; -#ifdef ENABLE_FEAT_F4HWN - gSetting_ScrambleEnable = false; #else - gSetting_ScrambleEnable = (Data[6] < 2) ? Data[6] : true; + gSetting_350EN = true; #endif + gSetting_ScrambleEnable = true; + //gSetting_TX_EN = (Data[7] & (1u << 0)) ? true : false; gSetting_live_DTMF_decoder = !!(Data[7] & (1u << 1)); - gSetting_battery_text = (((Data[7] >> 2) & 3u) <= 2) ? (Data[7] >> 2) & 3 : 2; - #ifdef ENABLE_AUDIO_BAR - gSetting_mic_bar = !!(Data[7] & (1u << 4)); - #endif - #ifndef ENABLE_FEAT_F4HWN - #ifdef ENABLE_AM_FIX - gSetting_AM_fix = !!(Data[7] & (1u << 5)); - #endif - #endif + gSetting_battery_text = (((Data[7] >> 2) & 3u) <= 2) ? (Data[7] >> 2) & 3 : 2; +#ifdef ENABLE_AUDIO_BAR + gSetting_mic_bar = !!(Data[7] & (1u << 4)); +#endif +#ifndef ENABLE_FEAT_F4HWN +#ifdef ENABLE_AM_FIX + gSetting_AM_fix = !!(Data[7] & (1u << 5)); +#endif +#endif gSetting_backlight_on_tx_rx = (Data[7] >> 6) & 3u; - if (!gEeprom.VFO_OPEN) - { + if (!gEeprom.VFO_OPEN) { gEeprom.ScreenChannel[0] = gEeprom.MrChannel[0]; gEeprom.ScreenChannel[1] = gEeprom.MrChannel[1]; } // 0D60..0E27 EEPROM_ReadBuffer(0x0D60, gMR_ChannelAttributes, sizeof(gMR_ChannelAttributes)); - for(uint16_t i = 0; i < sizeof(gMR_ChannelAttributes); i++) { + for (uint16_t i = 0; i < sizeof(gMR_ChannelAttributes); i++) { ChannelAttributes_t *att = &gMR_ChannelAttributes[i]; - if(att->__val == 0xff){ + if (att->__val == 0xff) { att->__val = 0; att->band = 0x7; } gMR_ChannelExclude[i] = false; } - // 0F30..0F3F - EEPROM_ReadBuffer(0x0F30, gCustomAesKey, sizeof(gCustomAesKey)); - bHasCustomAesKey = false; - #ifndef ENABLE_FEAT_F4HWN - for (unsigned int i = 0; i < ARRAY_SIZE(gCustomAesKey); i++) - { - if (gCustomAesKey[i] != 0xFFFFFFFFu) - { - bHasCustomAesKey = true; - return; - } - } - #endif + // 0F30..0F3F + EEPROM_ReadBuffer(0x0F30, gCustomAesKey, sizeof(gCustomAesKey)); + bHasCustomAesKey = false; +#ifndef ENABLE_FEAT_F4HWN + for (unsigned int i = 0; i < ARRAY_SIZE(gCustomAesKey); i++) + { + if (gCustomAesKey[i] != 0xFFFFFFFFu) + { + bHasCustomAesKey = true; + return; + } + } +#endif - #ifdef ENABLE_FEAT_F4HWN - // 1FF0..0x1FF7 - EEPROM_ReadBuffer(0x1FF0, Data, 8); - gSetting_set_pwr = (((Data[7] & 0xF0) >> 4) < 7) ? ((Data[7] & 0xF0) >> 4) : 0; - gSetting_set_ptt = (((Data[7] & 0x0F)) < 2) ? ((Data[7] & 0x0F)) : 0; +#ifdef ENABLE_FEAT_F4HWN + // 1FF0..0x1FF7 + EEPROM_ReadBuffer(0x1FF0, Data, 8); + gSetting_set_pwr = (((Data[7] & 0xF0) >> 4) < 7) ? ((Data[7] & 0xF0) >> 4) : 0; + gSetting_set_ptt = (((Data[7] & 0x0F)) < 2) ? ((Data[7] & 0x0F)) : 0; - gSetting_set_tot = (((Data[6] & 0xF0) >> 4) < 4) ? ((Data[6] & 0xF0) >> 4) : 0; - gSetting_set_eot = (((Data[6] & 0x0F)) < 4) ? ((Data[6] & 0x0F)) : 0; + gSetting_set_tot = (((Data[6] & 0xF0) >> 4) < 4) ? ((Data[6] & 0xF0) >> 4) : 0; + gSetting_set_eot = (((Data[6] & 0x0F)) < 4) ? ((Data[6] & 0x0F)) : 0; - /* - int tmp = ((Data[5] & 0xF0) >> 4); + /* + int tmp = ((Data[5] & 0xF0) >> 4); - gSetting_set_inv = (((tmp >> 0) & 0x01) < 2) ? ((tmp >> 0) & 0x01): 0; - gSetting_set_lck = (((tmp >> 1) & 0x01) < 2) ? ((tmp >> 1) & 0x01): 0; - gSetting_set_met = (((tmp >> 2) & 0x01) < 2) ? ((tmp >> 2) & 0x01): 0; - gSetting_set_gui = (((tmp >> 3) & 0x01) < 2) ? ((tmp >> 3) & 0x01): 0; - gSetting_set_ctr = (((Data[5] & 0x0F)) > 00 && ((Data[5] & 0x0F)) < 16) ? ((Data[5] & 0x0F)) : 10; + gSetting_set_inv = (((tmp >> 0) & 0x01) < 2) ? ((tmp >> 0) & 0x01): 0; + gSetting_set_lck = (((tmp >> 1) & 0x01) < 2) ? ((tmp >> 1) & 0x01): 0; + gSetting_set_met = (((tmp >> 2) & 0x01) < 2) ? ((tmp >> 2) & 0x01): 0; + gSetting_set_gui = (((tmp >> 3) & 0x01) < 2) ? ((tmp >> 3) & 0x01): 0; + gSetting_set_ctr = (((Data[5] & 0x0F)) > 00 && ((Data[5] & 0x0F)) < 16) ? ((Data[5] & 0x0F)) : 10; - gSetting_set_tmr = ((Data[4] & 1) < 2) ? (Data[4] & 1): 0; - */ + gSetting_set_tmr = ((Data[4] & 1) < 2) ? (Data[4] & 1): 0; + */ - int tmp = (Data[5] & 0xF0) >> 4; + int tmp = (Data[5] & 0xF0) >> 4; #ifdef ENABLE_FEAT_F4HWN_INV - gSetting_set_inv = (tmp >> 0) & 0x01; + gSetting_set_inv = (tmp >> 0) & 0x01; #else - gSetting_set_inv = 0; + gSetting_set_inv = 0; #endif - gSetting_set_lck = (tmp >> 1) & 0x01; - gSetting_set_met = (tmp >> 2) & 0x01; - gSetting_set_gui = (tmp >> 3) & 0x01; + gSetting_set_lck = (tmp >> 1) & 0x01; + gSetting_set_met = (tmp >> 2) & 0x01; + gSetting_set_gui = (tmp >> 3) & 0x01; #ifdef ENABLE_FEAT_F4HWN_CTR - int ctr_value = Data[5] & 0x0F; - gSetting_set_ctr = (ctr_value > 0 && ctr_value < 16) ? ctr_value : 10; + int ctr_value = Data[5] & 0x0F; + gSetting_set_ctr = (ctr_value > 0 && ctr_value < 16) ? ctr_value : 10; #else - gSetting_set_ctr = 10; + gSetting_set_ctr = 10; #endif - gSetting_set_tmr = Data[4] & 0x01; + gSetting_set_tmr = Data[4] & 0x01; #ifdef ENABLE_FEAT_F4HWN_SLEEP - gSetting_set_off = (Data[4] >> 1) > 120 ? 60 : (Data[4] >> 1); + gSetting_set_off = (Data[4] >> 1) > 120 ? 60 : (Data[4] >> 1); #endif - // Warning - // Be aware, Data[3] is use by Spectrum - // Warning + // Warning + // Be aware, Data[3] is use by Spectrum + // Warning - // And set special session settings for actions - gSetting_set_ptt_session = gSetting_set_ptt; - gEeprom.KEY_LOCK_PTT = gSetting_set_lck; - #endif + // And set special session settings for actions + gSetting_set_ptt_session = gSetting_set_ptt; + gEeprom.KEY_LOCK_PTT = gSetting_set_lck; +#endif } -void SETTINGS_LoadCalibration(void) -{ +void SETTINGS_LoadCalibration(void) { // uint8_t Mic; EEPROM_ReadBuffer(0x1EC0, gEEPROM_RSSI_CALIB[3], 8); @@ -408,55 +401,52 @@ void SETTINGS_LoadCalibration(void) memcpy(gEEPROM_RSSI_CALIB[2], gEEPROM_RSSI_CALIB[0], 8); EEPROM_ReadBuffer(0x1F40, gBatteryCalibration, 12); - if (gBatteryCalibration[0] >= 5000) - { + if (gBatteryCalibration[0] >= 5000) { gBatteryCalibration[0] = 1900; gBatteryCalibration[1] = 2000; } gBatteryCalibration[5] = 2300; - #ifdef ENABLE_VOX - EEPROM_ReadBuffer(0x1F50 + (gEeprom.VOX_LEVEL * 2), &gEeprom.VOX1_THRESHOLD, 2); - EEPROM_ReadBuffer(0x1F68 + (gEeprom.VOX_LEVEL * 2), &gEeprom.VOX0_THRESHOLD, 2); - #endif +#ifdef ENABLE_VOX + EEPROM_ReadBuffer(0x1F50 + (gEeprom.VOX_LEVEL * 2), &gEeprom.VOX1_THRESHOLD, 2); + EEPROM_ReadBuffer(0x1F68 + (gEeprom.VOX_LEVEL * 2), &gEeprom.VOX0_THRESHOLD, 2); +#endif //EEPROM_ReadBuffer(0x1F80 + gEeprom.MIC_SENSITIVITY, &Mic, 1); //gEeprom.MIC_SENSITIVITY_TUNING = (Mic < 32) ? Mic : 15; gEeprom.MIC_SENSITIVITY_TUNING = gMicGain_dB2[gEeprom.MIC_SENSITIVITY]; { - struct - { - int16_t BK4819_XtalFreqLow; + struct { + int16_t BK4819_XtalFreqLow; uint16_t EEPROM_1F8A; uint16_t EEPROM_1F8C; - uint8_t VOLUME_GAIN; - uint8_t DAC_GAIN; + uint8_t VOLUME_GAIN; + uint8_t DAC_GAIN; } __attribute__((packed)) Misc; // radio 1 .. 04 00 46 00 50 00 2C 0E // radio 2 .. 05 00 46 00 50 00 2C 0E EEPROM_ReadBuffer(0x1F88, &Misc, 8); - gEeprom.BK4819_XTAL_FREQ_LOW = (Misc.BK4819_XtalFreqLow >= -1000 && Misc.BK4819_XtalFreqLow <= 1000) ? Misc.BK4819_XtalFreqLow : 0; - gEEPROM_1F8A = Misc.EEPROM_1F8A & 0x01FF; - gEEPROM_1F8C = Misc.EEPROM_1F8C & 0x01FF; - gEeprom.VOLUME_GAIN = (Misc.VOLUME_GAIN < 64) ? Misc.VOLUME_GAIN : 58; - gEeprom.DAC_GAIN = (Misc.DAC_GAIN < 16) ? Misc.DAC_GAIN : 8; + gEeprom.BK4819_XTAL_FREQ_LOW = (Misc.BK4819_XtalFreqLow >= -1000 && Misc.BK4819_XtalFreqLow <= 1000) + ? Misc.BK4819_XtalFreqLow : 0; + gEEPROM_1F8A = Misc.EEPROM_1F8A & 0x01FF; + gEEPROM_1F8C = Misc.EEPROM_1F8C & 0x01FF; + gEeprom.VOLUME_GAIN = (Misc.VOLUME_GAIN < 64) ? Misc.VOLUME_GAIN : 58; + gEeprom.DAC_GAIN = (Misc.DAC_GAIN < 16) ? Misc.DAC_GAIN : 8; - #ifdef ENABLE_FEAT_F4HWN - gEeprom.VOLUME_GAIN_BACKUP = gEeprom.VOLUME_GAIN; - #endif +#ifdef ENABLE_FEAT_F4HWN + gEeprom.VOLUME_GAIN_BACKUP = gEeprom.VOLUME_GAIN; +#endif BK4819_WriteRegister(BK4819_REG_3B, 22656 + gEeprom.BK4819_XTAL_FREQ_LOW); // BK4819_WriteRegister(BK4819_REG_3C, gEeprom.BK4819_XTAL_FREQ_HIGH); } } -uint32_t SETTINGS_FetchChannelFrequency(const int channel) -{ - struct - { +uint32_t SETTINGS_FetchChannelFrequency(const int channel) { + struct { uint32_t frequency; uint32_t offset; } __attribute__((packed)) info; @@ -466,8 +456,7 @@ uint32_t SETTINGS_FetchChannelFrequency(const int channel) return info.frequency; } -void SETTINGS_FetchChannelName(char *s, const int channel) -{ +void SETTINGS_FetchChannelName(char *s, const int channel) { if (s == NULL) return; @@ -492,55 +481,51 @@ void SETTINGS_FetchChannelName(char *s, const int channel) s[i--] = 0; // null term } -void SETTINGS_FactoryReset(bool bIsAll) -{ +void SETTINGS_FactoryReset(bool bIsAll) { uint16_t i; - uint8_t Template[8]; + uint8_t Template[8]; memset(Template, 0xFF, sizeof(Template)); //for (i = 0x0C80; i < 0x1E00; i += 8) - for (i = 0x0000; i < 0x1E00; i += 8) - { + for (i = 0x0000; i < 0x1E00; i += 8) { if ( - !(i >= 0x0EE0 && i < 0x0F18) && // ANI ID + DTMF codes - !(i >= 0x0F30 && i < 0x0F50) && // AES KEY + F LOCK + Scramble Enable - !(i >= 0x1C00 && i < 0x1E00) && // DTMF contacts - !(i >= 0x0EB0 && i < 0x0ED0) && // Welcome strings - !(i >= 0x0EA0 && i < 0x0EA8) && // Voice Prompt - (bIsAll || - ( - !(i >= 0x0D60 && i < 0x0E28) && // MR Channel Attributes - !(i >= 0x0F18 && i < 0x0F30) && // Scan List - !(i >= 0x0F50 && i < 0x1C00) && // MR Channel Names - !(i >= 0x0E40 && i < 0x0E70) && // FM Channels - !(i >= 0x0E88 && i < 0x0E90) // FM settings - )) - ) - { + !(i >= 0x0EE0 && i < 0x0F18) && // ANI ID + DTMF codes + !(i >= 0x0F30 && i < 0x0F50) && // AES KEY + F LOCK + Scramble Enable + !(i >= 0x1C00 && i < 0x1E00) && // DTMF contacts + !(i >= 0x0EB0 && i < 0x0ED0) && // Welcome strings + !(i >= 0x0EA0 && i < 0x0EA8) && // Voice Prompt + (bIsAll || + ( + !(i >= 0x0D60 && i < 0x0E28) && // MR Channel Attributes + !(i >= 0x0F18 && i < 0x0F30) && // Scan List + !(i >= 0x0F50 && i < 0x1C00) && // MR Channel Names + !(i >= 0x0E40 && i < 0x0E70) && // FM Channels + !(i >= 0x0E88 && i < 0x0E90) // FM settings + )) + ) { EEPROM_WriteBuffer(i, Template); } } - if (bIsAll) - { + if (bIsAll) { RADIO_InitInfo(gRxVfo, FREQ_CHANNEL_FIRST + BAND6_400MHz, 43350000); - #ifdef ENABLE_FEAT_F4HWN_RESET_CHANNEL - // set the first few memory channels - for (i = 0; i < ARRAY_SIZE(gDefaultFrequencyTable); i++) - { - const uint32_t Frequency = gDefaultFrequencyTable[i]; - gRxVfo->freq_config_RX.Frequency = Frequency; - gRxVfo->freq_config_TX.Frequency = Frequency; - gRxVfo->Band = FREQUENCY_GetBand(Frequency); - SETTINGS_SaveChannel(MR_CHANNEL_FIRST + i, 0, gRxVfo, 2); - } - #endif +#ifdef ENABLE_FEAT_F4HWN_RESET_CHANNEL + // set the first few memory channels + for (i = 0; i < ARRAY_SIZE(gDefaultFrequencyTable); i++) + { + const uint32_t Frequency = gDefaultFrequencyTable[i]; + gRxVfo->freq_config_RX.Frequency = Frequency; + gRxVfo->freq_config_TX.Frequency = Frequency; + gRxVfo->Band = FREQUENCY_GetBand(Frequency); + SETTINGS_SaveChannel(MR_CHANNEL_FIRST + i, 0, gRxVfo, 2); + } +#endif - #ifdef ENABLE_FEAT_F4HWN - EEPROM_WriteBuffer(0x1FF0, Template); - #endif +#ifdef ENABLE_FEAT_F4HWN + EEPROM_WriteBuffer(0x1FF0, Template); +#endif } } @@ -571,13 +556,12 @@ void SETTINGS_SaveFM(void) } #endif -void SETTINGS_SaveVfoIndices(void) -{ +void SETTINGS_SaveVfoIndices(void) { uint8_t State[8]; - #ifndef ENABLE_NOAA - EEPROM_ReadBuffer(0x0E80, State, sizeof(State)); - #endif +#ifndef ENABLE_NOAA + EEPROM_ReadBuffer(0x0E80, State, sizeof(State)); +#endif State[0] = gEeprom.ScreenChannel[0]; State[1] = gEeprom.MrChannel[0]; @@ -585,45 +569,44 @@ void SETTINGS_SaveVfoIndices(void) State[3] = gEeprom.ScreenChannel[1]; State[4] = gEeprom.MrChannel[1]; State[5] = gEeprom.FreqChannel[1]; - #ifdef ENABLE_NOAA - State[6] = gEeprom.NoaaChannel[0]; - State[7] = gEeprom.NoaaChannel[1]; - #endif +#ifdef ENABLE_NOAA + State[6] = gEeprom.NoaaChannel[0]; + State[7] = gEeprom.NoaaChannel[1]; +#endif EEPROM_WriteBuffer(0x0E80, State); } -void SETTINGS_SaveSettings(void) -{ - uint8_t State[8]; +void SETTINGS_SaveSettings(void) { + uint8_t State[8]; uint8_t tmp = 0; - #ifdef ENABLE_PWRON_PASSWORD - uint32_t Password[2]; - #endif +#ifdef ENABLE_PWRON_PASSWORD + uint32_t Password[2]; +#endif State[0] = gEeprom.CHAN_1_CALL; State[1] = gEeprom.SQUELCH_LEVEL; State[2] = gEeprom.TX_TIMEOUT_TIMER; - #ifdef ENABLE_NOAA - State[3] = gEeprom.NOAA_AUTO_SCAN; - #else - State[3] = false; - #endif +#ifdef ENABLE_NOAA + State[3] = gEeprom.NOAA_AUTO_SCAN; +#else + State[3] = false; +#endif - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS - State[4] = (gEeprom.KEY_LOCK ? 0x01 : 0) | (gEeprom.MENU_LOCK ? 0x02 :0) | ((gEeprom.SET_KEY & 0x0F) << 2); - #else - State[4] = gEeprom.KEY_LOCK; - #endif +#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS + State[4] = (gEeprom.KEY_LOCK ? 0x01 : 0) | (gEeprom.MENU_LOCK ? 0x02 :0) | ((gEeprom.SET_KEY & 0x0F) << 2); +#else + State[4] = gEeprom.KEY_LOCK; +#endif - #ifdef ENABLE_VOX - State[5] = gEeprom.VOX_SWITCH; - State[6] = gEeprom.VOX_LEVEL; - #else - State[5] = false; - State[6] = 0; - #endif +#ifdef ENABLE_VOX + State[5] = gEeprom.VOX_SWITCH; + State[6] = gEeprom.VOX_LEVEL; +#else + State[5] = false; + State[6] = 0; +#endif State[7] = gEeprom.MIC_SENSITIVITY; EEPROM_WriteBuffer(0x0E70, State); @@ -633,35 +616,32 @@ void SETTINGS_SaveSettings(void) State[3] = gEeprom.BATTERY_SAVE; State[4] = gEeprom.DUAL_WATCH; - #ifdef ENABLE_FEAT_F4HWN - if(!gSaveRxMode) - { - State[2] = gCB; - State[4] = gDW; - } - if(gBackLight) - { - State[5] = gBacklightTimeOriginal; - } - else - { - State[5] = gEeprom.BACKLIGHT_TIME; - } - #else +#ifdef ENABLE_FEAT_F4HWN + if (!gSaveRxMode) { + State[2] = gCB; + State[4] = gDW; + } + if (gBackLight) { + State[5] = gBacklightTimeOriginal; + } else { State[5] = gEeprom.BACKLIGHT_TIME; - #endif + } +#else + State[5] = gEeprom.BACKLIGHT_TIME; +#endif - #ifdef ENABLE_FEAT_F4HWN_NARROWER - State[6] = (gEeprom.TAIL_TONE_ELIMINATION & 0x01) | ((gSetting_set_nfm & 0x03) << 1); - #else - State[6] = gEeprom.TAIL_TONE_ELIMINATION; - #endif +#ifdef ENABLE_FEAT_F4HWN_NARROWER + State[6] = (gEeprom.TAIL_TONE_ELIMINATION & 0x01) | ((gSetting_set_nfm & 0x03) << 1); +#else + State[6] = gEeprom.TAIL_TONE_ELIMINATION; +#endif - #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE - State[7] = (gEeprom.VFO_OPEN & 0x01) | ((gEeprom.CURRENT_STATE & 0x07) << 1) | ((gEeprom.SCAN_LIST_DEFAULT & 0x07) << 4); - #else - State[7] = gEeprom.VFO_OPEN; - #endif +#ifdef ENABLE_FEAT_F4HWN_RESUME_STATE + State[7] = (gEeprom.VFO_OPEN & 0x01) | ((gEeprom.CURRENT_STATE & 0x07) << 1) | + ((gEeprom.SCAN_LIST_DEFAULT & 0x07) << 4); +#else + State[7] = gEeprom.VFO_OPEN; +#endif EEPROM_WriteBuffer(0x0E78, State); State[0] = gEeprom.BEEP_CONTROL; @@ -672,14 +652,14 @@ void SETTINGS_SaveSettings(void) State[4] = gEeprom.KEY_2_LONG_PRESS_ACTION; State[5] = gEeprom.SCAN_RESUME_MODE; State[6] = gEeprom.AUTO_KEYPAD_LOCK; - State[7] = gEeprom.POWER_ON_DISPLAY_MODE; + State[7] = gEeprom.FSKMode; EEPROM_WriteBuffer(0x0E90, State); - #ifdef ENABLE_PWRON_PASSWORD - memset(Password, 0xFF, sizeof(Password)); - Password[0] = gEeprom.POWER_ON_PASSWORD; - EEPROM_WriteBuffer(0x0E98, Password); - #endif +#ifdef ENABLE_PWRON_PASSWORD + memset(Password, 0xFF, sizeof(Password)); + Password[0] = gEeprom.POWER_ON_PASSWORD; + EEPROM_WriteBuffer(0x0E98, Password); +#endif memset(State, 0xFF, sizeof(State)); #ifdef ENABLE_VOICE @@ -692,11 +672,11 @@ void SETTINGS_SaveSettings(void) EEPROM_WriteBuffer(0x0EA0, State); - #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) - State[0] = gEeprom.ALARM_MODE; - #else - State[0] = false; - #endif +#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) + State[0] = gEeprom.ALARM_MODE; +#else + State[0] = false; +#endif State[1] = gEeprom.ROGER; State[2] = gEeprom.REPEATER_TAIL_TONE_ELIMINATION; State[3] = gEeprom.TX_VFO; @@ -743,36 +723,36 @@ void SETTINGS_SaveSettings(void) State[7] = gEeprom.SCANLIST_PRIORITY_CH2[2]; EEPROM_WriteBuffer(0x0F18, State); + State[0] = gEeprom.FSKSRCAddress & 0xFF; + State[1] = (gEeprom.FSKSRCAddress >> 8) & 0xFF; + State[2] = (gEeprom.FSKSRCAddress >> 16) & 0xFF; + State[3] = (gEeprom.FSKSRCAddress >> 24) & 0xFF; + EEPROM_WriteBuffer(0x0F20, State); + memset(State, 0xFF, sizeof(State)); - State[0] = gSetting_F_LOCK; + State[0] = gSetting_F_LOCK; #ifndef ENABLE_FEAT_F4HWN State[1] = gSetting_350TX; #endif -#ifdef ENABLE_DTMF_CALLING - State[2] = gSetting_KILLED; -#endif #ifndef ENABLE_FEAT_F4HWN State[3] = gSetting_200TX; State[4] = gSetting_500TX; #endif - State[5] = gSetting_350EN; -#ifdef ENABLE_FEAT_F4HWN - State[6] = false; -#else - State[6] = gSetting_ScrambleEnable; -#endif + State[5] = gSetting_350EN; + + State[6] = gSetting_ScrambleEnable; //if (!gSetting_TX_EN) State[7] &= ~(1u << 0); if (!gSetting_live_DTMF_decoder) State[7] &= ~(1u << 1); State[7] = (State[7] & ~(3u << 2)) | ((gSetting_battery_text & 3u) << 2); - #ifdef ENABLE_AUDIO_BAR - if (!gSetting_mic_bar) State[7] &= ~(1u << 4); - #endif - #ifndef ENABLE_FEAT_F4HWN - #ifdef ENABLE_AM_FIX - if (!gSetting_AM_fix) State[7] &= ~(1u << 5); - #endif - #endif +#ifdef ENABLE_AUDIO_BAR + if (!gSetting_mic_bar) State[7] &= ~(1u << 4); +#endif +#ifndef ENABLE_FEAT_F4HWN +#ifdef ENABLE_AM_FIX + if (!gSetting_AM_fix) State[7] &= ~(1u << 5); +#endif +#endif State[7] = (State[7] & ~(3u << 6)) | ((gSetting_backlight_on_tx_rx & 3u) << 6); EEPROM_WriteBuffer(0x0F40, State); @@ -802,16 +782,16 @@ void SETTINGS_SaveSettings(void) tmp = tmp | (1 << 3); */ -#ifdef ENABLE_FEAT_F4HWN_SLEEP +#ifdef ENABLE_FEAT_F4HWN_SLEEP State[4] = (gSetting_set_off << 1) | (gSetting_set_tmr & 0x01); #else State[4] = gSetting_set_tmr ? (1 << 0) : 0; #endif - tmp = (gSetting_set_inv << 0) | - (gSetting_set_lck << 1) | - (gSetting_set_met << 2) | - (gSetting_set_gui << 3); + tmp = (gSetting_set_inv << 0) | + (gSetting_set_lck << 1) | + (gSetting_set_met << 2) | + (gSetting_set_gui << 3); State[5] = ((tmp << 4) | (gSetting_set_ctr & 0x0F)); State[6] = ((gSetting_set_tot << 4) | (gSetting_set_eot & 0x0F)); @@ -827,8 +807,7 @@ void SETTINGS_SaveSettings(void) #endif } -void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode) -{ +void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode) { #ifdef ENABLE_NOAA if (IS_NOAA_CHANNEL(Channel)) return; @@ -837,7 +816,7 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint16_t OffsetVFO = Channel * 16; if (IS_FREQ_CHANNEL(Channel)) { // it's a VFO, not a channel - OffsetVFO = (VFO == 0) ? 0x0C80 : 0x0C90; + OffsetVFO = (VFO == 0) ? 0x0C80 : 0x0C90; OffsetVFO += (Channel - FREQ_CHANNEL_FIRST) * 32; } @@ -851,27 +830,24 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, State._32[1] = pVFO->TX_OFFSET_FREQUENCY; EEPROM_WriteBuffer(OffsetVFO + 0, State._32); - State._8[0] = pVFO->freq_config_RX.Code; - State._8[1] = pVFO->freq_config_TX.Code; + State._8[0] = pVFO->freq_config_RX.Code; + State._8[1] = pVFO->freq_config_TX.Code; State._8[2] = (pVFO->freq_config_TX.CodeType << 4) | pVFO->freq_config_RX.CodeType; State._8[3] = (pVFO->Modulation << 4) | pVFO->TX_OFFSET_FREQUENCY_DIRECTION; State._8[4] = 0 - | (pVFO->TX_LOCK << 6) - | (pVFO->BUSY_CHANNEL_LOCK << 5) - | (pVFO->OUTPUT_POWER << 2) - | (pVFO->CHANNEL_BANDWIDTH << 1) - | (pVFO->FrequencyReverse << 0); + | (pVFO->TX_LOCK << 6) + | (pVFO->BUSY_CHANNEL_LOCK << 5) + | (pVFO->OUTPUT_POWER << 2) + | (pVFO->CHANNEL_BANDWIDTH << 1) + | (pVFO->FrequencyReverse << 0); State._8[5] = ((pVFO->DTMF_PTT_ID_TX_MODE & 7u) << 1) #ifdef ENABLE_DTMF_CALLING | ((pVFO->DTMF_DECODING_ENABLE & 1u) << 0) #endif - ; - State._8[6] = pVFO->STEP_SETTING; -#ifdef ENABLE_FEAT_F4HWN - State._8[7] = 0; -#else - State._8[7] = pVFO->SCRAMBLING_TYPE; -#endif + ; + State._8[6] = pVFO->STEP_SETTING; + + State._8[7] = pVFO->SCRAMBLING_TYPE; EEPROM_WriteBuffer(OffsetVFO + 8, State._8); SETTINGS_UpdateChannel(Channel, pVFO, true, true, true); @@ -890,18 +866,16 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, } -void SETTINGS_SaveBatteryCalibration(const uint16_t * batteryCalibration) -{ +void SETTINGS_SaveBatteryCalibration(const uint16_t *batteryCalibration) { uint16_t buf[4]; EEPROM_WriteBuffer(0x1F40, batteryCalibration); - EEPROM_ReadBuffer( 0x1F48, buf, sizeof(buf)); + EEPROM_ReadBuffer(0x1F48, buf, sizeof(buf)); buf[0] = batteryCalibration[4]; buf[1] = batteryCalibration[5]; EEPROM_WriteBuffer(0x1F48, buf); } -void SETTINGS_SaveChannelName(uint8_t channel, const char * name) -{ +void SETTINGS_SaveChannelName(uint8_t channel, const char *name) { uint16_t offset = channel * 16; uint8_t buf[16] = {0}; memcpy(buf, name, MIN(strlen(name), 10u)); @@ -909,20 +883,19 @@ void SETTINGS_SaveChannelName(uint8_t channel, const char * name) EEPROM_WriteBuffer(0x0F58 + offset, buf + 8); } -void SETTINGS_UpdateChannel(uint8_t channel, const VFO_Info_t *pVFO, bool keep, bool check, bool save) -{ +void SETTINGS_UpdateChannel(uint8_t channel, const VFO_Info_t *pVFO, bool keep, bool check, bool save) { #ifdef ENABLE_NOAA if (!IS_NOAA_CHANNEL(channel)) #endif { - uint8_t state[8]; - ChannelAttributes_t att = { - .band = 0x7, - .compander = 0, - .scanlist1 = 0, - .scanlist2 = 0, - .scanlist3 = 0, - }; // default attributes + uint8_t state[8]; + ChannelAttributes_t att = { + .band = 0x7, + .compander = 0, + .scanlist1 = 0, + .scanlist2 = 0, + .scanlist3 = 0, + }; // default attributes uint16_t offset = 0x0D60 + (channel & ~7u); EEPROM_ReadBuffer(offset, state, sizeof(state)); @@ -940,8 +913,7 @@ void SETTINGS_UpdateChannel(uint8_t channel, const VFO_Info_t *pVFO, bool keep, state[channel & 7u] = att.__val; #ifdef ENABLE_FEAT_F4HWN - if(save) - { + if (save) { EEPROM_WriteBuffer(offset, state); } #else @@ -959,98 +931,100 @@ void SETTINGS_UpdateChannel(uint8_t channel, const VFO_Info_t *pVFO, bool keep, } } -void SETTINGS_WriteBuildOptions(void) -{ +void SETTINGS_WriteBuildOptions(void) { uint8_t State[8]; #ifdef ENABLE_FEAT_F4HWN EEPROM_ReadBuffer(0x1FF0, State, sizeof(State)); #endif - -State[0] = 0 -#ifdef ENABLE_FMRADIO - | (1 << 0) -#endif -#ifdef ENABLE_NOAA - | (1 << 1) -#endif -#ifdef ENABLE_VOICE - | (1 << 2) -#endif -#ifdef ENABLE_VOX - | (1 << 3) -#endif -#ifdef ENABLE_ALARM - | (1 << 4) -#endif -#ifdef ENABLE_TX1750 - | (1 << 5) + + State[0] = 0 + #ifdef ENABLE_FMRADIO + | (1 << 0) + #endif + #ifdef ENABLE_NOAA + | (1 << 1) + #endif + #ifdef ENABLE_VOICE + | (1 << 2) + #endif + #ifdef ENABLE_VOX + | (1 << 3) + #endif + #ifdef ENABLE_ALARM + | (1 << 4) + #endif + #ifdef ENABLE_TX1750 + | (1 << 5) #endif #ifdef ENABLE_PWRON_PASSWORD - | (1 << 6) + | (1 << 6) #endif #ifdef ENABLE_DTMF_CALLING - | (1 << 7) + | (1 << 7) #endif -; + ; -State[1] = 0 -#ifdef ENABLE_FLASHLIGHT - | (1 << 0) -#endif -#ifdef ENABLE_WIDE_RX - | (1 << 1) -#endif -#ifdef ENABLE_BYP_RAW_DEMODULATORS - | (1 << 2) -#endif -#ifdef ENABLE_BLMIN_TMP_OFF - | (1 << 3) -#endif -#ifdef ENABLE_AM_FIX - | (1 << 4) -#endif -#ifdef ENABLE_SPECTRUM - | (1 << 5) + State[1] = 0 + #ifdef ENABLE_FLASHLIGHT + | (1 << 0) + #endif + #ifdef ENABLE_WIDE_RX + | (1 << 1) + #endif + #ifdef ENABLE_BYP_RAW_DEMODULATORS + | (1 << 2) + #endif + #ifdef ENABLE_BLMIN_TMP_OFF + | (1 << 3) + #endif + #ifdef ENABLE_AM_FIX + | (1 << 4) + #endif + #ifdef ENABLE_SPECTRUM + | (1 << 5) #endif #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS - | (1 << 6) + | (1 << 6) #endif -; + ; EEPROM_WriteBuffer(0x1FF0, State); } #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE - void SETTINGS_WriteCurrentState(void) - { - uint8_t State[8]; - EEPROM_ReadBuffer(0x0E78, State, sizeof(State)); - //State[3] = (gEeprom.CURRENT_STATE << 4) | (gEeprom.BATTERY_SAVE & 0x0F); - State[7] = (gEeprom.VFO_OPEN & 0x01) | ((gEeprom.CURRENT_STATE & 0x07) << 1) | ((gEeprom.SCAN_LIST_DEFAULT & 0x07) << 4); - EEPROM_WriteBuffer(0x0E78, State); - } + +void SETTINGS_WriteCurrentState(void) { + uint8_t State[8]; + EEPROM_ReadBuffer(0x0E78, State, sizeof(State)); + //State[3] = (gEeprom.CURRENT_STATE << 4) | (gEeprom.BATTERY_SAVE & 0x0F); + State[7] = (gEeprom.VFO_OPEN & 0x01) | ((gEeprom.CURRENT_STATE & 0x07) << 1) | + ((gEeprom.SCAN_LIST_DEFAULT & 0x07) << 4); + EEPROM_WriteBuffer(0x0E78, State); +} + #endif #ifdef ENABLE_FEAT_F4HWN_VOL - void SETTINGS_WriteCurrentVol(void) - { - uint8_t State[8]; - EEPROM_ReadBuffer(0x1F88, State, sizeof(State)); - State[6] = gEeprom.VOLUME_GAIN; - EEPROM_WriteBuffer(0x1F88, State); - } + +void SETTINGS_WriteCurrentVol(void) { + uint8_t State[8]; + EEPROM_ReadBuffer(0x1F88, State, sizeof(State)); + State[6] = gEeprom.VOLUME_GAIN; + EEPROM_WriteBuffer(0x1F88, State); +} + #endif #ifdef ENABLE_FEAT_F4HWN -void SETTINGS_ResetTxLock(void) -{ + +void SETTINGS_ResetTxLock(void) { uint8_t State[8]; - for(uint8_t channel = 0; channel < 200; channel++) - { + for (uint8_t channel = 0; channel < 200; channel++) { uint16_t OffsetVFO = channel * 16; EEPROM_ReadBuffer(OffsetVFO + 8, State, sizeof(State)); State[4] |= (1 << 6); EEPROM_WriteBuffer(OffsetVFO + 8, State); } } + #endif diff --git a/settings.h b/settings.h index c42be02..f7e6858 100644 --- a/settings.h +++ b/settings.h @@ -23,8 +23,20 @@ #include "frequencies.h" #include #include "radio.h" +#include "functions.h" +#include "app/fskmodem.h" #include +// Modem Modulation +typedef enum ModemModulation { + MOD_FSK_450, // for bad conditions + MOD_FSK_700, // for medium conditions + MOD_AFSK_1200, // for good conditions + MOD_AFSK_2400, + MOD_FSK_1200_2400, + MOD_NOAA_SAME +} ModemModulation; + enum POWER_OnDisplayMode_t { #ifdef ENABLE_FEAT_F4HWN POWER_ON_DISPLAY_MODE_ALL, @@ -40,14 +52,14 @@ typedef enum POWER_OnDisplayMode_t POWER_OnDisplayMode_t; enum TxLockModes_t { F_LOCK_DEF, //all default frequencies + configurable - F_LOCK_FCC, #ifdef ENABLE_FEAT_F4HWN_CA + F_LOCK_FCC, F_LOCK_CA, -#endif F_LOCK_CE, F_LOCK_GB, F_LOCK_430, F_LOCK_438, +#endif #ifdef ENABLE_FEAT_F4HWN_PMR F_LOCK_PMR, #endif @@ -118,10 +130,10 @@ enum ACTION_OPT_t { ACTION_OPT_WN, ACTION_OPT_BACKLIGHT, ACTION_OPT_MUTE, - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS - ACTION_OPT_POWER_HIGH, - ACTION_OPT_REMOVE_OFFSET, - #endif +#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS + ACTION_OPT_POWER_HIGH, + ACTION_OPT_REMOVE_OFFSET, +#endif #endif #ifdef ENABLE_REGA ACTION_OPT_REGA_ALARM, @@ -131,13 +143,13 @@ enum ACTION_OPT_t { }; #ifdef ENABLE_VOICE - enum VOICE_Prompt_t - { - VOICE_PROMPT_OFF = 0, - VOICE_PROMPT_CHINESE, - VOICE_PROMPT_ENGLISH - }; - typedef enum VOICE_Prompt_t VOICE_Prompt_t; +enum VOICE_Prompt_t +{ + VOICE_PROMPT_OFF = 0, + VOICE_PROMPT_CHINESE, + VOICE_PROMPT_ENGLISH +}; +typedef enum VOICE_Prompt_t VOICE_Prompt_t; #endif enum ALARM_Mode_t { @@ -162,23 +174,23 @@ enum CHANNEL_DisplayMode_t { typedef enum CHANNEL_DisplayMode_t CHANNEL_DisplayMode_t; typedef struct { - uint8_t ScreenChannel[2]; // current channels set in the radio (memory or frequency channels) - uint8_t FreqChannel[2]; // last frequency channels used - uint8_t MrChannel[2]; // last memory channels used + uint8_t ScreenChannel[2]; // current channels set in the radio (memory or frequency channels) + uint8_t FreqChannel[2]; // last frequency channels used + uint8_t MrChannel[2]; // last memory channels used #ifdef ENABLE_NOAA uint8_t NoaaChannel[2]; #endif // The actual VFO index (0-upper/1-lower) that is now used for RX, // It is being alternated by dual watch, and flipped by crossband - uint8_t RX_VFO; + uint8_t RX_VFO; // The main VFO index (0-upper/1-lower) selected by the user // - uint8_t TX_VFO; + uint8_t TX_VFO; - uint8_t field7_0xa; - uint8_t field8_0xb; + uint8_t field7_0xa; + uint8_t field8_0xb; #ifdef ENABLE_FMRADIO uint16_t FM_SelectedFrequency; @@ -189,145 +201,167 @@ typedef struct { //uint8_t FM_Space : 2; #endif - uint8_t SQUELCH_LEVEL; - uint8_t TX_TIMEOUT_TIMER; - bool KEY_LOCK; + uint8_t SQUELCH_LEVEL; + uint8_t TX_TIMEOUT_TIMER; + bool KEY_LOCK; #ifdef ENABLE_FEAT_F4HWN - bool KEY_LOCK_PTT; + bool KEY_LOCK_PTT; #endif #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS bool MENU_LOCK; uint8_t SET_KEY; #endif - bool VOX_SWITCH; - uint8_t VOX_LEVEL; + bool VOX_SWITCH; + uint8_t VOX_LEVEL; #ifdef ENABLE_VOICE VOICE_Prompt_t VOICE_PROMPT; #endif - bool BEEP_CONTROL; - uint8_t CHANNEL_DISPLAY_MODE; - bool TAIL_TONE_ELIMINATION; - bool VFO_OPEN; - uint8_t DUAL_WATCH; - uint8_t CROSS_BAND_RX_TX; - uint8_t BATTERY_SAVE; - uint8_t BACKLIGHT_TIME; - uint8_t SCAN_RESUME_MODE; - uint8_t SCAN_LIST_DEFAULT; - bool SCAN_LIST_ENABLED[3]; - uint8_t SCANLIST_PRIORITY_CH1[3]; - uint8_t SCANLIST_PRIORITY_CH2[3]; + bool BEEP_CONTROL; + uint8_t CHANNEL_DISPLAY_MODE; + bool TAIL_TONE_ELIMINATION; + bool VFO_OPEN; + uint8_t DUAL_WATCH; + uint8_t CROSS_BAND_RX_TX; + uint8_t BATTERY_SAVE; + uint8_t BACKLIGHT_TIME; + uint8_t SCAN_RESUME_MODE; + uint8_t SCAN_LIST_DEFAULT; + bool SCAN_LIST_ENABLED[3]; + uint8_t SCANLIST_PRIORITY_CH1[3]; + uint8_t SCANLIST_PRIORITY_CH2[3]; #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE - uint8_t CURRENT_STATE; - uint8_t CURRENT_LIST; + uint8_t CURRENT_STATE; + uint8_t CURRENT_LIST; #endif - uint8_t field29_0x26; - uint8_t field30_0x27; - - uint8_t field37_0x32; - uint8_t field38_0x33; + uint8_t field29_0x26; + uint8_t field30_0x27; - uint8_t AUTO_KEYPAD_LOCK; + uint8_t field37_0x32; + uint8_t field38_0x33; + + uint8_t AUTO_KEYPAD_LOCK; #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) - ALARM_Mode_t ALARM_MODE; + ALARM_Mode_t ALARM_MODE; #endif POWER_OnDisplayMode_t POWER_ON_DISPLAY_MODE; - ROGER_Mode_t ROGER; - uint8_t REPEATER_TAIL_TONE_ELIMINATION; - uint8_t KEY_1_SHORT_PRESS_ACTION; - uint8_t KEY_1_LONG_PRESS_ACTION; - uint8_t KEY_2_SHORT_PRESS_ACTION; - uint8_t KEY_2_LONG_PRESS_ACTION; - uint8_t MIC_SENSITIVITY; - uint8_t MIC_SENSITIVITY_TUNING; - uint8_t CHAN_1_CALL; + ROGER_Mode_t ROGER; + uint8_t REPEATER_TAIL_TONE_ELIMINATION; + uint8_t KEY_1_SHORT_PRESS_ACTION; + uint8_t KEY_1_LONG_PRESS_ACTION; + uint8_t KEY_2_SHORT_PRESS_ACTION; + uint8_t KEY_2_LONG_PRESS_ACTION; + uint8_t MIC_SENSITIVITY; + uint8_t MIC_SENSITIVITY_TUNING; + uint8_t CHAN_1_CALL; #ifdef ENABLE_DTMF_CALLING char ANI_DTMF_ID[8]; char KILL_CODE[8]; char REVIVE_CODE[8]; #endif - char DTMF_UP_CODE[16]; + char DTMF_UP_CODE[16]; - uint8_t field57_0x6c; - uint8_t field58_0x6d; + uint8_t field57_0x6c; + uint8_t field58_0x6d; - char DTMF_DOWN_CODE[16]; + char DTMF_DOWN_CODE[16]; - uint8_t field60_0x7e; - uint8_t field61_0x7f; + uint8_t field60_0x7e; + uint8_t field61_0x7f; #ifdef ENABLE_DTMF_CALLING char DTMF_SEPARATE_CODE; char DTMF_GROUP_CALL_CODE; uint8_t DTMF_DECODE_RESPONSE; uint8_t DTMF_auto_reset_time; -#endif - uint16_t DTMF_PRELOAD_TIME; - uint16_t DTMF_FIRST_CODE_PERSIST_TIME; - uint16_t DTMF_HASH_CODE_PERSIST_TIME; - uint16_t DTMF_CODE_PERSIST_TIME; - uint16_t DTMF_CODE_INTERVAL_TIME; - bool DTMF_SIDE_TONE; +#endif + uint16_t DTMF_PRELOAD_TIME; + uint16_t DTMF_FIRST_CODE_PERSIST_TIME; + uint16_t DTMF_HASH_CODE_PERSIST_TIME; + uint16_t DTMF_CODE_PERSIST_TIME; + uint16_t DTMF_CODE_INTERVAL_TIME; + bool DTMF_SIDE_TONE; #ifdef ENABLE_DTMF_CALLING bool PERMIT_REMOTE_KILL; #endif - int16_t BK4819_XTAL_FREQ_LOW; + int16_t BK4819_XTAL_FREQ_LOW; #ifdef ENABLE_NOAA bool NOAA_AUTO_SCAN; #endif - uint8_t VOLUME_GAIN; - #ifdef ENABLE_FEAT_F4HWN - uint8_t VOLUME_GAIN_BACKUP; - #endif - uint8_t DAC_GAIN; + uint8_t VOLUME_GAIN; +#ifdef ENABLE_FEAT_F4HWN + uint8_t VOLUME_GAIN_BACKUP; +#endif + uint8_t DAC_GAIN; - VFO_Info_t VfoInfo[2]; - uint32_t POWER_ON_PASSWORD; - uint16_t VOX1_THRESHOLD; - uint16_t VOX0_THRESHOLD; + VFO_Info_t VfoInfo[2]; + uint32_t POWER_ON_PASSWORD; + uint16_t VOX1_THRESHOLD; + uint16_t VOX0_THRESHOLD; - uint8_t field77_0x95; - uint8_t field78_0x96; - uint8_t field79_0x97; + uint8_t field77_0x95; + uint8_t field78_0x96; + uint8_t field79_0x97; - uint8_t KEY_M_LONG_PRESS_ACTION; - uint8_t BACKLIGHT_MIN; + uint8_t KEY_M_LONG_PRESS_ACTION; + uint8_t BACKLIGHT_MIN; #ifdef ENABLE_BLMIN_TMP_OFF - BLMIN_STAT_t BACKLIGHT_MIN_STAT; + BLMIN_STAT_t BACKLIGHT_MIN_STAT; #endif - uint8_t BACKLIGHT_MAX; - BATTERY_Type_t BATTERY_TYPE; + uint8_t BACKLIGHT_MAX; + BATTERY_Type_t BATTERY_TYPE; #ifdef ENABLE_RSSI_BAR - uint8_t S0_LEVEL; - uint8_t S9_LEVEL; + uint8_t S0_LEVEL; + uint8_t S9_LEVEL; #endif + + ModemModulation FSKMode; + uint32_t FSKSRCAddress; } EEPROM_Config_t; extern EEPROM_Config_t gEeprom; -void SETTINGS_InitEEPROM(void); -void SETTINGS_LoadCalibration(void); +void SETTINGS_InitEEPROM(void); + +void SETTINGS_LoadCalibration(void); + uint32_t SETTINGS_FetchChannelFrequency(const int channel); -void SETTINGS_FetchChannelName(char *s, const int channel); -void SETTINGS_FactoryReset(bool bIsAll); + +void SETTINGS_FetchChannelName(char *s, const int channel); + +void SETTINGS_FactoryReset(bool bIsAll); + #ifdef ENABLE_FMRADIO - void SETTINGS_SaveFM(void); +void SETTINGS_SaveFM(void); #endif + void SETTINGS_SaveVfoIndices(void); + void SETTINGS_SaveSettings(void); -void SETTINGS_SaveChannelName(uint8_t channel, const char * name); + +void SETTINGS_SaveChannelName(uint8_t channel, const char *name); + void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode); -void SETTINGS_SaveBatteryCalibration(const uint16_t * batteryCalibration); + +void SETTINGS_SaveBatteryCalibration(const uint16_t *batteryCalibration); + void SETTINGS_UpdateChannel(uint8_t channel, const VFO_Info_t *pVFO, bool keep, bool check, bool save); + void SETTINGS_WriteBuildOptions(void); + #ifdef ENABLE_FEAT_F4HWN_RESUME_STATE - void SETTINGS_WriteCurrentState(void); + +void SETTINGS_WriteCurrentState(void); + #endif #ifdef ENABLE_FEAT_F4HWN_VOL - void SETTINGS_WriteCurrentVol(void); + +void SETTINGS_WriteCurrentVol(void); + #endif #ifdef ENABLE_FEAT_F4HWN - void SETTINGS_ResetTxLock(void); + +void SETTINGS_ResetTxLock(void); + #endif #endif diff --git a/ui/aircopy.c b/ui/aircopy.c index 8dd1666..6b7b60c 100644 --- a/ui/aircopy.c +++ b/ui/aircopy.c @@ -61,11 +61,13 @@ void UI_DisplayAircopy(void) UI_PrintStringSmallNormal(String + 7, 97, 0, 3); String[7] = 0; // show the main large frequency digits - UI_DisplayFrequency(String, 16, 2, false); + //UI_DisplayFrequency(String, 16, 2, false); + UI_PrintStringSmallNormal(String, 0, 20, 2); } else { const char *ascii = INPUTBOX_GetAscii(); sprintf(String, "%.3s.%.3s", ascii, ascii + 3); - UI_DisplayFrequency(String, 16, 2, false); + //UI_DisplayFrequency(String, 16, 2, false); + UI_PrintStringSmallNormal(String, 0, 20, 2); } memset(String, 0, sizeof(String)); diff --git a/ui/fmradio.c b/ui/fmradio.c index f6f20c1..24c2bd3 100644 --- a/ui/fmradio.c +++ b/ui/fmradio.c @@ -50,7 +50,7 @@ void UI_DisplayFM(void) //UI_PrintStringSmallNormal(String, 127 - 4*7, 0, 6); if (gAskToSave) { - pPrintStr = "SAVE?"; + pPrintStr = "SAV?"; } else if (gAskToDelete) { pPrintStr = "DEL?"; } else if (gFM_ScanState == FM_SCAN_OFF) { @@ -61,35 +61,35 @@ void UI_DisplayFM(void) pPrintStr = "VFO"; for (unsigned int i = 0; i < 20; i++) { if (gEeprom.FM_FrequencyPlaying == gFM_Channels[i]) { - sprintf(String, "VFO(CH%02u)", i + 1); + sprintf(String, "VF(C%02u)", i + 1); pPrintStr = String; break; } } } } else if (gFM_AutoScan) { - sprintf(String, "A-SCAN(%u)", gFM_ChannelPosition + 1); + sprintf(String, "A-SCN(%u)", gFM_ChannelPosition + 1); pPrintStr = String; } else { - pPrintStr = "M-SCAN"; + pPrintStr = "M-SCN"; } - UI_PrintString(pPrintStr, 0, 127, 3, 10); // memory, vfo, scan + UI_PrintString(pPrintStr, 0, 127, 3, 12); // memory, vfo, scan memset(String, 0, sizeof(String)); if (gAskToSave || (gEeprom.FM_IsMrMode && gInputBoxIndex > 0)) { UI_GenerateChannelString(String, gFM_ChannelPosition); } else if (gAskToDelete) { - sprintf(String, "CH-%02u", gEeprom.FM_SelectedChannel + 1); + sprintf(String, "C-%02u", gEeprom.FM_SelectedChannel + 1); } else { if (gInputBoxIndex == 0) { - sprintf(String, "%3d.%d", gEeprom.FM_FrequencyPlaying / 10, gEeprom.FM_FrequencyPlaying % 10); + sprintf(String, " %3d.%d", gEeprom.FM_FrequencyPlaying / 10, gEeprom.FM_FrequencyPlaying % 10); } else { const char * ascii = INPUTBOX_GetAscii(); sprintf(String, "%.3s.%.1s",ascii, ascii + 3); } - UI_DisplayFrequency(String, 36, 1, gInputBoxIndex == 0); // frequency + UI_PrintString(String, 0, 20, 1, 10); // frequency ST7565_BlitFullScreen(); return; } diff --git a/ui/helper.c b/ui/helper.c index cf63819..79e14b6 100644 --- a/ui/helper.c +++ b/ui/helper.c @@ -24,15 +24,13 @@ #include "misc.h" #ifndef ARRAY_SIZE - #define ARRAY_SIZE(arr) (sizeof(arr)/sizeof((arr)[0])) +#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof((arr)[0])) #endif -void UI_GenerateChannelString(char *pString, const uint8_t Channel) -{ +void UI_GenerateChannelString(char *pString, const uint8_t Channel) { unsigned int i; - if (gInputBoxIndex == 0) - { + if (gInputBoxIndex == 0) { sprintf(pString, "CH-%02u", Channel + 1); return; } @@ -44,8 +42,7 @@ void UI_GenerateChannelString(char *pString, const uint8_t Channel) pString[i + 3] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0'; } -void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint8_t ChannelNumber) -{ +void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uint8_t ChannelNumber) { if (gInputBoxIndex > 0) { for (unsigned int i = 0; i < 3; i++) { pString[i] = (gInputBox[i] == 10) ? '-' : gInputBox[i] + '0'; @@ -65,41 +62,38 @@ void UI_GenerateChannelStringEx(char *pString, const bool bShowPrefix, const uin } } -void UI_PrintStringBuffer(const char *pString, uint8_t * buffer, uint32_t char_width, const uint8_t *font) -{ +void *memcpy_inv(void *dst, const void *src, size_t n) { + if (!dst || !src) return dst; + + uint8_t *d = (uint8_t *) dst; + const uint8_t *s = (const uint8_t *) src; + + while (n--) { + *d++ = ~(*s++); + } + + return dst; +} + +void UI_PrintStringBuffer(const char *pString, uint8_t *buffer, uint32_t char_width, const uint8_t *font, bool inv) { const size_t Length = strlen(pString); const unsigned int char_spacing = char_width + 1; for (size_t i = 0; i < Length; i++) { const unsigned int index = pString[i] - ' ' - 1; if (pString[i] > ' ' && pString[i] < 127) { const uint32_t offset = i * char_spacing + 1; - memcpy(buffer + offset, font + index * char_width, char_width); + if (inv) { + memcpy_inv(buffer + offset, font + index * char_width, char_width); + } else { + memcpy(buffer + offset, font + index * char_width, char_width); + } } } } -void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width) -{ - size_t i; - size_t Length = strlen(pString); - if (End > Start) - Start += (((End - Start) - (Length * Width)) + 1) / 2; - - for (i = 0; i < Length; i++) - { - const unsigned int ofs = (unsigned int)Start + (i * Width); - if (pString[i] > ' ' && pString[i] < 127) - { - const unsigned int index = pString[i] - ' ' - 1; - memcpy(gFrameBuffer[Line + 0] + ofs, &gFontBig[index][0], 7); - memcpy(gFrameBuffer[Line + 1] + ofs, &gFontBig[index][7], 7); - } - } -} - -void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t char_width, const uint8_t *font) -{ +void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t char_width, + const uint8_t *font, bool inv) { const size_t Length = strlen(pString); const unsigned int char_spacing = char_width + 1; @@ -107,79 +101,99 @@ void UI_PrintStringSmall(const char *pString, uint8_t Start, uint8_t End, uint8_ Start += (((End - Start) - Length * char_spacing) + 1) / 2; } - UI_PrintStringBuffer(pString, gFrameBuffer[Line] + Start, char_width, font); + UI_PrintStringBuffer(pString, gFrameBuffer[Line] + Start, char_width, font, inv); } -void UI_PrintStringSmallNormal(const char *pString, uint8_t Start, uint8_t End, uint8_t Line) -{ - UI_PrintStringSmall(pString, Start, End, Line, ARRAY_SIZE(gFontSmall[0]), (const uint8_t *)gFontSmall); +void UI_PrintStringSmallNormal(const char *pString, uint8_t Start, uint8_t End, uint8_t Line) { + UI_PrintStringSmall(pString, Start, End, Line, ARRAY_SIZE(gFontSmall[0]), (const uint8_t *) gFontSmall, false); } -void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, uint8_t Line) -{ +void UI_PrintString(const char *pString, uint8_t Start, uint8_t End, uint8_t Line, uint8_t Width) { + Width = Width; + UI_PrintStringSmallNormal(pString, Start, End, Line); +// size_t i; +// size_t Length = strlen(pString); +// +// if (End > Start) +// Start += (((End - Start) - (Length * Width)) + 1) / 2; +// +// for (i = 0; i < Length; i++) +// { +// const unsigned int ofs = (unsigned int)Start + (i * Width); +// if (pString[i] > ' ' && pString[i] < 127) +// { +// const unsigned int index = pString[i] - ' ' - 1; +// memcpy(gFrameBuffer[Line + 0] + ofs, &gFontSmall[index + '0'][0], 7); +// memcpy(gFrameBuffer[Line + 1] + ofs, &gFontSmall[index + '0'][7], 7); +// } +// } +} + +void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, uint8_t Line) { +//#ifdef ENABLE_SMALL_BOLD +// const uint8_t *font = (uint8_t *)gFontSmallBold; +// const uint8_t char_width = ARRAY_SIZE(gFontSmallBold[0]); +//#else +// const uint8_t *font = (uint8_t *) gFontSmall; +// const uint8_t char_width = ARRAY_SIZE(gFontSmall[0]); +//#endif +// +// UI_PrintStringSmall(pString, Start, End, Line, char_width, font); + UI_PrintStringSmall(pString, Start, End, Line, ARRAY_SIZE(gFontSmall[0]), (const uint8_t *) gFontSmall, true); +} + +void UI_PrintStringSmallBufferNormal(const char *pString, uint8_t *buffer) { + UI_PrintStringBuffer(pString, buffer, ARRAY_SIZE(gFontSmall[0]), (uint8_t *) gFontSmall, false); +} + +void UI_PrintStringSmallBufferBold(const char *pString, uint8_t *buffer) { #ifdef ENABLE_SMALL_BOLD const uint8_t *font = (uint8_t *)gFontSmallBold; const uint8_t char_width = ARRAY_SIZE(gFontSmallBold[0]); #else - const uint8_t *font = (uint8_t *)gFontSmall; + const uint8_t *font = (uint8_t *) gFontSmall; const uint8_t char_width = ARRAY_SIZE(gFontSmall[0]); #endif - - UI_PrintStringSmall(pString, Start, End, Line, char_width, font); + UI_PrintStringBuffer(pString, buffer, char_width, font, false); } -void UI_PrintStringSmallBufferNormal(const char *pString, uint8_t * buffer) -{ - UI_PrintStringBuffer(pString, buffer, ARRAY_SIZE(gFontSmall[0]), (uint8_t *)gFontSmall); -} - -void UI_PrintStringSmallBufferBold(const char *pString, uint8_t * buffer) -{ -#ifdef ENABLE_SMALL_BOLD - const uint8_t *font = (uint8_t *)gFontSmallBold; - const uint8_t char_width = ARRAY_SIZE(gFontSmallBold[0]); -#else - const uint8_t *font = (uint8_t *)gFontSmall; - const uint8_t char_width = ARRAY_SIZE(gFontSmall[0]); -#endif - UI_PrintStringBuffer(pString, buffer, char_width, font); -} - -void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center) -{ - const unsigned int char_width = 13; - uint8_t *pFb0 = gFrameBuffer[Y] + X; - uint8_t *pFb1 = pFb0 + 128; - bool bCanDisplay = false; - - uint8_t len = strlen(string); - for(int i = 0; i < len; i++) { - char c = string[i]; - if(c=='-') c = '9' + 1; - if (bCanDisplay || c != ' ') - { - bCanDisplay = true; - if(c>='0' && c<='9' + 1) { - memcpy(pFb0 + 2, gFontBigDigits[c-'0'], char_width - 3); - memcpy(pFb1 + 2, gFontBigDigits[c-'0'] + char_width - 3, char_width - 3); - } - else if(c=='.') { - *pFb1 = 0x60; pFb0++; pFb1++; - *pFb1 = 0x60; pFb0++; pFb1++; - *pFb1 = 0x60; pFb0++; pFb1++; - continue; - } - - } - else if (center) { - pFb0 -= 6; - pFb1 -= 6; - } - pFb0 += char_width; - pFb1 += char_width; - } -} +//void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center) { +// const unsigned int char_width = 13; +// uint8_t *pFb0 = gFrameBuffer[Y] + X; +// uint8_t *pFb1 = pFb0 + 128; +// bool bCanDisplay = false; +// +// uint8_t len = strlen(string); +// for (int i = 0; i < len; i++) { +// char c = string[i]; +// if (c == '-') c = '9' + 1; +// if (bCanDisplay || c != ' ') { +// bCanDisplay = true; +// if (c >= '0' && c <= '9' + 1) { +// memcpy(pFb0 + 2, gFontSmall[(unsigned char) c], char_width - 3); +// memcpy(pFb1 + 2, gFontSmall[(unsigned char) c] + char_width - 3, char_width - 3); +// } else if (c == '.') { +// *pFb1 = 0x60; +// pFb0++; +// pFb1++; +// *pFb1 = 0x60; +// pFb0++; +// pFb1++; +// *pFb1 = 0x60; +// pFb0++; +// pFb1++; +// continue; +// } +// +// } else if (center) { +// pFb0 -= 6; +// pFb1 -= 6; +// } +// pFb0 += char_width; +// pFb1 += char_width; +// } +//} /* void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center) @@ -221,18 +235,16 @@ void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center) } */ -void UI_DrawPixelBuffer(uint8_t (*buffer)[128], uint8_t x, uint8_t y, bool black) -{ +void UI_DrawPixelBuffer(uint8_t (*buffer)[128], uint8_t x, uint8_t y, bool black) { const uint8_t pattern = 1 << (y % 8); - if(black) - buffer[y/8][x] |= pattern; + if (black) + buffer[y / 8][x] |= pattern; else - buffer[y/8][x] &= ~pattern; + buffer[y / 8][x] &= ~pattern; } -static void sort(int16_t *a, int16_t *b) -{ - if(*a > *b) { +static void sort(int16_t *a, int16_t *b) { + if (*a > *b) { int16_t t = *a; *a = *b; *b = t; @@ -240,66 +252,13 @@ static void sort(int16_t *a, int16_t *b) } #ifdef ENABLE_FEAT_F4HWN - /* - void UI_DrawLineDottedBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black) - { - if(x2==x1) { - sort(&y1, &y2); - for(int16_t i = y1; i <= y2; i+=2) { - UI_DrawPixelBuffer(buffer, x1, i, black); - } - } else { - const int multipl = 1000; - int a = (y2-y1)*multipl / (x2-x1); - int b = y1 - a * x1 / multipl; - sort(&x1, &x2); - for(int i = x1; i<= x2; i+=2) - { - UI_DrawPixelBuffer(buffer, i, i*a/multipl +b, black); - } - } - } - */ - - void PutPixel(uint8_t x, uint8_t y, bool fill) { - UI_DrawPixelBuffer(gFrameBuffer, x, y, fill); - } - - void PutPixelStatus(uint8_t x, uint8_t y, bool fill) { - UI_DrawPixelBuffer(&gStatusLine, x, y, fill); - } - - void GUI_DisplaySmallest(const char *pString, uint8_t x, uint8_t y, - bool statusbar, bool fill) { - uint8_t c; - uint8_t pixels; - const uint8_t *p = (const uint8_t *)pString; - - while ((c = *p++) && c != '\0') { - c -= 0x20; - for (int i = 0; i < 3; ++i) { - pixels = gFont3x5[c][i]; - for (int j = 0; j < 6; ++j) { - if (pixels & 1) { - if (statusbar) - PutPixelStatus(x + i, y + j, fill); - else - PutPixel(x + i, y + j, fill); - } - pixels >>= 1; - } - } - x += 4; - } - } -#endif - -void UI_DrawLineBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black) +/* +void UI_DrawLineDottedBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black) { if(x2==x1) { sort(&y1, &y2); - for(int16_t i = y1; i <= y2; i++) { + for(int16_t i = y1; i <= y2; i+=2) { UI_DrawPixelBuffer(buffer, x1, i, black); } } else { @@ -308,24 +267,75 @@ void UI_DrawLineBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x int b = y1 - a * x1 / multipl; sort(&x1, &x2); - for(int i = x1; i<= x2; i++) + for(int i = x1; i<= x2; i+=2) { UI_DrawPixelBuffer(buffer, i, i*a/multipl +b, black); } } } +*/ -void UI_DrawRectangleBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black) -{ - UI_DrawLineBuffer(buffer, x1,y1, x1,y2, black); - UI_DrawLineBuffer(buffer, x1,y1, x2,y1, black); - UI_DrawLineBuffer(buffer, x2,y1, x2,y2, black); - UI_DrawLineBuffer(buffer, x1,y2, x2,y2, black); +void PutPixel(uint8_t x, uint8_t y, bool fill) { + UI_DrawPixelBuffer(gFrameBuffer, x, y, fill); +} + +void PutPixelStatus(uint8_t x, uint8_t y, bool fill) { + UI_DrawPixelBuffer(&gStatusLine, x, y, fill); +} + +void GUI_DisplaySmallest(const char *pString, uint8_t x, uint8_t y, + bool statusbar, bool fill) { + uint8_t c; + uint8_t pixels; + const uint8_t *p = (const uint8_t *) pString; + + while ((c = *p++) && c != '\0') { + c -= 0x20; + for (int i = 0; i < 3; ++i) { + pixels = gFont3x5[c][i]; + for (int j = 0; j < 6; ++j) { + if (pixels & 1) { + if (statusbar) + PutPixelStatus(x + i, y + j, fill); + else + PutPixel(x + i, y + j, fill); + } + pixels >>= 1; + } + } + x += 4; + } +} + +#endif + +void UI_DrawLineBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black) { + if (x2 == x1) { + sort(&y1, &y2); + for (int16_t i = y1; i <= y2; i++) { + UI_DrawPixelBuffer(buffer, x1, i, black); + } + } else { + const int multipl = 1000; + int a = (y2 - y1) * multipl / (x2 - x1); + int b = y1 - a * x1 / multipl; + + sort(&x1, &x2); + for (int i = x1; i <= x2; i++) { + UI_DrawPixelBuffer(buffer, i, i * a / multipl + b, black); + } + } +} + +void UI_DrawRectangleBuffer(uint8_t (*buffer)[128], int16_t x1, int16_t y1, int16_t x2, int16_t y2, bool black) { + UI_DrawLineBuffer(buffer, x1, y1, x1, y2, black); + UI_DrawLineBuffer(buffer, x1, y1, x2, y1, black); + UI_DrawLineBuffer(buffer, x2, y1, x2, y2, black); + UI_DrawLineBuffer(buffer, x1, y2, x2, y2, black); } -void UI_DisplayPopup(const char *string) -{ +void UI_DisplayPopup(const char *string) { UI_DisplayClear(); // for(uint8_t i = 1; i < 5; i++) { @@ -346,7 +356,6 @@ void UI_DisplayPopup(const char *string) UI_PrintStringSmallNormal("Press EXIT", 9, 118, 6); } -void UI_DisplayClear() -{ +void UI_DisplayClear() { memset(gFrameBuffer, 0, sizeof(gFrameBuffer)); } diff --git a/ui/helper.h b/ui/helper.h index 2dea9ea..24682f5 100644 --- a/ui/helper.h +++ b/ui/helper.h @@ -27,7 +27,7 @@ void UI_PrintStringSmallNormal(const char *pString, uint8_t Start, uint8_t End, void UI_PrintStringSmallBold(const char *pString, uint8_t Start, uint8_t End, uint8_t Line); void UI_PrintStringSmallBufferNormal(const char *pString, uint8_t *buffer); void UI_PrintStringSmallBufferBold(const char *pString, uint8_t * buffer); -void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center); +//void UI_DisplayFrequency(const char *string, uint8_t X, uint8_t Y, bool center); void UI_DisplayPopup(const char *string); diff --git a/ui/main.c b/ui/main.c index 26496b5..ff3e26c 100644 --- a/ui/main.c +++ b/ui/main.c @@ -19,9 +19,13 @@ #include "app/chFrScanner.h" #include "app/dtmf.h" + #ifdef ENABLE_AM_FIX - #include "am_fix.h" + +#include "am_fix.h" + #endif + #include "bitmaps.h" #include "board.h" #include "driver/bk4819.h" @@ -39,64 +43,65 @@ #include "audio.h" #ifdef ENABLE_FEAT_F4HWN - #include "driver/system.h" + +#include "driver/system.h" + #endif center_line_t center_line = CENTER_LINE_NONE; #ifdef ENABLE_FEAT_F4HWN - static int8_t RxBlink; - static int8_t RxBlinkLed = 0; - static int8_t RxBlinkLedCounter; - static int8_t RxLine; - static uint32_t RxOnVfofrequency; +static int8_t RxBlink; +static int8_t RxBlinkLed = 0; +static int8_t RxBlinkLedCounter; +static int8_t RxLine; +static uint32_t RxOnVfofrequency; - bool isMainOnlyInputDTMF = false; +bool isMainOnlyInputDTMF = false; + +static bool isMainOnly() { + return (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF) && (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF); +} - static bool isMainOnly() - { - return (gEeprom.DUAL_WATCH == DUAL_WATCH_OFF) && (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF); - } #endif const int8_t dBmCorrTable[7] = { - -15, // band 1 - -25, // band 2 - -20, // band 3 - -4, // band 4 - -7, // band 5 - -6, // band 6 - -1 // band 7 - }; + -15, // band 1 + -25, // band 2 + -20, // band 3 + -4, // band 4 + -7, // band 5 + -6, // band 6 + -1 // band 7 +}; const char *VfoStateStr[] = { - [VFO_STATE_NORMAL]="", - [VFO_STATE_BUSY]="BUSY", - [VFO_STATE_BAT_LOW]="BAT LOW", - [VFO_STATE_TX_DISABLE]="TX DISABLE", - [VFO_STATE_TIMEOUT]="TIMEOUT", - [VFO_STATE_ALARM]="ALARM", - [VFO_STATE_VOLTAGE_HIGH]="VOLT HIGH" + [VFO_STATE_NORMAL]="", + [VFO_STATE_BUSY]="BUSY", + [VFO_STATE_BAT_LOW]="BAT LOW", + [VFO_STATE_TX_DISABLE]="TX DISABLE", + [VFO_STATE_TIMEOUT]="TIMEOUT", + [VFO_STATE_ALARM]="ALARM", + [VFO_STATE_VOLTAGE_HIGH]="VOLT HIGH" }; // *************************************************************************** -static void DrawSmallAntennaAndBars(uint8_t *p, unsigned int level) -{ - if(level>6) +static void DrawSmallAntennaAndBars(uint8_t *p, unsigned int level) { + if (level > 6) level = 6; memcpy(p, BITMAP_Antenna, ARRAY_SIZE(BITMAP_Antenna)); - for(uint8_t i = 1; i <= level; i++) { - char bar = (0xff << (6-i)) & 0x7F; - memset(p + 2 + i*3, bar, 2); + for (uint8_t i = 1; i <= level; i++) { + char bar = (0xff << (6 - i)) & 0x7F; + memset(p + 2 + i * 3, bar, 2); } } + #if defined ENABLE_AUDIO_BAR || defined ENABLE_RSSI_BAR -static void DrawLevelBar(uint8_t xpos, uint8_t line, uint8_t level, uint8_t bars) -{ +static void DrawLevelBar(uint8_t xpos, uint8_t line, uint8_t level, uint8_t bars) { #ifndef ENABLE_FEAT_F4HWN const char hollowBar[] = { 0b01111111, @@ -105,49 +110,44 @@ static void DrawLevelBar(uint8_t xpos, uint8_t line, uint8_t level, uint8_t bars 0b01111111 }; #endif - + uint8_t *p_line = gFrameBuffer[line]; level = MIN(level, bars); - for(uint8_t i = 0; i < level; i++) { + for (uint8_t i = 0; i < level; i++) { #ifdef ENABLE_FEAT_F4HWN - if(gSetting_set_met) - { + if (gSetting_set_met) { const char hollowBar[] = { - 0b01111111, - 0b01000001, - 0b01000001, - 0b01111111 + 0b01111111, + 0b01000001, + 0b01000001, + 0b01111111 }; - if(i < bars - 4) { - for(uint8_t j = 0; j < 4; j++) + if (i < bars - 4) { + for (uint8_t j = 0; j < 4; j++) p_line[xpos + i * 5 + j] = (~(0x7F >> (i + 1))) & 0x7F; - } - else { + } else { memcpy(p_line + (xpos + i * 5), &hollowBar, ARRAY_SIZE(hollowBar)); } - } - else - { + } else { const char hollowBar[] = { - 0b00111110, - 0b00100010, - 0b00100010, - 0b00111110 + 0b00111110, + 0b00100010, + 0b00100010, + 0b00111110 }; const char simpleBar[] = { - 0b00111110, - 0b00111110, - 0b00111110, - 0b00111110 + 0b00111110, + 0b00111110, + 0b00111110, + 0b00111110 }; - if(i < bars - 4) { + if (i < bars - 4) { memcpy(p_line + (xpos + i * 5), &simpleBar, ARRAY_SIZE(simpleBar)); - } - else { + } else { memcpy(p_line + (xpos + i * 5), &hollowBar, ARRAY_SIZE(hollowBar)); } } @@ -162,6 +162,7 @@ static void DrawLevelBar(uint8_t xpos, uint8_t line, uint8_t level, uint8_t bars #endif } } + #endif #ifdef ENABLE_AUDIO_BAR @@ -175,11 +176,9 @@ uint8_t log2_approx(unsigned int value) { return log; } -void UI_DisplayAudioBar(void) -{ - if (gSetting_mic_bar) - { - if(gLowBattery && !gLowBatteryConfirmed) +void UI_DisplayAudioBar(void) { + if (gSetting_mic_bar) { + if (gLowBattery && !gLowBatteryConfirmed) return; #ifdef ENABLE_FEAT_F4HWN @@ -187,12 +186,9 @@ void UI_DisplayAudioBar(void) RxBlinkLedCounter = 0; BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2_GREEN, false); unsigned int line; - if (isMainOnly()) - { + if (isMainOnly()) { line = 5; - } - else - { + } else { line = 3; } #else @@ -201,11 +197,10 @@ void UI_DisplayAudioBar(void) if (gCurrentFunction != FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN -#ifdef ENABLE_DTMF_CALLING + #ifdef ENABLE_DTMF_CALLING || gDTMF_CallState != DTMF_CALL_STATE_NONE #endif - ) - { + ) { return; // screen is in use } @@ -220,7 +215,7 @@ void UI_DisplayAudioBar(void) uint8_t logLevel; uint8_t bars; - unsigned int voiceLevel = BK4819_GetVoiceAmplitudeOut(); // 15:0 + unsigned int voiceLevel = BK4819_GetVoiceAmplitudeOut(); // 15:0 voiceLevel = (voiceLevel >= thresold) ? (voiceLevel - thresold) : 0; logLevel = log2_approx(MIN(voiceLevel * 16, 32768u) + 1); @@ -236,14 +231,14 @@ void UI_DisplayAudioBar(void) ST7565_BlitFullScreen(); } } + #endif -void DisplayRSSIBar(const bool now) -{ +void DisplayRSSIBar(const bool now) { #if defined(ENABLE_RSSI_BAR) - const unsigned int txt_width = 7 * 8; // 8 text chars - const unsigned int bar_x = 2 + txt_width + 4; // X coord of bar graph + const unsigned int txt_width = 7 * 8; // 8 text chars + const unsigned int bar_x = 2 + txt_width + 4; // X coord of bar graph #ifdef ENABLE_FEAT_F4HWN /* @@ -259,12 +254,9 @@ void DisplayRSSIBar(const bool now) */ unsigned int line; - if (isMainOnly()) - { + if (isMainOnly()) { line = 5; - } - else - { + } else { line = 3; } @@ -272,14 +264,12 @@ void DisplayRSSIBar(const bool now) //sprintf(String, "%d", RxBlink); //UI_PrintStringSmallBold(String, 80, 0, RxLine); - if(RxLine >= 0 && center_line != CENTER_LINE_IN_USE) - { + if (RxLine >= 0 && center_line != CENTER_LINE_IN_USE) { if (RxBlink == 0 || RxBlink == 1) { UI_PrintStringSmallBold("RX", 8, 0, RxLine); if (RxBlink == 1) RxBlink = 2; } else { - for (uint8_t i = 8; i < 24; i++) - { + for (uint8_t i = 8; i < 24; i++) { gFrameBuffer[RxLine][i] = 0x00; } RxBlink = 1; @@ -289,8 +279,8 @@ void DisplayRSSIBar(const bool now) #else const unsigned int line = 3; #endif - uint8_t *p_line = gFrameBuffer[line]; - char str[16]; + uint8_t *p_line = gFrameBuffer[line]; + char str[16]; #ifndef ENABLE_FEAT_F4HWN const char plus[] = { @@ -309,10 +299,10 @@ void DisplayRSSIBar(const bool now) if (gCurrentFunction == FUNCTION_TRANSMIT || gScreenToDisplay != DISPLAY_MAIN -#ifdef ENABLE_DTMF_CALLING + #ifdef ENABLE_DTMF_CALLING || gDTMF_CallState != DTMF_CALL_STATE_NONE #endif - ) + ) return; // display is in use if (now) @@ -320,25 +310,24 @@ void DisplayRSSIBar(const bool now) #ifdef ENABLE_FEAT_F4HWN int16_t rssi_dBm = - BK4819_GetRSSI_dBm() -#ifdef ENABLE_AM_FIX - + ((gSetting_AM_fix && gRxVfo->Modulation == MODULATION_AM) ? AM_fix_get_gain_diff() : 0) -#endif - + dBmCorrTable[gRxVfo->Band]; + BK4819_GetRSSI_dBm() + #ifdef ENABLE_AM_FIX + + ((gSetting_AM_fix && gRxVfo->Modulation == MODULATION_AM) ? AM_fix_get_gain_diff() : 0) + #endif + + dBmCorrTable[gRxVfo->Band]; rssi_dBm = -rssi_dBm; - if(rssi_dBm > 141) rssi_dBm = 141; - if(rssi_dBm < 53) rssi_dBm = 53; + if (rssi_dBm > 141) rssi_dBm = 141; + if (rssi_dBm < 53) rssi_dBm = 53; uint8_t s_level = 0; uint8_t overS9dBm = 0; uint8_t overS9Bars = 0; - if(rssi_dBm >= 93) { + if (rssi_dBm >= 93) { s_level = map(rssi_dBm, 141, 93, 1, 9); - } - else { + } else { s_level = 9; overS9dBm = map(rssi_dBm, 93, 53, 0, 40); overS9Bars = map(overS9dBm, 0, 40, 0, 4); @@ -359,24 +348,20 @@ void DisplayRSSIBar(const bool now) #endif #ifdef ENABLE_FEAT_F4HWN - if (gSetting_set_gui) - { + if (gSetting_set_gui) { sprintf(str, "%3d", -rssi_dBm); UI_PrintStringSmallNormal(str, LCD_WIDTH + 8, 0, line - 1); - } - else - { + } else { sprintf(str, "% 4d %s", -rssi_dBm, "dBm"); - if(isMainOnly()) + if (isMainOnly()) GUI_DisplaySmallest(str, 2, 41, false, true); else GUI_DisplaySmallest(str, 2, 25, false, true); } - if(overS9Bars == 0) { + if (overS9Bars == 0) { sprintf(str, "S%d", s_level); - } - else { + } else { sprintf(str, "+%02d", overS9dBm); } @@ -460,62 +445,50 @@ void UI_MAIN_PrintAGC(bool now) } #endif -void UI_MAIN_TimeSlice500ms(void) -{ - if(gScreenToDisplay==DISPLAY_MAIN) { +void UI_MAIN_TimeSlice500ms(void) { + if (gScreenToDisplay == DISPLAY_MAIN) { #ifdef ENABLE_AGC_SHOW_DATA UI_MAIN_PrintAGC(true); return; #endif - if(FUNCTION_IsRx()) { + if (FUNCTION_IsRx()) { DisplayRSSIBar(true); } #ifdef ENABLE_FEAT_F4HWN // Blink Green Led for white... - else if(gSetting_set_eot > 0 && RxBlinkLed == 2) - { - if(RxBlinkLedCounter <= 8) - { - if(RxBlinkLedCounter % 2 == 0) - { - if(gSetting_set_eot > 1 ) - { + else if (gSetting_set_eot > 0 && RxBlinkLed == 2) { + if (RxBlinkLedCounter <= 8) { + if (RxBlinkLedCounter % 2 == 0) { + if (gSetting_set_eot > 1) { BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2_GREEN, false); } - } - else - { - if(gSetting_set_eot > 1 ) - { + } else { + if (gSetting_set_eot > 1) { BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2_GREEN, true); } - if(gSetting_set_eot == 1 || gSetting_set_eot == 3) - { - switch(RxBlinkLedCounter) - { + if (gSetting_set_eot == 1 || gSetting_set_eot == 3) { + switch (RxBlinkLedCounter) { case 1: - AUDIO_PlayBeep(BEEP_400HZ_30MS); - break; + AUDIO_PlayBeep(BEEP_400HZ_30MS); + break; case 3: - AUDIO_PlayBeep(BEEP_400HZ_30MS); - break; + AUDIO_PlayBeep(BEEP_400HZ_30MS); + break; case 5: - AUDIO_PlayBeep(BEEP_500HZ_30MS); - break; + AUDIO_PlayBeep(BEEP_500HZ_30MS); + break; case 7: - AUDIO_PlayBeep(BEEP_600HZ_30MS); - break; + AUDIO_PlayBeep(BEEP_600HZ_30MS); + break; } } } RxBlinkLedCounter += 1; - } - else - { + } else { RxBlinkLed = 0; } } @@ -525,16 +498,15 @@ void UI_MAIN_TimeSlice500ms(void) // *************************************************************************** -void UI_DisplayMain(void) -{ - char String[22]; +void UI_DisplayMain(void) { + char String[22]; center_line = CENTER_LINE_NONE; // clear the screen UI_DisplayClear(); - if(gLowBattery && !gLowBatteryConfirmed) { + if (gLowBattery && !gLowBatteryConfirmed) { UI_DisplayPopup("LOW BATTERY"); ST7565_BlitFullScreen(); return; @@ -549,8 +521,7 @@ void UI_DisplayMain(void) return; } #else - if (gEeprom.KEY_LOCK && gKeypadLocked > 0) - { // tell user how to unlock the keyboard + if (gEeprom.KEY_LOCK && gKeypadLocked > 0) { // tell user how to unlock the keyboard uint8_t shift = 3; /* @@ -560,8 +531,7 @@ void UI_DisplayMain(void) SYSTEM_DelayMs(50); */ - if(isMainOnly()) - { + if (isMainOnly()) { shift = 5; } //memcpy(gFrameBuffer[shift] + 2, gFontKeyLock, sizeof(gFontKeyLock)); @@ -579,24 +549,20 @@ void UI_DisplayMain(void) unsigned int activeTxVFO = gRxVfoIsActive ? gEeprom.RX_VFO : gEeprom.TX_VFO; - for (unsigned int vfo_num = 0; vfo_num < 2; vfo_num++) - { + for (unsigned int vfo_num = 0; vfo_num < 2; vfo_num++) { #ifdef ENABLE_FEAT_F4HWN const unsigned int line0 = 0; // text screen line const unsigned int line1 = 4; unsigned int line; - if (isMainOnly()) - { - line = 0; + if (isMainOnly()) { + line = 0; + } else { + line = (vfo_num == 0) ? line0 : line1; } - else - { - line = (vfo_num == 0) ? line0 : line1; - } - const bool isMainVFO = (vfo_num == gEeprom.TX_VFO); - uint8_t *p_line0 = gFrameBuffer[line + 0]; - uint8_t *p_line1 = gFrameBuffer[line + 1]; - enum Vfo_txtr_mode mode = VFO_MODE_NONE; + const bool isMainVFO = (vfo_num == gEeprom.TX_VFO); + uint8_t *p_line0 = gFrameBuffer[line + 0]; + uint8_t *p_line1 = gFrameBuffer[line + 1]; + enum Vfo_txtr_mode mode = VFO_MODE_NONE; #else const unsigned int line0 = 0; // text screen line const unsigned int line1 = 4; @@ -608,32 +574,29 @@ void UI_DisplayMain(void) #endif #ifdef ENABLE_FEAT_F4HWN - if (isMainOnly()) - { - if (activeTxVFO != vfo_num) - { - continue; + if (isMainOnly()) { + if (activeTxVFO != vfo_num) { + continue; + } } - } #endif #ifdef ENABLE_FEAT_F4HWN if (activeTxVFO != vfo_num || isMainOnly()) #else - if (activeTxVFO != vfo_num) // this is not active TX VFO + if (activeTxVFO != vfo_num) // this is not active TX VFO #endif { #ifdef ENABLE_SCAN_RANGES - if(gScanRangeStart) { + if (gScanRangeStart) { #ifdef ENABLE_FEAT_F4HWN //if(IS_FREQ_CHANNEL(gEeprom.ScreenChannel[0]) && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[1])) { - if(IS_FREQ_CHANNEL(gEeprom.ScreenChannel[activeTxVFO])) { + if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[activeTxVFO])) { uint8_t shift = 0; - if (isMainOnly()) - { + if (isMainOnly()) { shift = 3; } @@ -645,9 +608,7 @@ void UI_DisplayMain(void) if (!isMainOnly()) continue; - } - else - { + } else { gScanRangeStart = 0; } #else @@ -662,11 +623,25 @@ void UI_DisplayMain(void) #endif + if (gEnteringSMS == SMS_ENTERING_DEST) { + UI_PrintString("SMS Dst", 0, 0, line - 1, 8); + sprintf(String, "%d", dataPacket.dest); + UI_PrintStringSmallNormal(String, 0, 0, line); + continue; + } + + if (gEnteringSMS == SMS_ENTERING_MESSAGE) { + UI_PrintString("SMS Dat", 0, 0, line - 1, 8); + sprintf(String, "%s", dataPacket.data); + UI_PrintStringSmallNormal(String, 0, 0, line); + continue; + } + if (gDTMF_InputMode -#ifdef ENABLE_DTMF_CALLING + #ifdef ENABLE_DTMF_CALLING || gDTMF_CallState != DTMF_CALL_STATE_NONE || gDTMF_IsTx #endif - ) { + ) { char *pPrintStr = ""; // show DTMF stuff #ifdef ENABLE_DTMF_CALLING @@ -674,9 +649,10 @@ void UI_DisplayMain(void) if (!gDTMF_InputMode) { if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT) { pPrintStr = DTMF_FindContact(gDTMF_String, Contact) ? Contact : gDTMF_String; - } else if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY){ + } else if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED || + gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY) { pPrintStr = DTMF_FindContact(gDTMF_Callee, Contact) ? Contact : gDTMF_Callee; - }else if (gDTMF_IsTx) { + } else if (gDTMF_IsTx) { pPrintStr = gDTMF_String; } } @@ -687,14 +663,15 @@ void UI_DisplayMain(void) if (!gDTMF_InputMode) { if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT) { pPrintStr = (gDTMF_State == DTMF_STATE_CALL_OUT_RSP) ? "CALL OUT(RSP)" : "CALL OUT"; - } else if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED || gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY) { - sprintf(String, "CALL FRM:%s", (DTMF_FindContact(gDTMF_Caller, Contact)) ? Contact : gDTMF_Caller); + } else if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED || + gDTMF_CallState == DTMF_CALL_STATE_RECEIVED_STAY) { + sprintf(String, "CALL FRM:%s", + (DTMF_FindContact(gDTMF_Caller, Contact)) ? Contact : gDTMF_Caller); pPrintStr = String; } else if (gDTMF_IsTx) { pPrintStr = (gDTMF_State == DTMF_STATE_TX_SUCC) ? "DTMF TX(SUCC)" : "DTMF TX"; } - } - else + } else #endif { sprintf(String, ">%s", gDTMF_InputBox); @@ -702,14 +679,11 @@ void UI_DisplayMain(void) } #ifdef ENABLE_FEAT_F4HWN - if (isMainOnly()) - { + if (isMainOnly()) { UI_PrintString(pPrintStr, 2, 0, 5, 8); isMainOnlyInputDTMF = true; center_line = CENTER_LINE_IN_USE; - } - else - { + } else { UI_PrintString(pPrintStr, 2, 0, 0 + (vfo_num * 3), 8); isMainOnlyInputDTMF = false; center_line = CENTER_LINE_IN_USE; @@ -725,8 +699,7 @@ void UI_DisplayMain(void) // highlight the selected/used VFO with a marker if (isMainVFO) memcpy(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); - } - else // active TX VFO + } else // active TX VFO { // highlight the selected/used VFO with a marker if (isMainVFO) memcpy(p_line0 + 0, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); @@ -736,16 +709,14 @@ void UI_DisplayMain(void) uint32_t frequency = gEeprom.VfoInfo[vfo_num].pRX->Frequency; - if(TX_freq_check(frequency) != 0 && gEeprom.VfoInfo[vfo_num].TX_LOCK == true) - { - if(isMainOnly()) + if (TX_freq_check(frequency) != 0 && gEeprom.VfoInfo[vfo_num].TX_LOCK == true) { + if (isMainOnly()) memcpy(p_line0 + 14, BITMAP_VFO_Lock, sizeof(BITMAP_VFO_Lock)); else memcpy(p_line0 + 24, BITMAP_VFO_Lock, sizeof(BITMAP_VFO_Lock)); } - if (gCurrentFunction == FUNCTION_TRANSMIT) - { // transmitting + if (gCurrentFunction == FUNCTION_TRANSMIT) { // transmitting #ifdef ENABLE_ALARM if (gAlarmState == ALARM_STATE_SITE_ALARM) @@ -753,15 +724,12 @@ void UI_DisplayMain(void) else #endif { - if (activeTxVFO == vfo_num) - { // show the TX symbol + if (activeTxVFO == vfo_num) { // show the TX symbol mode = VFO_MODE_TX; UI_PrintStringSmallBold("TX", 8, 0, line); } } - } - else - { // receiving .. show the RX symbol + } else { // receiving .. show the RX symbol mode = VFO_MODE_RX; //if (FUNCTION_IsRx() && gEeprom.RX_VFO == vfo_num) { if (FUNCTION_IsRx() && gEeprom.RX_VFO == vfo_num && VfoState[vfo_num] == VFO_STATE_NORMAL) { @@ -770,12 +738,9 @@ void UI_DisplayMain(void) RxBlinkLedCounter = 0; RxLine = line; RxOnVfofrequency = frequency; - if(!isMainVFO) - { + if (!isMainVFO) { RxBlink = 1; - } - else - { + } else { RxBlink = 0; } #else @@ -783,22 +748,19 @@ void UI_DisplayMain(void) #endif } #ifdef ENABLE_FEAT_F4HWN - else - { - if(RxOnVfofrequency == frequency && !isMainOnly()) - { + else { + if (RxOnVfofrequency == frequency && !isMainOnly()) { UI_PrintStringSmallNormal(">>", 8, 0, line); //memcpy(p_line0 + 14, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); } - if(RxBlinkLed == 1) + if (RxBlinkLed == 1) RxBlinkLed = 2; } #endif } - if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num])) - { // channel mode + if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num])) { // channel mode const unsigned int x = 2; const bool inputting = gInputBoxIndex != 0 && gEeprom.TX_VFO == vfo_num; if (!inputting) @@ -806,12 +768,10 @@ void UI_DisplayMain(void) else sprintf(String, "M%.3s", INPUTBOX_GetAscii()); // show the input text UI_PrintStringSmallNormal(String, x, 0, line + 1); - } - else if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num])) - { // frequency mode + } else if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num])) { // frequency mode // show the frequency band number const unsigned int x = 2; - char * buf = gEeprom.VfoInfo[vfo_num].pRX->Frequency < _1GHz_in_KHz ? "" : "+"; + char *buf = gEeprom.VfoInfo[vfo_num].pRX->Frequency < _1GHz_in_KHz ? "" : "+"; sprintf(String, "F%u%s", 1 + gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST, buf); UI_PrintStringSmallNormal(String, x, 0, line + 1); } @@ -840,25 +800,22 @@ void UI_DisplayMain(void) state = VFO_STATE_ALARM; } #endif - if (state != VFO_STATE_NORMAL) - { + if (state != VFO_STATE_NORMAL) { if (state < ARRAY_SIZE(VfoStateStr)) UI_PrintString(VfoStateStr[state], 31, 0, line, 8); - } - else if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_VFO == vfo_num) - { // user entering a frequency - const char * ascii = INPUTBOX_GetAscii(); - bool isGigaF = frequency>=_1GHz_in_KHz; + } else if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && + gEeprom.TX_VFO == vfo_num) { // user entering a frequency + const char *ascii = INPUTBOX_GetAscii(); + bool isGigaF = frequency >= _1GHz_in_KHz; sprintf(String, "%.*s.%.3s", 3 + isGigaF, ascii, ascii + 3 + isGigaF); #ifdef ENABLE_BIG_FREQ - if(!isGigaF) { + if (!isGigaF) { // show the remaining 2 small frequency digits UI_PrintStringSmallNormal(String + 7, 113, 0, line + 1); String[7] = 0; // show the main large frequency digits UI_DisplayFrequency(String, 32, line, false); - } - else + } else #endif { // show the frequency in the main font @@ -866,87 +823,73 @@ void UI_DisplayMain(void) } continue; - } - else - { - if (gCurrentFunction == FUNCTION_TRANSMIT) - { // transmitting + } else { + if (gCurrentFunction == FUNCTION_TRANSMIT) { // transmitting if (activeTxVFO == vfo_num) frequency = gEeprom.VfoInfo[vfo_num].pTX->Frequency; } - if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num])) - { // it's a channel + if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num])) { // it's a channel - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS - if(gEeprom.MENU_LOCK == false) { - #endif +#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS + if(gEeprom.MENU_LOCK == false) { +#endif uint8_t countList = 0; uint8_t shiftList = 0; - if(gMR_ChannelExclude[gEeprom.ScreenChannel[vfo_num]] == false) - { + if (gMR_ChannelExclude[gEeprom.ScreenChannel[vfo_num]] == false) { // show the scan list assigment symbols const ChannelAttributes_t att = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; countList = att.scanlist1 + att.scanlist2 + att.scanlist3; - if(countList == 0) - { + if (countList == 0) { memcpy(p_line0 + 127 - (1 * 6), BITMAP_ScanList0, sizeof(BITMAP_ScanList0)); - } - else - { + } else { shiftList = countList; - if (att.scanlist1) - { + if (att.scanlist1) { memcpy(p_line0 + 127 - (shiftList * 6), BITMAP_ScanList1, sizeof(BITMAP_ScanList1)); shiftList--; } - if (att.scanlist2) - { + if (att.scanlist2) { memcpy(p_line0 + 127 - (shiftList * 6), BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); shiftList--; } - if (att.scanlist3) - { + if (att.scanlist3) { memcpy(p_line0 + 127 - (shiftList * 6), BITMAP_ScanList3, sizeof(BITMAP_ScanList3)); } } - } - else - { + } else { memcpy(p_line0 + 127 - (1 * 6), BITMAP_ScanListE, sizeof(BITMAP_ScanListE)); } - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS +#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS { } } - #endif +#endif // compander symbol #ifndef ENABLE_BIG_FREQ + const ChannelAttributes_t att = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; if (att.compander) memcpy(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); #else // TODO: // find somewhere else to put the symbol #endif - switch (gEeprom.CHANNEL_DISPLAY_MODE) - { + switch (gEeprom.CHANNEL_DISPLAY_MODE) { case MDF_FREQUENCY: // show the channel frequency sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000); #ifdef ENABLE_BIG_FREQ - if(frequency < _1GHz_in_KHz) { + if (frequency < _1GHz_in_KHz) { // show the remaining 2 small frequency digits UI_PrintStringSmallNormal(String + 7, 113, 0, line + 1); String[7] = 0; // show the main large frequency digits UI_DisplayFrequency(String, 32, line, false); - } - else + } else #endif { // show the frequency in the main font @@ -964,28 +907,21 @@ void UI_DisplayMain(void) case MDF_NAME_FREQ: // show the channel name and frequency SETTINGS_FetchChannelName(String, gEeprom.ScreenChannel[vfo_num]); - if (String[0] == 0) - { // no channel name, show the channel number instead + if (String[0] == 0) { // no channel name, show the channel number instead sprintf(String, "CH-%03u", gEeprom.ScreenChannel[vfo_num] + 1); } if (gEeprom.CHANNEL_DISPLAY_MODE == MDF_NAME) { UI_PrintString(String, 32, 0, line, 8); - } - else { + } else { #ifdef ENABLE_FEAT_F4HWN - if (isMainOnly()) - { + if (isMainOnly()) { UI_PrintString(String, 32, 0, line, 8); - } - else - { - if(activeTxVFO == vfo_num) { + } else { + if (activeTxVFO == vfo_num) { UI_PrintStringSmallBold(String, 32 + 4, 0, line); - } - else - { - UI_PrintStringSmallNormal(String, 32 + 4, 0, line); + } else { + UI_PrintStringSmallNormal(String, 32 + 4, 0, line); } } #else @@ -993,24 +929,20 @@ void UI_DisplayMain(void) #endif #ifdef ENABLE_FEAT_F4HWN - if (isMainOnly()) - { + if (isMainOnly()) { sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000); - if(frequency < _1GHz_in_KHz) { + if (frequency < _1GHz_in_KHz) { // show the remaining 2 small frequency digits UI_PrintStringSmallNormal(String + 7, 113, 0, line + 4); String[7] = 0; // show the main large frequency digits - UI_DisplayFrequency(String, 32, line + 3, false); - } - else - { + //UI_DisplayFrequency(String, 32, line + 3, false); + UI_PrintStringSmallNormal(String, 0, 20, line + 3); + } else { // show the frequency in the main font UI_PrintString(String, 32, 0, line + 3, 8); } - } - else - { + } else { sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000); UI_PrintStringSmallNormal(String, 32 + 4, 0, line + 1); } @@ -1022,20 +954,17 @@ void UI_DisplayMain(void) break; } - } - else - { // frequency mode + } else { // frequency mode sprintf(String, "%3u.%05u", frequency / 100000, frequency % 100000); #ifdef ENABLE_BIG_FREQ - if(frequency < _1GHz_in_KHz) { + if (frequency < _1GHz_in_KHz) { // show the remaining 2 small frequency digits UI_PrintStringSmallNormal(String + 7, 113, 0, line + 1); String[7] = 0; // show the main large frequency digits UI_DisplayFrequency(String, 32, line, false); - } - else + } else #endif { // show the frequency in the main font @@ -1048,7 +977,7 @@ void UI_DisplayMain(void) #ifdef ENABLE_BIG_FREQ memcpy(p_line0 + 120, BITMAP_compand, sizeof(BITMAP_compand)); #else - memcpy(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); + memcpy(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); #endif } } @@ -1058,8 +987,7 @@ void UI_DisplayMain(void) { // show the TX/RX level int8_t Level = -1; - if (mode == VFO_MODE_TX) - { // TX power level + if (mode == VFO_MODE_TX) { // TX power level /* switch (gRxVfo->OUTPUT_POWER) { @@ -1081,17 +1009,14 @@ void UI_DisplayMain(void) } */ Level = gRxVfo->OUTPUT_POWER - 1; + } else if (mode == VFO_MODE_RX) { // RX signal level +#ifndef ENABLE_RSSI_BAR + // bar graph + if (gVFO_RSSI_bar_level[vfo_num] > 0) + Level = gVFO_RSSI_bar_level[vfo_num]; +#endif } - else - if (mode == VFO_MODE_RX) - { // RX signal level - #ifndef ENABLE_RSSI_BAR - // bar graph - if (gVFO_RSSI_bar_level[vfo_num] > 0) - Level = gVFO_RSSI_bar_level[vfo_num]; - #endif - } - if(Level >= 0) + if (Level >= 0) DrawSmallAntennaAndBars(p_line1 + LCD_WIDTH, Level); } @@ -1101,12 +1026,12 @@ void UI_DisplayMain(void) const VFO_Info_t *vfoInfo = &gEeprom.VfoInfo[vfo_num]; // show the modulation symbol - const char * s = ""; + const char *s = ""; #ifdef ENABLE_FEAT_F4HWN - const char * t = ""; + const char *t = ""; #endif const ModulationMode_t mod = vfoInfo->Modulation; - switch (mod){ + switch (mod) { case MODULATION_FM: { const FREQ_Config_t *pConfig = (mode == VFO_MODE_TX) ? vfoInfo->pTX : vfoInfo->pRX; const unsigned int code_type = pConfig->CodeType; @@ -1118,64 +1043,55 @@ void UI_DisplayMain(void) if (code_type < ARRAY_SIZE(code_list)) s = code_list[code_type]; #ifdef ENABLE_FEAT_F4HWN - if(gCurrentFunction != FUNCTION_TRANSMIT || activeTxVFO != vfo_num) + if (gCurrentFunction != FUNCTION_TRANSMIT || activeTxVFO != vfo_num) t = gModulationStr[mod]; #endif break; } default: t = gModulationStr[mod]; - break; + break; } #if ENABLE_FEAT_F4HWN const FREQ_Config_t *pConfig = (mode == VFO_MODE_TX) ? vfoInfo->pTX : vfoInfo->pRX; int8_t shift = 0; - switch((int)pConfig->CodeType) - { + switch ((int) pConfig->CodeType) { case 1: - sprintf(String, "%u.%u", CTCSS_Options[pConfig->Code] / 10, CTCSS_Options[pConfig->Code] % 10); - break; + sprintf(String, "%u.%u", CTCSS_Options[pConfig->Code] / 10, CTCSS_Options[pConfig->Code] % 10); + break; case 2: - sprintf(String, "%03oN", DCS_Options[pConfig->Code]); - break; + sprintf(String, "%03oN", DCS_Options[pConfig->Code]); + break; case 3: - sprintf(String, "%03oI", DCS_Options[pConfig->Code]); - break; + sprintf(String, "%03oI", DCS_Options[pConfig->Code]); + break; default: - sprintf(String, "%d.%02uK", vfoInfo->StepFrequency / 100, vfoInfo->StepFrequency % 100); - shift = -10; + sprintf(String, "%d.%02uK", vfoInfo->StepFrequency / 100, vfoInfo->StepFrequency % 100); + shift = -10; } - if (gSetting_set_gui) - { + if (gSetting_set_gui) { UI_PrintStringSmallNormal(s, LCD_WIDTH + 22, 0, line + 1); UI_PrintStringSmallNormal(t, LCD_WIDTH + 2, 0, line + 1); - if (isMainOnly() && !gDTMF_InputMode) - { - if(shift == 0) - { + if (isMainOnly() && !gDTMF_InputMode) { + if (shift == 0) { UI_PrintStringSmallNormal(String, 2, 0, 6); } - if((vfoInfo->StepFrequency / 100) < 100) - { + if ((vfoInfo->StepFrequency / 100) < 100) { sprintf(String, "%d.%02uK", vfoInfo->StepFrequency / 100, vfoInfo->StepFrequency % 100); - } - else - { - sprintf(String, "%dK", vfoInfo->StepFrequency / 100); + } else { + sprintf(String, "%dK", vfoInfo->StepFrequency / 100); } UI_PrintStringSmallNormal(String, 46, 0, 6); } - } - else - { + } else { if ((s != NULL) && (s[0] != '\0')) { GUI_DisplaySmallest(s, 58, line == 0 ? 17 : 49, false, true); } @@ -1193,81 +1109,69 @@ void UI_DisplayMain(void) UI_PrintStringSmallNormal(s, LCD_WIDTH + 24, 0, line + 1); #endif - if (state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM) - { // show the TX power + if (state == VFO_STATE_NORMAL || state == VFO_STATE_ALARM) { // show the TX power uint8_t currentPower = vfoInfo->OUTPUT_POWER % 8; uint8_t arrowPos = 19; bool userPower = false; - if(currentPower == OUTPUT_POWER_USER) - { + if (currentPower == OUTPUT_POWER_USER) { currentPower = gSetting_set_pwr; userPower = true; - } - else - { + } else { currentPower--; userPower = false; } - if (gSetting_set_gui) - { + if (gSetting_set_gui) { const char pwr_short[][3] = {"L1", "L2", "L3", "L4", "L5", "M", "H"}; //sprintf(String, "%s", pwr_short[currentPower]); //UI_PrintStringSmallNormal(String, LCD_WIDTH + 42, 0, line + 1); UI_PrintStringSmallNormal(pwr_short[currentPower], LCD_WIDTH + 42, 0, line + 1); arrowPos = 38; - } - else - { + } else { const char pwr_long[][5] = {"LOW1", "LOW2", "LOW3", "LOW4", "LOW5", "MID", "HIGH"}; //sprintf(String, "%s", pwr_long[currentPower]); //GUI_DisplaySmallest(String, 24, line == 0 ? 17 : 49, false, true); GUI_DisplaySmallest(pwr_long[currentPower], 24, line == 0 ? 17 : 49, false, true); } - if(userPower == true) - { + if (userPower == true) { memcpy(p_line0 + 256 + arrowPos, BITMAP_PowerUser, sizeof(BITMAP_PowerUser)); } } - if (vfoInfo->freq_config_RX.Frequency != vfoInfo->freq_config_TX.Frequency) - { // show the TX offset symbol + if (vfoInfo->freq_config_RX.Frequency != vfoInfo->freq_config_TX.Frequency) { // show the TX offset symbol int i = vfoInfo->TX_OFFSET_FREQUENCY_DIRECTION % 3; - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS - const char dir_list[][2] = {"", "+", "-", "D"}; +#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS + const char dir_list[][2] = {"", "+", "-", "D"}; - if(gTxVfo->TX_OFFSET_FREQUENCY_DIRECTION != 0 && gTxVfo->pTX == &gTxVfo->freq_config_RX && !vfoInfo->FrequencyReverse) - { - i = 3; - } - #else - const char dir_list[][2] = {"", "+", "-"}; - #endif + if(gTxVfo->TX_OFFSET_FREQUENCY_DIRECTION != 0 && gTxVfo->pTX == &gTxVfo->freq_config_RX && !vfoInfo->FrequencyReverse) + { + i = 3; + } +#else + const char dir_list[][2] = {"", "+", "-"}; +#endif #if ENABLE_FEAT_F4HWN - if (gSetting_set_gui) - { - UI_PrintStringSmallNormal(dir_list[i], LCD_WIDTH + 60, 0, line + 1); - } - else - { - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS - if(i == 3) - { - GUI_DisplaySmallest(dir_list[i], 43, line == 0 ? 17 : 49, false, true); + if (gSetting_set_gui) { + UI_PrintStringSmallNormal(dir_list[i], LCD_WIDTH + 60, 0, line + 1); + } else { +#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS + if(i == 3) + { + GUI_DisplaySmallest(dir_list[i], 43, line == 0 ? 17 : 49, false, true); + } + else + { +#endif + UI_PrintStringSmallNormal(dir_list[i], LCD_WIDTH + 41, 0, line + 1); +#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS + } +#endif } - else - { - #endif - UI_PrintStringSmallNormal(dir_list[i], LCD_WIDTH + 41, 0, line + 1); - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS - } - #endif - } #else UI_PrintStringSmallNormal(dir_list[i], LCD_WIDTH + 54, 0, line + 1); #endif @@ -1277,50 +1181,45 @@ void UI_DisplayMain(void) if (vfoInfo->FrequencyReverse) #if ENABLE_FEAT_F4HWN { - if (gSetting_set_gui) - { + if (gSetting_set_gui) { UI_PrintStringSmallNormal("R", LCD_WIDTH + 68, 0, line + 1); - } - else - { + } else { GUI_DisplaySmallest("R", 51, line == 0 ? 17 : 49, false, true); } } #else - UI_PrintStringSmallNormal("R", LCD_WIDTH + 62, 0, line + 1); + UI_PrintStringSmallNormal("R", LCD_WIDTH + 62, 0, line + 1); #endif #if ENABLE_FEAT_F4HWN - #ifdef ENABLE_FEAT_F4HWN_NARROWER - bool narrower = 0; +#ifdef ENABLE_FEAT_F4HWN_NARROWER + bool narrower = 0; - if(vfoInfo->CHANNEL_BANDWIDTH == BANDWIDTH_NARROW && gSetting_set_nfm == 1) - { - narrower = 1; - } + if (vfoInfo->CHANNEL_BANDWIDTH == BANDWIDTH_NARROW && gSetting_set_nfm == 1) { + narrower = 1; + } - if (gSetting_set_gui) - { - const char *bandWidthNames[] = {"W", "N", "N+"}; - UI_PrintStringSmallNormal(bandWidthNames[vfoInfo->CHANNEL_BANDWIDTH + narrower], LCD_WIDTH + 80, 0, line + 1); - } - else - { - const char *bandWidthNames[] = {"WIDE", "NAR", "NAR+"}; - GUI_DisplaySmallest(bandWidthNames[vfoInfo->CHANNEL_BANDWIDTH + narrower], 91, line == 0 ? 17 : 49, false, true); - } - #else - if (gSetting_set_gui) - { - const char *bandWidthNames[] = {"W", "N"}; - UI_PrintStringSmallNormal(bandWidthNames[vfoInfo->CHANNEL_BANDWIDTH], LCD_WIDTH + 80, 0, line + 1); - } - else - { - const char *bandWidthNames[] = {"WIDE", "NAR"}; - GUI_DisplaySmallest(bandWidthNames[vfoInfo->CHANNEL_BANDWIDTH], 91, line == 0 ? 17 : 49, false, true); - } - #endif + if (gSetting_set_gui) { + const char *bandWidthNames[] = {"W", "N", "N+"}; + UI_PrintStringSmallNormal(bandWidthNames[vfoInfo->CHANNEL_BANDWIDTH + narrower], LCD_WIDTH + 80, 0, + line + 1); + } else { + const char *bandWidthNames[] = {"WIDE", "NAR", "NAR+"}; + GUI_DisplaySmallest(bandWidthNames[vfoInfo->CHANNEL_BANDWIDTH + narrower], 91, line == 0 ? 17 : 49, false, + true); + } +#else + if (gSetting_set_gui) + { + const char *bandWidthNames[] = {"W", "N"}; + UI_PrintStringSmallNormal(bandWidthNames[vfoInfo->CHANNEL_BANDWIDTH], LCD_WIDTH + 80, 0, line + 1); + } + else + { + const char *bandWidthNames[] = {"WIDE", "NAR"}; + GUI_DisplaySmallest(bandWidthNames[vfoInfo->CHANNEL_BANDWIDTH], 91, line == 0 ? 17 : 49, false, true); + } +#endif #else if (vfoInfo->CHANNEL_BANDWIDTH == BANDWIDTH_NARROW) UI_PrintStringSmallNormal("N", LCD_WIDTH + 70, 0, line + 1); @@ -1328,15 +1227,13 @@ void UI_DisplayMain(void) #ifdef ENABLE_DTMF_CALLING // show the DTMF decoding symbol - if (vfoInfo->DTMF_DECODING_ENABLE || gSetting_KILLED) + if (vfoInfo->DTMF_DECODING_ENABLE) UI_PrintStringSmallNormal("DTMF", LCD_WIDTH + 78, 0, line + 1); #endif -#ifndef ENABLE_FEAT_F4HWN // show the audio scramble symbol - if (vfoInfo->SCRAMBLING_TYPE > 0 && gSetting_ScrambleEnable) - UI_PrintStringSmallNormal("SCR", LCD_WIDTH + 106, 0, line + 1); -#endif + if (vfoInfo->SCRAMBLING_TYPE > 0) + UI_PrintStringSmallNormal("S", LCD_WIDTH + 106, 0, line); #ifdef ENABLE_FEAT_F4HWN /* @@ -1366,17 +1263,17 @@ void UI_DisplayMain(void) } */ if (isMainVFO) { - if (gMonitor) { + if (gMonitor) { strcpy(String, "MONI"); - } else { + } else { sprintf(String, "SQL%d", gEeprom.SQUELCH_LEVEL); - } + } - if (gSetting_set_gui) { + if (gSetting_set_gui) { UI_PrintStringSmallNormal(String, LCD_WIDTH + 98, 0, line + 1); - } else { + } else { GUI_DisplaySmallest(String, 110, line == 0 ? 17 : 49, false, true); - } + } } #endif } @@ -1386,8 +1283,7 @@ void UI_DisplayMain(void) UI_MAIN_PrintAGC(false); #endif - if (center_line == CENTER_LINE_NONE) - { // we're free to use the middle line + if (center_line == CENTER_LINE_NONE) { // we're free to use the middle line const bool rx = FUNCTION_IsRx(); @@ -1395,82 +1291,75 @@ void UI_DisplayMain(void) if (gSetting_mic_bar && gCurrentFunction == FUNCTION_TRANSMIT) { center_line = CENTER_LINE_AUDIO_BAR; UI_DisplayAudioBar(); - } - else + } else #endif #if defined(ENABLE_AM_FIX) && defined(ENABLE_AM_FIX_SHOW_DATA) - if (rx && gEeprom.VfoInfo[gEeprom.RX_VFO].Modulation == MODULATION_AM && gSetting_AM_fix) - { - if (gScreenToDisplay != DISPLAY_MAIN + if (rx && gEeprom.VfoInfo[gEeprom.RX_VFO].Modulation == MODULATION_AM && gSetting_AM_fix) + { + if (gScreenToDisplay != DISPLAY_MAIN #ifdef ENABLE_DTMF_CALLING - || gDTMF_CallState != DTMF_CALL_STATE_NONE + || gDTMF_CallState != DTMF_CALL_STATE_NONE #endif - ) - return; + ) + return; - center_line = CENTER_LINE_AM_FIX_DATA; - AM_fix_print_data(gEeprom.RX_VFO, String); - UI_PrintStringSmallNormal(String, 2, 0, 3); - } - else + center_line = CENTER_LINE_AM_FIX_DATA; + AM_fix_print_data(gEeprom.RX_VFO, String); + UI_PrintStringSmallNormal(String, 2, 0, 3); + } + else #endif #ifdef ENABLE_RSSI_BAR if (rx) { center_line = CENTER_LINE_RSSI; DisplayRSSIBar(false); - } - else + } else #endif - if (rx || gCurrentFunction == FUNCTION_FOREGROUND || gCurrentFunction == FUNCTION_POWER_SAVE) - { - #if 1 - if (gSetting_live_DTMF_decoder && gDTMF_RX_live[0] != 0) - { // 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 + if (rx || gCurrentFunction == FUNCTION_FOREGROUND || gCurrentFunction == FUNCTION_POWER_SAVE) { +#if 1 + if (gSetting_live_DTMF_decoder && gDTMF_RX_live[0] != 0) { // 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 - if (gScreenToDisplay != DISPLAY_MAIN -#ifdef ENABLE_DTMF_CALLING - || gDTMF_CallState != DTMF_CALL_STATE_NONE + if (gScreenToDisplay != DISPLAY_MAIN + #ifdef ENABLE_DTMF_CALLING + || gDTMF_CallState != DTMF_CALL_STATE_NONE #endif ) - return; + return; - center_line = CENTER_LINE_DTMF_DEC; + center_line = CENTER_LINE_DTMF_DEC; - sprintf(String, "DTMF %s", gDTMF_RX_live + idx); + sprintf(String, "DTMF %s", gDTMF_RX_live + idx); #ifdef ENABLE_FEAT_F4HWN - if (isMainOnly()) - { - UI_PrintStringSmallNormal(String, 2, 0, 5); - } - else - { - UI_PrintStringSmallNormal(String, 2, 0, 3); - } -#else + if (isMainOnly()) { + UI_PrintStringSmallNormal(String, 2, 0, 5); + } else { UI_PrintStringSmallNormal(String, 2, 0, 3); + } +#else + UI_PrintStringSmallNormal(String, 2, 0, 3); #endif - } - #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 + } +#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 - if (gScreenToDisplay != DISPLAY_MAIN || - gDTMF_CallState != DTMF_CALL_STATE_NONE) - return; + if (gScreenToDisplay != DISPLAY_MAIN || + gDTMF_CallState != DTMF_CALL_STATE_NONE) + return; - center_line = CENTER_LINE_DTMF_DEC; + center_line = CENTER_LINE_DTMF_DEC; - sprintf(String, "DTMF %s", gDTMF_RX_live + idx); - UI_PrintStringSmallNormal(String, 2, 0, 3); - } - #endif + sprintf(String, "DTMF %s", gDTMF_RX_live + idx); + UI_PrintStringSmallNormal(String, 2, 0, 3); + } +#endif #ifdef ENABLE_SHOW_CHARGE_LEVEL else if (gChargingWithTypeC) @@ -1498,12 +1387,10 @@ void UI_DisplayMain(void) //if(gEeprom.MENU_LOCK == false) //{ //#endif - if (isMainOnly() && !gDTMF_InputMode) - { + if (isMainOnly() && !gDTMF_InputMode) { sprintf(String, "VFO %s", activeTxVFO ? "B" : "A"); UI_PrintStringSmallBold(String, 92, 0, 6); - for (uint8_t i = 92; i < 128; i++) - { + for (uint8_t i = 92; i < 128; i++) { gFrameBuffer[6][i] ^= 0x7F; } } diff --git a/ui/menu.c b/ui/menu.c index 0c5d079..e93d270 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -38,220 +38,214 @@ const t_menu_item MenuList[] = -{ + { // text, menu ID - {"Step", MENU_STEP }, - {"Power", MENU_TXP }, // was "TXP" - {"RxDCS", MENU_R_DCS }, // was "R_DCS" - {"RxCTCS", MENU_R_CTCS }, // was "R_CTCS" - {"TxDCS", MENU_T_DCS }, // was "T_DCS" - {"TxCTCS", MENU_T_CTCS }, // was "T_CTCS" - {"TxODir", MENU_SFT_D }, // was "SFT_D" - {"TxOffs", MENU_OFFSET }, // was "OFFSET" - {"W/N", MENU_W_N }, -#ifndef ENABLE_FEAT_F4HWN - {"Scramb", MENU_SCR }, // was "SCR" -#endif - {"BusyCL", MENU_BCL }, // was "BCL" - {"Compnd", MENU_COMPAND }, - {"Mode", MENU_AM }, // was "AM" + {"STP", MENU_STEP}, + {"PWR", MENU_TXP}, // was "TXP" + {"RDCS", MENU_R_DCS}, // was "R_DCS" + {"RCTCS", MENU_R_CTCS}, // was "R_CTCS" + {"TDCS", MENU_T_DCS}, // was "T_DCS" + {"TCTCS", MENU_T_CTCS}, // was "T_CTCS" + {"TxODir", MENU_SFT_D}, // was "SFT_D" + {"TxOffs", MENU_OFFSET}, // was "OFFSET" + {"W/N", MENU_W_N}, + {"SCR", MENU_SCR}, // was "SCR" + {"BusyL", MENU_BCL}, // was "BCL" + {"COMP", MENU_COMPAND}, + {"Mod", MENU_AM}, // was "AM" #ifdef ENABLE_FEAT_F4HWN - {"TXLock", MENU_TX_LOCK }, + {"TXLck", MENU_TX_LOCK}, #endif - {"ScAdd1", MENU_S_ADD1 }, - {"ScAdd2", MENU_S_ADD2 }, - {"ScAdd3", MENU_S_ADD3 }, - {"ChSave", MENU_MEM_CH }, // was "MEM-CH" - {"ChDele", MENU_DEL_CH }, // was "DEL-CH" - {"ChName", MENU_MEM_NAME }, + {"ScAdd1", MENU_S_ADD1}, + {"ScAdd2", MENU_S_ADD2}, + {"ScAdd3", MENU_S_ADD3}, + {"ChSave", MENU_MEM_CH}, // was "MEM-CH" + {"ChDele", MENU_DEL_CH}, // was "DEL-CH" + {"ChName", MENU_MEM_NAME}, - {"SList", MENU_S_LIST }, - {"SList1", MENU_SLIST1 }, - {"SList2", MENU_SLIST2 }, - {"SList3", MENU_SLIST3 }, - {"ScnRev", MENU_SC_REV }, + {"SList", MENU_S_LIST}, + {"SList1", MENU_SLIST1}, + {"SList2", MENU_SLIST2}, + {"SList3", MENU_SLIST3}, + {"ScnRev", MENU_SC_REV}, #ifndef ENABLE_FEAT_F4HWN - #ifdef ENABLE_NOAA - {"NOAA-S", MENU_NOAA_S }, - #endif +#ifdef ENABLE_NOAA + {"NOAA-S", MENU_NOAA_S }, #endif - {"F1Shrt", MENU_F1SHRT }, - {"F1Long", MENU_F1LONG }, - {"F2Shrt", MENU_F2SHRT }, - {"F2Long", MENU_F2LONG }, - {"M Long", MENU_MLONG }, +#endif + {"F1S", MENU_F1SHRT}, + {"F1L", MENU_F1LONG}, + {"F2S", MENU_F2SHRT}, + {"F2L", MENU_F2LONG}, + {"ML", MENU_MLONG}, - {"KeyLck", MENU_AUTOLK }, // was "AUTOLk" - {"TxTOut", MENU_TOT }, // was "TOT" - {"BatSav", MENU_SAVE }, // was "SAVE" - {"BatTxt", MENU_BAT_TXT }, - {"Mic", MENU_MIC }, - {"MicBar", MENU_MIC_BAR }, - {"ChDisp", MENU_MDF }, // was "MDF" - {"POnMsg", MENU_PONMSG }, - {"BLTime", MENU_ABR }, // was "ABR" - {"BLMin", MENU_ABR_MIN }, - {"BLMax", MENU_ABR_MAX }, - {"BLTxRx", MENU_ABR_ON_TX_RX }, - {"Beep", MENU_BEEP }, + {"KeyLck", MENU_AUTOLK}, // was "AUTOLk" + {"TxTOut", MENU_TOT}, // was "TOT" + {"BatSav", MENU_SAVE}, // was "SAVE" + {"BatTxt", MENU_BAT_TXT}, + {"Mic", MENU_MIC}, + {"MicBar", MENU_MIC_BAR}, + {"ChDisp", MENU_MDF}, // was "MDF" + {"FSKMod", MENU_FSKMOD}, + {"FSKSRC", MENU_FSKSRC}, // was "AUTOLk" + {"BLTime", MENU_ABR}, // was "ABR" + {"BLMin", MENU_ABR_MIN}, + {"BLMax", MENU_ABR_MAX}, + {"BLTxRx", MENU_ABR_ON_TX_RX}, + {"Beep", MENU_BEEP}, #ifdef ENABLE_VOICE - {"Voice", MENU_VOICE }, + {"Voice", MENU_VOICE }, #endif - {"Roger", MENU_ROGER }, - {"STE", MENU_STE }, - {"RP STE", MENU_RP_STE }, - {"1 Call", MENU_1_CALL }, + {"Roger", MENU_ROGER}, + {"STE", MENU_STE}, + {"RP STE", MENU_RP_STE}, + {"1 Call", MENU_1_CALL}, #ifdef ENABLE_ALARM - {"AlarmT", MENU_AL_MOD }, + {"AlarmT", MENU_AL_MOD}, #endif #ifdef ENABLE_DTMF_CALLING - {"ANI ID", MENU_ANI_ID }, + {"ANI ID", MENU_ANI_ID }, #endif - {"UPCode", MENU_UPCODE }, - {"DWCode", MENU_DWCODE }, - {"PTT ID", MENU_PTT_ID }, - {"D ST", MENU_D_ST }, + {"UPCode", MENU_UPCODE}, + {"DNCode", MENU_DWCODE}, + {"PTT ID", MENU_PTT_ID}, + {"L DTMF", MENU_D_ST}, #ifdef ENABLE_DTMF_CALLING - {"D Resp", MENU_D_RSP }, - {"D Hold", MENU_D_HOLD }, + {"D Resp", MENU_D_RSP }, + {"D Hold", MENU_D_HOLD }, #endif - {"D Prel", MENU_D_PRE }, + {"D Prel", MENU_D_PRE}, #ifdef ENABLE_DTMF_CALLING - {"D Decd", MENU_D_DCD }, - {"D List", MENU_D_LIST }, + {"D Decd", MENU_D_DCD }, + {"D List", MENU_D_LIST }, #endif - {"D Live", MENU_D_LIVE_DEC }, // live DTMF decoder + {"D Live", MENU_D_LIVE_DEC}, // live DTMF decoder #ifndef ENABLE_FEAT_F4HWN - #ifdef ENABLE_AM_FIX - {"AM Fix", MENU_AM_FIX }, - #endif +#ifdef ENABLE_AM_FIX + {"AM Fix", MENU_AM_FIX }, #endif - {"VOX", MENU_VOX }, -#ifdef ENABLE_FEAT_F4HWN - {"SysInf", MENU_VOL }, // was "VOL" -#else - {"BatVol", MENU_VOL }, // was "VOL" #endif - {"RxMode", MENU_TDR }, - {"Sql", MENU_SQL }, +#ifdef ENABLE_VOX + {"VOX", MENU_VOX}, +#endif + {"RxMode", MENU_TDR}, + {"Sql", MENU_SQL}, #ifdef ENABLE_FEAT_F4HWN - {"SetPwr", MENU_SET_PWR }, - {"SetPTT", MENU_SET_PTT }, - {"SetTOT", MENU_SET_TOT }, - {"SetEOT", MENU_SET_EOT }, - {"SetCtr", MENU_SET_CTR }, - {"SetInv", MENU_SET_INV }, - {"SetLck", MENU_SET_LCK }, - {"SetMet", MENU_SET_MET }, - {"SetGUI", MENU_SET_GUI }, - {"SetTmr", MENU_SET_TMR }, + {"SPwr", MENU_SET_PWR}, + {"SPTT", MENU_SET_PTT}, + {"STOT", MENU_SET_TOT}, + {"SEOT", MENU_SET_EOT}, + {"SCtr", MENU_SET_CTR}, + {"SInv", MENU_SET_INV}, + {"SLck", MENU_SET_LCK}, + //{"SMet", MENU_SET_MET}, + //{"SGUI", MENU_SET_GUI}, + {"STmr", MENU_SET_TMR}, #ifdef ENABLE_FEAT_F4HWN_SLEEP - {"SetOff", MENU_SET_OFF }, + {"SOff", MENU_SET_OFF}, #endif #ifdef ENABLE_FEAT_F4HWN_NARROWER - {"SetNFM", MENU_SET_NFM }, + {"SNFM", MENU_SET_NFM}, #endif #ifdef ENABLE_FEAT_F4HWN_VOL - {"SetVol", MENU_SET_VOL }, + {"SVol", MENU_SET_VOL}, #endif #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS - {"SetKey", MENU_SET_KEY }, + {"SKey", MENU_SET_KEY }, #endif #ifdef ENABLE_NOAA - {"SetNWR", MENU_NOAA_S }, + {"SNWR", MENU_NOAA_S }, #endif #endif - // hidden menu items from here on - // enabled if pressing both the PTT and upper side button at power-on - {"F Lock", MENU_F_LOCK }, + // hidden menu items from here on + // enabled if pressing both the PTT and upper side button at power-on + {"F Lock", MENU_F_LOCK}, #ifndef ENABLE_FEAT_F4HWN - {"Tx 200", MENU_200TX }, // was "200TX" - {"Tx 350", MENU_350TX }, // was "350TX" - {"Tx 500", MENU_500TX }, // was "500TX" -#endif - {"350 En", MENU_350EN }, // was "350EN" -#ifndef ENABLE_FEAT_F4HWN - {"ScraEn", MENU_SCREN }, // was "SCREN" + {"Tx 200", MENU_200TX }, // was "200TX" + {"Tx 350", MENU_350TX }, // was "350TX" + {"Tx 500", MENU_500TX }, // was "500TX" + {"350 En", MENU_350EN }, // was "350EN" #endif + //{"ScraEn", MENU_SCREN }, // was "SCREN" #ifdef ENABLE_F_CAL_MENU - {"FrCali", MENU_F_CALI }, // reference xtal calibration + {"FrCali", MENU_F_CALI}, // reference xtal calibration #endif - {"BatCal", MENU_BATCAL }, // battery voltage calibration - {"BatTyp", MENU_BATTYP }, // battery type 1600/2200mAh - {"Reset", MENU_RESET }, // might be better to move this to the hidden menu items ? + {"BatCal", MENU_BATCAL}, // battery voltage calibration + {"BatTyp", MENU_BATTYP}, // battery type 1600/2200mAh + {"Reset", MENU_RESET}, // might be better to move this to the hidden menu items ? - {"", 0xff } // end of list - DO NOT delete or move this this -}; + {"", 0xff} // end of list - DO NOT delete or move this this + }; const uint8_t FIRST_HIDDEN_MENU_ITEM = MENU_F_LOCK; const char gSubMenu_TXP[][6] = -{ - "USER", - "LOW 1", - "LOW 2", - "LOW 3", - "LOW 4", - "LOW 5", - "MID", - "HIGH" -}; + { + "USR", + "L1", + "L2", + "L3", + "L4", + "L5", + "M", + "H" + }; const char gSubMenu_SFT_D[][4] = -{ - "OFF", - "+", - "-" -}; + { + "OFF", + "+", + "-" + }; const char gSubMenu_W_N[][7] = -{ - "WIDE", - "NARROW" -}; + { + "WIDE", + "NARR" + }; const char gSubMenu_OFF_ON[][4] = -{ - "OFF", - "ON" -}; + { + "OFF", + "ON" + }; const char gSubMenu_NA[4] = -{ - "N/A" -}; + { + "N/A" + }; -const char* const gSubMenu_RXMode[] = -{ - "MAIN\nONLY", // TX and RX on main only - "DUAL RX\nRESPOND", // Watch both and respond - "CROSS\nBAND", // TX on main, RX on secondary - "MAIN TX\nDUAL RX" // always TX on main, but RX on both -}; +const char *const gSubMenu_RXMode[] = + { + "MAIN", // TX and RX on main only + "RESP", // Watch both and respond + "XBAND ONLY", // TX on main, RX on secondary + "DUALMON" // always TX on main, but RX on both + }; #ifdef ENABLE_VOICE - const char gSubMenu_VOICE[][4] = - { - "OFF", - "CHI", - "ENG" - }; +const char gSubMenu_VOICE[][4] = +{ + "OFF", + "CHI", + "ENG" +}; #endif -const char* const gSubMenu_MDF[] = -{ - "FREQ", - "CHANNEL\nNUMBER", - "NAME", - "NAME\n+\nFREQ" -}; +const char *const gSubMenu_MDF[] = + { + "FREQ", + "CHNUMB", + "NAME", + "NAME\n+\nFREQ" + }; #ifdef ENABLE_ALARM - const char gSubMenu_AL_MOD[][5] = - { - "SITE", - "TONE" - }; +const char gSubMenu_AL_MOD[][5] = + { + "SITE", + "TONE" + }; #endif #ifdef ENABLE_DTMF_CALLING @@ -264,221 +258,210 @@ const char gSubMenu_D_RSP[][11] = }; #endif -const char* const gSubMenu_PTT_ID[] = -{ - "OFF", - "UP CODE", - "DOWN CODE", - "UP+DOWN\nCODE", - "APOLLO\nQUINDAR" -}; +const char *const gSubMenu_PTT_ID[] = + { + "OFF", + "UP CODE", + "DN CODE", + "UP+DN\nCODE", + "APOLLO" + }; -const char gSubMenu_PONMSG[][8] = -{ -#ifdef ENABLE_FEAT_F4HWN - "ALL", - "SOUND", -#else - "FULL", -#endif - "MESSAGE", - "VOLTAGE", - "NONE" -}; +const char gSubMenu_FSKMod[][8] = + { + "450", + "700", + "A1200", + "A2400", + "2400", + "NOAA" + }; const char gSubMenu_ROGER[][6] = -{ - "OFF", - "ROGER", - "MDC" -}; + { + "OFF", + "RGR", + "MDC" + }; const char gSubMenu_RESET[][4] = -{ - "VFO", - "ALL" -}; + { + "VFO", + "ALL" + }; -const char * const gSubMenu_F_LOCK[] = -{ - "DEFAULT+\n137-174\n400-470", - "FCC HAM\n144-148\n420-450", +const char *const gSubMenu_F_LOCK[] = + { + "137-174\n400-470", #ifdef ENABLE_FEAT_F4HWN_CA - "CA HAM\n144-148\n430-450", + "FCC HAM\n144-148\n420-450", + "CA HAM\n144-148\n430-450", + "CE HAM\n144-146\n430-440", + "GB HAM\n144-148\n430-440", + "137-174\n400-430", + "137-174\n400-438", #endif - "CE HAM\n144-146\n430-440", - "GB HAM\n144-148\n430-440", - "137-174\n400-430", - "137-174\n400-438", #ifdef ENABLE_FEAT_F4HWN_PMR - "PMR 446", + "PMR 446", #endif #ifdef ENABLE_FEAT_F4HWN_GMRS_FRS_MURS - "GMRS\nFRS\nMURS", + "GMRS\nFRS\nMURS", #endif - "DISABLE\nALL", - "UNLOCK\nALL", -}; + "DIS\nALL", + "UNL\nALL", + }; const char gSubMenu_RX_TX[][6] = -{ - "OFF", - "TX", - "RX", - "TX/RX" -}; + { + "OFF", + "TX", + "RX", + "TX/RX" + }; const char gSubMenu_BAT_TXT[][8] = -{ - "NONE", - "VOLTAGE", - "PERCENT" -}; + { + "NONE", + "VLT", + "PRC" + }; const char gSubMenu_BATTYP[][9] = -{ - "1600mAh", - "2200mAh", - "3500mAh" -}; + { + "16", + "22", + "35" + }; -#ifndef ENABLE_FEAT_F4HWN const char gSubMenu_SCRAMBLER[][7] = -{ - "OFF", - "2600Hz", - "2700Hz", - "2800Hz", - "2900Hz", - "3000Hz", - "3100Hz", - "3200Hz", - "3300Hz", - "3400Hz", - "3500Hz" -}; -#endif + { + "OFF", + "26K", + "27K", + "28K", + "29K", + "30K", + "31K", + "32K", + "33K", + "34K", + "35K" + }; #ifdef ENABLE_FEAT_F4HWN - const char gSubMenu_SET_PWR[][6] = - { - "< 20m", - "125m", - "250m", - "500m", - "1", - "2", - "5" - }; - - const char gSubMenu_SET_PTT[][8] = - { - "CLASSIC", - "ONEPUSH" - }; - - const char gSubMenu_SET_TOT[][7] = // Use by SET_EOT too - { - "OFF", - "SOUND", - "VISUAL", - "ALL" - }; - - const char gSubMenu_SET_LCK[][9] = - { - "KEYS", - "KEYS+PTT" - }; - - const char gSubMenu_SET_MET[][8] = - { - "TINY", - "CLASSIC" - }; - - #ifdef ENABLE_FEAT_F4HWN_NARROWER - const char gSubMenu_SET_NFM[][9] = +const char gSubMenu_SET_PWR[][6] = { - "NARROW", - "NARROWER" + "<.02", + ".125", + ".25", + ".5", + "1", + "2", + "5" }; - #endif - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS - const char gSubMenu_SET_KEY[][9] = +const char gSubMenu_SET_PTT[][8] = { - "KEY_MENU", - "KEY_UP", - "KEY_DOWN", - "KEY_EXIT", - "KEY_STAR" + "HOLD", + "TAP" }; - #endif + +const char gSubMenu_SET_TOT[][7] = // Use by SET_EOT too + { + "OFF", + "SND", + "VIS", + "ALL" + }; + +const char gSubMenu_SET_LCK[][9] = + { + "KEY", + "KEY+PTT" + }; + +#ifdef ENABLE_FEAT_F4HWN_NARROWER +const char gSubMenu_SET_NFM[][9] = + { + "NRW", + "NRWER" + }; +#endif + +#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS +const char gSubMenu_SET_KEY[][9] = +{ + "KEY_MENU", + "KEY_UP", + "KEY_DOWN", + "KEY_EXIT", + "KEY_STAR" +}; +#endif #endif const t_sidefunction gSubMenu_SIDEFUNCTIONS[] = -{ - {"NONE", ACTION_OPT_NONE}, + { + {"NONE", ACTION_OPT_NONE}, #ifdef ENABLE_FLASHLIGHT - {"FLASH\nLIGHT", ACTION_OPT_FLASHLIGHT}, + {"FLASH", ACTION_OPT_FLASHLIGHT}, #endif - {"POWER", ACTION_OPT_POWER}, - {"MONITOR", ACTION_OPT_MONITOR}, - {"SCAN", ACTION_OPT_SCAN}, + {"PWR", ACTION_OPT_POWER}, + {"MON", ACTION_OPT_MONITOR}, + {"SCAN", ACTION_OPT_SCAN}, #ifdef ENABLE_VOX - {"VOX", ACTION_OPT_VOX}, + {"VOX", ACTION_OPT_VOX}, #endif #ifdef ENABLE_ALARM - {"ALARM", ACTION_OPT_ALARM}, + {"ALARM", ACTION_OPT_ALARM}, #endif #ifdef ENABLE_FMRADIO - {"FM RADIO", ACTION_OPT_FM}, + {"WFM", ACTION_OPT_FM}, #endif #ifdef ENABLE_TX1750 - {"1750Hz", ACTION_OPT_1750}, + {"1750", ACTION_OPT_1750}, #endif #ifdef ENABLE_REGA - {"REGA\nALARM", ACTION_OPT_REGA_ALARM}, - {"REGA\nTEST", ACTION_OPT_REGA_TEST}, + {"REGA\nALARM", ACTION_OPT_REGA_ALARM}, + {"REGA\nTEST", ACTION_OPT_REGA_TEST}, #endif - {"LOCK\nKEYPAD", ACTION_OPT_KEYLOCK}, - {"VFO A\nVFO B", ACTION_OPT_A_B}, - {"VFO\nMEM", ACTION_OPT_VFO_MR}, - {"MODE", ACTION_OPT_SWITCH_DEMODUL}, + {"LOCK\nKEY", ACTION_OPT_KEYLOCK}, + {"VFO A\nVFO B", ACTION_OPT_A_B}, + {"VFO\nMEM", ACTION_OPT_VFO_MR}, + {"MODE", ACTION_OPT_SWITCH_DEMODUL}, #ifdef ENABLE_BLMIN_TMP_OFF - {"BLMIN\nTMP OFF", ACTION_OPT_BLMIN_TMP_OFF}, //BackLight Minimum Temporay OFF + {"BLMIN\nTMP OFF", ACTION_OPT_BLMIN_TMP_OFF}, //BackLight Minimum Temporay OFF #endif #ifdef ENABLE_FEAT_F4HWN - {"RX MODE", ACTION_OPT_RXMODE}, - {"MAIN ONLY", ACTION_OPT_MAINONLY}, - {"PTT", ACTION_OPT_PTT}, - {"WIDE\nNARROW", ACTION_OPT_WN}, - #if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO) - {"MUTE", ACTION_OPT_MUTE}, - #endif - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS - {"POWER\nHIGH", ACTION_OPT_POWER_HIGH}, - {"REMOVE\nOFFSET", ACTION_OPT_REMOVE_OFFSET}, - #endif + {"RX MOD", ACTION_OPT_RXMODE}, + {"MAIN ONLY", ACTION_OPT_MAINONLY}, + {"PTT", ACTION_OPT_PTT}, + {"WIDE\nNAR", ACTION_OPT_WN}, +#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO) + {"MUTE", ACTION_OPT_MUTE}, #endif -}; +#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS + {"POWER\nHIGH", ACTION_OPT_POWER_HIGH}, + {"REMOVE\nOFFSET", ACTION_OPT_REMOVE_OFFSET}, +#endif +#endif + }; const uint8_t gSubMenu_SIDEFUNCTIONS_size = ARRAY_SIZE(gSubMenu_SIDEFUNCTIONS); -bool gIsInSubMenu; +bool gIsInSubMenu; uint8_t gMenuCursor; + int UI_MENU_GetCurrentMenuId() { - if(gMenuCursor < ARRAY_SIZE(MenuList)) + if (gMenuCursor < ARRAY_SIZE(MenuList)) return MenuList[gMenuCursor].menu_id; - return MenuList[ARRAY_SIZE(MenuList)-1].menu_id; + return MenuList[ARRAY_SIZE(MenuList) - 1].menu_id; } -uint8_t UI_MENU_GetMenuIdx(uint8_t id) -{ - for(uint8_t i = 0; i < ARRAY_SIZE(MenuList); i++) - if(MenuList[i].menu_id == id) +uint8_t UI_MENU_GetMenuIdx(uint8_t id) { + for (uint8_t i = 0; i < ARRAY_SIZE(MenuList); i++) + if (MenuList[i].menu_id == id) return i; return 0; } @@ -486,17 +469,16 @@ uint8_t UI_MENU_GetMenuIdx(uint8_t id) int32_t gSubMenuSelection; // edit box -char edit_original[17]; // a copy of the text before editing so that we can easily test for changes/difference -char edit[17]; -int edit_index; +char edit_original[17]; // a copy of the text before editing so that we can easily test for changes/difference +char edit[17]; +int edit_index; -void UI_DisplayMenu(void) -{ +void UI_DisplayMenu(void) { const unsigned int menu_list_width = 6; // max no. of characters on the menu list (left side) - const unsigned int menu_item_x1 = (8 * menu_list_width) + 2; - const unsigned int menu_item_x2 = LCD_WIDTH - 1; - unsigned int i; - char String[64]; // bigger cuz we can now do multi-line in one string (use '\n' char) + const unsigned int menu_item_x1 = (8 * menu_list_width) + 2; + const unsigned int menu_item_x2 = LCD_WIDTH - 1; + unsigned int i; + char String[64]; // bigger cuz we can now do multi-line in one string (use '\n' char) #ifdef ENABLE_DTMF_CALLING char Contact[16]; @@ -508,38 +490,37 @@ void UI_DisplayMenu(void) UI_DrawLineBuffer(gFrameBuffer, 48, 0, 48, 55, 1); // Be ware, status zone = 8 lines, the rest = 56 ->total 64 //UI_DrawLineDottedBuffer(gFrameBuffer, 0, 46, 50, 46, 1); - for (uint8_t i = 0; i < 48; i += 2) - { + for (uint8_t i = 0; i < 48; i += 2) { gFrameBuffer[5][i] = 0x40; } #endif #ifndef ENABLE_CUSTOM_MENU_LAYOUT - // original menu layout - for (i = 0; i < 3; i++) - if (gMenuCursor > 0 || i > 0) - if ((gMenuListCount - 1) != gMenuCursor || i != 2) - UI_PrintString(MenuList[gMenuCursor + i - 1].name, 0, 0, i * 2, 8); + // original menu layout +for (i = 0; i < 3; i++) + if (gMenuCursor > 0 || i > 0) + if ((gMenuListCount - 1) != gMenuCursor || i != 2) + UI_PrintString(MenuList[gMenuCursor + i - 1].name, 0, 0, i * 2, 8); - // invert the current menu list item pixels - for (i = 0; i < (8 * menu_list_width); i++) - { - gFrameBuffer[2][i] ^= 0xFF; - gFrameBuffer[3][i] ^= 0xFF; - } +// invert the current menu list item pixels +for (i = 0; i < (8 * menu_list_width); i++) +{ + gFrameBuffer[2][i] ^= 0xFF; + gFrameBuffer[3][i] ^= 0xFF; +} - // draw vertical separating dotted line - for (i = 0; i < 7; i++) - gFrameBuffer[i][(8 * menu_list_width) + 1] = 0xAA; +// draw vertical separating dotted line +for (i = 0; i < 7; i++) + gFrameBuffer[i][(8 * menu_list_width) + 1] = 0xAA; - // draw the little sub-menu triangle marker - if (gIsInSubMenu) - memcpy(gFrameBuffer[0] + (8 * menu_list_width) + 1, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator)); +// draw the little sub-menu triangle marker +if (gIsInSubMenu) + memcpy(gFrameBuffer[0] + (8 * menu_list_width) + 1, BITMAP_CurrentIndicator, sizeof(BITMAP_CurrentIndicator)); - // draw the menu index number/count - sprintf(String, "%2u.%u", 1 + gMenuCursor, gMenuListCount); +// draw the menu index number/count +sprintf(String, "%2u.%u", 1 + gMenuCursor, gMenuListCount); - UI_PrintStringSmallNormal(String, 2, 0, 6); +UI_PrintStringSmallNormal(String, 2, 0, 6); #else { // new menu layout .. experimental & unfinished @@ -547,28 +528,28 @@ void UI_DisplayMenu(void) i = 1; if (!gIsInSubMenu) { - while (i < 2) - { // leading menu items - small text + while (i < 2) { // leading menu items - small text const int k = menu_index + i - 2; if (k < 0) UI_PrintStringSmallNormal(MenuList[gMenuListCount + k].name, 0, 0, i); // wrap-a-round - else if (k >= 0 && k < (int)gMenuListCount) + else if (k >= 0 && k < (int) gMenuListCount) UI_PrintStringSmallNormal(MenuList[k].name, 0, 0, i); i++; } // current menu item - keep big n fat - if (menu_index >= 0 && menu_index < (int)gMenuListCount) - UI_PrintString(MenuList[menu_index].name, 0, 0, 2, 8); + if (menu_index >= 0 && menu_index < (int) gMenuListCount) { + //UI_DrawRectangleBuffer(gFrameBuffer, 0, 37, 16, 45, true); + UI_PrintStringSmallBold(MenuList[menu_index].name, 0, 0, 2); + } i++; - while (i < 4) - { // trailing menu item - small text + while (i < 5) { // trailing menu item - small text const int k = menu_index + i - 2; - if (k >= 0 && k < (int)gMenuListCount) - UI_PrintStringSmallNormal(MenuList[k].name, 0, 0, 1 + i); - else if (k >= (int)gMenuListCount) - UI_PrintStringSmallNormal(MenuList[gMenuListCount - k].name, 0, 0, 1 + i); // wrap-a-round + if (k >= 0 && k < (int) gMenuListCount) + UI_PrintStringSmallNormal(MenuList[k].name, 0, 0, i); + else if (k >= (int) gMenuListCount) + UI_PrintStringSmallNormal(MenuList[gMenuListCount - k].name, 0, 0, i); // wrap-a-round i++; } @@ -577,9 +558,7 @@ void UI_DisplayMenu(void) sprintf(String, "%2u.%u", 1 + gMenuCursor, gMenuListCount); UI_PrintStringSmallNormal(String, 2, 0, 6); #endif - } - else if (menu_index >= 0 && menu_index < (int)gMenuListCount) - { // current menu item + } else if (menu_index >= 0 && menu_index < (int) gMenuListCount) { // current menu item // strcat(String, ":"); UI_PrintString(MenuList[menu_index].name, 0, 0, 0, 8); // UI_PrintStringSmallNormal(String, 0, 0, 0); @@ -604,31 +583,29 @@ void UI_DisplayMenu(void) BACKLIGHT_TurnOn(); - #if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO) - uint8_t gaugeLine = 0; - uint8_t gaugeMin = 0; - uint8_t gaugeMax = 0; - #endif +#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO) + uint8_t gaugeLine = 0; + uint8_t gaugeMin = 0; + uint8_t gaugeMax = 0; +#endif - switch (UI_MENU_GetCurrentMenuId()) - { + switch (UI_MENU_GetCurrentMenuId()) { case MENU_SQL: sprintf(String, "%d", gSubMenuSelection); break; - case MENU_MIC: - { // display the mic gain in actual dB rather than just an index number - const uint8_t mic = gMicGain_dB2[gSubMenuSelection]; - sprintf(String, "+%u.%01udB", mic / 2, mic % 2); - } + case MENU_MIC: { // display the mic gain in actual dB rather than just an index number + const uint8_t mic = gMicGain_dB2[gSubMenuSelection]; + sprintf(String, "+%u.%01udB", mic / 2, mic % 2); + } break; case MENU_MIC_BAR: - #ifdef ENABLE_AUDIO_BAR - strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]); - #else - strcpy(String, gSubMenu_NA); - #endif +#ifdef ENABLE_AUDIO_BAR + strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]); +#else + strcpy(String, gSubMenu_NA); +#endif break; case MENU_STEP: { @@ -638,12 +615,9 @@ void UI_DisplayMenu(void) } case MENU_TXP: - if(gSubMenuSelection == 0) - { + if (gSubMenuSelection == 0) { strcpy(String, gSubMenu_TXP[gSubMenuSelection]); - } - else - { + } else { sprintf(String, "%s\n%sW", gSubMenu_TXP[gSubMenuSelection], gSubMenu_SET_PWR[gSubMenuSelection - 1]); } break; @@ -653,18 +627,18 @@ void UI_DisplayMenu(void) if (gSubMenuSelection == 0) strcpy(String, gSubMenu_OFF_ON[0]); else if (gSubMenuSelection < 105) - sprintf(String, "D%03oN", DCS_Options[gSubMenuSelection - 1]); + sprintf(String, "D%03oN", DCS_Options[gSubMenuSelection - 1]); else sprintf(String, "D%03oI", DCS_Options[gSubMenuSelection - 105]); break; case MENU_R_CTCS: - case MENU_T_CTCS: - { + case MENU_T_CTCS: { if (gSubMenuSelection == 0) strcpy(String, gSubMenu_OFF_ON[0]); else - sprintf(String, "%u.%uHz", CTCSS_Options[gSubMenuSelection - 1] / 10, CTCSS_Options[gSubMenuSelection - 1] % 10); + sprintf(String, "%u.%uHz", CTCSS_Options[gSubMenuSelection - 1] / 10, + CTCSS_Options[gSubMenuSelection - 1] % 10); break; } @@ -673,19 +647,16 @@ void UI_DisplayMenu(void) break; case MENU_OFFSET: - if (!gIsInSubMenu || gInputBoxIndex == 0) - { + if (!gIsInSubMenu || gInputBoxIndex == 0) { sprintf(String, "%3d.%05u", gSubMenuSelection / 100000, abs(gSubMenuSelection) % 100000); UI_PrintString(String, menu_item_x1, menu_item_x2, 1, 8); - } - else - { - const char * ascii = INPUTBOX_GetAscii(); - sprintf(String, "%.3s.%.3s ",ascii, ascii + 3); + } else { + const char *ascii = INPUTBOX_GetAscii(); + sprintf(String, "%.3s.%.3s ", ascii, ascii + 3); UI_PrintString(String, menu_item_x1, menu_item_x2, 1, 8); } - UI_PrintString("MHz", menu_item_x1, menu_item_x2, 3, 8); + UI_PrintString("MHz", menu_item_x1, menu_item_x2, 3, 8); already_printed = true; break; @@ -694,43 +665,34 @@ void UI_DisplayMenu(void) strcpy(String, gSubMenu_W_N[gSubMenuSelection]); break; -#ifndef ENABLE_FEAT_F4HWN case MENU_SCR: strcpy(String, gSubMenu_SCRAMBLER[gSubMenuSelection]); - #if 1 - if (gSubMenuSelection > 0 && gSetting_ScrambleEnable) - BK4819_EnableScramble(gSubMenuSelection - 1); - else - BK4819_DisableScramble(); - #endif + if (gSubMenuSelection > 0) + BK4819_EnableScramble(gSubMenuSelection - 1); + else + BK4819_DisableScramble(); break; -#endif case MENU_VOX: - #ifdef ENABLE_VOX - sprintf(String, gSubMenuSelection == 0 ? gSubMenu_OFF_ON[0] : "%u", gSubMenuSelection); - #else - strcpy(String, gSubMenu_NA); - #endif +#ifdef ENABLE_VOX + sprintf(String, gSubMenuSelection == 0 ? gSubMenu_OFF_ON[0] : "%u", gSubMenuSelection); +#else + strcpy(String, gSubMenu_NA); +#endif break; case MENU_ABR: - if(gSubMenuSelection == 0) - { + if (gSubMenuSelection == 0) { strcpy(String, gSubMenu_OFF_ON[0]); - } - else if(gSubMenuSelection < 61) - { + } else if (gSubMenuSelection < 61) { sprintf(String, "%02dm:%02ds", (((gSubMenuSelection) * 5) / 60), (((gSubMenuSelection) * 5) % 60)); - #if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO) +#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO) //ST7565_Gauge(4, 1, 60, gSubMenuSelection); gaugeLine = 4; gaugeMin = 1; gaugeMax = 60; - #endif - } - else - { +#endif + } else { strcpy(String, "ON"); } @@ -742,7 +704,7 @@ void UI_DisplayMenu(void) case MENU_ABR_MIN: case MENU_ABR_MAX: sprintf(String, "%d", gSubMenuSelection); - if(gIsInSubMenu) + if (gIsInSubMenu) BACKLIGHT_SetBrightness(gSubMenuSelection); // Obsolete ??? //else if(BACKLIGHT_GetBrightness() < 4) @@ -756,28 +718,31 @@ void UI_DisplayMenu(void) case MENU_AUTOLK: if (gSubMenuSelection == 0) strcpy(String, gSubMenu_OFF_ON[0]); - else - { + else { sprintf(String, "%02dm:%02ds", ((gSubMenuSelection * 15) / 60), ((gSubMenuSelection * 15) % 60)); - #if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO) +#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO) //ST7565_Gauge(4, 1, 40, gSubMenuSelection); gaugeLine = 4; gaugeMin = 1; gaugeMax = 40; - #endif +#endif } break; + case MENU_FSKSRC: + sprintf(String, "%d", gSubMenuSelection); + break; + case MENU_COMPAND: case MENU_ABR_ON_TX_RX: strcpy(String, gSubMenu_RX_TX[gSubMenuSelection]); break; - #ifndef ENABLE_FEAT_F4HWN - #ifdef ENABLE_AM_FIX - case MENU_AM_FIX: - #endif - #endif +#ifndef ENABLE_FEAT_F4HWN +#ifdef ENABLE_AM_FIX + case MENU_AM_FIX: +#endif +#endif case MENU_BCL: case MENU_BEEP: case MENU_S_ADD1: @@ -786,21 +751,19 @@ void UI_DisplayMenu(void) case MENU_STE: case MENU_D_ST: #ifdef ENABLE_DTMF_CALLING - case MENU_D_DCD: + case MENU_D_DCD: #endif case MENU_D_LIVE_DEC: - #ifdef ENABLE_NOAA +#ifdef ENABLE_NOAA case MENU_NOAA_S: - #endif +#endif #ifndef ENABLE_FEAT_F4HWN - case MENU_350TX: - case MENU_200TX: - case MENU_500TX: + case MENU_350TX: + case MENU_200TX: + case MENU_500TX: #endif case MENU_350EN: -#ifndef ENABLE_FEAT_F4HWN - case MENU_SCREN: -#endif + //case MENU_SCREN: #ifdef ENABLE_FEAT_F4HWN case MENU_SET_TMR: #endif @@ -809,15 +772,13 @@ void UI_DisplayMenu(void) case MENU_MEM_CH: case MENU_1_CALL: - case MENU_DEL_CH: - { + case MENU_DEL_CH: { const bool valid = RADIO_CheckValidChannel(gSubMenuSelection, false, 0); UI_GenerateChannelStringEx(String, valid, gSubMenuSelection); UI_PrintString(String, menu_item_x1, menu_item_x2, 0, 8); - if (valid && !gAskForConfirmation) - { // show the frequency so that the user knows the channels frequency + if (valid && !gAskForConfirmation) { // show the frequency so that the user knows the channels frequency const uint32_t frequency = SETTINGS_FetchChannelFrequency(gSubMenuSelection); sprintf(String, "%u.%05u", frequency / 100000, frequency % 100000); UI_PrintString(String, menu_item_x1, menu_item_x2, 4, 8); @@ -829,37 +790,31 @@ void UI_DisplayMenu(void) break; } - case MENU_MEM_NAME: - { + case MENU_MEM_NAME: { const bool valid = RADIO_CheckValidChannel(gSubMenuSelection, false, 0); UI_GenerateChannelStringEx(String, valid, gSubMenuSelection); UI_PrintString(String, menu_item_x1, menu_item_x2, 0, 8); - if (valid) - { + if (valid) { const uint32_t frequency = SETTINGS_FetchChannelFrequency(gSubMenuSelection); //if (!gIsInSubMenu || edit_index < 0) if (!gIsInSubMenu) edit_index = -1; - if (edit_index < 0) - { // show the channel name + if (edit_index < 0) { // show the channel name SETTINGS_FetchChannelName(String, gSubMenuSelection); char *pPrintStr = String[0] ? String : "--"; UI_PrintString(pPrintStr, menu_item_x1, menu_item_x2, 2, 8); - } - else - { // show the channel name being edited + } else { // show the channel name being edited //UI_PrintString(edit, menu_item_x1, 0, 2, 8); UI_PrintString(edit, menu_item_x1, menu_item_x2, 2, 8); if (edit_index < 10) //UI_PrintString("^", menu_item_x1 + (8 * edit_index), 0, 4, 8); // show the cursor - UI_PrintString("^", menu_item_x1 - 1 + (8 * edit_index),0, 4, 8); // show the cursor + UI_PrintString("^", menu_item_x1 - 1 + (8 * edit_index), 0, 4, 8); // show the cursor } - if (!gAskForConfirmation) - { // show the frequency so that the user knows the channels frequency + if (!gAskForConfirmation) { // show the frequency so that the user knows the channels frequency sprintf(String, "%u.%05u", frequency / 100000, frequency % 100000); UI_PrintString(String, menu_item_x1, menu_item_x2, 4 + (gIsInSubMenu && edit_index >= 0), 8); } @@ -879,44 +834,41 @@ void UI_DisplayMenu(void) case MENU_TOT: sprintf(String, "%02dm:%02ds", (((gSubMenuSelection + 1) * 5) / 60), (((gSubMenuSelection + 1) * 5) % 60)); - #if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO) +#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO) //ST7565_Gauge(4, 5, 179, gSubMenuSelection); gaugeLine = 4; gaugeMin = 5; gaugeMax = 179; - #endif +#endif break; - #ifdef ENABLE_VOICE +#ifdef ENABLE_VOICE case MENU_VOICE: strcpy(String, gSubMenu_VOICE[gSubMenuSelection]); break; - #endif +#endif case MENU_SC_REV: - if(gSubMenuSelection == 0) - { + if (gSubMenuSelection == 0) { strcpy(String, "STOP"); - } - else if(gSubMenuSelection < 81) - { - sprintf(String, "CARRIER\n%02ds:%03dms", ((gSubMenuSelection * 250) / 1000), ((gSubMenuSelection * 250) % 1000)); - #if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO) + } else if (gSubMenuSelection < 81) { + sprintf(String, "CARRIER\n%02ds:%03dms", ((gSubMenuSelection * 250) / 1000), + ((gSubMenuSelection * 250) % 1000)); +#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO) //ST7565_Gauge(5, 1, 80, gSubMenuSelection); gaugeLine = 5; gaugeMin = 1; gaugeMax = 80; - #endif - } - else - { - sprintf(String, "TIMEOUT\n%02dm:%02ds", (((gSubMenuSelection - 80) * 5) / 60), (((gSubMenuSelection - 80) * 5) % 60)); - #if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO) +#endif + } else { + sprintf(String, "TIMEOUT\n%02dm:%02ds", (((gSubMenuSelection - 80) * 5) / 60), + (((gSubMenuSelection - 80) * 5) % 60)); +#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO) //ST7565_Gauge(5, 80, 104, gSubMenuSelection); gaugeLine = 5; gaugeMin = 80; gaugeMax = 104; - #endif +#endif } break; @@ -939,16 +891,16 @@ void UI_DisplayMenu(void) strcpy(String, "ALL"); break; - #ifdef ENABLE_ALARM +#ifdef ENABLE_ALARM case MENU_AL_MOD: sprintf(String, gSubMenu_AL_MOD[gSubMenuSelection]); break; - #endif +#endif #ifdef ENABLE_DTMF_CALLING - case MENU_ANI_ID: - strcpy(String, gEeprom.ANI_DTMF_ID); - break; + case MENU_ANI_ID: + strcpy(String, gEeprom.ANI_DTMF_ID); + break; #endif case MENU_UPCODE: sprintf(String, "%.8s\n%.8s", gEeprom.DTMF_UP_CODE, gEeprom.DTMF_UP_CODE + 8); @@ -959,13 +911,13 @@ void UI_DisplayMenu(void) break; #ifdef ENABLE_DTMF_CALLING - case MENU_D_RSP: - strcpy(String, gSubMenu_D_RSP[gSubMenuSelection]); - break; + case MENU_D_RSP: + strcpy(String, gSubMenu_D_RSP[gSubMenuSelection]); + break; - case MENU_D_HOLD: - sprintf(String, "%ds", gSubMenuSelection); - break; + case MENU_D_HOLD: + sprintf(String, "%ds", gSubMenuSelection); + break; #endif case MENU_D_PRE: sprintf(String, "%d*10ms", gSubMenuSelection); @@ -980,69 +932,47 @@ void UI_DisplayMenu(void) break; #ifdef ENABLE_DTMF_CALLING - case MENU_D_LIST: - gIsDtmfContactValid = DTMF_GetContact((int)gSubMenuSelection - 1, Contact); - if (!gIsDtmfContactValid) - strcpy(String, "NULL"); - else - memcpy(String, Contact, 8); - break; + case MENU_D_LIST: + gIsDtmfContactValid = DTMF_GetContact((int)gSubMenuSelection - 1, Contact); + if (!gIsDtmfContactValid) + strcpy(String, "NULL"); + else + memcpy(String, Contact, 8); + break; #endif - case MENU_PONMSG: - strcpy(String, gSubMenu_PONMSG[gSubMenuSelection]); + case MENU_FSKMOD: + strcpy(String, gSubMenu_FSKMod[gSubMenuSelection]); break; case MENU_ROGER: strcpy(String, gSubMenu_ROGER[gSubMenuSelection]); break; - case MENU_VOL: -#ifdef ENABLE_FEAT_F4HWN - sprintf(String, "%s\n%s", - AUTHOR_STRING_2, - VERSION_STRING_2 - ); -#else - sprintf(String, "%u.%02uV\n%u%%", - gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100, - BATTERY_VoltsToPercent(gBatteryVoltageAverage)); -#endif - break; - case MENU_RESET: strcpy(String, gSubMenu_RESET[gSubMenuSelection]); break; case MENU_F_LOCK: -#ifdef ENABLE_FEAT_F4HWN - if(!gIsInSubMenu && gUnlockAllTxConfCnt>0 && gUnlockAllTxConfCnt<3) -#else - if(!gIsInSubMenu && gUnlockAllTxConfCnt>0 && gUnlockAllTxConfCnt<10) -#endif - strcpy(String, "READ\nMANUAL"); - else - strcpy(String, gSubMenu_F_LOCK[gSubMenuSelection]); + strcpy(String, gSubMenu_F_LOCK[gSubMenuSelection]); break; - #ifdef ENABLE_F_CAL_MENU - case MENU_F_CALI: - { - const uint32_t value = 22656 + gSubMenuSelection; - const uint32_t xtal_Hz = (0x4f0000u + value) * 5; +#ifdef ENABLE_F_CAL_MENU + case MENU_F_CALI: { + const uint32_t value = 22656 + gSubMenuSelection; + const uint32_t xtal_Hz = (0x4f0000u + value) * 5; - writeXtalFreqCal(gSubMenuSelection, false); + writeXtalFreqCal(gSubMenuSelection, false); - sprintf(String, "%d\n%u.%06u\nMHz", - gSubMenuSelection, - xtal_Hz / 1000000, xtal_Hz % 1000000); - } - break; - #endif + sprintf(String, "%d\n%u.%06u\nMHz", + gSubMenuSelection, + xtal_Hz / 1000000, xtal_Hz % 1000000); + } + break; +#endif - case MENU_BATCAL: - { - const uint16_t vol = (uint32_t)gBatteryVoltageAverage * gBatteryCalibration[3] / gSubMenuSelection; + case MENU_BATCAL: { + const uint16_t vol = (uint32_t) gBatteryVoltageAverage * gBatteryCalibration[3] / gSubMenuSelection; sprintf(String, "%u.%02uV\n%u", vol / 100, vol % 100, gSubMenuSelection); break; } @@ -1061,19 +991,16 @@ void UI_DisplayMenu(void) #ifdef ENABLE_FEAT_F4HWN_SLEEP case MENU_SET_OFF: - if(gSubMenuSelection == 0) - { + if (gSubMenuSelection == 0) { strcpy(String, gSubMenu_OFF_ON[0]); - } - else if(gSubMenuSelection < 121) - { + } else if (gSubMenuSelection < 121) { sprintf(String, "%dh:%02dm", (gSubMenuSelection / 60), (gSubMenuSelection % 60)); - #if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO) +#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO) //ST7565_Gauge(4, 1, 120, gSubMenuSelection); gaugeLine = 4; gaugeMin = 1; gaugeMax = 120; - #endif +#endif } break; #endif @@ -1082,7 +1009,7 @@ void UI_DisplayMenu(void) case MENU_SET_PWR: sprintf(String, "%s\n%sW", gSubMenu_TXP[gSubMenuSelection + 1], gSubMenu_SET_PWR[gSubMenuSelection]); break; - + case MENU_SET_PTT: strcpy(String, gSubMenu_SET_PTT[gSubMenuSelection]); break; @@ -1093,31 +1020,28 @@ void UI_DisplayMenu(void) break; case MENU_SET_CTR: - #ifdef ENABLE_FEAT_F4HWN_CTR - sprintf(String, "%d", gSubMenuSelection); - gSetting_set_ctr = gSubMenuSelection; - ST7565_ContrastAndInv(); - #else - strcpy(String, gSubMenu_NA); - #endif +#ifdef ENABLE_FEAT_F4HWN_CTR + sprintf(String, "%d", gSubMenuSelection); + gSetting_set_ctr = gSubMenuSelection; + ST7565_ContrastAndInv(); +#else + strcpy(String, gSubMenu_NA); +#endif break; case MENU_SET_INV: - #ifdef ENABLE_FEAT_F4HWN_INV - strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]); - ST7565_ContrastAndInv(); - #else - strcpy(String, gSubMenu_NA); - #endif +#ifdef ENABLE_FEAT_F4HWN_INV + strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]); + ST7565_ContrastAndInv(); +#else + strcpy(String, gSubMenu_NA); +#endif break; case MENU_TX_LOCK: - if(TX_freq_check(gEeprom.VfoInfo[gEeprom.TX_VFO].pRX->Frequency) == 0) - { + if (TX_freq_check(gEeprom.VfoInfo[gEeprom.TX_VFO].pRX->Frequency) == 0) { strcpy(String, "Inside\nF Lock\nPlan"); - } - else - { + } else { strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]); } break; @@ -1126,80 +1050,71 @@ void UI_DisplayMenu(void) strcpy(String, gSubMenu_SET_LCK[gSubMenuSelection]); break; - case MENU_SET_MET: - case MENU_SET_GUI: + //case MENU_SET_MET: + //case MENU_SET_GUI: strcpy(String, gSubMenu_SET_MET[gSubMenuSelection]); // Same as SET_MET break; - #ifdef ENABLE_FEAT_F4HWN_NARROWER - case MENU_SET_NFM: - strcpy(String, gSubMenu_SET_NFM[gSubMenuSelection]); - break; - #endif +#ifdef ENABLE_FEAT_F4HWN_NARROWER + case MENU_SET_NFM: + strcpy(String, gSubMenu_SET_NFM[gSubMenuSelection]); + break; +#endif - #ifdef ENABLE_FEAT_F4HWN_VOL - case MENU_SET_VOL: - if(gSubMenuSelection == 0) - { - strcpy(String, gSubMenu_OFF_ON[0]); - } - else if(gSubMenuSelection < 64) - { - sprintf(String, "%02u", gSubMenuSelection); - #if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO) - //ST7565_Gauge(4, 1, 63, gSubMenuSelection); - gaugeLine = 4; - gaugeMin = 1; - gaugeMax = 63; - #endif - } - gEeprom.VOLUME_GAIN = gSubMenuSelection; - BK4819_WriteRegister(BK4819_REG_48, - (11u << 12) | // ??? .. 0 ~ 15, doesn't seem to make any difference - ( 0u << 10) | // AF Rx Gain-1 - (gEeprom.VOLUME_GAIN << 4) | // AF Rx Gain-2 - (gEeprom.DAC_GAIN << 0)); // AF DAC Gain (after Gain-1 and Gain-2) - break; - #endif +#ifdef ENABLE_FEAT_F4HWN_VOL + case MENU_SET_VOL: + if (gSubMenuSelection == 0) { + strcpy(String, gSubMenu_OFF_ON[0]); + } else if (gSubMenuSelection < 64) { + sprintf(String, "%02u", gSubMenuSelection); +#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO) + //ST7565_Gauge(4, 1, 63, gSubMenuSelection); + gaugeLine = 4; + gaugeMin = 1; + gaugeMax = 63; +#endif + } + gEeprom.VOLUME_GAIN = gSubMenuSelection; + BK4819_WriteRegister(BK4819_REG_48, + (11u << 12) | // ??? .. 0 ~ 15, doesn't seem to make any difference + (0u << 10) | // AF Rx Gain-1 + (gEeprom.VOLUME_GAIN << 4) | // AF Rx Gain-2 + (gEeprom.DAC_GAIN << 0)); // AF DAC Gain (after Gain-1 and Gain-2) + break; +#endif - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS +#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS case MENU_SET_KEY: strcpy(String, gSubMenu_SET_KEY[gSubMenuSelection]); - break; - #endif + break; +#endif #endif } - #if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO) - if(gaugeLine != 0) - { +#if !defined(ENABLE_SPECTRUM) || !defined(ENABLE_FMRADIO) + if (gaugeLine != 0) { ST7565_Gauge(gaugeLine, gaugeMin, gaugeMax, gSubMenuSelection); } - #endif +#endif - if (!already_printed) - { // we now do multi-line text in a single string + if (!already_printed) { // we now do multi-line text in a single string unsigned int y; unsigned int lines = 1; - unsigned int len = strlen(String); - bool small = false; + unsigned int len = strlen(String); + bool small = false; - if (len > 0) - { + if (len > 0) { // count number of lines - for (i = 0; i < len; i++) - { - if (String[i] == '\n' && i < (len - 1)) - { // found new line char + for (i = 0; i < len; i++) { + if (String[i] == '\n' && i < (len - 1)) { // found new line char lines++; String[i] = 0; // null terminate the line } } - if (lines > 3) - { // use small text + if (lines > 3) { // use small text small = true; if (lines > 7) lines = 7; @@ -1213,34 +1128,10 @@ void UI_DisplayMenu(void) y = 2 - ((lines + 0) / 2); */ - y = (small ? 3 : 2) - (lines / 2); - - // only for SysInf - if(UI_MENU_GetCurrentMenuId() == MENU_VOL) - { - sprintf(edit, "%u.%02uV %u%%", - gBatteryVoltageAverage / 100, gBatteryVoltageAverage % 100, - BATTERY_VoltsToPercent(gBatteryVoltageAverage) - ); - - UI_PrintStringSmallNormal(edit, 54, 127, 1); - - #if defined(ENABLE_SPECTRUM) && defined(ENABLE_FMRADIO) - UI_PrintStringSmallNormal("Basic", 54, 127, 6); - #elif defined(ENABLE_SPECTRUM) - UI_PrintStringSmallNormal("Bandscope", 54, 127, 6); - #elif defined(ENABLE_FMRADIO) - UI_PrintStringSmallNormal("Broadcast", 54, 127, 6); - #elif defined(ENABLE_FEAT_F4HWN_RESCUE_OPS) - UI_PrintStringSmallNormal("RescueOps", 54, 127, 6); - #endif - - y = 2; - } + y = (small ? 3 : 2) - (lines / 2); // draw the text lines - for (i = 0; i < len && lines > 0; lines--) - { + for (i = 0; i < len && lines > 0; lines--) { if (small) UI_PrintStringSmallNormal(String + i, menu_item_x1, menu_item_x2, y); else @@ -1259,8 +1150,8 @@ void UI_DisplayMenu(void) } } - if (UI_MENU_GetCurrentMenuId() == MENU_SLIST1 || UI_MENU_GetCurrentMenuId() == MENU_SLIST2 || UI_MENU_GetCurrentMenuId() == MENU_SLIST3) - { + if (UI_MENU_GetCurrentMenuId() == MENU_SLIST1 || UI_MENU_GetCurrentMenuId() == MENU_SLIST2 || + UI_MENU_GetCurrentMenuId() == MENU_SLIST3) { i = UI_MENU_GetCurrentMenuId() - MENU_SLIST1; char *pPrintStr = String; @@ -1324,21 +1215,20 @@ void UI_DisplayMenu(void) if (UI_MENU_GetCurrentMenuId() == MENU_R_CTCS || UI_MENU_GetCurrentMenuId() == MENU_T_CTCS || - UI_MENU_GetCurrentMenuId() == MENU_R_DCS || + UI_MENU_GetCurrentMenuId() == MENU_R_DCS || UI_MENU_GetCurrentMenuId() == MENU_T_DCS #ifdef ENABLE_DTMF_CALLING || UI_MENU_GetCurrentMenuId() == MENU_D_LIST #endif - ) { + ) { sprintf(String, "%2d", gSubMenuSelection); UI_PrintStringSmallNormal(String, 105, 0, 0); } - if ((UI_MENU_GetCurrentMenuId() == MENU_RESET || - UI_MENU_GetCurrentMenuId() == MENU_MEM_CH || + if ((UI_MENU_GetCurrentMenuId() == MENU_RESET || + UI_MENU_GetCurrentMenuId() == MENU_MEM_CH || UI_MENU_GetCurrentMenuId() == MENU_MEM_NAME || - UI_MENU_GetCurrentMenuId() == MENU_DEL_CH) && gAskForConfirmation) - { // display confirmation + UI_MENU_GetCurrentMenuId() == MENU_DEL_CH) && gAskForConfirmation) { // display confirmation char *pPrintStr = (gAskForConfirmation == 1) ? "SURE?" : "WAIT!"; UI_PrintString(pPrintStr, menu_item_x1, menu_item_x2, 5, 8); } diff --git a/ui/menu.h b/ui/menu.h index de6f5a1..acd78d1 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -24,12 +24,11 @@ #include "settings.h" typedef struct { - const char name[7]; // menu display area only has room for 6 characters - uint8_t menu_id; + const char name[7]; // menu display area only has room for 6 characters + uint8_t menu_id; } t_menu_item; -enum -{ +enum { MENU_SQL = 0, MENU_STEP, MENU_TXP, @@ -41,12 +40,10 @@ enum MENU_OFFSET, MENU_TOT, MENU_W_N, -#ifndef ENABLE_FEAT_F4HWN MENU_SCR, -#endif MENU_BCL, #ifdef ENABLE_FEAT_F4HWN - MENU_TX_LOCK, + MENU_TX_LOCK, #endif MENU_MEM_CH, MENU_DEL_CH, @@ -93,23 +90,23 @@ enum MENU_D_HOLD, #endif MENU_D_PRE, -#ifdef ENABLE_DTMF_CALLING +#ifdef ENABLE_DTMF_CALLING MENU_D_DCD, MENU_D_LIST, #endif MENU_D_LIVE_DEC, - MENU_PONMSG, + MENU_FSKSRC, + MENU_FSKMOD, MENU_ROGER, - MENU_VOL, MENU_BAT_TXT, MENU_AM, #ifdef ENABLE_AM_FIX MENU_AM_FIX, #endif #ifndef ENABLE_FEAT_F4HWN - #ifdef ENABLE_NOAA - MENU_NOAA_S, - #endif +#ifdef ENABLE_NOAA + MENU_NOAA_S, +#endif #endif MENU_RESET, MENU_F_LOCK, @@ -117,11 +114,9 @@ enum MENU_200TX, MENU_350TX, MENU_500TX, -#endif - MENU_350EN, -#ifndef ENABLE_FEAT_F4HWN MENU_SCREN, #endif + MENU_350EN, #ifdef ENABLE_F_CAL_MENU MENU_F_CALI, // reference xtal calibration #endif @@ -139,18 +134,18 @@ enum MENU_SET_MET, MENU_SET_GUI, MENU_SET_TMR, - #ifdef ENABLE_FEAT_F4HWN_NARROWER - MENU_SET_NFM, - #endif - #ifdef ENABLE_FEAT_F4HWN_VOL - MENU_SET_VOL, - #endif - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS - MENU_SET_KEY, - #endif - #ifdef ENABLE_NOAA - MENU_NOAA_S, - #endif +#ifdef ENABLE_FEAT_F4HWN_NARROWER + MENU_SET_NFM, +#endif +#ifdef ENABLE_FEAT_F4HWN_VOL + MENU_SET_VOL, +#endif +#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS + MENU_SET_KEY, +#endif +#ifdef ENABLE_NOAA + MENU_NOAA_S, +#endif #endif MENU_BATCAL, // battery voltage calibration MENU_F1SHRT, @@ -164,72 +159,71 @@ enum extern const uint8_t FIRST_HIDDEN_MENU_ITEM; extern const t_menu_item MenuList[]; -extern const char gSubMenu_TXP[8][6]; -extern const char gSubMenu_SFT_D[3][4]; -extern const char gSubMenu_W_N[2][7]; -extern const char gSubMenu_OFF_ON[2][4]; -extern const char gSubMenu_NA[4]; -extern const char gSubMenu_TOT[11][7]; -extern const char* const gSubMenu_RXMode[4]; +extern const char gSubMenu_TXP[8][6]; +extern const char gSubMenu_SFT_D[3][4]; +extern const char gSubMenu_W_N[2][7]; +extern const char gSubMenu_OFF_ON[2][4]; +extern const char gSubMenu_NA[4]; +extern const char gSubMenu_TOT[11][7]; +extern const char *const gSubMenu_RXMode[4]; #ifdef ENABLE_VOICE - extern const char gSubMenu_VOICE[3][4]; +extern const char gSubMenu_VOICE[3][4]; #endif -extern const char* const gSubMenu_MDF[4]; +extern const char *const gSubMenu_MDF[4]; #ifdef ENABLE_ALARM - extern const char gSubMenu_AL_MOD[2][5]; +extern const char gSubMenu_AL_MOD[2][5]; #endif #ifdef ENABLE_DTMF_CALLING -extern const char gSubMenu_D_RSP[4][11]; +extern const char gSubMenu_D_RSP[4][11]; #endif #ifdef ENABLE_FEAT_F4HWN - extern const char gSubMenu_SET_PWR[7][6]; - extern const char gSubMenu_SET_PTT[2][8]; - extern const char gSubMenu_SET_TOT[4][7]; - extern const char gSubMenu_SET_LCK[2][9]; - extern const char gSubMenu_SET_MET[2][8]; - #ifdef ENABLE_FEAT_F4HWN_NARROWER - extern const char gSubMenu_SET_NFM[2][9]; - #endif - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS - extern const char gSubMenu_SET_KEY[][9]; - #endif +extern const char gSubMenu_SET_PWR[7][6]; +extern const char gSubMenu_SET_PTT[2][8]; +extern const char gSubMenu_SET_TOT[4][7]; +extern const char gSubMenu_SET_LCK[2][9]; +extern const char gSubMenu_SET_MET[2][8]; +#ifdef ENABLE_FEAT_F4HWN_NARROWER +extern const char gSubMenu_SET_NFM[2][9]; +#endif +#ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS +extern const char gSubMenu_SET_KEY[][9]; +#endif #endif -extern const char* const gSubMenu_PTT_ID[5]; -#ifdef ENABLE_FEAT_F4HWN - extern const char gSubMenu_PONMSG[5][8]; -#else - extern const char gSubMenu_PONMSG[4][8]; -#endif -extern const char gSubMenu_ROGER[3][6]; -extern const char gSubMenu_RESET[2][4]; -extern const char* const gSubMenu_F_LOCK[F_LOCK_LEN]; -extern const char gSubMenu_RX_TX[4][6]; -extern const char gSubMenu_BAT_TXT[3][8]; -extern const char gSubMenu_BATTYP[3][9]; +extern const char *const gSubMenu_PTT_ID[5]; +extern const char gSubMenu_FSKMod[6][8]; +extern const char gSubMenu_ROGER[3][6]; +extern const char gSubMenu_RESET[2][4]; +extern const char *const gSubMenu_F_LOCK[F_LOCK_LEN]; +extern const char gSubMenu_RX_TX[4][6]; +extern const char gSubMenu_BAT_TXT[3][8]; +extern const char gSubMenu_BATTYP[3][9]; -#ifndef ENABLE_FEAT_F4HWN - extern const char gSubMenu_SCRAMBLER[11][7]; -#endif +extern const char gSubMenu_SCRAMBLER[11][7]; -typedef struct {char* name; uint8_t id;} t_sidefunction; -extern const uint8_t gSubMenu_SIDEFUNCTIONS_size; +typedef struct { + char *name; + uint8_t id; +} t_sidefunction; +extern const uint8_t gSubMenu_SIDEFUNCTIONS_size; extern const t_sidefunction gSubMenu_SIDEFUNCTIONS[]; - -extern bool gIsInSubMenu; - -extern uint8_t gMenuCursor; -extern int32_t gSubMenuSelection; - -extern char edit_original[17]; -extern char edit[17]; -extern int edit_index; +extern bool gIsInSubMenu; + +extern uint8_t gMenuCursor; + +extern int32_t gSubMenuSelection; + +extern char edit_original[17]; +extern char edit[17]; +extern int edit_index; void UI_DisplayMenu(void); + int UI_MENU_GetCurrentMenuId(); + uint8_t UI_MENU_GetMenuIdx(uint8_t id); #endif diff --git a/ui/status.c b/ui/status.c index bd723c6..dec8140 100644 --- a/ui/status.c +++ b/ui/status.c @@ -84,13 +84,6 @@ void UI_DisplayStatus() unsigned int x1 = x; -#ifdef ENABLE_DTMF_CALLING - if (gSetting_KILLED) { - memset(line + x, 0xFF, 10); - x1 = x + 10; - } - else -#endif { // SCAN indicator if (gScanStateDir != SCAN_OFF || SCANNER_IsScanning()) { if (IS_MR_CHANNEL(gNextMrChannel) && !SCANNER_IsScanning()) { // channel mode diff --git a/ui/welcome.c b/ui/welcome.c index 023cee6..919d7ec 100644 --- a/ui/welcome.c +++ b/ui/welcome.c @@ -28,11 +28,10 @@ #include "version.h" #include "bitmaps.h" -void UI_DisplayReleaseKeys(void) -{ - memset(gStatusLine, 0, sizeof(gStatusLine)); +void UI_DisplayReleaseKeys(void) { + memset(gStatusLine, 0, sizeof(gStatusLine)); #if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV) - ST7565_ContrastAndInv(); + ST7565_ContrastAndInv(); #endif UI_DisplayClear(); @@ -43,160 +42,24 @@ void UI_DisplayReleaseKeys(void) ST7565_BlitFullScreen(); } -void UI_DisplayWelcome(void) -{ - char WelcomeString0[16]; - char WelcomeString1[16]; - char WelcomeString2[16]; - char WelcomeString3[20]; +void UI_DisplayWelcome(void) { - memset(gStatusLine, 0, sizeof(gStatusLine)); + memset(gStatusLine, 0, sizeof(gStatusLine)); #if defined(ENABLE_FEAT_F4HWN_CTR) || defined(ENABLE_FEAT_F4HWN_INV) - ST7565_ContrastAndInv(); + ST7565_ContrastAndInv(); #endif UI_DisplayClear(); - -#ifdef ENABLE_FEAT_F4HWN ST7565_BlitStatusLine(); ST7565_BlitFullScreen(); - - if (gEeprom.POWER_ON_DISPLAY_MODE == POWER_ON_DISPLAY_MODE_NONE || gEeprom.POWER_ON_DISPLAY_MODE == POWER_ON_DISPLAY_MODE_SOUND) { - ST7565_FillScreen(0x00); -#else - if (gEeprom.POWER_ON_DISPLAY_MODE == POWER_ON_DISPLAY_MODE_NONE || gEeprom.POWER_ON_DISPLAY_MODE == POWER_ON_DISPLAY_MODE_FULL_SCREEN) { - ST7565_FillScreen(0xFF); -#endif - } else { - memset(WelcomeString0, 0, sizeof(WelcomeString0)); - memset(WelcomeString1, 0, sizeof(WelcomeString1)); - EEPROM_ReadBuffer(0x0EB0, WelcomeString0, 16); - EEPROM_ReadBuffer(0x0EC0, WelcomeString1, 16); - sprintf(WelcomeString2, "%u.%02uV %u%%", - gBatteryVoltageAverage / 100, - gBatteryVoltageAverage % 100, - BATTERY_VoltsToPercent(gBatteryVoltageAverage)); + UI_DrawLineBuffer(gFrameBuffer, 0, 31, 127, 31, 1); // Be ware, status zone = 8 lines, the rest = 56 ->total 64 - if (gEeprom.POWER_ON_DISPLAY_MODE == POWER_ON_DISPLAY_MODE_VOLTAGE) - { - strcpy(WelcomeString0, "VOLTAGE"); - strcpy(WelcomeString1, WelcomeString2); - } - else if(gEeprom.POWER_ON_DISPLAY_MODE == POWER_ON_DISPLAY_MODE_ALL) - { - if(strlen(WelcomeString0) == 0 && strlen(WelcomeString1) == 0) - { - strcpy(WelcomeString0, "WELCOME"); - strcpy(WelcomeString1, WelcomeString2); - } - else if(strlen(WelcomeString0) == 0 || strlen(WelcomeString1) == 0) - { - if(strlen(WelcomeString0) == 0) - { - strcpy(WelcomeString0, WelcomeString1); - } - strcpy(WelcomeString1, WelcomeString2); - } - } - else if(gEeprom.POWER_ON_DISPLAY_MODE == POWER_ON_DISPLAY_MODE_MESSAGE) - { - if(strlen(WelcomeString0) == 0) - { - strcpy(WelcomeString0, "WELCOME"); - } - - if(strlen(WelcomeString1) == 0) - { - strcpy(WelcomeString1, "BIENVENUE"); - } - } - - UI_PrintString(WelcomeString0, 0, 127, 0, 10); - UI_PrintString(WelcomeString1, 0, 127, 2, 10); - -#ifdef ENABLE_FEAT_F4HWN - UI_PrintStringSmallNormal(Version, 0, 128, 4); - - UI_DrawLineBuffer(gFrameBuffer, 0, 31, 127, 31, 1); // Be ware, status zone = 8 lines, the rest = 56 ->total 64 - - for (uint8_t i = 18; i < 110; i++) - { - gFrameBuffer[4][i] ^= 0xFF; - } - - sprintf(WelcomeString3, "%s Edition", Edition); - UI_PrintStringSmallNormal(WelcomeString3, 0, 127, 6); - - /* - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS - #if ENABLE_FEAT_F4HWN_RESCUE_OPS > 1 - UI_PrintStringSmallNormal(Edition, 18, 0, 6); - if(gEeprom.MENU_LOCK == true) { - memcpy(gFrameBuffer[6] + 103, BITMAP_Ready, sizeof(BITMAP_Ready)); - } - else - { - memcpy(gFrameBuffer[6] + 103, BITMAP_NotReady, sizeof(BITMAP_NotReady)); - } - #else - UI_PrintStringSmallNormal(Edition, 18, 0, 5); - memcpy(gFrameBuffer[5] + 103, BITMAP_Ready, sizeof(BITMAP_Ready)); - - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS - UI_PrintStringSmallNormal("RescueOps", 18, 0, 6); - if(gEeprom.MENU_LOCK == true) { - memcpy(gFrameBuffer[6] + 103, BITMAP_Ready, sizeof(BITMAP_Ready)); - } - else - { - memcpy(gFrameBuffer[6] + 103, BITMAP_NotReady, sizeof(BITMAP_NotReady)); - } - #endif - #endif - #else - UI_PrintStringSmallNormal(Edition, 18, 0, 6); - memcpy(gFrameBuffer[6] + 103, BITMAP_Ready, sizeof(BITMAP_Ready)); - #endif - */ - - /* - #ifdef ENABLE_SPECTRUM - #ifdef ENABLE_FMRADIO - UI_PrintStringSmallNormal(Based, 0, 127, 5); - UI_PrintStringSmallNormal(Credits, 0, 127, 6); - #else - UI_PrintStringSmallNormal("Bandscope ", 0, 127, 5); - memcpy(gFrameBuffer[5] + 95, BITMAP_Ready, sizeof(BITMAP_Ready)); - - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS - UI_PrintStringSmallNormal("RescueOps ", 0, 127, 6); - if(gEeprom.MENU_LOCK == true) { - memcpy(gFrameBuffer[6] + 95, BITMAP_Ready, sizeof(BITMAP_Ready)); - } - #else - UI_PrintStringSmallNormal("Broadcast ", 0, 127, 6); - #endif - #endif - #else - #ifdef ENABLE_FEAT_F4HWN_RESCUE_OPS - UI_PrintStringSmallNormal("RescueOps ", 0, 127, 5); - if(gEeprom.MENU_LOCK == true) { - memcpy(gFrameBuffer[5] + 95, BITMAP_Ready, sizeof(BITMAP_Ready)); - } - #else - UI_PrintStringSmallNormal("Bandscope ", 0, 127, 5); - #endif - UI_PrintStringSmallNormal("Broadcast ", 0, 127, 6); - memcpy(gFrameBuffer[6] + 95, BITMAP_Ready, sizeof(BITMAP_Ready)); - #endif - */ -#else - UI_PrintStringSmallNormal(Version, 0, 127, 6); -#endif - - //ST7565_BlitStatusLine(); // blank status line : I think it's useless - ST7565_BlitFullScreen(); + for (uint8_t i = 18; i < 110; i++) { + gFrameBuffer[4][i] ^= 0xFF; } + + //ST7565_BlitStatusLine(); // blank status line : I think it's useless + ST7565_BlitFullScreen(); } diff --git a/version.c b/version.c index 4fd5929..66599ae 100644 --- a/version.c +++ b/version.c @@ -7,7 +7,6 @@ #ifdef ENABLE_FEAT_F4HWN const char Version[] = AUTHOR_STRING_2 " " VERSION_STRING_2; - const char Edition[] = EDITION_STRING; #else const char Version[] = AUTHOR_STRING VER; #endif diff --git a/version.h b/version.h index 0af7d1c..e8e84dc 100644 --- a/version.h +++ b/version.h @@ -20,8 +20,4 @@ extern const char Version[]; extern const char UART_Version[]; -#endif - -#ifdef ENABLE_FEAT_F4HWN -extern const char Edition[]; -#endif +#endif \ No newline at end of file