diff --git a/README.md b/README.md index 3fc5a67..c3fe87e 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ ENABLE_TX_WHEN_AM := 0 allow TX (always FM) when RX is set to 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 hold down keys 0-9 to access the functions ENABLE_BOOT_BEEPS := 0 give user audio feedback on volume knob position at boot-up -ENABLE_COMPANDER := 1 compander option - setting not yet saved (per channel) +ENABLE_COMPANDER := 1 compander option (per channel) ENABLE_SHOW_CHARGE_LEVEL := 1 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_STATUSBAR_VOLTAGE := 0 show the battery voltage on the top status bar - when possible diff --git a/app/menu.c b/app/menu.c index e170330..2f5ebf6 100644 --- a/app/menu.c +++ b/app/menu.c @@ -578,7 +578,7 @@ void MENU_AcceptSetting(void) #ifdef ENABLE_COMPANDER case MENU_COMPAND: gTxVfo->Compander = gSubMenuSelection; - //gRequestSaveChannel = 2; + gRequestSaveChannel = 2; return; #endif diff --git a/bitmaps.c b/bitmaps.c index a346eee..9ee4004 100644 --- a/bitmaps.c +++ b/bitmaps.c @@ -539,7 +539,7 @@ const uint8_t BITMAP_ScanList[6] = }; */ const uint8_t BITMAP_ScanList1[6] = -{ // 1 symbol +{ // 'I' symbol 0b00000000, 0b00000000, 0b01000010, @@ -549,7 +549,7 @@ const uint8_t BITMAP_ScanList1[6] = }; const uint8_t BITMAP_ScanList2[6] = -{ // 2 symbol +{ // 'II' symbol 0b00000000, 0b01000010, 0b01111110, @@ -557,3 +557,15 @@ const uint8_t BITMAP_ScanList2[6] = 0b01111110, 0b01000010 }; + +#ifdef ENABLE_COMPANDER + const uint8_t BITMAP_compand[6] = + { + 0b00000000, + 0b00111100, + 0b01000010, + 0b01000010, + 0b01000010, + 0b00100100 + }; +#endif diff --git a/bitmaps.h b/bitmaps.h index 7109758..987bed7 100644 --- a/bitmaps.h +++ b/bitmaps.h @@ -60,5 +60,9 @@ 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 + #endif diff --git a/firmware b/firmware index fd23855..f9358c3 100644 Binary files a/firmware and b/firmware differ diff --git a/firmware.bin b/firmware.bin index 44448d0..080ccf7 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 89bde94..41d3ed1 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/radio.c b/radio.c index 461ffc8..ceba43c 100644 --- a/radio.c +++ b/radio.c @@ -48,7 +48,8 @@ STEP_Setting_t gStepSetting; VfoState_t VfoState[2]; bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO) -{ +{ // return true if the channel appears valid + uint8_t Attributes; uint8_t PriorityCh1; uint8_t PriorityCh2; @@ -56,8 +57,8 @@ bool RADIO_CheckValidChannel(uint16_t Channel, bool bCheckScanList, uint8_t VFO) if (!IS_MR_CHANNEL(Channel)) return false; - // Check channel is valid Attributes = gMR_ChannelAttributes[Channel]; + if ((Attributes & MR_CH_BAND_MASK) > BAND7_470MHz) return false; @@ -177,8 +178,9 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Arg) if (gEeprom.CROSS_BAND_RX_TX == CROSS_BAND_OFF) return; - gUpdateStatus = true; gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF; + + gUpdateStatus = true; return; } #endif @@ -203,7 +205,8 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Arg) Attributes = gMR_ChannelAttributes[Channel]; if (Attributes == 0xFF) - { + { // invalid/unused channel + uint8_t Index; if (IS_MR_CHANNEL(Channel)) @@ -220,8 +223,11 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Arg) Band = Attributes & MR_CH_BAND_MASK; if (Band > BAND7_470MHz) - Band = BAND6_400MHz; - + { +// Band = BAND6_400MHz; + Band = FREQUENCY_GetBand(gEeprom.ScreenChannel[VFO]); // 111 bug fix, or have I broke it ? + } + if (IS_MR_CHANNEL(Channel)) { gEeprom.VfoInfo[VFO].Band = Band; @@ -349,7 +355,9 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Arg) } __attribute__((packed)) Info; EEPROM_ReadBuffer(Base, &Info, sizeof(Info)); + pRadio->ConfigRX.Frequency = Info.Frequency; + if (Info.Offset >= 100000000) Info.Offset = 1000000; gEeprom.VfoInfo[VFO].TX_OFFSET_FREQUENCY = Info.Offset; @@ -418,7 +426,7 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Arg) gEeprom.VfoInfo[VFO].IsAM = false; #ifdef ENABLE_COMPANDER - gEeprom.VfoInfo[VFO].Compander = 0; // off + gEeprom.VfoInfo[VFO].Compander = (Attributes & MR_CH_COMPAND) >> 4; #endif RADIO_ConfigureSquelchAndOutputPower(pRadio); @@ -465,7 +473,7 @@ void RADIO_ConfigureSquelchAndOutputPower(VFO_Info_t *pInfo) Txp[1], Txp[2], LowerLimitFrequencyBandTable[Band], - MiddleFrequencyBandTable[Band], + MiddleFrequencyBandTable[Band], UpperLimitFrequencyBandTable[Band], pInfo->pTX->Frequency); } diff --git a/radio.h b/radio.h index a9dad79..d2ac398 100644 --- a/radio.h +++ b/radio.h @@ -23,9 +23,12 @@ #include "dcs.h" enum { - MR_CH_SCANLIST1 = (1u << 7), - MR_CH_SCANLIST2 = (1u << 6), - MR_CH_BAND_MASK = 0x0Fu + MR_CH_BAND_MASK = 0x0F << 0, + #ifdef ENABLE_COMPANDER + MR_CH_COMPAND = 3u << 4, // new + #endif + MR_CH_SCANLIST2 = 1u << 6, + MR_CH_SCANLIST1 = 1u << 7 }; enum { diff --git a/settings.c b/settings.c index 212c59d..77d3c79 100644 --- a/settings.c +++ b/settings.c @@ -229,7 +229,7 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, } } -void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool bUpdate) +void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep) { UART_LogSend("svalid\r\n", 8); @@ -238,32 +238,39 @@ void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool bUpdat #endif { uint8_t State[8]; - uint8_t Attributes = 0xFF; - uint16_t Offset = 0x0D60 + (Channel & ~7U); + 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); EEPROM_ReadBuffer(Offset, State, sizeof(State)); - if (bUpdate) + if (keep) { - Attributes = (pVFO->SCANLIST1_PARTICIPATION << 7) | (pVFO->SCANLIST2_PARTICIPATION << 6) | (pVFO->Band << 0); - if (State[Channel & 7U] == Attributes) - return; + #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 + if (State[Channel & 7u] == Attributes) + return; // no change in the attributes } - State[Channel & 7U] = Attributes; + State[Channel & 7u] = Attributes; EEPROM_WriteBuffer(Offset, State); gMR_ChannelAttributes[Channel] = Attributes; - #ifndef KEEP_MEM_NAME - if (IS_MR_CHANNEL(Channel)) +// #ifndef KEEP_MEM_NAME + if (IS_MR_CHANNEL(Channel) && !keep) { // clear/reset the channel name const uint16_t OffsetMR = Channel * 16; memset(&State, 0xFF, sizeof(State)); EEPROM_WriteBuffer(0x0F50 + OffsetMR, State); EEPROM_WriteBuffer(0x0F58 + OffsetMR, State); } - #endif +// #endif } } diff --git a/settings.h b/settings.h index 0db016f..3b94b8c 100644 --- a/settings.h +++ b/settings.h @@ -235,6 +235,6 @@ extern EEPROM_Config_t gEeprom; void SETTINGS_SaveVfoIndices(void); void SETTINGS_SaveSettings(void); void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO, uint8_t Mode); -void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool bUpdate); +void SETTINGS_UpdateChannel(uint8_t Channel, const VFO_Info_t *pVFO, bool keep); #endif diff --git a/ui/main.c b/ui/main.c index 29f3bc2..eeb110e 100644 --- a/ui/main.c +++ b/ui/main.c @@ -244,22 +244,19 @@ void UI_DisplayMain(void) if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num])) { // channel mode - // show the scanlist symbols - const uint8_t Attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; -// #ifdef ENABLE_BIG_FREQ - // side-by-side - if (Attributes & MR_CH_SCANLIST1) - memmove(pLine0 + 113, BITMAP_ScanList1, sizeof(BITMAP_ScanList1)); - if (Attributes & MR_CH_SCANLIST2) - memmove(pLine0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); -// #else -// // top-bottom .. makes room for full 10 characters of channel name -// if (Attributes & MR_CH_SCANLIST1) -// memmove(pLine0 + 120, BITMAP_ScanList1, sizeof(BITMAP_ScanList1)); -// if (Attributes & MR_CH_SCANLIST2) -// memmove(pLine0 + 120 + LCD_WIDTH, BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); -// #endif - + // show the channel symbols + const uint8_t attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; + if (attributes & MR_CH_SCANLIST1) + memmove(pLine0 + 113, BITMAP_ScanList1, sizeof(BITMAP_ScanList1)); + if (attributes & MR_CH_SCANLIST2) + memmove(pLine0 + 120, BITMAP_ScanList2, sizeof(BITMAP_ScanList2)); + #ifndef ENABLE_BIG_FREQ + #ifdef ENABLE_COMPANDER + if ((attributes & MR_CH_COMPAND) > 0) + memmove(pLine0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); + #endif + #endif + switch (gEeprom.CHANNEL_DISPLAY_MODE) { case MDF_FREQUENCY: // show the channel frequency @@ -327,6 +324,21 @@ void UI_DisplayMain(void) sprintf(String, "%03u.%05u", frequency / 100000, frequency % 100000); UI_PrintString(String, 32, 0, Line, 8); #endif + + // show the channel symbols + const uint8_t attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; + (void)attributes; // stop compiler warning/error + #ifdef ENABLE_BIG_FREQ + #ifdef ENABLE_COMPANDER + if ((attributes & MR_CH_COMPAND) > 0) + memmove(pLine0 + 120, BITMAP_compand, sizeof(BITMAP_compand)); + #endif + #else + #ifdef ENABLE_COMPANDER + if ((attributes & MR_CH_COMPAND) > 0) + memmove(pLine0 + 120 + LCD_WIDTH, BITMAP_compand, sizeof(BITMAP_compand)); + #endif + #endif } }