diff --git a/Makefile b/Makefile index 08a3e36..75fd7e7 100644 --- a/Makefile +++ b/Makefile @@ -93,6 +93,7 @@ LDFLAGS = -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld #LDFLAGS = -mcpu=cortex-m0 -nostartfiles -Wl,-gc-sections,-T,firmware.ld # compilation options +#CFLAGS += -DBIG_FREQ_FONT CFLAGS += -DDISABLE_NOAA CFLAGS += -DDISABLE_VOICE CFLAGS += -DDISABLE_AIRCOPY diff --git a/README.md b/README.md index 50173d0..40dba20 100644 --- a/README.md +++ b/README.md @@ -11,14 +11,15 @@ Am amazing achievement if you ask me ! This version you can customize at compile time by making various changes to the makefile. You can edit those changes by (currently) editing the MakeFile, look for these lines .. -* CFLAGS += -DDISABLE_NOAA .. remove NOAA channels option from the firmware -* CFLAGS += -DDISABLE_VOICE .. remove spoken VOICES option from the firmware -* CFLAGS += -DDISABLE_AIRCOPY .. remove AIRCOPY option -* CFLAGS += -DKEEP_MEM_NAME .. maintain the memory channel's name when re-saving the memory channel -* CFLAGS += -DDISABLE_ALARM .. remove the ALARM transmit option from the firmware -* CFLAGS += -DCHAN_NAME_FREQ .. show the channel frequency (as well as channel number/name) -* CFLAGS += -DSINGLE_VFO_CHAN .. not yet implemented .. only show a single VFO/CHANNEL if dual watch is disabled -* #CFLAGS += -DBAND_SCOPE .. not yet implemented +* CFLAGS += -DBIG_FREQ_FONT .. show frequency using big font +* CFLAGS += -DDISABLE_NOAA .. remove NOAA channels option from the firmware +* CFLAGS += -DDISABLE_VOICE .. remove spoken VOICES option from the firmware +* CFLAGS += -DDISABLE_AIRCOPY .. remove AIRCOPY option +* CFLAGS += -DKEEP_MEM_NAME .. keep the memory channels name when re-saving a channel +* CFLAGS += -DDISABLE_ALARM .. remove the ALARM transmit option from the firmware +* CFLAGS += -DCHAN_NAME_FREQ .. show the channel frequency (as well as channel number/name) +* #CFLAGS += -DSINGLE_VFO_CHAN .. (not yet implemented) show a single VFO/CHANNEL if dual-watch/cross-band are disabled +* #CFLAGS += -DBAND_SCOPE .. (not yet implemented) show a band scope (spectrum/panadapter) To enable the custom option just uncomment the line by removing the starting '#'. @@ -29,6 +30,7 @@ To enable the custom option just uncomment the line by removing the starting '#' * Slightly less intense menu style * AM RX now allowed everywhere, although the radio really doesn't do AM, the adverts are a con ! * Finer RSSI bar steps +* Nicer big font than original big font (frequency mode) * * "MEM-CH" and "DEL-CH" menus now include channel name * "STEP" menu, added 1.25kHz option, removed 5kHz option diff --git a/app/action.c b/app/action.c index ff6ba58..0ab85bf 100644 --- a/app/action.c +++ b/app/action.c @@ -109,18 +109,20 @@ void ACTION_Scan(bool bRestart) { if (gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT) { - uint16_t Frequency; - GUI_SelectNextDisplay(DISPLAY_FM); + if (gFM_ScanState != FM_SCAN_OFF) { FM_PlayAndUpdate(); + #ifndef DISABLE_VOICE gAnotherVoiceID = VOICE_ID_SCANNING_STOP; #endif } else { + uint16_t Frequency; + if (bRestart) { gFM_AutoScan = true; @@ -134,8 +136,10 @@ void ACTION_Scan(bool bRestart) gFM_ChannelPosition = 0; Frequency = gEeprom.FM_FrequencyPlaying; } + BK1080_GetFrequencyDeviation(Frequency); FM_Tune(Frequency, 1, bRestart); + #ifndef DISABLE_VOICE gAnotherVoiceID = VOICE_ID_SCANNING_BEGIN; #endif @@ -152,9 +156,11 @@ void ACTION_Scan(bool bRestart) #endif { GUI_SelectNextDisplay(DISPLAY_MAIN); + if (gScanState != SCAN_OFF) { SCANNER_Stop(); + #ifndef DISABLE_VOICE gAnotherVoiceID = VOICE_ID_SCANNING_STOP; #endif @@ -162,6 +168,7 @@ void ACTION_Scan(bool bRestart) else { CHANNEL_Next(true, 1); + #ifndef DISABLE_VOICE AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN); AUDIO_PlaySingleVoice(true); diff --git a/app/app.c b/app/app.c index 7d46cd5..1372a84 100644 --- a/app/app.c +++ b/app/app.c @@ -66,7 +66,7 @@ static void APP_CheckForIncoming(void) { if (gCssScanMode != CSS_SCAN_MODE_OFF && gRxReceptionMode == RX_MODE_NONE) { - ScanPauseDelayIn10msec = 100; + ScanPauseDelayIn10msec = 100; // 1 second gScheduleScanListen = false; gRxReceptionMode = RX_MODE_DETECTED; } @@ -80,6 +80,7 @@ static void APP_CheckForIncoming(void) gScheduleNOAA = false; } #endif + FUNCTION_Select(FUNCTION_INCOMING); return; } @@ -100,6 +101,7 @@ static void APP_CheckForIncoming(void) FUNCTION_Select(FUNCTION_INCOMING); return; } + ScanPauseDelayIn10msec = 20; gScheduleScanListen = false; } @@ -125,14 +127,14 @@ static void APP_HandleIncoming(void) #ifndef DISABLE_NOAA if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gSystickCountdown2) { - bFlag = true; + bFlag = true; gSystickCountdown2 = 0; } #endif if (g_CTCSS_Lost && gCurrentCodeType == CODE_TYPE_CONTINUOUS_TONE) { - bFlag = true; + bFlag = true; gFoundCTCSS = false; } @@ -229,7 +231,7 @@ static void APP_HandleReceive(void) { if (g_CxCSS_TAIL_Found) { - Mode = END_OF_RX_MODE_TTE; + Mode = END_OF_RX_MODE_TTE; g_CxCSS_TAIL_Found = false; } } @@ -249,7 +251,7 @@ static void APP_HandleReceive(void) if (g_CxCSS_TAIL_Found) { - Mode = END_OF_RX_MODE_TTE; + Mode = END_OF_RX_MODE_TTE; g_CxCSS_TAIL_Found = false; } break; @@ -264,14 +266,15 @@ static void APP_HandleReceive(void) gFoundCDCSS = true; gFoundCDCSSCountdown = 100; } + if (g_CxCSS_TAIL_Found) { if (BK4819_GetCTCType() == 1) - { Mode = END_OF_RX_MODE_TTE; - } + g_CxCSS_TAIL_Found = false; } + break; default: @@ -306,7 +309,7 @@ Skip: { case SCAN_RESUME_CO: ScanPauseDelayIn10msec = 360; - gScheduleScanListen = false; + gScheduleScanListen = false; break; case SCAN_RESUME_SE: SCANNER_Stop(); @@ -382,6 +385,7 @@ void APP_StartListening(FUNCTION_Type_t Function) gScheduleScanListen = false; break; } + bScanKeepFrequency = true; } @@ -417,6 +421,7 @@ void APP_StartListening(FUNCTION_Type_t Function) #ifndef DISABLE_VOICE if (gVoiceWriteIndex == 0) +// BK4819_SetAF(gRxVfo->IsAM ? BK4819_AF_AM : BK4819_AF_OPEN); #endif BK4819_SetAF(gRxVfo->IsAM ? BK4819_AF_AM : BK4819_AF_OPEN); @@ -434,14 +439,15 @@ void APP_StartListening(FUNCTION_Type_t Function) void APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step) { - const uint32_t Frequency = pInfo->ConfigRX.Frequency + (Step * pInfo->StepFrequency); + uint32_t Frequency = pInfo->ConfigRX.Frequency + (Step * pInfo->StepFrequency); + if (Frequency > gUpperLimitFrequencyBandTable[pInfo->Band]) - pInfo->ConfigRX.Frequency = gLowerLimitFrequencyBandTable[pInfo->Band]; + Frequency = gLowerLimitFrequencyBandTable[pInfo->Band]; else if (Frequency < gLowerLimitFrequencyBandTable[pInfo->Band]) - pInfo->ConfigRX.Frequency = FREQUENCY_FloorToStep(gUpperLimitFrequencyBandTable[pInfo->Band], pInfo->StepFrequency, gLowerLimitFrequencyBandTable[pInfo->Band]); - else - pInfo->ConfigRX.Frequency = Frequency; + Frequency = FREQUENCY_FloorToStep(gUpperLimitFrequencyBandTable[pInfo->Band], pInfo->StepFrequency, gLowerLimitFrequencyBandTable[pInfo->Band]); + + pInfo->ConfigRX.Frequency = Frequency; } static void FREQ_NextChannel(void) @@ -471,7 +477,7 @@ static void MR_NextChannel(void) { gPreviousMrChannel = gNextMrChannel; if (RADIO_CheckValidChannel(Ch1, false, 0)) - gNextMrChannel = Ch1; + gNextMrChannel = Ch1; else gCurrentScanList = 1; } @@ -479,7 +485,7 @@ static void MR_NextChannel(void) if (gCurrentScanList == 1) { if (RADIO_CheckValidChannel(Ch2, false, 0)) - gNextMrChannel = Ch2; + gNextMrChannel = Ch2; else gCurrentScanList = 2; } @@ -501,8 +507,10 @@ Skip: { gEeprom.MrChannel[gEeprom.RX_CHANNEL] = gNextMrChannel; gEeprom.ScreenChannel[gEeprom.RX_CHANNEL] = gNextMrChannel; + RADIO_ConfigureChannel(gEeprom.RX_CHANNEL, 2); RADIO_SetupRegisters(true); + gUpdateDisplay = true; } @@ -529,7 +537,7 @@ static void DUALWATCH_Alternate(void) if (gIsNoaaMode) { if (IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) || IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) - gEeprom.RX_CHANNEL = gEeprom.RX_CHANNEL == 0; + gEeprom.RX_CHANNEL = 1 - gEeprom.RX_CHANNEL; else gEeprom.RX_CHANNEL = 0; @@ -541,7 +549,7 @@ static void DUALWATCH_Alternate(void) else #endif { - gEeprom.RX_CHANNEL = (gEeprom.RX_CHANNEL == 0); + gEeprom.RX_CHANNEL = 1 - gEeprom.RX_CHANNEL; gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_CHANNEL]; } @@ -566,19 +574,22 @@ void APP_CheckRadioInterrupts(void) BK4819_WriteRegister(BK4819_REG_02, 0); Mask = BK4819_ReadRegister(BK4819_REG_02); + if (Mask & BK4819_REG_02_DTMF_5TONE_FOUND) { gDTMF_RequestPending = true; gDTMF_RecvTimeout = 5; + if (gDTMF_WriteIndex > 15) { - uint8_t i; + unsigned int i; for (i = 0; i < (sizeof(gDTMF_Received) - 1); i++) gDTMF_Received[i] = gDTMF_Received[i + 1]; gDTMF_WriteIndex = 15; } gDTMF_Received[gDTMF_WriteIndex++] = DTMF_GetCharacter(BK4819_GetDTMF_5TONE_Code()); + if (gCurrentFunction == FUNCTION_RECEIVE) DTMF_HandleRequest(); } @@ -605,6 +616,7 @@ void APP_CheckRadioInterrupts(void) { g_VOX_Lost = true; gVoxPauseCountdown = 10; + if (gEeprom.VOX_SWITCH) { if (gCurrentFunction == FUNCTION_POWER_SAVE && !gRxIdleMode) @@ -642,7 +654,7 @@ void APP_CheckRadioInterrupts(void) #ifndef DISABLE_AIRCOPY if (Mask & BK4819_REG_02_FSK_FIFO_ALMOST_FULL && gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState == AIRCOPY_TRANSFER && gAirCopyIsSendMode == 0) { - uint8_t i; + unsigned int i; for (i = 0; i < 4; i++) g_FSK_Buffer[gFSKWriteIndex++] = BK4819_ReadRegister(BK4819_REG_5F); AIRCOPY_StorePacket(); @@ -885,8 +897,10 @@ void APP_Update(void) { gCurrentRSSI = BK4819_GetRSSI(); UI_UpdateRSSI(gCurrentRSSI); + gBatterySave = gEeprom.BATTERY_SAVE * 10; gRxIdleMode = true; + BK4819_DisableVox(); BK4819_Sleep(); BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, false); @@ -897,6 +911,7 @@ void APP_Update(void) else { DUALWATCH_Alternate(); + gUpdateRSSI = true; gBatterySave = 10; } @@ -1186,7 +1201,7 @@ void APP_TimeSlice10ms(void) GUI_SelectNextDisplay(DISPLAY_SCANNER); } - gScanDelay = 21; + gScanDelay = g_scan_delay; break; case SCAN_CSS_STATE_SCANNING: @@ -1232,7 +1247,7 @@ void APP_TimeSlice10ms(void) if (gScanCssState < SCAN_CSS_STATE_FOUND) { BK4819_SetScanFrequency(gScanFrequency); - gScanDelay = 21; + gScanDelay = g_scan_delay; break; } @@ -1339,6 +1354,7 @@ void APP_TimeSlice500ms(void) if (gScreenToDisplay == DISPLAY_SCANNER) { BK4819_StopScan(); + RADIO_ConfigureChannel(0, 2); RADIO_ConfigureChannel(1, 2); RADIO_SetupRegisters(true); @@ -1379,6 +1395,7 @@ void APP_TimeSlice500ms(void) if (gLowBattery) { gLowBatteryBlink = ++gLowBatteryCountdown & 1; + UI_DisplayBattery(gLowBatteryCountdown); if (gCurrentFunction != FUNCTION_TRANSMIT) @@ -1409,6 +1426,7 @@ void APP_TimeSlice500ms(void) gReducedService = true; FUNCTION_Select(FUNCTION_POWER_SAVE); ST7565_Configure_GPIO_B11(); + //if (gEeprom.BACKLIGHT < 5) GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); } @@ -1440,7 +1458,7 @@ void APP_TimeSlice500ms(void) if (--gDTMF_AUTO_RESET_TIME == 0) { gDTMF_CallState = DTMF_CALL_STATE_NONE; - gUpdateDisplay = true; + gUpdateDisplay = true; } } @@ -1498,9 +1516,11 @@ void APP_TimeSlice500ms(void) void CHANNEL_Next(bool bFlag, int8_t Direction) { RADIO_SelectVfos(); + gNextMrChannel = gRxVfo->CHANNEL_SAVE; gCurrentScanList = 0; gScanState = Direction; + if (IS_MR_CHANNEL(gNextMrChannel)) { if (bFlag) @@ -1513,7 +1533,8 @@ void CHANNEL_Next(bool bFlag, int8_t Direction) gRestoreFrequency = gRxVfo->ConfigRX.Frequency; FREQ_NextChannel(); } - ScanPauseDelayIn10msec = 50; + + ScanPauseDelayIn10msec = 50; // 500ms gScheduleScanListen = false; gRxReceptionMode = RX_MODE_NONE; gScanPauseMode = false; diff --git a/app/dtmf.c b/app/dtmf.c index d8c7185..45aa198 100644 --- a/app/dtmf.c +++ b/app/dtmf.c @@ -344,6 +344,7 @@ void DTMF_Reply(void) if (gEeprom.DTMF_SIDE_TONE) { GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); + gEnableSpeaker = true; Delay = gEeprom.DTMF_PRELOAD_TIME; diff --git a/app/fm.c b/app/fm.c index 5541db5..f2446b6 100644 --- a/app/fm.c +++ b/app/fm.c @@ -30,36 +30,36 @@ #include "ui/inputbox.h" #include "ui/ui.h" -uint16_t gFM_Channels[20]; -bool gFmRadioMode; -uint8_t gFmRadioCountdown; +#ifndef ARRAY_SIZE + #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) +#endif + +uint16_t gFM_Channels[20]; +bool gFmRadioMode; +uint8_t gFmRadioCountdown; volatile uint16_t gFmPlayCountdown; -volatile int8_t gFM_ScanState; -bool gFM_AutoScan; -uint8_t gFM_ChannelPosition; -bool gFM_FoundFrequency; -bool gFM_AutoScan; -uint8_t gFM_ResumeCountdown; -uint16_t gFM_RestoreCountdown; +volatile int8_t gFM_ScanState; +bool gFM_AutoScan; +uint8_t gFM_ChannelPosition; +bool gFM_FoundFrequency; +bool gFM_AutoScan; +uint8_t gFM_ResumeCountdown; +uint16_t gFM_RestoreCountdown; bool FM_CheckValidChannel(uint8_t Channel) { - if (Channel < 20 && (gFM_Channels[Channel] >= 760 && gFM_Channels[Channel] < 1080)) { - return true; - } - - return false; + return (Channel < ARRAY_SIZE(gFM_Channels) && (gFM_Channels[Channel] >= 760 && gFM_Channels[Channel] < 1080)) ? true : false; } uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction) { - uint8_t i; + unsigned int i; - for (i = 0; i < 20; i++) { - Channel %= 20; - if (FM_CheckValidChannel(Channel)) { + for (i = 0; i < ARRAY_SIZE(gFM_Channels); i++) + { + Channel %= ARRAY_SIZE(gFM_Channels); + if (FM_CheckValidChannel(Channel)) return Channel; - } Channel += Direction; } @@ -68,16 +68,17 @@ uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction) int FM_ConfigureChannelState(void) { - uint8_t Channel; - gEeprom.FM_FrequencyPlaying = gEeprom.FM_SelectedFrequency; - if (gEeprom.FM_IsMrMode) { - Channel = FM_FindNextChannel(gEeprom.FM_SelectedChannel, FM_CHANNEL_UP); - if (Channel == 0xFF) { + + if (gEeprom.FM_IsMrMode) + { + const uint8_t Channel = FM_FindNextChannel(gEeprom.FM_SelectedChannel, FM_CHANNEL_UP); + if (Channel == 0xFF) + { gEeprom.FM_IsMrMode = false; return -1; } - gEeprom.FM_SelectedChannel = Channel; + gEeprom.FM_SelectedChannel = Channel; gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel]; } @@ -86,24 +87,27 @@ int FM_ConfigureChannelState(void) void FM_TurnOff(void) { - gFmRadioMode = false; - gFM_ScanState = FM_SCAN_OFF; + gFmRadioMode = false; + gFM_ScanState = FM_SCAN_OFF; gFM_RestoreCountdown = 0; + GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); + gEnableSpeaker = false; + BK1080_Init(0, false); - gUpdateStatus = true; + + gUpdateStatus = true; } void FM_EraseChannels(void) { - uint8_t i; - uint8_t Template[8]; + unsigned int i; + uint8_t Template[8]; memset(Template, 0xFF, sizeof(Template)); - for (i = 0; i < 5; i++) { + for (i = 0; i < 5; i++) EEPROM_WriteBuffer(0x0E40 + (i * 8), Template); - } memset(gFM_Channels, 0xFF, sizeof(gFM_Channels)); } @@ -111,84 +115,97 @@ void FM_EraseChannels(void) void FM_Tune(uint16_t Frequency, int8_t Step, bool bFlag) { GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); + gEnableSpeaker = false; - if (gFM_ScanState == FM_SCAN_OFF) { - gFmPlayCountdown = 120; - } else { - gFmPlayCountdown = 10; - } - gScheduleFM = false; - gFM_FoundFrequency = false; - gAskToSave = false; - gAskToDelete = false; + + gFmPlayCountdown = (gFM_ScanState == FM_SCAN_OFF) ? 120 : 10; + + gScheduleFM = false; + gFM_FoundFrequency = false; + gAskToSave = false; + gAskToDelete = false; gEeprom.FM_FrequencyPlaying = Frequency; - if (!bFlag) { + + if (!bFlag) + { Frequency += Step; - if (Frequency < gEeprom.FM_LowerLimit) { + if (Frequency < gEeprom.FM_LowerLimit) Frequency = gEeprom.FM_UpperLimit; - } else if (Frequency > gEeprom.FM_UpperLimit) { + else + if (Frequency > gEeprom.FM_UpperLimit) Frequency = gEeprom.FM_LowerLimit; - } + gEeprom.FM_FrequencyPlaying = Frequency; } gFM_ScanState = Step; + BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); } void FM_PlayAndUpdate(void) { gFM_ScanState = FM_SCAN_OFF; - if (gFM_AutoScan) { - gEeprom.FM_IsMrMode = true; + + if (gFM_AutoScan) + { + gEeprom.FM_IsMrMode = true; gEeprom.FM_SelectedChannel = 0; } + FM_ConfigureChannelState(); BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); SETTINGS_SaveFM(); + gFmPlayCountdown = 0; - gScheduleFM = false; - gAskToSave = false; + gScheduleFM = false; + gAskToSave = false; + GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); - gEnableSpeaker = true; + + gEnableSpeaker = true; } int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit) { - uint16_t Test2; - uint16_t Deviation; int ret = -1; - Test2 = BK1080_ReadRegister(BK1080_REG_07); + const uint16_t Test2 = BK1080_ReadRegister(BK1080_REG_07); + // This is supposed to be a signed value, but above function is unsigned - Deviation = BK1080_REG_07_GET_FREQD(Test2); + const uint16_t Deviation = BK1080_REG_07_GET_FREQD(Test2); - if (BK1080_REG_07_GET_SNR(Test2) >= 2) { - uint16_t Status; - - Status = BK1080_ReadRegister(BK1080_REG_10); - if ((Status & BK1080_REG_10_MASK_AFCRL) == BK1080_REG_10_AFCRL_NOT_RAILED && BK1080_REG_10_GET_RSSI(Status) >= 10) { + if (BK1080_REG_07_GET_SNR(Test2) >= 2) + { + const uint16_t Status = BK1080_ReadRegister(BK1080_REG_10); + if ((Status & BK1080_REG_10_MASK_AFCRL) == BK1080_REG_10_AFCRL_NOT_RAILED && BK1080_REG_10_GET_RSSI(Status) >= 10) + { // if (Deviation > -281 && Deviation < 280) - if (Deviation < 280 || Deviation > 3815) { + if (Deviation < 280 || Deviation > 3815) + { // not BLE(less than or equal) - if (Frequency > LowerLimit && (Frequency - BK1080_BaseFrequency) == 1) { - if (BK1080_FrequencyDeviation & 0x800) { + + if (Frequency > LowerLimit && (Frequency - BK1080_BaseFrequency) == 1) + { + if (BK1080_FrequencyDeviation & 0x800) goto Bail; - } - if (BK1080_FrequencyDeviation < 20) { + + if (BK1080_FrequencyDeviation < 20) goto Bail; - } } + // not BLT(less than) - if (Frequency >= LowerLimit && (BK1080_BaseFrequency - Frequency) == 1) { - if ((BK1080_FrequencyDeviation & 0x800) == 0) { + + if (Frequency >= LowerLimit && (BK1080_BaseFrequency - Frequency) == 1) + { + if ((BK1080_FrequencyDeviation & 0x800) == 0) goto Bail; - } - // if (BK1080_FrequencyDeviation > -21) { - if (BK1080_FrequencyDeviation > 4075) { + + // if (BK1080_FrequencyDeviation > -21) + if (BK1080_FrequencyDeviation > 4075) goto Bail; - } } + ret = 0; } } @@ -196,73 +213,97 @@ int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit) Bail: BK1080_FrequencyDeviation = Deviation; - BK1080_BaseFrequency = Frequency; + BK1080_BaseFrequency = Frequency; return ret; } static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) { -#define STATE_FREQ_MODE 0 -#define STATE_MR_MODE 1 -#define STATE_SAVE 2 + #define STATE_FREQ_MODE 0 + #define STATE_MR_MODE 1 + #define STATE_SAVE 2 - if (!bKeyHeld && bKeyPressed) { - if (!gWasFKeyPressed) { + if (!bKeyHeld && bKeyPressed) + { + if (!gWasFKeyPressed) + { uint8_t State; - if (gAskToDelete) { + if (gAskToDelete) + { gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } - if (gAskToSave) { + + if (gAskToSave) + { State = STATE_SAVE; - } else { - if (gFM_ScanState != FM_SCAN_OFF) { + } + else + { + if (gFM_ScanState != FM_SCAN_OFF) + { gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } - if (gEeprom.FM_IsMrMode) { - State = STATE_MR_MODE; - } else { - State = STATE_FREQ_MODE; - } + + State = gEeprom.FM_IsMrMode ? STATE_MR_MODE : STATE_FREQ_MODE; } + INPUTBOX_Append(Key); + gRequestDisplayScreen = DISPLAY_FM; - if (State == STATE_FREQ_MODE) { - if (gInputBoxIndex == 1) { - if (gInputBox[0] > 1) { + + if (State == STATE_FREQ_MODE) + { + if (gInputBoxIndex == 1) + { + if (gInputBox[0] > 1) + { gInputBox[1] = gInputBox[0]; gInputBox[0] = 0; gInputBoxIndex = 2; } - } else if (gInputBoxIndex > 3) { + } + else + if (gInputBoxIndex > 3) + { uint32_t Frequency; gInputBoxIndex = 0; NUMBER_Get(gInputBox, &Frequency); - Frequency = Frequency / 10000; - if (Frequency < gEeprom.FM_LowerLimit || gEeprom.FM_UpperLimit < Frequency) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + Frequency /= 10000; + + if (Frequency < gEeprom.FM_LowerLimit || gEeprom.FM_UpperLimit < Frequency) + { + gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gRequestDisplayScreen = DISPLAY_FM; return; } + gEeprom.FM_SelectedFrequency = (uint16_t)Frequency; + #ifndef DISABLE_VOICE gAnotherVoiceID = (VOICE_ID_t)Key; #endif + gEeprom.FM_FrequencyPlaying = gEeprom.FM_SelectedFrequency; BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); gRequestSaveFM = true; return; } - } else if (gInputBoxIndex == 2) { + } + else + if (gInputBoxIndex == 2) + { uint8_t Channel; gInputBoxIndex = 0; Channel = ((gInputBox[0] * 10) + gInputBox[1]) - 1; - if (State == STATE_MR_MODE) { + + if (State == STATE_MR_MODE) + { if (FM_CheckValidChannel(Channel)) { #ifndef DISABLE_VOICE @@ -286,6 +327,7 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) gFM_ChannelPosition = Channel; return; } + gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } @@ -293,73 +335,90 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) #ifndef DISABLE_VOICE gAnotherVoiceID = (VOICE_ID_t)Key; #endif - + return; } - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; - gWasFKeyPressed = false; - gUpdateStatus = true; + + gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + gWasFKeyPressed = false; + gUpdateStatus = true; gRequestDisplayScreen = DISPLAY_FM; - switch (Key) { - case KEY_0: - ACTION_FM(); - break; - case KEY_1: - gEeprom.FM_IsMrMode = !gEeprom.FM_IsMrMode; - if (!FM_ConfigureChannelState()) { - BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); - gRequestSaveFM = true; - } else { + switch (Key) + { + case KEY_0: + ACTION_FM(); + break; + + case KEY_1: + gEeprom.FM_IsMrMode = !gEeprom.FM_IsMrMode; + + if (!FM_ConfigureChannelState()) + { + BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); + gRequestSaveFM = true; + } + else + gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + break; + + case KEY_2: + ACTION_Scan(true); + break; + + case KEY_3: + ACTION_Scan(false); + break; + + default: gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; - } - break; - - case KEY_2: - ACTION_Scan(true); - break; - - case KEY_3: - ACTION_Scan(false); - break; - - default: - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; - break; + break; } } } static void FM_Key_EXIT(bool bKeyPressed, bool bKeyHeld) { - if (bKeyHeld) { + if (bKeyHeld) return; - } - if (!bKeyPressed) { + + if (!bKeyPressed) return; - } + gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; - if (gFM_ScanState == FM_SCAN_OFF) { - if (gInputBoxIndex == 0) { - if (!gAskToSave && !gAskToDelete) { + + if (gFM_ScanState == FM_SCAN_OFF) + { + if (gInputBoxIndex == 0) + { + if (!gAskToSave && !gAskToDelete) + { ACTION_FM(); return; } - gAskToSave = false; + + gAskToSave = false; gAskToDelete = false; - } else { - gInputBoxIndex--; - gInputBox[gInputBoxIndex] = 10; - if (gInputBoxIndex) { - if (gInputBoxIndex != 1) { + } + else + { + gInputBox[--gInputBoxIndex] = 10; + + if (gInputBoxIndex) + { + if (gInputBoxIndex != 1) + { gRequestDisplayScreen = DISPLAY_FM; return; } - if (gInputBox[0] != 0) { + + if (gInputBox[0] != 0) + { gRequestDisplayScreen = DISPLAY_FM; return; } } + gInputBoxIndex = 0; } @@ -380,184 +439,224 @@ static void FM_Key_EXIT(bool bKeyPressed, bool bKeyHeld) static void FM_Key_MENU(bool bKeyPressed, bool bKeyHeld) { - if (bKeyHeld) { + if (bKeyHeld) return; - } - if (!bKeyPressed) { + + if (!bKeyPressed) return; - } gRequestDisplayScreen = DISPLAY_FM; - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; - if (gFM_ScanState == FM_SCAN_OFF) { - if (!gEeprom.FM_IsMrMode) { - if (gAskToSave) { + if (gFM_ScanState == FM_SCAN_OFF) + { + if (!gEeprom.FM_IsMrMode) + { + if (gAskToSave) + { gFM_Channels[gFM_ChannelPosition] = gEeprom.FM_FrequencyPlaying; - gAskToSave = false; - gRequestSaveFM = true; - } else { - gAskToSave = true; + gAskToSave = false; + gRequestSaveFM = true; } - } else { - if (gAskToDelete) { + else + gAskToSave = true; + } + else + { + if (gAskToDelete) + { gFM_Channels[gEeprom.FM_SelectedChannel] = 0xFFFF; + FM_ConfigureChannelState(); BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); + gRequestSaveFM = true; - gAskToDelete = false; - } else { - gAskToDelete = true; + gAskToDelete = false; } + else + gAskToDelete = true; } - } else { - if (gFM_AutoScan || !gFM_FoundFrequency) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + } + else + { + if (gFM_AutoScan || !gFM_FoundFrequency) + { + gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gInputBoxIndex = 0; return; - } else if (gAskToSave) { - gFM_Channels[gFM_ChannelPosition] = gEeprom.FM_FrequencyPlaying; - gAskToSave = false; - gRequestSaveFM = true; - } else { - gAskToSave = true; } + + if (gAskToSave) + { + gFM_Channels[gFM_ChannelPosition] = gEeprom.FM_FrequencyPlaying; + gAskToSave = false; + gRequestSaveFM = true; + } + else + gAskToSave = true; } } static void FM_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Step) { - if (bKeyHeld || !bKeyPressed) { - if (gInputBoxIndex) { + if (bKeyHeld || !bKeyPressed) + { + if (gInputBoxIndex) return; - } - if (!bKeyPressed) { + + if (!bKeyPressed) return; - } - } else { - if (gInputBoxIndex) { + } + else + { + if (gInputBoxIndex) + { gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } + gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; } - if (gAskToSave) { + + if (gAskToSave) + { gRequestDisplayScreen = DISPLAY_FM; - gFM_ChannelPosition = NUMBER_AddWithWraparound(gFM_ChannelPosition, Step, 0, 19); + gFM_ChannelPosition = NUMBER_AddWithWraparound(gFM_ChannelPosition, Step, 0, 19); return; } - if (gFM_ScanState != FM_SCAN_OFF) { - if (gFM_AutoScan) { + + if (gFM_ScanState != FM_SCAN_OFF) + { + if (gFM_AutoScan) + { gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; return; } + FM_Tune(gEeprom.FM_FrequencyPlaying, Step, false); gRequestDisplayScreen = DISPLAY_FM; return; } - if (gEeprom.FM_IsMrMode) { - uint8_t Channel; - Channel = FM_FindNextChannel(gEeprom.FM_SelectedChannel + Step, Step); - if (Channel == 0xFF || gEeprom.FM_SelectedChannel == Channel) { + if (gEeprom.FM_IsMrMode) + { + const uint8_t Channel = FM_FindNextChannel(gEeprom.FM_SelectedChannel + Step, Step); + if (Channel == 0xFF || gEeprom.FM_SelectedChannel == Channel) goto Bail; - } - gEeprom.FM_SelectedChannel = Channel; - gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel]; - } else { - uint16_t Frequency; - Frequency = gEeprom.FM_SelectedFrequency + Step; - if (Frequency < gEeprom.FM_LowerLimit) { + gEeprom.FM_SelectedChannel = Channel; + gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel]; + } + else + { + uint16_t Frequency = gEeprom.FM_SelectedFrequency + Step; + if (Frequency < gEeprom.FM_LowerLimit) Frequency = gEeprom.FM_UpperLimit; - } else if (Frequency > gEeprom.FM_UpperLimit) { + else + if (Frequency > gEeprom.FM_UpperLimit) Frequency = gEeprom.FM_LowerLimit; - } - gEeprom.FM_FrequencyPlaying = Frequency; + + gEeprom.FM_FrequencyPlaying = Frequency; gEeprom.FM_SelectedFrequency = gEeprom.FM_FrequencyPlaying; } + gRequestSaveFM = true; Bail: BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); + gRequestDisplayScreen = DISPLAY_FM; } void FM_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: - FM_Key_DIGITS(Key, bKeyPressed, bKeyHeld); - break; - case KEY_MENU: - FM_Key_MENU(bKeyPressed, bKeyHeld); - return; - case KEY_UP: - FM_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1); - break; - case KEY_DOWN: - FM_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1); - break;; - case KEY_EXIT: - FM_Key_EXIT(bKeyPressed, bKeyHeld); - break; - case KEY_F: - GENERIC_Key_F(bKeyPressed, bKeyHeld); - break; - case KEY_PTT: - GENERIC_Key_PTT(bKeyPressed); - break; - default: - if (!bKeyHeld && bKeyPressed) { - gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; - } - break; + 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: + FM_Key_DIGITS(Key, bKeyPressed, bKeyHeld); + break; + case KEY_MENU: + FM_Key_MENU(bKeyPressed, bKeyHeld); + return; + case KEY_UP: + FM_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1); + break; + case KEY_DOWN: + FM_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1); + break;; + case KEY_EXIT: + FM_Key_EXIT(bKeyPressed, bKeyHeld); + break; + case KEY_F: + GENERIC_Key_F(bKeyPressed, bKeyHeld); + break; + case KEY_PTT: + GENERIC_Key_PTT(bKeyPressed); + break; + default: + if (!bKeyHeld && bKeyPressed) + gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; + break; } } void FM_Play(void) { - if (!FM_CheckFrequencyLock(gEeprom.FM_FrequencyPlaying, gEeprom.FM_LowerLimit)) { - if (!gFM_AutoScan) { - gFmPlayCountdown = 0; + if (!FM_CheckFrequencyLock(gEeprom.FM_FrequencyPlaying, gEeprom.FM_LowerLimit)) + { + if (!gFM_AutoScan) + { + gFmPlayCountdown = 0; gFM_FoundFrequency = true; - if (!gEeprom.FM_IsMrMode) { + + if (!gEeprom.FM_IsMrMode) gEeprom.FM_SelectedFrequency = gEeprom.FM_FrequencyPlaying; - } + GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); gEnableSpeaker = true; + GUI_SelectNextDisplay(DISPLAY_FM); return; } - if (gFM_ChannelPosition < 20) { + + if (gFM_ChannelPosition < 20) gFM_Channels[gFM_ChannelPosition++] = gEeprom.FM_FrequencyPlaying; - } - if (gFM_ChannelPosition >= 20) { + + if (gFM_ChannelPosition >= 20) + { FM_PlayAndUpdate(); GUI_SelectNextDisplay(DISPLAY_FM); return; } } - if (gFM_AutoScan && gEeprom.FM_FrequencyPlaying >= gEeprom.FM_UpperLimit) { + if (gFM_AutoScan && gEeprom.FM_FrequencyPlaying >= gEeprom.FM_UpperLimit) FM_PlayAndUpdate(); - } else { + else FM_Tune(gEeprom.FM_FrequencyPlaying, gFM_ScanState, false); - } GUI_SelectNextDisplay(DISPLAY_FM); } void FM_Start(void) { - gFmRadioMode = true; - gFM_ScanState = FM_SCAN_OFF; + gFmRadioMode = true; + gFM_ScanState = FM_SCAN_OFF; gFM_RestoreCountdown = 0; - BK1080_Init(gEeprom.FM_FrequencyPlaying, true); - GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); - gEnableSpeaker = true; - gUpdateStatus = true; -} + BK1080_Init(gEeprom.FM_FrequencyPlaying, true); + + GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); + + gEnableSpeaker = true; + gUpdateStatus = true; +} diff --git a/app/main.c b/app/main.c index 5a25f44..b6ce16a 100644 --- a/app/main.c +++ b/app/main.c @@ -341,6 +341,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld) if (!bKeyHeld && bKeyPressed) { gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + if (!gFmRadioMode) { if (gScanState == SCAN_OFF) @@ -348,6 +349,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld) if (gInputBoxIndex == 0) return; gInputBox[--gInputBoxIndex] = 10; + #ifndef DISABLE_VOICE if (gInputBoxIndex == 0) gAnotherVoiceID = VOICE_ID_CANCEL; @@ -356,6 +358,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld) else { SCANNER_Stop(); + #ifndef DISABLE_VOICE gAnotherVoiceID = VOICE_ID_SCANNING_STOP; #endif @@ -364,6 +367,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld) gRequestDisplayScreen = DISPLAY_MAIN; return; } + ACTION_FM(); } } diff --git a/app/menu.c b/app/menu.c index 0c64724..0422e73 100644 --- a/app/menu.c +++ b/app/menu.c @@ -642,10 +642,7 @@ void MENU_SelectNextCode(void) RADIO_SetupRegisters(true); - if (gSelectedCodeType == CODE_TYPE_CONTINUOUS_TONE) - ScanPauseDelayIn10msec = 20; - else - ScanPauseDelayIn10msec = 30; + ScanPauseDelayIn10msec = (gSelectedCodeType == CODE_TYPE_CONTINUOUS_TONE) ? 20 : 30; gUpdateDisplay = true; } diff --git a/app/scanner.c b/app/scanner.c index d8ec012..e77b380 100644 --- a/app/scanner.c +++ b/app/scanner.c @@ -108,6 +108,7 @@ static void SCANNER_Key_EXIT(bool bKeyPressed, bool bKeyHeld) gRequestDisplayScreen = DISPLAY_SCANNER; break; } + // Fallthrough case 2: @@ -159,14 +160,10 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld) case 0: if (!gScanSingleFrequency) { - uint32_t Freq250; - uint32_t Freq625; - int16_t Delta250; int16_t Delta625; - - Freq250 = FREQUENCY_FloorToStep(gScanFrequency, 250, 0); - Freq625 = FREQUENCY_FloorToStep(gScanFrequency, 625, 0); - Delta250 = (short)gScanFrequency - (short)Freq250; + uint32_t Freq250 = FREQUENCY_FloorToStep(gScanFrequency, 250, 0); + uint32_t Freq625 = FREQUENCY_FloorToStep(gScanFrequency, 625, 0); + int16_t Delta250 = (int16_t)gScanFrequency - (int16_t)Freq250; if (125 < Delta250) { @@ -174,7 +171,7 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld) Freq250 += 250; } - Delta625 = (short)gScanFrequency - (short)Freq625; + Delta625 = (int16_t)gScanFrequency - (int16_t)Freq625; if (312 < Delta625) { @@ -239,6 +236,7 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld) { RADIO_ConfigureChannel(0, 2); RADIO_ConfigureChannel(1, 2); + gTxVfo->ConfigRX.CodeType = gScanCssResultType; gTxVfo->ConfigRX.Code = gScanCssResultCode; gTxVfo->ConfigTX.CodeType = gScanCssResultType; @@ -274,9 +272,9 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld) static void SCANNER_Key_STAR(bool bKeyPressed, bool bKeyHeld) { - if ((!bKeyHeld) && (bKeyPressed)) + if (!bKeyHeld && bKeyPressed) { - gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; + gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gFlagStartScan = true; } return; @@ -328,7 +326,7 @@ void SCANNER_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) SCANNER_Key_MENU(bKeyPressed, bKeyHeld); break; case KEY_UP: - SCANNER_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1); + SCANNER_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1); break; case KEY_DOWN: SCANNER_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1); @@ -355,6 +353,7 @@ void SCANNER_Start(void) uint16_t BackupFrequency; BK4819_StopScan(); + RADIO_SelectVfos(); #ifndef DISABLE_NOAA @@ -392,7 +391,7 @@ void SCANNER_Start(void) BK4819_EnableFrequencyScan(); } - gScanDelay = 21; + gScanDelay = g_scan_delay; gScanCssResultCode = 0xFF; gScanCssResultType = 0xFF; gScanHitCount = 0; @@ -410,7 +409,7 @@ void SCANNER_Start(void) void SCANNER_Stop(void) { - uint8_t Previous = gRestoreMrChannel; + const uint8_t Previous = gRestoreMrChannel; gScanState = SCAN_OFF; diff --git a/driver/bk1080.c b/driver/bk1080.c index 7c9d6bb..48b8157 100644 --- a/driver/bk1080.c +++ b/driver/bk1080.c @@ -21,17 +21,16 @@ #include "driver/system.h" #include "misc.h" -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) +#ifndef ARRAY_SIZE + #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) +#endif -static const uint16_t BK1080_RegisterTable[] = { - 0x0008, 0x1080, 0x0201, 0x0000, - 0x40C0, 0x0A1F, 0x002E, 0x02FF, - 0x5B11, 0x0000, 0x411E, 0x0000, - 0xCE00, 0x0000, 0x0000, 0x1000, - 0x3197, 0x0000, 0x13FF, 0x9852, - 0x0000, 0x0000, 0x0008, 0x0000, - 0x51E1, 0xA8BC, 0x2645, 0x00E4, - 0x1CD8, 0x3A50, 0xEAE0, 0x3000, +static const uint16_t BK1080_RegisterTable[] = +{ + 0x0008, 0x1080, 0x0201, 0x0000, 0x40C0, 0x0A1F, 0x002E, 0x02FF, + 0x5B11, 0x0000, 0x411E, 0x0000, 0xCE00, 0x0000, 0x0000, 0x1000, + 0x3197, 0x0000, 0x13FF, 0x9852, 0x0000, 0x0000, 0x0008, 0x0000, + 0x51E1, 0xA8BC, 0x2645, 0x00E4, 0x1CD8, 0x3A50, 0xEAE0, 0x3000, 0x0200, 0x0000, }; @@ -42,28 +41,40 @@ uint16_t BK1080_FrequencyDeviation; void BK1080_Init(uint16_t Frequency, bool bDoScan) { - uint8_t i; + unsigned int i; - if (bDoScan) { + if (bDoScan) + { GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BK1080); - if (!gIsInitBK1080) { - for (i = 0; i < ARRAY_SIZE(BK1080_RegisterTable); i++) { + if (!gIsInitBK1080) + { + for (i = 0; i < ARRAY_SIZE(BK1080_RegisterTable); i++) BK1080_WriteRegister(i, BK1080_RegisterTable[i]); - } + SYSTEM_DelayMs(250); + BK1080_WriteRegister(BK1080_REG_25_INTERNAL, 0xA83C); BK1080_WriteRegister(BK1080_REG_25_INTERNAL, 0xA8BC); + SYSTEM_DelayMs(60); + gIsInitBK1080 = true; - } else { + } + else + { BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x0201); } + BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, 0x0A5F); BK1080_WriteRegister(BK1080_REG_03_CHANNEL, Frequency - 760); + SYSTEM_DelayMs(10); + BK1080_WriteRegister(BK1080_REG_03_CHANNEL, (Frequency - 760) | 0x8000); - } else { + } + else + { BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x0241); GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BK1080); } @@ -78,6 +89,7 @@ uint16_t BK1080_ReadRegister(BK1080_Register_t Register) I2C_Write((Register << 1) | I2C_READ); I2C_ReadBuffer(Value, sizeof(Value)); I2C_Stop(); + return (Value[0] << 8) | Value[1]; } @@ -93,11 +105,7 @@ void BK1080_WriteRegister(BK1080_Register_t Register, uint16_t Value) void BK1080_Mute(bool Mute) { - if (Mute) { - BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x4201); - } else { - BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x0201); - } + BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, Mute ? 0x4201 : 0x0201); } void BK1080_SetFrequency(uint16_t Frequency) @@ -109,7 +117,6 @@ void BK1080_SetFrequency(uint16_t Frequency) void BK1080_GetFrequencyDeviation(uint16_t Frequency) { - BK1080_BaseFrequency = Frequency; + BK1080_BaseFrequency = Frequency; BK1080_FrequencyDeviation = BK1080_ReadRegister(BK1080_REG_07) / 16; } - diff --git a/driver/bk4819.c b/driver/bk4819.c index 40eedf7..8a14456 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -102,15 +102,16 @@ uint16_t BK4819_ReadRegister(BK4819_REGISTER_t Register) GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCN); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCL); + SYSTICK_DelayUs(1); + GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCN); - BK4819_WriteU8(Register | 0x80); - Value = BK4819_ReadU16(); - GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCN); + SYSTICK_DelayUs(1); + GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCL); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SDA); @@ -121,14 +122,22 @@ void BK4819_WriteRegister(BK4819_REGISTER_t Register, uint16_t Data) { GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCN); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCL); + SYSTICK_DelayUs(1); + GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCN); BK4819_WriteU8(Register); + SYSTICK_DelayUs(1); + BK4819_WriteU16(Data); + SYSTICK_DelayUs(1); + GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCN); + SYSTICK_DelayUs(1); + GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCL); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SDA); } @@ -140,7 +149,7 @@ void BK4819_WriteU8(uint8_t Data) GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCL); for (i = 0; i < 8; i++) { - if ((Data & 0x80U) == 0) + if ((Data & 0x80) == 0) GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SDA); else GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SDA); @@ -163,7 +172,7 @@ void BK4819_WriteU16(uint16_t Data) GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCL); for (i = 0; i < 16; i++) { - if ((Data & 0x8000U) == 0U) + if ((Data & 0x8000) == 0) GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SDA); else GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SDA); @@ -229,8 +238,8 @@ void BK4819_SetCDCSSCodeWord(uint32_t CodeWord) // Enable Auto CDCSS Bw Mode // Enable Auto CTCSS Bw Mode // CTCSS/CDCSS Tx Gain1 Tuning = 51 - BK4819_WriteRegister(BK4819_REG_51, 0 - | BK4819_REG_51_ENABLE_CxCSS + BK4819_WriteRegister(BK4819_REG_51, + BK4819_REG_51_ENABLE_CxCSS | BK4819_REG_51_GPIO6_PIN2_NORMAL | BK4819_REG_51_TX_CDCSS_POSITIVE | BK4819_REG_51_MODE_CDCSS @@ -238,16 +247,14 @@ void BK4819_SetCDCSSCodeWord(uint32_t CodeWord) | BK4819_REG_51_1050HZ_NO_DETECTION | BK4819_REG_51_AUTO_CDCSS_BW_ENABLE | BK4819_REG_51_AUTO_CTCSS_BW_ENABLE - | (51U << BK4819_REG_51_SHIFT_CxCSS_TX_GAIN1)); + | (51u << BK4819_REG_51_SHIFT_CxCSS_TX_GAIN1)); // CTC1 Frequency Control Word = 2775 - BK4819_WriteRegister(BK4819_REG_07, 0 - | BK4819_REG_07_MODE_CTC1 - | (2775u << BK4819_REG_07_SHIFT_FREQUENCY)); + BK4819_WriteRegister(BK4819_REG_07, BK4819_REG_07_MODE_CTC1 | (2775u << BK4819_REG_07_SHIFT_FREQUENCY)); // Set the code word - BK4819_WriteRegister(BK4819_REG_08, 0x0000 | ((CodeWord >> 0) & 0xFFF)); - BK4819_WriteRegister(BK4819_REG_08, 0x8000 | ((CodeWord >> 12) & 0xFFF)); + BK4819_WriteRegister(BK4819_REG_08, 0x0000 | ((CodeWord >> 0) & 0x0FFF)); + BK4819_WriteRegister(BK4819_REG_08, 0x8000 | ((CodeWord >> 12) & 0x0FFF)); } void BK4819_SetCTCSSFrequency(uint32_t FreqControlWord) @@ -255,7 +262,7 @@ void BK4819_SetCTCSSFrequency(uint32_t FreqControlWord) uint16_t Config; if (FreqControlWord == 2625) - { // Enables 1050Hz detection mode + { // Enables 1050Hz detection mode // Enable TxCTCSS // CTCSS Mode // 1050/4 Detect Enable @@ -265,8 +272,7 @@ void BK4819_SetCTCSSFrequency(uint32_t FreqControlWord) Config = 0x944A; } else - { - // Enable TxCTCSS + { // Enable TxCTCSS // CTCSS Mode // Enable Auto CDCSS Bw Mode // Enable Auto CTCSS Bw Mode @@ -276,15 +282,13 @@ void BK4819_SetCTCSSFrequency(uint32_t FreqControlWord) BK4819_WriteRegister(BK4819_REG_51, Config); // CTC1 Frequency Control Word - BK4819_WriteRegister(BK4819_REG_07, 0 - | BK4819_REG_07_MODE_CTC1 - | ((FreqControlWord * 2065) / 1000) << BK4819_REG_07_SHIFT_FREQUENCY); + BK4819_WriteRegister(BK4819_REG_07, BK4819_REG_07_MODE_CTC1 | ((FreqControlWord * 2065) / 1000) << BK4819_REG_07_SHIFT_FREQUENCY); } void BK4819_Set55HzTailDetection(void) { // CTC2 Frequency Control Word = round_nearest(25391 / 55) = 462 - BK4819_WriteRegister(BK4819_REG_07, (1U << 13) | 462); + BK4819_WriteRegister(BK4819_REG_07, (1u << 13) | 462); } void BK4819_EnableVox(uint16_t VoxEnableThreshold, uint16_t VoxDisableThreshold) @@ -356,15 +360,14 @@ void BK4819_SetupSquelch(uint8_t SquelchOpenRSSIThresh, uint8_t SquelchCloseRSSI #if 1 BK4819_WriteRegister(BK4819_REG_4D, 0xA000 | SquelchCloseGlitchThresh); #else - // fastest squelch, https://github.com/fagci/uv-k5-firmware-fagci-mod - // this doesn't work ! + // fastest squelch, https://github.com/fagci/uv-k5-firmware-fagci-mod this doesn't work BK4819_WriteRegister(BK4819_REG_4D, 0b01000000 | SquelchCloseGlitchThresh); #endif // 0x6f = 0110 1111 meaning the default sql delays from the datasheet are used (101 and 111) BK4819_WriteRegister(BK4819_REG_4E, 0x6F00 | SquelchOpenGlitchThresh); BK4819_WriteRegister(BK4819_REG_4F, (SquelchCloseNoiseThresh << 8) | SquelchOpenNoiseThresh); - BK4819_WriteRegister(BK4819_REG_78, (SquelchOpenRSSIThresh << 8) | SquelchCloseRSSIThresh); + BK4819_WriteRegister(BK4819_REG_78, (SquelchOpenRSSIThresh << 8) | SquelchCloseRSSIThresh); BK4819_SetAF(BK4819_AF_MUTE); @@ -456,8 +459,8 @@ void BK4819_DisableDTMF(void) void BK4819_EnableDTMF(void) { BK4819_WriteRegister(BK4819_REG_21, 0x06D8); - BK4819_WriteRegister(BK4819_REG_24, 0 - | (1U << BK4819_REG_24_SHIFT_UNKNOWN_15) + BK4819_WriteRegister(BK4819_REG_24, + (1U << BK4819_REG_24_SHIFT_UNKNOWN_15) | (24 << BK4819_REG_24_SHIFT_THRESHOLD) | (1U << BK4819_REG_24_SHIFT_UNKNOWN_6) | BK4819_REG_24_ENABLE @@ -473,16 +476,13 @@ void BK4819_PlayTone(uint16_t Frequency, bool bTuningGainSwitch) BK4819_SetAF(BK4819_AF_BEEP); if (bTuningGainSwitch == 0) - ToneConfig = 0 | BK4819_REG_70_ENABLE_TONE1 | (96U << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN); + ToneConfig = BK4819_REG_70_ENABLE_TONE1 | (96U << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN); else - ToneConfig = 0 | BK4819_REG_70_ENABLE_TONE1 | (28U << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN); + ToneConfig = BK4819_REG_70_ENABLE_TONE1 | (28U << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN); BK4819_WriteRegister(BK4819_REG_70, ToneConfig); BK4819_WriteRegister(BK4819_REG_30, 0); - BK4819_WriteRegister(BK4819_REG_30, 0 - | BK4819_REG_30_ENABLE_AF_DAC - | BK4819_REG_30_ENABLE_DISC_MODE - | BK4819_REG_30_ENABLE_TX_DSP); + BK4819_WriteRegister(BK4819_REG_30, BK4819_REG_30_ENABLE_AF_DAC | BK4819_REG_30_ENABLE_DISC_MODE | BK4819_REG_30_ENABLE_TX_DSP); BK4819_WriteRegister(BK4819_REG_71, scale_freq(Frequency)); } @@ -507,9 +507,12 @@ void BK4819_TurnsOffTones_TurnsOnRX(void) { BK4819_WriteRegister(BK4819_REG_70, 0); BK4819_SetAF(BK4819_AF_MUTE); + BK4819_ExitTxMute(); + BK4819_WriteRegister(BK4819_REG_30, 0); - BK4819_WriteRegister(BK4819_REG_30, 0 + BK4819_WriteRegister(BK4819_REG_30, + 0 | BK4819_REG_30_ENABLE_VCO_CALIB | BK4819_REG_30_ENABLE_RX_LINK | BK4819_REG_30_ENABLE_AF_DAC @@ -521,20 +524,22 @@ void BK4819_TurnsOffTones_TurnsOnRX(void) #ifndef DISABLE_AIRCOPY void BK4819_SetupAircopy(void) { - BK4819_WriteRegister(BK4819_REG_70, 0x00E0); // Enable Tone2, tuning gain 48 - BK4819_WriteRegister(BK4819_REG_72, 0x3065); // Tone2 baudrate 1200 - BK4819_WriteRegister(BK4819_REG_58, 0x00C1); // FSK Enable, FSK 1.2K RX Bandwidth, Preamble 0xAA or 0x55, RX Gain 0, RX Mode - // (FSK1.2K, FSK2.4K Rx and NOAA SAME Rx), TX Mode FSK 1.2K and FSK 2.4K Tx - BK4819_WriteRegister(BK4819_REG_5C, 0x5665); // Enable CRC among other things we don't know yet - BK4819_WriteRegister(BK4819_REG_5D, 0x4700); // FSK Data Length 72 Bytes (0xabcd + 2 byte length + 64 byte payload + 2 byte CRC + 0xdcba) + BK4819_WriteRegister(BK4819_REG_70, 0x00E0); // Enable Tone2, tuning gain 48 + BK4819_WriteRegister(BK4819_REG_72, 0x3065); // Tone2 baudrate 1200 + BK4819_WriteRegister(BK4819_REG_58, 0x00C1); // FSK Enable, FSK 1.2K RX Bandwidth, Preamble 0xAA or 0x55, RX Gain 0, RX Mode + // (FSK1.2K, FSK2.4K Rx and NOAA SAME Rx), TX Mode FSK 1.2K and FSK 2.4K Tx + BK4819_WriteRegister(BK4819_REG_5C, 0x5665); // Enable CRC among other things we don't know yet + BK4819_WriteRegister(BK4819_REG_5D, 0x4700); // FSK Data Length 72 Bytes (0xabcd + 2 byte length + 64 byte payload + 2 byte CRC + 0xdcba) } #endif void BK4819_ResetFSK(void) { - BK4819_WriteRegister(BK4819_REG_3F, 0x0000); // Disable interrupts - BK4819_WriteRegister(BK4819_REG_59, 0x0068); // Sync length 4 bytes, 7 byte preamble + BK4819_WriteRegister(BK4819_REG_3F, 0x0000); // Disable interrupts + BK4819_WriteRegister(BK4819_REG_59, 0x0068); // Sync length 4 bytes, 7 byte preamble + SYSTEM_DelayMs(30); + BK4819_Idle(); } @@ -583,7 +588,8 @@ void BK4819_EnterDTMF_TX(bool bLocalLoopback) BK4819_EnableDTMF(); BK4819_EnterTxMute(); BK4819_SetAF(bLocalLoopback ? BK4819_AF_BEEP : BK4819_AF_MUTE); - BK4819_WriteRegister(BK4819_REG_70, 0 + BK4819_WriteRegister(BK4819_REG_70, + 0 | BK4819_REG_70_MASK_ENABLE_TONE1 | (83 << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN) | BK4819_REG_70_MASK_ENABLE_TONE2 @@ -605,7 +611,8 @@ void BK4819_ExitDTMF_TX(bool bKeep) void BK4819_EnableTXLink(void) { - BK4819_WriteRegister(BK4819_REG_30, 0 + BK4819_WriteRegister(BK4819_REG_30, + 0 | BK4819_REG_30_ENABLE_VCO_CALIB | BK4819_REG_30_ENABLE_UNKNOWN | BK4819_REG_30_DISABLE_RX_LINK @@ -713,11 +720,16 @@ void BK4819_PlayDTMFString(const char *pString, bool bDelayFirst, uint16_t First void BK4819_TransmitTone(bool bLocalLoopback, uint32_t Frequency) { BK4819_EnterTxMute(); + BK4819_WriteRegister(BK4819_REG_70, 0 | BK4819_REG_70_MASK_ENABLE_TONE1 | (96U << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN)); BK4819_WriteRegister(BK4819_REG_71, scale_freq(Frequency)); + BK4819_SetAF(bLocalLoopback ? BK4819_AF_BEEP : BK4819_AF_MUTE); + BK4819_EnableTXLink(); + SYSTEM_DelayMs(50); + BK4819_ExitTxMute(); } @@ -897,18 +909,27 @@ void BK4819_PrepareFSKReceive(void) void BK4819_PlayRoger(void) { BK4819_EnterTxMute(); + BK4819_SetAF(BK4819_AF_MUTE); BK4819_WriteRegister(BK4819_REG_70, 0xE000); + BK4819_EnableTXLink(); + SYSTEM_DelayMs(50); + BK4819_WriteRegister(BK4819_REG_71, 0x142A); BK4819_ExitTxMute(); + SYSTEM_DelayMs(80); + BK4819_EnterTxMute(); BK4819_WriteRegister(BK4819_REG_71, 0x1C3B); BK4819_ExitTxMute(); + SYSTEM_DelayMs(80); + BK4819_EnterTxMute(); + BK4819_WriteRegister(BK4819_REG_70, 0x0000); BK4819_WriteRegister(BK4819_REG_30, 0xC1FE); } @@ -966,10 +987,15 @@ void BK4819_PlayDTMFEx(bool bLocalLoopback, char Code) { BK4819_EnableDTMF(); BK4819_EnterTxMute(); + BK4819_SetAF(bLocalLoopback ? BK4819_AF_BEEP : BK4819_AF_MUTE); BK4819_WriteRegister(BK4819_REG_70, 0xD3D3); + BK4819_EnableTXLink(); + SYSTEM_DelayMs(50); + BK4819_PlayDTMF(Code); + BK4819_ExitTxMute(); } diff --git a/driver/eeprom.c b/driver/eeprom.c index 25c2bdb..606e4c6 100644 --- a/driver/eeprom.c +++ b/driver/eeprom.c @@ -37,7 +37,6 @@ void EEPROM_ReadBuffer(uint16_t Address, void *pBuffer, uint8_t Size) } void EEPROM_WriteBuffer(uint16_t Address, const void *pBuffer) - { I2C_Start(); @@ -52,4 +51,3 @@ void EEPROM_WriteBuffer(uint16_t Address, const void *pBuffer) SYSTEM_DelayMs(10); } - diff --git a/driver/st7565.c b/driver/st7565.c index da9685f..4b8ee89 100644 --- a/driver/st7565.c +++ b/driver/st7565.c @@ -15,6 +15,7 @@ */ #include + #include "bsp/dp32g030/gpio.h" #include "bsp/dp32g030/spi.h" #include "driver/gpio.h" @@ -84,7 +85,7 @@ void ST7565_BlitFullScreen(void) #else SYSTEM_DelayMs(1); #endif - + SPI_ToggleMasterMode(&SPI0->CR, true); } @@ -158,9 +159,9 @@ void ST7565_Init(void) SYSTEM_DelayMs(1); ST7565_WriteByte(0x2E); - + SYSTEM_DelayMs(1); - + ST7565_WriteByte(0x2F); ST7565_WriteByte(0x2F); ST7565_WriteByte(0x2F); diff --git a/driver/system.c b/driver/system.c index 989d2fb..abcfb06 100644 --- a/driver/system.c +++ b/driver/system.c @@ -27,9 +27,7 @@ void SYSTEM_DelayMs(uint32_t Delay) void SYSTEM_ConfigureClocks(void) { // Set source clock from external crystal - PMU_SRC_CFG = (PMU_SRC_CFG & ~(PMU_SRC_CFG_RCHF_SEL_MASK | PMU_SRC_CFG_RCHF_EN_MASK)) - | PMU_SRC_CFG_RCHF_SEL_BITS_48MHZ - | PMU_SRC_CFG_RCHF_EN_BITS_ENABLE; + PMU_SRC_CFG = (PMU_SRC_CFG & ~(PMU_SRC_CFG_RCHF_SEL_MASK | PMU_SRC_CFG_RCHF_EN_MASK)) | PMU_SRC_CFG_RCHF_SEL_BITS_48MHZ | PMU_SRC_CFG_RCHF_EN_BITS_ENABLE; // Divide by 2 SYSCON_CLK_SEL = SYSCON_CLK_SEL_DIV_BITS_2; @@ -37,4 +35,3 @@ void SYSTEM_ConfigureClocks(void) // Disable division clock gate SYSCON_DIV_CLK_GATE = (SYSCON_DIV_CLK_GATE & ~SYSCON_DIV_CLK_GATE_DIV_CLK_GATE_MASK) | SYSCON_DIV_CLK_GATE_DIV_CLK_GATE_BITS_DISABLE; } - diff --git a/firmware b/firmware index f626ede..90c7dfb 100644 Binary files a/firmware and b/firmware differ diff --git a/firmware.bin b/firmware.bin index f12cab4..d38606c 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 8d1c274..00bc2ff 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/font.c b/font.c index 70a1ff6..a68dfd4 100644 --- a/font.c +++ b/font.c @@ -115,20 +115,39 @@ const uint8_t gFontBig[95][16] = {0x10, 0x18, 0x08, 0x18, 0x10, 0x18, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} }; -const uint8_t gFontBigDigits[11][26] = -{ - {0x00, 0xC0, 0xF0, 0xF8, 0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1C, 0xF8, 0xF0, 0xE0, 0x00, 0x07, 0x1F, 0x3F, 0x78, 0x60, 0x60, 0x60, 0x60, 0x70, 0x3F, 0x1F, 0x0F}, - {0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0xFC, 0xFC, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00}, - {0x00, 0x10, 0x38, 0x38, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C, 0xFC, 0xF8, 0xF0, 0x00, 0x00, 0x70, 0x78, 0x7C, 0x7C, 0x6E, 0x66, 0x67, 0x67, 0x63, 0x61, 0x60, 0x00}, - {0x00, 0x10, 0x18, 0x18, 0x9C, 0x8C, 0x8C, 0x8C, 0x8C, 0xCC, 0xF8, 0xF8, 0x70, 0x00, 0x30, 0x30, 0x30, 0x71, 0x61, 0x61, 0x61, 0x61, 0x71, 0x3F, 0x3F, 0x1E}, - {0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0x70, 0x38, 0xFC, 0xFC, 0xFC, 0x00, 0x00, 0x1C, 0x1E, 0x1F, 0x1F, 0x19, 0x18, 0x18, 0x18, 0x7F, 0x7F, 0x7F, 0x18}, - {0x00, 0x00, 0xFC, 0xFC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x8C, 0x0C, 0x00, 0x00, 0x18, 0x30, 0x70, 0x60, 0x60, 0x60, 0x60, 0x71, 0x7B, 0x3F, 0x1F}, - {0x00, 0xC0, 0xF0, 0xF8, 0x38, 0x9C, 0x8C, 0x8C, 0x8C, 0x8C, 0x9C, 0x38, 0x30, 0x00, 0x0F, 0x1F, 0x3F, 0x73, 0x61, 0x61, 0x61, 0x61, 0x73, 0x33, 0x3F, 0x1E}, - {0x00, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x8C, 0xEC, 0xFC, 0x3C, 0x1C, 0x00, 0x00, 0x00, 0x40, 0x60, 0x78, 0x7C, 0x1F, 0x07, 0x03, 0x00, 0x00, 0x00}, - {0x00, 0x00, 0x78, 0xF8, 0xDC, 0x8C, 0x8C, 0x8C, 0x8C, 0xDC, 0xF8, 0x78, 0x00, 0x00, 0x1E, 0x3F, 0x3F, 0x73, 0x61, 0x61, 0x61, 0x61, 0x73, 0x3F, 0x3F, 0x1E}, - {0x00, 0xF0, 0xF8, 0xB8, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1C, 0xB8, 0xF0, 0xE0, 0x00, 0x11, 0x33, 0x77, 0x67, 0x66, 0x66, 0x66, 0x76, 0x33, 0x3F, 0x1F, 0x07}, - {0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00} -}; +#if 0 + // original font + const uint8_t gFontBigDigits[11][26] = + { + {0x00, 0xC0, 0xF0, 0xF8, 0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1C, 0xF8, 0xF0, 0xE0, 0x00, 0x07, 0x1F, 0x3F, 0x78, 0x60, 0x60, 0x60, 0x60, 0x70, 0x3F, 0x1F, 0x0F}, + {0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0xFC, 0xFC, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x10, 0x38, 0x38, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C, 0xFC, 0xF8, 0xF0, 0x00, 0x00, 0x70, 0x78, 0x7C, 0x7C, 0x6E, 0x66, 0x67, 0x67, 0x63, 0x61, 0x60, 0x00}, + {0x00, 0x10, 0x18, 0x18, 0x9C, 0x8C, 0x8C, 0x8C, 0x8C, 0xCC, 0xF8, 0xF8, 0x70, 0x00, 0x30, 0x30, 0x30, 0x71, 0x61, 0x61, 0x61, 0x61, 0x71, 0x3F, 0x3F, 0x1E}, + {0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0x70, 0x38, 0xFC, 0xFC, 0xFC, 0x00, 0x00, 0x1C, 0x1E, 0x1F, 0x1F, 0x19, 0x18, 0x18, 0x18, 0x7F, 0x7F, 0x7F, 0x18}, + {0x00, 0x00, 0xFC, 0xFC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x8C, 0x0C, 0x00, 0x00, 0x18, 0x30, 0x70, 0x60, 0x60, 0x60, 0x60, 0x71, 0x7B, 0x3F, 0x1F}, + {0x00, 0xC0, 0xF0, 0xF8, 0x38, 0x9C, 0x8C, 0x8C, 0x8C, 0x8C, 0x9C, 0x38, 0x30, 0x00, 0x0F, 0x1F, 0x3F, 0x73, 0x61, 0x61, 0x61, 0x61, 0x73, 0x33, 0x3F, 0x1E}, + {0x00, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x8C, 0xEC, 0xFC, 0x3C, 0x1C, 0x00, 0x00, 0x00, 0x40, 0x60, 0x78, 0x7C, 0x1F, 0x07, 0x03, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x78, 0xF8, 0xDC, 0x8C, 0x8C, 0x8C, 0x8C, 0xDC, 0xF8, 0x78, 0x00, 0x00, 0x1E, 0x3F, 0x3F, 0x73, 0x61, 0x61, 0x61, 0x61, 0x73, 0x3F, 0x3F, 0x1E}, + {0x00, 0xF0, 0xF8, 0xB8, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1C, 0xB8, 0xF0, 0xE0, 0x00, 0x11, 0x33, 0x77, 0x67, 0x66, 0x66, 0x66, 0x76, 0x33, 0x3F, 0x1F, 0x07}, + {0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00} + }; +#else + // VCR font + const uint8_t gFontBigDigits[11][26] = + { + {0x00, 0x00, 0xF8, 0xFC, 0x06, 0x86, 0xC6, 0xE6, 0xF6, 0x76, 0xFC, 0xF8, 0x00, 0x00, 0x00, 0x1F, 0x3F, 0x77, 0x67, 0x63, 0x61, 0x60, 0x70, 0x3F, 0x1F, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x18, 0x1C, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x7F, 0x7F, 0x60, 0x60, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x18, 0x1C, 0x86, 0x86, 0x86, 0x86, 0x86, 0xC6, 0xFC, 0x78, 0x00, 0x00, 0x00, 0x7E, 0x7F, 0x63, 0x61, 0x61, 0x61, 0x61, 0x61, 0x60, 0x60, 0x00}, + {0x00, 0x00, 0x18, 0x1C, 0x06, 0x06, 0x86, 0x86, 0x86, 0xC6, 0xFC, 0x78, 0x00, 0x00, 0x00, 0x18, 0x38, 0x70, 0x60, 0x61, 0x61, 0x61, 0x73, 0x3F, 0x1E, 0x00}, + {0x00, 0x00, 0x80, 0xC0, 0xE0, 0x70, 0x38, 0x1C, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x06, 0x06, 0x06, 0x06, 0x7F, 0x7F, 0x06, 0x06, 0x00}, + {0x00, 0x00, 0x7E, 0x7E, 0x66, 0x66, 0x66, 0x66, 0x66, 0xE6, 0xC6, 0x86, 0x00, 0x00, 0x00, 0x18, 0x38, 0x70, 0x60, 0x60, 0x60, 0x60, 0x70, 0x3F, 0x1F, 0x00}, + {0x00, 0x00, 0xF8, 0xFC, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x1C, 0x18, 0x00, 0x00, 0x00, 0x1F, 0x3F, 0x71, 0x61, 0x61, 0x61, 0x61, 0x73, 0x3F, 0x1E, 0x00}, + {0x00, 0x00, 0x06, 0x06, 0x06, 0x06, 0x06, 0x86, 0xC6, 0xE6, 0x7E, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x01, 0x00, 0x00, 0x00, 0x00}, + {0x00, 0x00, 0x78, 0xFC, 0xC6, 0x86, 0x86, 0x86, 0x86, 0xC6, 0xFC, 0x78, 0x00, 0x00, 0x00, 0x1E, 0x3F, 0x73, 0x61, 0x61, 0x61, 0x61, 0x73, 0x3F, 0x1E, 0x00}, + {0x00, 0x00, 0x78, 0xFC, 0xC6, 0x86, 0x86, 0x86, 0x86, 0x86, 0xFC, 0xF8, 0x00, 0x00, 0x00, 0x18, 0x38, 0x71, 0x61, 0x61, 0x61, 0x61, 0x71, 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/helper/boot.c b/helper/boot.c index 311fb7a..5ffbfd0 100644 --- a/helper/boot.c +++ b/helper/boot.c @@ -69,6 +69,7 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode) gMenuCursor = MENU_350TX; gSubMenuSelection = gSetting_350TX; GUI_SelectNextDisplay(DISPLAY_MENU); + gF_LOCK = true; gMenuListCount = 57; #ifdef DISABLE_VOICE gMenuListCount--; @@ -76,7 +77,6 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode) #ifdef DISABLE_NOAA gMenuListCount--; #endif - gF_LOCK = true; } #ifndef DISABLE_AIRCOPY else @@ -91,23 +91,22 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode) gEeprom.KEY_1_LONG_PRESS_ACTION = 0; gEeprom.KEY_2_SHORT_PRESS_ACTION = 0; gEeprom.KEY_2_LONG_PRESS_ACTION = 0; - + RADIO_InitInfo(gRxVfo, 205, 5, 41002500); - + gRxVfo->CHANNEL_BANDWIDTH = BANDWIDTH_NARROW; gRxVfo->OUTPUT_POWER = 0; - + RADIO_ConfigureSquelchAndOutputPower(gRxVfo); - + gCurrentVfo = gRxVfo; - + RADIO_SetupRegisters(true); BK4819_SetupAircopy(); BK4819_ResetFSK(); - + gAircopyState = AIRCOPY_READY; GUI_SelectNextDisplay(DISPLAY_AIRCOPY); - } #endif else diff --git a/misc.c b/misc.c index 24cb914..8c166d6 100644 --- a/misc.c +++ b/misc.c @@ -18,6 +18,15 @@ #include "misc.h" +const uint8_t g_scan_delay = 21; // 21 + +const uint16_t gMax_bat_v = 840; // 8.4V +const uint16_t gMin_bat_v = 660; // 6.6V + +const uint32_t gDefaultAesKey[4] = {0x4AA5CC60, 0x0312CC5F, 0xFFD2DABB, 0x6BBA7F92}; + +const uint8_t gMicGain_dB2[5] = {3, 8, 16, 24, 31}; + const uint32_t *gUpperLimitFrequencyBandTable; const uint32_t *gLowerLimitFrequencyBandTable; @@ -29,19 +38,6 @@ bool gSetting_350EN; uint8_t gSetting_F_LOCK; bool gSetting_ScrambleEnable; -const uint16_t gMax_bat_v = 840; // 8.4V -const uint16_t gMin_bat_v = 660; // 6.6V - -const uint32_t gDefaultAesKey[4] = -{ - 0x4AA5CC60, - 0x0312CC5F, - 0xFFD2DABB, - 0x6BBA7F92, -}; - -const uint8_t gMicGain_dB2[5] = {3, 8, 16, 24, 31}; - uint32_t gCustomAesKey[4]; bool bHasCustomAesKey; uint32_t gChallenge[4]; diff --git a/misc.h b/misc.h index a753c9c..b513178 100644 --- a/misc.h +++ b/misc.h @@ -30,51 +30,53 @@ #endif enum { - MR_CHANNEL_FIRST = 0U, - MR_CHANNEL_LAST = 199U, - FREQ_CHANNEL_FIRST = 200U, - FREQ_CHANNEL_LAST = 206U, - NOAA_CHANNEL_FIRST = 207U, - NOAA_CHANNEL_LAST = 216U + MR_CHANNEL_FIRST = 0U, + MR_CHANNEL_LAST = 199U, + FREQ_CHANNEL_FIRST = 200U, + FREQ_CHANNEL_LAST = 206U, + NOAA_CHANNEL_FIRST = 207U, + NOAA_CHANNEL_LAST = 216U }; enum { - FLASHLIGHT_OFF = 0U, - FLASHLIGHT_ON = 1U, - FLASHLIGHT_BLINK = 2U + FLASHLIGHT_OFF = 0, + FLASHLIGHT_ON, + FLASHLIGHT_BLINK }; enum { - VFO_CONFIGURE_0 = 0U, - VFO_CONFIGURE_1 = 1U, - VFO_CONFIGURE_RELOAD = 2U + VFO_CONFIGURE_0 = 0, + VFO_CONFIGURE_1, + VFO_CONFIGURE_RELOAD }; enum AlarmState_t { - ALARM_STATE_OFF = 0U, - ALARM_STATE_TXALARM = 1U, - ALARM_STATE_ALARM = 2U, - ALARM_STATE_TX1750 = 3U + ALARM_STATE_OFF = 0, + ALARM_STATE_TXALARM, + ALARM_STATE_ALARM, + ALARM_STATE_TX1750 }; typedef enum AlarmState_t AlarmState_t; enum ReceptionMode_t { - RX_MODE_NONE = 0U, - RX_MODE_DETECTED = 1U, - RX_MODE_LISTENING = 2U + RX_MODE_NONE = 0, + RX_MODE_DETECTED, + RX_MODE_LISTENING }; typedef enum ReceptionMode_t ReceptionMode_t; enum CssScanMode_t { - CSS_SCAN_MODE_OFF = 0U, - CSS_SCAN_MODE_SCANNING = 1U, - CSS_SCAN_MODE_FOUND = 2U, + CSS_SCAN_MODE_OFF = 0, + CSS_SCAN_MODE_SCANNING, + CSS_SCAN_MODE_FOUND, }; typedef enum CssScanMode_t CssScanMode_t; +extern const uint8_t g_scan_delay; + extern const uint16_t gMax_bat_v; extern const uint16_t gMin_bat_v; diff --git a/radio.c b/radio.c index 5bdb0b8..fb64565 100644 --- a/radio.c +++ b/radio.c @@ -744,6 +744,11 @@ void RADIO_SetTxParameters(void) switch (gCurrentVfo->pTX->CodeType) { + default: + case CODE_TYPE_OFF: + BK4819_ExitSubAu(); + break; + case CODE_TYPE_CONTINUOUS_TONE: BK4819_SetCTCSSFrequency(CTCSS_Options[gCurrentVfo->pTX->Code]); break; @@ -754,10 +759,6 @@ void RADIO_SetTxParameters(void) DCS_GetGolayCodeWord(gCurrentVfo->pTX->CodeType, gCurrentVfo->pTX->Code) ); break; - - default: - BK4819_ExitSubAu(); - break; } } diff --git a/ui/main.c b/ui/main.c index 9fc29cb..32a3f71 100644 --- a/ui/main.c +++ b/ui/main.c @@ -59,7 +59,8 @@ void UI_DisplayMain(void) uint32_t frequency_Hz = 0; if (single_vfo) - { + { // we're in single VFO mode + if (!bIsSameVfo) continue; // skip the unused vfo .. screen is dedicated to just a single VFO @@ -74,7 +75,8 @@ void UI_DisplayMain(void) if (Channel != vfo_num) { if (gDTMF_CallState != DTMF_CALL_STATE_NONE || gDTMF_IsTx || gDTMF_InputMode) - { + { // show DTMF stuff + char Contact[16]; if (!gDTMF_InputMode) @@ -98,14 +100,10 @@ void UI_DisplayMain(void) { memset(Contact, 0, sizeof(Contact)); if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT) - { sprintf(String, ">%s", (DTMF_FindContact(gDTMF_String, Contact)) ? Contact : gDTMF_String); - } else if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED) - { sprintf(String, ">%s", (DTMF_FindContact(gDTMF_Callee, Contact)) ? Contact : gDTMF_Callee); - } else if (gDTMF_IsTx) sprintf(String, ">%s", gDTMF_String); @@ -128,11 +126,11 @@ void UI_DisplayMain(void) //memcpy(pLine0 + 2, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault)); } - // 0x8EE2 uint32_t SomeValue = 0; if (gCurrentFunction == FUNCTION_TRANSMIT) - { + { // transmitting + #ifndef DISABLE_ALARM if (gAlarmState == ALARM_STATE_ALARM) { @@ -157,8 +155,12 @@ void UI_DisplayMain(void) } if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num])) - { // show the mrmory channel number + { // channel mode + + // show the memory symbol memcpy(pLine1 + 2, BITMAP_M, sizeof(BITMAP_M)); + + // show the memory channel number if (gInputBoxIndex == 0 || gEeprom.TX_CHANNEL != vfo_num) NUMBER_ToDigits(gEeprom.ScreenChannel[vfo_num] + 1, String); else @@ -167,7 +169,8 @@ void UI_DisplayMain(void) } else if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num])) - { // show the frequency band number + { + // show the frequency band number char c; memcpy(pLine1 + 14, BITMAP_F, sizeof(BITMAP_F)); c = (gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST) + 1; @@ -190,8 +193,6 @@ void UI_DisplayMain(void) UI_DisplaySmallDigits(2, String + 6, 15, Line + 1); } - // 0x8FEC - uint8_t State = VfoState[vfo_num]; #ifndef DISABLE_ALARM @@ -213,7 +214,7 @@ void UI_DisplayMain(void) { case VFO_STATE_BUSY: strcpy(String, "BUSY"); - Width = 15; + //Width = 15; break; case VFO_STATE_BAT_LOW: strcpy(String, "BAT LOW"); @@ -237,14 +238,16 @@ void UI_DisplayMain(void) } else { // normal state + if (gInputBoxIndex && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_CHANNEL == vfo_num) - { + { // user is entering a new frequency UI_DisplayFrequency(gInputBox, 31, vfo_num * 4, true, false); } else { if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num])) - { + { // channel mode# + frequency_Hz = gEeprom.VfoInfo[vfo_num].pRX->Frequency; if (gCurrentFunction == FUNCTION_TRANSMIT) { // transmitting @@ -253,24 +256,28 @@ void UI_DisplayMain(void) frequency_Hz = gEeprom.VfoInfo[vfo_num].pTX->Frequency; } + { // show the scanlist symbols + const uint8_t Attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; + if (Attributes & MR_CH_SCANLIST1) + memcpy(pLine0 + 113, BITMAP_ScanList, sizeof(BITMAP_ScanList)); + if (Attributes & MR_CH_SCANLIST2) + memcpy(pLine0 + 120, BITMAP_ScanList, sizeof(BITMAP_ScanList)); + } + switch (gEeprom.CHANNEL_DISPLAY_MODE) { case MDF_FREQUENCY: // show the channel frequency - NUMBER_ToDigits(frequency_Hz, String); - - // show the first lot of the frequency digits - UI_DisplayFrequency(String, 31, vfo_num * 4, false, false); - // show the remaining 2 frequency digits - UI_DisplaySmallDigits(2, String + 6, 112, Line + 1); - - if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num])) - { - const uint8_t Attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; - if (Attributes & MR_CH_SCANLIST1) - memcpy(pLine0 + 113, BITMAP_ScanList, sizeof(BITMAP_ScanList)); - if (Attributes & MR_CH_SCANLIST2) - memcpy(pLine0 + 120, BITMAP_ScanList, sizeof(BITMAP_ScanList)); - } + #ifdef BIG_FREQ_FONT + NUMBER_ToDigits(frequency_Hz, String); + // show the main large frequency digits + UI_DisplayFrequency(String, 31, vfo_num * 4, false, false); + // show the remaining 2 small frequency digits + UI_DisplaySmallDigits(2, String + 6, 112, Line + 1); + #else + // show the frequency in the main font + sprintf(String, "%9.5f", frequency_Hz * 0.00001); + UI_PrintString(String, 31, 112, vfo_num * 4, 8, true); + #endif frequency_Hz = 0; break; @@ -283,7 +290,7 @@ void UI_DisplayMain(void) case MDF_NAME: // show the channel name if (gEeprom.VfoInfo[vfo_num].Name[0] == 0 || gEeprom.VfoInfo[vfo_num].Name[0] == 0xFF) - { // channel number + { // no channel name, show the channel number instead sprintf(String, "CH-%03d", gEeprom.ScreenChannel[vfo_num] + 1); UI_PrintString(String, 31, 112, vfo_num * 4, 8, true); } @@ -297,22 +304,23 @@ void UI_DisplayMain(void) #ifdef CHAN_NAME_FREQ case MDF_NAME_FREQ: // show the channel name and frequency if (gEeprom.VfoInfo[vfo_num].Name[0] == 0 || gEeprom.VfoInfo[vfo_num].Name[0] == 0xFF) - { // channel number + { // no channel name, show channel number instead sprintf(String, "CH-%03d", gEeprom.ScreenChannel[vfo_num] + 1); - UI_PrintStringSmall(gEeprom.VfoInfo[vfo_num].Name, 31 + 16, 0, (vfo_num * 4) + 0, false); + UI_PrintStringSmall(gEeprom.VfoInfo[vfo_num].Name, 31 + 8, 0, (vfo_num * 4) + 0, false); } else { // channel name memset(String, 0, sizeof(String)); memcpy(String, gEeprom.VfoInfo[vfo_num].Name, 8); - UI_PrintStringSmall(gEeprom.VfoInfo[vfo_num].Name, 31 + 16, 0, (vfo_num * 4) + 0, false); + UI_PrintStringSmall(gEeprom.VfoInfo[vfo_num].Name, 31 + 8, 0, (vfo_num * 4) + 0, false); } break; #endif } } else - { + { // frequency mode + frequency_Hz = gEeprom.VfoInfo[vfo_num].pRX->Frequency; if (gCurrentFunction == FUNCTION_TRANSMIT) { // transmitting @@ -321,21 +329,17 @@ void UI_DisplayMain(void) frequency_Hz = gEeprom.VfoInfo[vfo_num].pTX->Frequency; } - NUMBER_ToDigits(frequency_Hz, String); // 8 digits - - // show main part of frequency - UI_DisplayFrequency(String, 31, vfo_num * 4, false, false); - // show the remaing 2 small frequency digits - UI_DisplaySmallDigits(2, String + 6, 112, Line + 1); - - if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num])) - { - const uint8_t Attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; - if (Attributes & MR_CH_SCANLIST1) - memcpy(pLine0 + 113, BITMAP_ScanList, sizeof(BITMAP_ScanList)); - if (Attributes & MR_CH_SCANLIST2) - memcpy(pLine0 + 120, BITMAP_ScanList, sizeof(BITMAP_ScanList)); - } + #ifdef BIG_FREQ_FONT + NUMBER_ToDigits(frequency_Hz, String); // 8 digits + // show the main large frequency digits + UI_DisplayFrequency(String, 31, vfo_num * 4, false, false); + // show the remaining 2 small frequency digits + UI_DisplaySmallDigits(2, String + 6, 112, Line + 1); + #else + // show the frequency in the main font + sprintf(String, "%9.5f", frequency_Hz * 0.00001); + UI_PrintString(String, 31, 112, vfo_num * 4, 8, true); + #endif frequency_Hz = 0; } @@ -407,7 +411,7 @@ void UI_DisplayMain(void) } switch (gEeprom.VfoInfo[vfo_num].OUTPUT_POWER) - { // show the TX power symbol + { // show the TX power level symbol case OUTPUT_POWER_LOW: memcpy(pLine1 + 128 + 44, BITMAP_PowerLow, sizeof(BITMAP_PowerLow)); break; @@ -446,12 +450,12 @@ void UI_DisplayMain(void) #ifdef CHAN_NAME_FREQ if (frequency_Hz > 0) { // show the channel frequency below the channel number/name - #if 0 + #if 1 NUMBER_ToDigits(frequency_Hz, String); // 8 digits UI_DisplayFrequencySmall(String, 31 + 8, (vfo_num * 4) + 1, false); #else sprintf(String, "%9.5f", frequency_Hz * 0.00001); - UI_PrintStringSmall(String, 31 + 16, 0, (vfo_num * 4) + 1, false); + UI_PrintStringSmall(String, 31 + 8, 0, (vfo_num * 4) + 1, false); #endif } #endif diff --git a/version.c b/version.c index 0896fbe..4758ee4 100644 --- a/version.c +++ b/version.c @@ -2,5 +2,5 @@ #ifdef GIT_HASH const char Version[] = "OEFW-" GIT_HASH; #else - const char Version[] = "OEFW-230910"; + const char Version[] = "OEFW-230911"; #endif diff --git a/win_make.bat b/win_make.bat index 5450646..328bae9 100644 --- a/win_make.bat +++ b/win_make.bat @@ -13,7 +13,7 @@ del /S /Q *.o >nul 2>nul del /S /Q *.d >nul 2>nul ::python -m pip install --upgrade pip crcmod -fw-pack.py firmware.bin 230910 firmware.packed.bin +fw-pack.py firmware.bin 230911 firmware.packed.bin ::arm-none-eabi-size firmware