From b6334e3b91091a9a8ff1aa4a088b6fc2c4a98df0 Mon Sep 17 00:00:00 2001 From: Armel FAUVEAU Date: Wed, 31 Jul 2024 03:21:39 +0200 Subject: [PATCH] F Lock is a trap... so refactoring --- Makefile | 4 ++-- app/menu.c | 8 ++++++++ bitmaps.c | 17 +++++++++++++---- bitmaps.h | 5 +++-- main.c | 4 ++-- radio.c | 18 ++++++++++++++---- radio.h | 1 + settings.c | 1 + ui/main.c | 20 ++++++++++++++------ ui/menu.c | 7 +++++++ ui/menu.h | 3 +++ 11 files changed, 68 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 80ea987..50fca58 100644 --- a/Makefile +++ b/Makefile @@ -44,8 +44,8 @@ ENABLE_FEAT_F4HWN ?= 1 ENABLE_FEAT_F4HWN_SCREENSHOT ?= 0 ENABLE_FEAT_F4HWN_SPECTRUM ?= 1 ENABLE_FEAT_F4HWN_CHARGING_C ?= 1 -ENABLE_FEAT_F4HWN_PMR ?= 1 -ENABLE_FEAT_F4HWN_GMRS_FRS_MURS ?= 1 +ENABLE_FEAT_F4HWN_PMR ?= 0 +ENABLE_FEAT_F4HWN_GMRS_FRS_MURS ?= 0 ENABLE_FEAT_F4HWN_CA ?= 1 # ---- DEBUGGING ---- diff --git a/app/menu.c b/app/menu.c index a4d7f11..1f7ca9b 100644 --- a/app/menu.c +++ b/app/menu.c @@ -390,6 +390,7 @@ int MENU_GetLimits(uint8_t menu_id, int32_t *pMin, int32_t *pMax) *pMin = 1; *pMax = 15; break; + case MENU_TX_LOCK: case MENU_SET_INV: //*pMin = 0; *pMax = ARRAY_SIZE(gSubMenu_OFF_ON) - 1; @@ -894,6 +895,10 @@ void MENU_AcceptSetting(void) case MENU_SET_GUI: gSetting_set_gui = gSubMenuSelection; break; + case MENU_TX_LOCK: + gTxVfo->TX_LOCK = gSubMenuSelection; + gRequestSaveChannel = 1; + return; #endif } @@ -1311,6 +1316,9 @@ void MENU_ShowCurrentSetting(void) case MENU_SET_GUI: gSubMenuSelection = gSetting_set_gui; break; + case MENU_TX_LOCK: + gSubMenuSelection = gTxVfo->TX_LOCK; + break; #endif default: diff --git a/bitmaps.c b/bitmaps.c index fd9c55e..fa746a4 100644 --- a/bitmaps.c +++ b/bitmaps.c @@ -135,9 +135,19 @@ const uint8_t BITMAP_Antenna[5] = 0b00000011 }; -const uint8_t BITMAP_VFO_Default[8] = +const uint8_t BITMAP_VFO_Lock[7] = +{ + 0b01111100, + 0b01000110, + 0b01000101, + 0b01000101, + 0b01000101, + 0b01000110, + 0b01111100, +}; + +const uint8_t BITMAP_VFO_Default[7] = { - 0b00000000, 0b01111111, 0b01111111, 0b00111110, @@ -147,9 +157,8 @@ const uint8_t BITMAP_VFO_Default[8] = 0b00001000 }; -const uint8_t BITMAP_VFO_NotDefault[8] = +const uint8_t BITMAP_VFO_NotDefault[7] = { - 0b00000000, 0b01000001, 0b01000001, 0b00100010, diff --git a/bitmaps.h b/bitmaps.h index 39d23fd..774c7ea 100644 --- a/bitmaps.h +++ b/bitmaps.h @@ -28,8 +28,9 @@ extern const uint8_t BITMAP_Ready[7]; #endif extern const uint8_t BITMAP_Antenna[5]; -extern const uint8_t BITMAP_VFO_Default[8]; -extern const uint8_t BITMAP_VFO_NotDefault[8]; +extern const uint8_t BITMAP_VFO_Default[7]; +extern const uint8_t BITMAP_VFO_NotDefault[7]; +extern const uint8_t BITMAP_VFO_Lock[7]; extern const uint8_t BITMAP_ScanList0[7]; extern const uint8_t BITMAP_ScanList1[7]; extern const uint8_t BITMAP_ScanList2[7]; diff --git a/main.c b/main.c index 5bbc664..e6fedb6 100644 --- a/main.c +++ b/main.c @@ -129,9 +129,9 @@ void Main(void) gEeprom.KEY_LOCK = 0; SETTINGS_SaveSettings(); #ifndef ENABLE_VOX - gMenuCursor = 62; // move to hidden section, fix me if change... !!! Remove VOX and Mic Bar + gMenuCursor = 63; // move to hidden section, fix me if change... !!! Remove VOX and Mic Bar #else - gMenuCursor = 64; // move to hidden section, fix me if change... !!! + gMenuCursor = 65; // move to hidden section, fix me if change... !!! #endif gSubMenuSelection = gSetting_F_LOCK; #endif diff --git a/radio.c b/radio.c index 814acde..634b893 100644 --- a/radio.c +++ b/radio.c @@ -141,6 +141,7 @@ void RADIO_InitInfo(VFO_Info_t *pInfo, const uint8_t ChannelSave, const uint32_t pInfo->StepFrequency = gStepFrequencyTable[pInfo->STEP_SETTING]; pInfo->CHANNEL_SAVE = ChannelSave; pInfo->FrequencyReverse = false; + pInfo->TX_LOCK = true; pInfo->OUTPUT_POWER = OUTPUT_POWER_LOW1; pInfo->freq_config_RX.Frequency = Frequency; pInfo->freq_config_TX.Frequency = Frequency; @@ -250,7 +251,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure { uint8_t tmp; uint8_t data[8]; - + // *************** EEPROM_ReadBuffer(base + 8, data, sizeof(data)); @@ -332,6 +333,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure pVfo->CHANNEL_BANDWIDTH = BK4819_FILTER_BW_WIDE; pVfo->OUTPUT_POWER = OUTPUT_POWER_LOW1; pVfo->BUSY_CHANNEL_LOCK = false; + pVfo->TX_LOCK = true; } else { @@ -340,6 +342,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure pVfo->CHANNEL_BANDWIDTH = !!((d4 >> 1) & 1u); pVfo->OUTPUT_POWER = ((d4 >> 2) & 7u); pVfo->BUSY_CHANNEL_LOCK = !!((d4 >> 5) & 1u); + pVfo->TX_LOCK = !!((d4 >> 6) & 1u); } if (data[5] == 0xFF) @@ -1053,9 +1056,16 @@ void RADIO_PrepareTX(void) RADIO_SelectCurrentVfo(); - if(TX_freq_check(gCurrentVfo->pTX->Frequency) != 0 -#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) - && gAlarmState != ALARM_STATE_SITE_ALARM +#ifdef ENABLE_FEAT_F4HWN + if(TX_freq_check(gCurrentVfo->pTX->Frequency) != 0 && gCurrentVfo->TX_LOCK == true + #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) + && gAlarmState != ALARM_STATE_SITE_ALARM + #endif +#else + if(TX_freq_check(gCurrentVfo->pTX->Frequency) != 0 + #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) + && gAlarmState != ALARM_STATE_SITE_ALARM + #endif #endif ){ // TX frequency not allowed diff --git a/radio.h b/radio.h index 12e6594..5320973 100644 --- a/radio.h +++ b/radio.h @@ -107,6 +107,7 @@ typedef struct VFO_Info_t uint8_t SquelchOpenGlitchThresh; STEP_Setting_t STEP_SETTING; + uint8_t TX_LOCK; uint8_t OUTPUT_POWER; uint8_t TXP_CalculatedSetting; bool FrequencyReverse; diff --git a/settings.c b/settings.c index 5a36dcc..dddcdd3 100644 --- a/settings.c +++ b/settings.c @@ -745,6 +745,7 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, 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) diff --git a/ui/main.c b/ui/main.c index 8e68aa7..1be3346 100644 --- a/ui/main.c +++ b/ui/main.c @@ -295,14 +295,14 @@ void DisplayRSSIBar(const bool now) switch(RxBlink) { case 0: - UI_PrintStringSmallBold("RX", 14, 0, RxLine); + UI_PrintStringSmallBold("RX", 8, 0, RxLine); break; case 1: - UI_PrintStringSmallBold("RX", 14, 0, RxLine); + UI_PrintStringSmallBold("RX", 8, 0, RxLine); RxBlink = 2; break; case 2: - for (uint8_t i = 14; i < 30; i++) + for (uint8_t i = 8; i < 24; i++) { gFrameBuffer[RxLine][i] = 0x00; } @@ -758,6 +758,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(false)) + 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 @@ -770,7 +778,7 @@ void UI_DisplayMain(void) if (activeTxVFO == vfo_num) { // show the TX symbol mode = VFO_MODE_TX; - UI_PrintStringSmallBold("TX", 14, 0, line); + UI_PrintStringSmallBold("TX", 8, 0, line); } } } @@ -793,7 +801,7 @@ void UI_DisplayMain(void) RxBlink = 0; } #else - UI_PrintStringSmallBold("RX", 14, 0, line); + UI_PrintStringSmallBold("RX", 8, 0, line); #endif } #ifdef ENABLE_FEAT_F4HWN @@ -801,7 +809,7 @@ void UI_DisplayMain(void) { if(RxOnVfofrequency == frequency && !isMainOnly(false)) { - UI_PrintStringSmallNormal(">>", 14, 0, line); + UI_PrintStringSmallNormal(">>", 8, 0, line); //memcpy(p_line0 + 14, BITMAP_VFO_Default, sizeof(BITMAP_VFO_Default)); } diff --git a/ui/menu.c b/ui/menu.c index c07235d..fbe6a53 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -55,6 +55,9 @@ const t_menu_item MenuList[] = {"BusyCL", MENU_BCL }, // was "BCL" {"Compnd", MENU_COMPAND }, {"Mode", MENU_AM }, // was "AM" +#ifdef ENABLE_FEAT_F4HWN + {"TXLock", MENU_TX_LOCK }, +#endif {"ScAdd1", MENU_S_ADD1 }, {"ScAdd2", MENU_S_ADD2 }, {"ScAdd3", MENU_S_ADD3 }, @@ -989,6 +992,10 @@ void UI_DisplayMenu(void) ST7565_ContrastAndInv(); break; + case MENU_TX_LOCK: + strcpy(String, gSubMenu_OFF_ON[gSubMenuSelection]); + break; + case MENU_SET_LCK: strcpy(String, gSubMenu_SET_LCK[gSubMenuSelection]); break; diff --git a/ui/menu.h b/ui/menu.h index ee20b22..4f40530 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -45,6 +45,9 @@ enum MENU_SCR, #endif MENU_BCL, +#ifdef ENABLE_FEAT_F4HWN + MENU_TX_LOCK, +#endif MENU_MEM_CH, MENU_DEL_CH, MENU_MEM_NAME,