diff --git a/Makefile b/Makefile index 28cb05b..31013ba 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # ---- STOCK QUANSHENG FERATURES ---- ENABLE_FMRADIO ?= 0 ENABLE_UART ?= 1 -ENABLE_AIRCOPY ?= 1 +ENABLE_AIRCOPY ?= 0 ENABLE_NOAA ?= 0 ENABLE_VOICE ?= 0 ENABLE_VOX ?= 1 @@ -17,7 +17,7 @@ ENABLE_DTMF_CALLING ?= 0 ENABLE_FLASHLIGHT ?= 1 # ---- CUSTOM MODS ---- -ENABLE_SPECTRUM ?= 1 +ENABLE_SPECTRUM ?= 0 ENABLE_BIG_FREQ ?= 1 ENABLE_SMALL_BOLD ?= 1 ENABLE_CUSTOM_MENU_LAYOUT ?= 1 @@ -49,6 +49,7 @@ ENABLE_FEAT_F4HWN_SLEEP ?= 1 ENABLE_FEAT_F4HWN_RESTORE_SCAN ?= 1 ENABLE_FEAT_F4HWN_NARROWER ?= 1 ENABLE_FEAT_F4HWN_CONTRAST ?= 1 +ENABLE_FEAT_F4HWN_MENU_LOCK ?= 0 ENABLE_FEAT_F4HWN_VOL ?= 0 ENABLE_FEAT_F4HWN_RESET_CHANNEL ?= 0 ENABLE_FEAT_F4HWN_PMR ?= 0 @@ -225,6 +226,8 @@ ifeq ($(ENABLE_FEAT_F4HWN),1) AUTHOR_STRING_2 ?= F4HWN VERSION_STRING_2 ?= v3.7 + EDITION_STRING ?= Custom + AUTHOR_STRING ?= $(AUTHOR_STRING_1)+$(AUTHOR_STRING_2) VERSION_STRING ?= $(VERSION_STRING_2) else @@ -412,6 +415,7 @@ ifeq ($(ENABLE_FEAT_F4HWN),1) CFLAGS += -DSQL_TONE=550 # For SA818, use 600 and python3 sa818.py --port /dev/ttyS2 radio --frequency 434.975 --ctcss 71.9 --tail Open CFLAGS += -DAUTHOR_STRING_1=\"$(AUTHOR_STRING_1)\" -DVERSION_STRING_1=\"$(VERSION_STRING_1)\" CFLAGS += -DAUTHOR_STRING_2=\"$(AUTHOR_STRING_2)\" -DVERSION_STRING_2=\"$(VERSION_STRING_2)\" + CFLAGS += -DEDITION_STRING=\"$(EDITION_STRING)\" else CFLAGS += -DSQL_TONE=550 endif @@ -439,6 +443,9 @@ endif ifeq ($(ENABLE_FEAT_F4HWN_CONTRAST),1) CFLAGS += -DENABLE_FEAT_F4HWN_CONTRAST endif +ifneq ($(filter $(ENABLE_FEAT_F4HWN_MENU_LOCK),1 2),) + CFLAGS += -DENABLE_FEAT_F4HWN_MENU_LOCK=$(ENABLE_FEAT_F4HWN_MENU_LOCK) +endif ifeq ($(ENABLE_FEAT_F4HWN_VOL),1) CFLAGS += -DENABLE_FEAT_F4HWN_VOL endif diff --git a/app/app.c b/app/app.c index dd2c502..32ec4e6 100644 --- a/app/app.c +++ b/app/app.c @@ -1398,7 +1398,7 @@ void APP_TimeSlice10ms(void) return; #endif -#ifndef ENABLE_FEAT_F4HWN +#if !defined(ENABLE_FEAT_F4HWN) || defined(ENABLE_FEAT_F4HWN_MENU_LOCK) #ifdef ENABLE_FLASHLIGHT FlashlightTimeSlice(); #endif diff --git a/app/flashlight.c b/app/flashlight.c index 28a48b9..fad618b 100644 --- a/app/flashlight.c +++ b/app/flashlight.c @@ -5,7 +5,7 @@ #include "flashlight.h" -#ifndef ENABLE_FEAT_F4HWN +#if !defined(ENABLE_FEAT_F4HWN) || defined(ENABLE_FEAT_F4HWN_MENU_LOCK) enum FlashlightMode_t gFlashLightState; void FlashlightTimeSlice() diff --git a/app/flashlight.h b/app/flashlight.h index 9c0a7c4..feca80a 100644 --- a/app/flashlight.h +++ b/app/flashlight.h @@ -5,7 +5,7 @@ #include -#ifndef ENABLE_FEAT_F4HWN +#if !defined(ENABLE_FEAT_F4HWN) || defined(ENABLE_FEAT_F4HWN_MENU_LOCK) enum FlashlightMode_t { FLASHLIGHT_OFF = 0, FLASHLIGHT_ON, diff --git a/app/main.c b/app/main.c index a7a8ab1..5a20bfa 100644 --- a/app/main.c +++ b/app/main.c @@ -84,6 +84,12 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) { uint8_t Vfo = gEeprom.TX_VFO; +#ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + if(gEeprom.MENU_LOCK == true) { + return; // prevent F function if MENU LOCK is true + } +#endif + if (gScreenToDisplay == DISPLAY_MENU) { gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; @@ -680,11 +686,19 @@ static void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld) return; } + #ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + if(gEeprom.MENU_LOCK == false) { + #endif + gFlagRefreshSetting = true; gRequestDisplayScreen = DISPLAY_MENU; #ifdef ENABLE_VOICE gAnotherVoiceID = VOICE_ID_MENU; #endif + + #ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + } + #endif } else { gRequestDisplayScreen = DISPLAY_MAIN; @@ -694,6 +708,13 @@ static void MAIN_Key_MENU(bool bKeyPressed, bool bKeyHeld) static void MAIN_Key_STAR(bool bKeyPressed, bool bKeyHeld) { + +#ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + if(gEeprom.MENU_LOCK == true) { + return; // prevent F function if MENU LOCK is true + } +#endif + if (gCurrentFunction == FUNCTION_TRANSMIT) return; @@ -927,7 +948,13 @@ void MAIN_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) MAIN_Key_STAR(bKeyPressed, bKeyHeld); break; case KEY_F: - GENERIC_Key_F(bKeyPressed, bKeyHeld); + #ifndef ENABLE_FEAT_F4HWN_MENU_LOCK + GENERIC_Key_F(bKeyPressed, bKeyHeld); + #else + if(gEeprom.MENU_LOCK == false) { + GENERIC_Key_F(bKeyPressed, bKeyHeld); + } + #endif break; case KEY_PTT: GENERIC_Key_PTT(bKeyPressed); diff --git a/bitmaps.c b/bitmaps.c index 0a2253a..088007b 100644 --- a/bitmaps.c +++ b/bitmaps.c @@ -291,6 +291,17 @@ const uint8_t BITMAP_Ready[7] = 0b00000010, }; +const uint8_t BITMAP_NotReady[7] = +{ + 0b00000000, + 0b01000010, + 0b00100100, + 0b00011000, + 0b00100100, + 0b01000010, + 0b00000000, +}; + const uint8_t BITMAP_PowerUser[3] = { // 'arrow' symbol 0b00111110, diff --git a/bitmaps.h b/bitmaps.h index a7853ec..b821a6c 100644 --- a/bitmaps.h +++ b/bitmaps.h @@ -22,6 +22,7 @@ extern const uint8_t BITMAP_BatteryLevel[2]; extern const uint8_t BITMAP_BatteryLevel1[17]; extern const uint8_t BITMAP_USB_C[9]; extern const uint8_t BITMAP_Ready[7]; +extern const uint8_t BITMAP_NotReady[7]; #ifdef ENABLE_VOX extern const uint8_t gFontVox[2][6]; diff --git a/compile-with-docker.sh b/compile-with-docker.sh index dce247e..cb37814 100755 --- a/compile-with-docker.sh +++ b/compile-with-docker.sh @@ -7,6 +7,7 @@ docker build -t $IMAGE_NAME . custom() { echo "Custom compilation..." docker run --rm -v "${PWD}/compiled-firmware/:/app/compiled-firmware" $IMAGE_NAME /bin/bash -c "rm ./compiled-firmware/*; cd /app && make -s \ + EDITION_STRING=Custom \ TARGET=f4hwn.custom \ && cp f4hwn.custom* compiled-firmware/" } @@ -18,6 +19,8 @@ bandscope() { ENABLE_FMRADIO=0 \ ENABLE_AIRCOPY=1 \ ENABLE_NOAA=0 \ + ENABLE_FEAT_F4HWN_MENU_LOCK=0 \ + EDITION_STRING=Bandscope \ TARGET=f4hwn.bandscope \ && cp f4hwn.bandscope* compiled-firmware/" } @@ -29,6 +32,8 @@ broadcast() { ENABLE_FMRADIO=1 \ ENABLE_AIRCOPY=1 \ ENABLE_NOAA=0 \ + EDITION_STRING=Broadcast \ + ENABLE_FEAT_F4HWN_MENU_LOCK=0 \ TARGET=f4hwn.broadcast \ && cp f4hwn.broadcast* compiled-firmware/" } @@ -46,19 +51,35 @@ voxless() { ENABLE_FEAT_F4HWN_RESTORE_SCAN=0 \ ENABLE_FEAT_F4HWN_CHARGING_C=0 \ ENABLE_FEAT_F4HWN_NARROWER=0 \ + ENABLE_FEAT_F4HWN_MENU_LOCK=0 \ + EDITION_STRING=Voxless \ TARGET=f4hwn.voxless \ && cp f4hwn.voxless* compiled-firmware/" } -light() { - echo "Light compilation..." +standard() { + echo "Standard compilation..." docker run --rm -v "${PWD}/compiled-firmware:/app/compiled-firmware" $IMAGE_NAME /bin/bash -c "cd /app && make -s \ ENABLE_SPECTRUM=0 \ ENABLE_FMRADIO=0 \ ENABLE_AIRCOPY=0 \ + ENABLE_NOAA=0 \ + EDITION_STRING=Standard \ + TARGET=f4hwn.standard \ + && cp f4hwn.standard* compiled-firmware/" +} + +rescueops() { + echo "RescueOps compilation..." + docker run --rm -v "${PWD}/compiled-firmware:/app/compiled-firmware" $IMAGE_NAME /bin/bash -c "cd /app && make -s \ + ENABLE_SPECTRUM=0 \ + ENABLE_FMRADIO=0 \ + ENABLE_AIRCOPY=1 \ ENABLE_NOAA=1 \ - TARGET=f4hwn.light \ - && cp f4hwn.light* compiled-firmware/" + ENABLE_FEAT_F4HWN_MENU_LOCK=2 \ + EDITION_STRING=RescueOps \ + TARGET=f4hwn.rescueops \ + && cp f4hwn.rescueops* compiled-firmware/" } case "$1" in @@ -74,17 +95,21 @@ case "$1" in voxless) voxless ;; - light) - light + standard) + standard + ;; + rescueops) + rescueops ;; all) bandscope broadcast voxless - light + standard + rescueops ;; *) - echo "Usage: $0 {custom|bandscope|broadcast|voxless|all}" + echo "Usage: $0 {custom|bandscope|broadcast|voxless|standard|all}" exit 1 ;; esac \ No newline at end of file diff --git a/helper/boot.c b/helper/boot.c index 9f69735..27cc369 100644 --- a/helper/boot.c +++ b/helper/boot.c @@ -44,6 +44,13 @@ BOOT_Mode_t BOOT_GetMode(void) SYSTEM_DelayMs(20); } + #ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + if (Keys[0] == KEY_MENU) + { + return BOOT_MODE_MENU_LOCK; // Menu pressed + } + #endif + if (Keys[0] == Keys[1]) { gKeyReading0 = Keys[0]; diff --git a/helper/boot.h b/helper/boot.h index e04c462..3222d40 100644 --- a/helper/boot.h +++ b/helper/boot.h @@ -24,6 +24,9 @@ enum BOOT_Mode_t { BOOT_MODE_NORMAL = 0, BOOT_MODE_F_LOCK, + #ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + BOOT_MODE_MENU_LOCK, + #endif #ifdef ENABLE_AIRCOPY BOOT_MODE_AIRCOPY #endif diff --git a/main.c b/main.c index db7ee7c..8b0794a 100644 --- a/main.c +++ b/main.c @@ -129,7 +129,30 @@ void Main(void) AM_fix_init(); #endif - const BOOT_Mode_t BootMode = BOOT_GetMode(); + BOOT_Mode_t BootMode = BOOT_GetMode(); + +#ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + if (BootMode == BOOT_MODE_MENU_LOCK) + { + gEeprom.MENU_LOCK = !gEeprom.MENU_LOCK; + SETTINGS_SaveSettings(); + } + + if(gEeprom.MENU_LOCK == true) // Force Main Only + { + gEeprom.DUAL_WATCH = 0; + gEeprom.CROSS_BAND_RX_TX = 0; + //gFlagReconfigureVfos = true; + //gUpdateStatus = true; + } +#endif + +#ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + if (BootMode == BOOT_MODE_F_LOCK && gEeprom.MENU_LOCK == true) + { + BootMode = BOOT_MODE_NORMAL; + } +#endif if (BootMode == BOOT_MODE_F_LOCK) { diff --git a/settings.c b/settings.c index 1aa2afb..9c7e0e9 100644 --- a/settings.c +++ b/settings.c @@ -51,7 +51,12 @@ void SETTINGS_InitEEPROM(void) #ifdef ENABLE_NOAA gEeprom.NOAA_AUTO_SCAN = (Data[3] < 2) ? Data[3] : false; #endif - gEeprom.KEY_LOCK = (Data[4] < 2) ? Data[4] : false; + #ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + gEeprom.KEY_LOCK = (Data[4] & 0x01) != 0; + gEeprom.MENU_LOCK = (Data[4] & 0x02) != 0; + #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; @@ -590,7 +595,13 @@ void SETTINGS_SaveSettings(void) #else State[3] = false; #endif - State[4] = gEeprom.KEY_LOCK; + + #ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + State[4] = (gEeprom.KEY_LOCK ? 0x01 : 0) | (gEeprom.MENU_LOCK ? 0x02 :0); + #else + State[4] = gEeprom.KEY_LOCK; + #endif + #ifdef ENABLE_VOX State[5] = gEeprom.VOX_SWITCH; State[6] = gEeprom.VOX_LEVEL; diff --git a/settings.h b/settings.h index d104b2b..bec443b 100644 --- a/settings.h +++ b/settings.h @@ -185,6 +185,9 @@ typedef struct { bool KEY_LOCK; #ifdef ENABLE_FEAT_F4HWN bool KEY_LOCK_PTT; +#endif +#ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + bool MENU_LOCK; #endif bool VOX_SWITCH; uint8_t VOX_LEVEL; diff --git a/ui/welcome.c b/ui/welcome.c index 48cd088..bdef9f3 100644 --- a/ui/welcome.c +++ b/ui/welcome.c @@ -128,6 +128,38 @@ void UI_DisplayWelcome(void) gFrameBuffer[4][i] ^= 0xFF; } + + #ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + #if ENABLE_FEAT_F4HWN_MENU_LOCK > 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_MENU_LOCK + 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); @@ -135,13 +167,29 @@ void UI_DisplayWelcome(void) #else UI_PrintStringSmallNormal("Bandscope ", 0, 127, 5); memcpy(gFrameBuffer[5] + 95, BITMAP_Ready, sizeof(BITMAP_Ready)); - UI_PrintStringSmallNormal("Broadcast ", 0, 127, 6); + + #ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + 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 - UI_PrintStringSmallNormal("Bandscope ", 0, 127, 5); + #ifdef ENABLE_FEAT_F4HWN_MENU_LOCK + 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 diff --git a/version.c b/version.c index f9c28ad..4fd5929 100644 --- a/version.c +++ b/version.c @@ -7,8 +7,7 @@ #ifdef ENABLE_FEAT_F4HWN const char Version[] = AUTHOR_STRING_2 " " VERSION_STRING_2; - const char Based[] = "based on"; - const char Credits[] = AUTHOR_STRING_1 " " VERSION_STRING_1; + const char Edition[] = EDITION_STRING; #else const char Version[] = AUTHOR_STRING VER; #endif diff --git a/version.h b/version.h index a19174f..0af7d1c 100644 --- a/version.h +++ b/version.h @@ -23,6 +23,5 @@ extern const char UART_Version[]; #endif #ifdef ENABLE_FEAT_F4HWN - extern const char Credits[]; - extern const char Based[]; +extern const char Edition[]; #endif