diff --git a/Makefile b/Makefile index 1f11a4a..c8ff385 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,6 @@ ENABLE_F_CAL_MENU := 0 ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1 ENABLE_MAIN_KEY_HOLD := 1 ENABLE_BOOT_BEEPS := 0 -ENABLE_COMPANDER := 1 ENABLE_SHOW_CHARGE_LEVEL := 1 ENABLE_REVERSE_BAT_SYMBOL := 1 ENABLE_CODE_SCAN_TIMEOUT := 0 @@ -232,9 +231,6 @@ endif ifeq ($(ENABLE_BOOT_BEEPS),1) CFLAGS += -DENABLE_BOOT_BEEPS endif -ifeq ($(ENABLE_COMPANDER),1) - CFLAGS += -DENABLE_COMPANDER -endif ifeq ($(ENABLE_SHOW_CHARGE_LEVEL),1) CFLAGS += -DENABLE_SHOW_CHARGE_LEVEL endif diff --git a/README.md b/README.md index 637fe80..a17ee5e 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,6 @@ ENABLE_F_CAL_MENU := 0 enable/disable the radios hidden freque ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1 standard CTCSS tail phase shift rather than QS's own 55Hz tone method ENABLE_MAIN_KEY_HOLD := 1 initial F-key press not needed, instead just hold down keys 0-9 to access the secondary butt functions ENABLE_BOOT_BEEPS := 0 gives user audio feedback on volume knob position at boot-up -ENABLE_COMPANDER := 0 compander option (per channel) ENABLE_SHOW_CHARGE_LEVEL := 0 show the charge level when the radio is on charge ENABLE_REVERSE_BAT_SYMBOL := 1 mirror the battery symbol on the status bar (+ pole on the right) ENABLE_CODE_SCAN_TIMEOUT := 0 enable/disable 32-sec CTCSS/DCS scan timeout (press exit butt instead of time-out to end scan) diff --git a/app/app.c b/app/app.c index 86b0588..5a8d112 100644 --- a/app/app.c +++ b/app/app.c @@ -486,7 +486,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix) gEnableSpeaker = true; - if (gSetting_backlight_on_tx_rx) + if (gSetting_backlight_on_tx_rx >= 2) BACKLIGHT_TurnOn(); if (gScanState != SCAN_OFF) @@ -2104,7 +2104,8 @@ static void APP_ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) } else { - BACKLIGHT_TurnOn(); + if (Key != KEY_PTT) + BACKLIGHT_TurnOn(); if (Key == KEY_EXIT && bKeyHeld) { // exit key held pressed diff --git a/app/menu.c b/app/menu.c index fcf0ef8..444bf0d 100644 --- a/app/menu.c +++ b/app/menu.c @@ -199,12 +199,11 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax) *pMax = ARRAY_SIZE(gSubMenu_RESET) - 1; break; - #ifdef ENABLE_COMPANDER - case MENU_COMPAND: - *pMin = 0; - *pMax = ARRAY_SIZE(gSubMenu_Compand) - 1; - break; - #endif + case MENU_COMPAND: + case MENU_ABR_ON_TX_RX: + *pMin = 0; + *pMax = ARRAY_SIZE(gSubMenu_RX_TX) - 1; + break; #ifdef ENABLE_AM_FIX_TEST1 case MENU_AM_FIX_TEST1: @@ -219,7 +218,6 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax) #ifdef ENABLE_AUDIO_BAR case MENU_MIC_BAR: #endif - case MENU_ABR_ON_TX_RX: case MENU_BCL: case MENU_BEEP: case MENU_AUTOLK: @@ -601,15 +599,13 @@ void MENU_AcceptSetting(void) break; #endif - #ifdef ENABLE_COMPANDER - case MENU_COMPAND: - gTxVfo->Compander = gSubMenuSelection; - SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true); - gVfoConfigureMode = VFO_CONFIGURE; - gFlagResetVfos = true; -// gRequestSaveChannel = 1; - return; - #endif + case MENU_COMPAND: + gTxVfo->Compander = gSubMenuSelection; + SETTINGS_UpdateChannel(gTxVfo->CHANNEL_SAVE, gTxVfo, true); + gVfoConfigureMode = VFO_CONFIGURE; + gFlagResetVfos = true; +// gRequestSaveChannel = 1; + return; case MENU_1_CALL: gEeprom.CHAN_1_CALL = gSubMenuSelection; @@ -998,11 +994,9 @@ void MENU_ShowCurrentSetting(void) break; #endif - #ifdef ENABLE_COMPANDER - case MENU_COMPAND: - gSubMenuSelection = gTxVfo->Compander; - return; - #endif + case MENU_COMPAND: + gSubMenuSelection = gTxVfo->Compander; + return; case MENU_1_CALL: gSubMenuSelection = gEeprom.CHAN_1_CALL; diff --git a/bitmaps.c b/bitmaps.c index 6907912..790c6f0 100644 --- a/bitmaps.c +++ b/bitmaps.c @@ -416,14 +416,12 @@ const uint8_t BITMAP_ScanList2[6] = 0b01000010 }; -#ifdef ENABLE_COMPANDER - const uint8_t BITMAP_compand[6] = - { - 0b00000000, - 0b00111100, - 0b01000010, - 0b01000010, - 0b01000010, - 0b00100100 - }; -#endif +const uint8_t BITMAP_compand[6] = +{ + 0b00000000, + 0b00111100, + 0b01000010, + 0b01000010, + 0b01000010, + 0b00100100 +}; diff --git a/bitmaps.h b/bitmaps.h index 64251e9..b73c516 100644 --- a/bitmaps.h +++ b/bitmaps.h @@ -65,9 +65,7 @@ extern const uint8_t BITMAP_VFO_NotDefault[8]; extern const uint8_t BITMAP_ScanList1[6]; extern const uint8_t BITMAP_ScanList2[6]; -#ifdef ENABLE_COMPANDER - extern const uint8_t BITMAP_compand[6]; -#endif +extern const uint8_t BITMAP_compand[6]; #endif diff --git a/board.c b/board.c index 23e7ab6..7847546 100644 --- a/board.c +++ b/board.c @@ -707,14 +707,14 @@ void BOARD_EEPROM_Init(void) gSetting_ScrambleEnable = (Data[6] < 2) ? Data[6] : true; gSetting_TX_EN = (Data[7] & (1u << 0)) ? true : false; gSetting_live_DTMF_decoder = (Data[7] & (1u << 1)) ? true : false; - gSetting_battery_text = (((Data[7] >> 2) & 3u) <= 2) ? (Data[7] >> 2) & 3: 2; + gSetting_battery_text = (((Data[7] >> 2) & 3u) <= 2) ? (Data[7] >> 2) & 3 : 2; #ifdef ENABLE_AUDIO_BAR gSetting_mic_bar = (Data[7] & (1u << 4)) ? true : false; #endif #ifdef ENABLE_AM_FIX gSetting_AM_fix = (Data[7] & (1u << 5)) ? true : false; #endif - gSetting_backlight_on_tx_rx = (Data[7] & (1u << 6)) ? true : false; + gSetting_backlight_on_tx_rx = (Data[7] >> 6) & 3u; if (!gEeprom.VFO_OPEN) { diff --git a/firmware.bin b/firmware.bin index 51e0154..087bc60 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 6d664af..216ad34 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/functions.c b/functions.c index 397e8be..97aca19 100644 --- a/functions.c +++ b/functions.c @@ -230,7 +230,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function) else BK4819_DisableScramble(); - if (gSetting_backlight_on_tx_rx) + if (gSetting_backlight_on_tx_rx == 1 || gSetting_backlight_on_tx_rx == 3) BACKLIGHT_TurnOn(); break; diff --git a/misc.c b/misc.c index a02485c..7b77063 100644 --- a/misc.c +++ b/misc.c @@ -87,7 +87,7 @@ bool gSetting_TX_EN; uint8_t gSetting_F_LOCK; bool gSetting_ScrambleEnable; -bool gSetting_backlight_on_tx_rx; +uint8_t gSetting_backlight_on_tx_rx; #ifdef ENABLE_AM_FIX bool gSetting_AM_fix; diff --git a/misc.h b/misc.h index af5d707..84beee4 100644 --- a/misc.h +++ b/misc.h @@ -156,7 +156,7 @@ extern bool gSetting_TX_EN; extern uint8_t gSetting_F_LOCK; extern bool gSetting_ScrambleEnable; -extern bool gSetting_backlight_on_tx_rx; +extern uint8_t gSetting_backlight_on_tx_rx; #ifdef ENABLE_AM_FIX extern bool gSetting_AM_fix; diff --git a/radio.c b/radio.c index 95dd923..538200b 100644 --- a/radio.c +++ b/radio.c @@ -130,9 +130,7 @@ void RADIO_InitInfo(VFO_Info_t *pInfo, const uint8_t ChannelSave, const uint32_t pInfo->freq_config_TX.Frequency = Frequency; pInfo->pRX = &pInfo->freq_config_RX; pInfo->pTX = &pInfo->freq_config_TX; - #ifdef ENABLE_COMPANDER - pInfo->Compander = 0; // off - #endif + pInfo->Compander = 0; // off if (ChannelSave == (FREQ_CHANNEL_FIRST + BAND2_108MHz)) pInfo->AM_mode = 1; @@ -420,9 +418,7 @@ void RADIO_ConfigureChannel(const unsigned int VFO, const unsigned int configure gEeprom.VfoInfo[VFO].freq_config_TX.CodeType = CODE_TYPE_OFF; } - #ifdef ENABLE_COMPANDER - gEeprom.VfoInfo[VFO].Compander = (Attributes & MR_CH_COMPAND) >> 4; - #endif + gEeprom.VfoInfo[VFO].Compander = (Attributes & MR_CH_COMPAND) >> 4; RADIO_ConfigureSquelchAndOutputPower(pRadio); } @@ -720,10 +716,8 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0) #endif BK4819_DisableVox(); - #ifdef ENABLE_COMPANDER - // RX expander - BK4819_SetCompander((gRxVfo->AM_mode == 0 && gRxVfo->Compander >= 2) ? gRxVfo->Compander : 0); - #endif + // RX expander + BK4819_SetCompander((gRxVfo->AM_mode == 0 && gRxVfo->Compander >= 2) ? gRxVfo->Compander : 0); #if 0 if (!gRxVfo->DTMF_DECODING_ENABLE && !gSetting_KILLED) @@ -828,10 +822,8 @@ void RADIO_SetTxParameters(void) BK4819_SetFrequency(gCurrentVfo->pTX->Frequency); - #ifdef ENABLE_COMPANDER - // TX compressor - BK4819_SetCompander((gRxVfo->AM_mode == 0 && (gRxVfo->Compander == 1 || gRxVfo->Compander >= 3)) ? gRxVfo->Compander : 0); - #endif + // TX compressor + BK4819_SetCompander((gRxVfo->AM_mode == 0 && (gRxVfo->Compander == 1 || gRxVfo->Compander >= 3)) ? gRxVfo->Compander : 0); BK4819_PrepareTransmit(); diff --git a/radio.h b/radio.h index a9c3681..66f1536 100644 --- a/radio.h +++ b/radio.h @@ -25,9 +25,7 @@ enum { MR_CH_BAND_MASK = 0x0F << 0, - #ifdef ENABLE_COMPANDER - MR_CH_COMPAND = 3u << 4, // new - #endif + MR_CH_COMPAND = 3u << 4, // new MR_CH_SCANLIST2 = 1u << 6, MR_CH_SCANLIST1 = 1u << 7 }; @@ -111,9 +109,7 @@ typedef struct VFO_Info_t uint8_t AM_mode; - #ifdef ENABLE_COMPANDER - uint8_t Compander; - #endif + uint8_t Compander; char Name[16]; } VFO_Info_t; diff --git a/settings.c b/settings.c index f8bfeb3..7a4f297 100644 --- a/settings.c +++ b/settings.c @@ -179,7 +179,7 @@ void SETTINGS_SaveSettings(void) #ifdef ENABLE_AM_FIX if (!gSetting_AM_fix) State[7] &= ~(1u << 5); #endif - if (!gSetting_backlight_on_tx_rx) State[7] &= ~(1u << 6); + State[7] = (State[7] & ~(3u << 6)) | ((gSetting_backlight_on_tx_rx & 3u) << 6); EEPROM_WriteBuffer(0x0F40, State); } @@ -260,20 +260,15 @@ void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep) { uint8_t State[8]; uint8_t Attributes = 0xFF; // default attributes - #ifdef ENABLE_COMPANDER - Attributes &= ~MR_CH_COMPAND; // default to '0' = compander disabled - #endif uint16_t Offset = 0x0D60 + (Channel & ~7u); + + Attributes &= ~MR_CH_COMPAND; // default to '0' = compander disabled EEPROM_ReadBuffer(Offset, State, sizeof(State)); if (keep) { - #ifdef ENABLE_COMPANDER - Attributes = (pVFO->SCANLIST1_PARTICIPATION << 7) | (pVFO->SCANLIST2_PARTICIPATION << 6) | (pVFO->Compander << 4) | (pVFO->Band << 0); - #else - Attributes = (pVFO->SCANLIST1_PARTICIPATION << 7) | (pVFO->SCANLIST2_PARTICIPATION << 6) | (pVFO->Band << 0); - #endif + Attributes = (pVFO->SCANLIST1_PARTICIPATION << 7) | (pVFO->SCANLIST2_PARTICIPATION << 6) | (pVFO->Compander << 4) | (pVFO->Band << 0); if (State[Channel & 7u] == Attributes) return; // no change in the attributes } diff --git a/ui/main.c b/ui/main.c index 254a7ae..2534fd3 100644 --- a/ui/main.c +++ b/ui/main.c @@ -543,10 +543,12 @@ void UI_DisplayMain(void) if (attributes & MR_CH_SCANLIST2) memmove(p_line0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); #ifndef ENABLE_BIG_FREQ - #ifdef ENABLE_COMPANDER - if ((attributes & MR_CH_COMPAND) > 0) - memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); - #endif + if ((attributes & MR_CH_COMPAND) > 0) + memmove(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) @@ -613,16 +615,14 @@ void UI_DisplayMain(void) UI_PrintString(String, 32, 0, line, 8); #endif - #ifdef ENABLE_COMPANDER - // show the channel symbols - const uint8_t attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; - if ((attributes & MR_CH_COMPAND) > 0) - #ifdef ENABLE_BIG_FREQ - memmove(p_line0 + 120, BITMAP_compand, sizeof(BITMAP_compand)); - #else - memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); - #endif - #endif + // show the channel symbols + const uint8_t attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; + if ((attributes & MR_CH_COMPAND) > 0) + #ifdef ENABLE_BIG_FREQ + memmove(p_line0 + 120, BITMAP_compand, sizeof(BITMAP_compand)); + #else + memmove(p_line0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); + #endif } } diff --git a/ui/menu.c b/ui/menu.c index d860463..585d23f 100644 --- a/ui/menu.c +++ b/ui/menu.c @@ -82,9 +82,7 @@ const t_menu_item MenuList[] = #ifdef ENABLE_AUDIO_BAR {"MICBAR", VOICE_ID_INVALID, MENU_MIC_BAR }, #endif -#ifdef ENABLE_COMPANDER {"COMPND", VOICE_ID_INVALID, MENU_COMPAND }, -#endif {"1 CALL", VOICE_ID_INVALID, MENU_1_CALL }, {"SLIST", VOICE_ID_INVALID, MENU_S_LIST }, {"SLIST1", VOICE_ID_INVALID, MENU_SLIST1 }, @@ -293,15 +291,13 @@ const char gSubMenu_BACKLIGHT[8][7] = "ON" }; -#ifdef ENABLE_COMPANDER - const char gSubMenu_Compand[4][6] = - { - "OFF", - "TX", - "RX", - "TX/RX" - }; -#endif +const char gSubMenu_RX_TX[4][6] = +{ + "OFF", + "TX", + "RX", + "TX/RX" +}; #ifdef ENABLE_AM_FIX_TEST1 const char gSubMenu_AM_fix_test1[4][8] = @@ -588,16 +584,14 @@ void UI_DisplayMenu(void) strcpy(String, (gSubMenuSelection == 0) ? "OFF" : "AUTO"); break; - #ifdef ENABLE_COMPANDER - case MENU_COMPAND: - strcpy(String, gSubMenu_Compand[gSubMenuSelection]); - break; - #endif + case MENU_COMPAND: + case MENU_ABR_ON_TX_RX: + strcpy(String, gSubMenu_RX_TX[gSubMenuSelection]); + break; #ifdef ENABLE_AM_FIX case MENU_AM_FIX: #endif - case MENU_ABR_ON_TX_RX: case MENU_BCL: case MENU_BEEP: case MENU_S_ADD1: diff --git a/ui/menu.h b/ui/menu.h index 01845e5..d4d96fa 100644 --- a/ui/menu.h +++ b/ui/menu.h @@ -69,9 +69,7 @@ enum #ifdef ENABLE_AUDIO_BAR MENU_MIC_BAR, #endif -#ifdef ENABLE_COMPANDER MENU_COMPAND, -#endif MENU_1_CALL, MENU_S_LIST, MENU_SLIST1, @@ -147,9 +145,7 @@ extern const char gSubMenu_ROGER[3][9]; extern const char gSubMenu_RESET[2][4]; extern const char gSubMenu_F_LOCK[6][4]; extern const char gSubMenu_BACKLIGHT[8][7]; -#ifdef ENABLE_COMPANDER - extern const char gSubMenu_Compand[4][6]; -#endif +extern const char gSubMenu_RX_TX[4][6]; #ifdef ENABLE_AM_FIX_TEST1 extern const char gSubMenu_AM_fix_test1[4][8]; #endif