0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 14:21:25 +03:00

Font and display updates

This commit is contained in:
OneOfEleven 2023-09-11 00:02:57 +01:00
parent 7dc3512a50
commit e5294129ae
25 changed files with 658 additions and 477 deletions

View File

@ -93,6 +93,7 @@ LDFLAGS = -mcpu=cortex-m0 -nostartfiles -Wl,-T,firmware.ld
#LDFLAGS = -mcpu=cortex-m0 -nostartfiles -Wl,-gc-sections,-T,firmware.ld #LDFLAGS = -mcpu=cortex-m0 -nostartfiles -Wl,-gc-sections,-T,firmware.ld
# compilation options # compilation options
#CFLAGS += -DBIG_FREQ_FONT
CFLAGS += -DDISABLE_NOAA CFLAGS += -DDISABLE_NOAA
CFLAGS += -DDISABLE_VOICE CFLAGS += -DDISABLE_VOICE
CFLAGS += -DDISABLE_AIRCOPY CFLAGS += -DDISABLE_AIRCOPY

View File

@ -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. 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 .. 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 += -DBIG_FREQ_FONT .. show frequency using big font
* CFLAGS += -DDISABLE_VOICE .. remove spoken VOICES option from the firmware * CFLAGS += -DDISABLE_NOAA .. remove NOAA channels option from the firmware
* CFLAGS += -DDISABLE_AIRCOPY .. remove AIRCOPY option * CFLAGS += -DDISABLE_VOICE .. remove spoken VOICES option from the firmware
* CFLAGS += -DKEEP_MEM_NAME .. maintain the memory channel's name when re-saving the memory channel * CFLAGS += -DDISABLE_AIRCOPY .. remove AIRCOPY option
* CFLAGS += -DDISABLE_ALARM .. remove the ALARM transmit option from the firmware * CFLAGS += -DKEEP_MEM_NAME .. keep the memory channels name when re-saving a channel
* CFLAGS += -DCHAN_NAME_FREQ .. show the channel frequency (as well as channel number/name) * CFLAGS += -DDISABLE_ALARM .. remove the ALARM transmit option from the firmware
* CFLAGS += -DSINGLE_VFO_CHAN .. not yet implemented .. only show a single VFO/CHANNEL if dual watch is disabled * CFLAGS += -DCHAN_NAME_FREQ .. show the channel frequency (as well as channel number/name)
* #CFLAGS += -DBAND_SCOPE .. not yet implemented * #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 '#'. 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 * Slightly less intense menu style
* AM RX now allowed everywhere, although the radio really doesn't do AM, the adverts are a con ! * AM RX now allowed everywhere, although the radio really doesn't do AM, the adverts are a con !
* Finer RSSI bar steps * Finer RSSI bar steps
* Nicer big font than original big font (frequency mode)
* *
* "MEM-CH" and "DEL-CH" menus now include channel name * "MEM-CH" and "DEL-CH" menus now include channel name
* "STEP" menu, added 1.25kHz option, removed 5kHz option * "STEP" menu, added 1.25kHz option, removed 5kHz option

View File

@ -109,18 +109,20 @@ void ACTION_Scan(bool bRestart)
{ {
if (gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT) if (gCurrentFunction != FUNCTION_RECEIVE && gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
{ {
uint16_t Frequency;
GUI_SelectNextDisplay(DISPLAY_FM); GUI_SelectNextDisplay(DISPLAY_FM);
if (gFM_ScanState != FM_SCAN_OFF) if (gFM_ScanState != FM_SCAN_OFF)
{ {
FM_PlayAndUpdate(); FM_PlayAndUpdate();
#ifndef DISABLE_VOICE #ifndef DISABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP; gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif #endif
} }
else else
{ {
uint16_t Frequency;
if (bRestart) if (bRestart)
{ {
gFM_AutoScan = true; gFM_AutoScan = true;
@ -134,8 +136,10 @@ void ACTION_Scan(bool bRestart)
gFM_ChannelPosition = 0; gFM_ChannelPosition = 0;
Frequency = gEeprom.FM_FrequencyPlaying; Frequency = gEeprom.FM_FrequencyPlaying;
} }
BK1080_GetFrequencyDeviation(Frequency); BK1080_GetFrequencyDeviation(Frequency);
FM_Tune(Frequency, 1, bRestart); FM_Tune(Frequency, 1, bRestart);
#ifndef DISABLE_VOICE #ifndef DISABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_BEGIN; gAnotherVoiceID = VOICE_ID_SCANNING_BEGIN;
#endif #endif
@ -152,9 +156,11 @@ void ACTION_Scan(bool bRestart)
#endif #endif
{ {
GUI_SelectNextDisplay(DISPLAY_MAIN); GUI_SelectNextDisplay(DISPLAY_MAIN);
if (gScanState != SCAN_OFF) if (gScanState != SCAN_OFF)
{ {
SCANNER_Stop(); SCANNER_Stop();
#ifndef DISABLE_VOICE #ifndef DISABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP; gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif #endif
@ -162,6 +168,7 @@ void ACTION_Scan(bool bRestart)
else else
{ {
CHANNEL_Next(true, 1); CHANNEL_Next(true, 1);
#ifndef DISABLE_VOICE #ifndef DISABLE_VOICE
AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN); AUDIO_SetVoiceID(0, VOICE_ID_SCANNING_BEGIN);
AUDIO_PlaySingleVoice(true); AUDIO_PlaySingleVoice(true);

View File

@ -66,7 +66,7 @@ static void APP_CheckForIncoming(void)
{ {
if (gCssScanMode != CSS_SCAN_MODE_OFF && gRxReceptionMode == RX_MODE_NONE) if (gCssScanMode != CSS_SCAN_MODE_OFF && gRxReceptionMode == RX_MODE_NONE)
{ {
ScanPauseDelayIn10msec = 100; ScanPauseDelayIn10msec = 100; // 1 second
gScheduleScanListen = false; gScheduleScanListen = false;
gRxReceptionMode = RX_MODE_DETECTED; gRxReceptionMode = RX_MODE_DETECTED;
} }
@ -80,6 +80,7 @@ static void APP_CheckForIncoming(void)
gScheduleNOAA = false; gScheduleNOAA = false;
} }
#endif #endif
FUNCTION_Select(FUNCTION_INCOMING); FUNCTION_Select(FUNCTION_INCOMING);
return; return;
} }
@ -100,6 +101,7 @@ static void APP_CheckForIncoming(void)
FUNCTION_Select(FUNCTION_INCOMING); FUNCTION_Select(FUNCTION_INCOMING);
return; return;
} }
ScanPauseDelayIn10msec = 20; ScanPauseDelayIn10msec = 20;
gScheduleScanListen = false; gScheduleScanListen = false;
} }
@ -125,14 +127,14 @@ static void APP_HandleIncoming(void)
#ifndef DISABLE_NOAA #ifndef DISABLE_NOAA
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gSystickCountdown2) if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE) && gSystickCountdown2)
{ {
bFlag = true; bFlag = true;
gSystickCountdown2 = 0; gSystickCountdown2 = 0;
} }
#endif #endif
if (g_CTCSS_Lost && gCurrentCodeType == CODE_TYPE_CONTINUOUS_TONE) if (g_CTCSS_Lost && gCurrentCodeType == CODE_TYPE_CONTINUOUS_TONE)
{ {
bFlag = true; bFlag = true;
gFoundCTCSS = false; gFoundCTCSS = false;
} }
@ -229,7 +231,7 @@ static void APP_HandleReceive(void)
{ {
if (g_CxCSS_TAIL_Found) if (g_CxCSS_TAIL_Found)
{ {
Mode = END_OF_RX_MODE_TTE; Mode = END_OF_RX_MODE_TTE;
g_CxCSS_TAIL_Found = false; g_CxCSS_TAIL_Found = false;
} }
} }
@ -249,7 +251,7 @@ static void APP_HandleReceive(void)
if (g_CxCSS_TAIL_Found) if (g_CxCSS_TAIL_Found)
{ {
Mode = END_OF_RX_MODE_TTE; Mode = END_OF_RX_MODE_TTE;
g_CxCSS_TAIL_Found = false; g_CxCSS_TAIL_Found = false;
} }
break; break;
@ -264,14 +266,15 @@ static void APP_HandleReceive(void)
gFoundCDCSS = true; gFoundCDCSS = true;
gFoundCDCSSCountdown = 100; gFoundCDCSSCountdown = 100;
} }
if (g_CxCSS_TAIL_Found) if (g_CxCSS_TAIL_Found)
{ {
if (BK4819_GetCTCType() == 1) if (BK4819_GetCTCType() == 1)
{
Mode = END_OF_RX_MODE_TTE; Mode = END_OF_RX_MODE_TTE;
}
g_CxCSS_TAIL_Found = false; g_CxCSS_TAIL_Found = false;
} }
break; break;
default: default:
@ -306,7 +309,7 @@ Skip:
{ {
case SCAN_RESUME_CO: case SCAN_RESUME_CO:
ScanPauseDelayIn10msec = 360; ScanPauseDelayIn10msec = 360;
gScheduleScanListen = false; gScheduleScanListen = false;
break; break;
case SCAN_RESUME_SE: case SCAN_RESUME_SE:
SCANNER_Stop(); SCANNER_Stop();
@ -382,6 +385,7 @@ void APP_StartListening(FUNCTION_Type_t Function)
gScheduleScanListen = false; gScheduleScanListen = false;
break; break;
} }
bScanKeepFrequency = true; bScanKeepFrequency = true;
} }
@ -417,6 +421,7 @@ void APP_StartListening(FUNCTION_Type_t Function)
#ifndef DISABLE_VOICE #ifndef DISABLE_VOICE
if (gVoiceWriteIndex == 0) if (gVoiceWriteIndex == 0)
// BK4819_SetAF(gRxVfo->IsAM ? BK4819_AF_AM : BK4819_AF_OPEN);
#endif #endif
BK4819_SetAF(gRxVfo->IsAM ? BK4819_AF_AM : BK4819_AF_OPEN); 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) 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]) if (Frequency > gUpperLimitFrequencyBandTable[pInfo->Band])
pInfo->ConfigRX.Frequency = gLowerLimitFrequencyBandTable[pInfo->Band]; Frequency = gLowerLimitFrequencyBandTable[pInfo->Band];
else else
if (Frequency < gLowerLimitFrequencyBandTable[pInfo->Band]) if (Frequency < gLowerLimitFrequencyBandTable[pInfo->Band])
pInfo->ConfigRX.Frequency = FREQUENCY_FloorToStep(gUpperLimitFrequencyBandTable[pInfo->Band], pInfo->StepFrequency, gLowerLimitFrequencyBandTable[pInfo->Band]); Frequency = FREQUENCY_FloorToStep(gUpperLimitFrequencyBandTable[pInfo->Band], pInfo->StepFrequency, gLowerLimitFrequencyBandTable[pInfo->Band]);
else
pInfo->ConfigRX.Frequency = Frequency; pInfo->ConfigRX.Frequency = Frequency;
} }
static void FREQ_NextChannel(void) static void FREQ_NextChannel(void)
@ -471,7 +477,7 @@ static void MR_NextChannel(void)
{ {
gPreviousMrChannel = gNextMrChannel; gPreviousMrChannel = gNextMrChannel;
if (RADIO_CheckValidChannel(Ch1, false, 0)) if (RADIO_CheckValidChannel(Ch1, false, 0))
gNextMrChannel = Ch1; gNextMrChannel = Ch1;
else else
gCurrentScanList = 1; gCurrentScanList = 1;
} }
@ -479,7 +485,7 @@ static void MR_NextChannel(void)
if (gCurrentScanList == 1) if (gCurrentScanList == 1)
{ {
if (RADIO_CheckValidChannel(Ch2, false, 0)) if (RADIO_CheckValidChannel(Ch2, false, 0))
gNextMrChannel = Ch2; gNextMrChannel = Ch2;
else else
gCurrentScanList = 2; gCurrentScanList = 2;
} }
@ -501,8 +507,10 @@ Skip:
{ {
gEeprom.MrChannel[gEeprom.RX_CHANNEL] = gNextMrChannel; gEeprom.MrChannel[gEeprom.RX_CHANNEL] = gNextMrChannel;
gEeprom.ScreenChannel[gEeprom.RX_CHANNEL] = gNextMrChannel; gEeprom.ScreenChannel[gEeprom.RX_CHANNEL] = gNextMrChannel;
RADIO_ConfigureChannel(gEeprom.RX_CHANNEL, 2); RADIO_ConfigureChannel(gEeprom.RX_CHANNEL, 2);
RADIO_SetupRegisters(true); RADIO_SetupRegisters(true);
gUpdateDisplay = true; gUpdateDisplay = true;
} }
@ -529,7 +537,7 @@ static void DUALWATCH_Alternate(void)
if (gIsNoaaMode) if (gIsNoaaMode)
{ {
if (IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[0]) || IS_NOT_NOAA_CHANNEL(gEeprom.ScreenChannel[1])) 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 else
gEeprom.RX_CHANNEL = 0; gEeprom.RX_CHANNEL = 0;
@ -541,7 +549,7 @@ static void DUALWATCH_Alternate(void)
else else
#endif #endif
{ {
gEeprom.RX_CHANNEL = (gEeprom.RX_CHANNEL == 0); gEeprom.RX_CHANNEL = 1 - gEeprom.RX_CHANNEL;
gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_CHANNEL]; gRxVfo = &gEeprom.VfoInfo[gEeprom.RX_CHANNEL];
} }
@ -566,19 +574,22 @@ void APP_CheckRadioInterrupts(void)
BK4819_WriteRegister(BK4819_REG_02, 0); BK4819_WriteRegister(BK4819_REG_02, 0);
Mask = BK4819_ReadRegister(BK4819_REG_02); Mask = BK4819_ReadRegister(BK4819_REG_02);
if (Mask & BK4819_REG_02_DTMF_5TONE_FOUND) if (Mask & BK4819_REG_02_DTMF_5TONE_FOUND)
{ {
gDTMF_RequestPending = true; gDTMF_RequestPending = true;
gDTMF_RecvTimeout = 5; gDTMF_RecvTimeout = 5;
if (gDTMF_WriteIndex > 15) if (gDTMF_WriteIndex > 15)
{ {
uint8_t i; unsigned int i;
for (i = 0; i < (sizeof(gDTMF_Received) - 1); i++) for (i = 0; i < (sizeof(gDTMF_Received) - 1); i++)
gDTMF_Received[i] = gDTMF_Received[i + 1]; gDTMF_Received[i] = gDTMF_Received[i + 1];
gDTMF_WriteIndex = 15; gDTMF_WriteIndex = 15;
} }
gDTMF_Received[gDTMF_WriteIndex++] = DTMF_GetCharacter(BK4819_GetDTMF_5TONE_Code()); gDTMF_Received[gDTMF_WriteIndex++] = DTMF_GetCharacter(BK4819_GetDTMF_5TONE_Code());
if (gCurrentFunction == FUNCTION_RECEIVE) if (gCurrentFunction == FUNCTION_RECEIVE)
DTMF_HandleRequest(); DTMF_HandleRequest();
} }
@ -605,6 +616,7 @@ void APP_CheckRadioInterrupts(void)
{ {
g_VOX_Lost = true; g_VOX_Lost = true;
gVoxPauseCountdown = 10; gVoxPauseCountdown = 10;
if (gEeprom.VOX_SWITCH) if (gEeprom.VOX_SWITCH)
{ {
if (gCurrentFunction == FUNCTION_POWER_SAVE && !gRxIdleMode) if (gCurrentFunction == FUNCTION_POWER_SAVE && !gRxIdleMode)
@ -642,7 +654,7 @@ void APP_CheckRadioInterrupts(void)
#ifndef DISABLE_AIRCOPY #ifndef DISABLE_AIRCOPY
if (Mask & BK4819_REG_02_FSK_FIFO_ALMOST_FULL && gScreenToDisplay == DISPLAY_AIRCOPY && gAircopyState == AIRCOPY_TRANSFER && gAirCopyIsSendMode == 0) 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++) for (i = 0; i < 4; i++)
g_FSK_Buffer[gFSKWriteIndex++] = BK4819_ReadRegister(BK4819_REG_5F); g_FSK_Buffer[gFSKWriteIndex++] = BK4819_ReadRegister(BK4819_REG_5F);
AIRCOPY_StorePacket(); AIRCOPY_StorePacket();
@ -885,8 +897,10 @@ void APP_Update(void)
{ {
gCurrentRSSI = BK4819_GetRSSI(); gCurrentRSSI = BK4819_GetRSSI();
UI_UpdateRSSI(gCurrentRSSI); UI_UpdateRSSI(gCurrentRSSI);
gBatterySave = gEeprom.BATTERY_SAVE * 10; gBatterySave = gEeprom.BATTERY_SAVE * 10;
gRxIdleMode = true; gRxIdleMode = true;
BK4819_DisableVox(); BK4819_DisableVox();
BK4819_Sleep(); BK4819_Sleep();
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, false); BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, false);
@ -897,6 +911,7 @@ void APP_Update(void)
else else
{ {
DUALWATCH_Alternate(); DUALWATCH_Alternate();
gUpdateRSSI = true; gUpdateRSSI = true;
gBatterySave = 10; gBatterySave = 10;
} }
@ -1186,7 +1201,7 @@ void APP_TimeSlice10ms(void)
GUI_SelectNextDisplay(DISPLAY_SCANNER); GUI_SelectNextDisplay(DISPLAY_SCANNER);
} }
gScanDelay = 21; gScanDelay = g_scan_delay;
break; break;
case SCAN_CSS_STATE_SCANNING: case SCAN_CSS_STATE_SCANNING:
@ -1232,7 +1247,7 @@ void APP_TimeSlice10ms(void)
if (gScanCssState < SCAN_CSS_STATE_FOUND) if (gScanCssState < SCAN_CSS_STATE_FOUND)
{ {
BK4819_SetScanFrequency(gScanFrequency); BK4819_SetScanFrequency(gScanFrequency);
gScanDelay = 21; gScanDelay = g_scan_delay;
break; break;
} }
@ -1339,6 +1354,7 @@ void APP_TimeSlice500ms(void)
if (gScreenToDisplay == DISPLAY_SCANNER) if (gScreenToDisplay == DISPLAY_SCANNER)
{ {
BK4819_StopScan(); BK4819_StopScan();
RADIO_ConfigureChannel(0, 2); RADIO_ConfigureChannel(0, 2);
RADIO_ConfigureChannel(1, 2); RADIO_ConfigureChannel(1, 2);
RADIO_SetupRegisters(true); RADIO_SetupRegisters(true);
@ -1379,6 +1395,7 @@ void APP_TimeSlice500ms(void)
if (gLowBattery) if (gLowBattery)
{ {
gLowBatteryBlink = ++gLowBatteryCountdown & 1; gLowBatteryBlink = ++gLowBatteryCountdown & 1;
UI_DisplayBattery(gLowBatteryCountdown); UI_DisplayBattery(gLowBatteryCountdown);
if (gCurrentFunction != FUNCTION_TRANSMIT) if (gCurrentFunction != FUNCTION_TRANSMIT)
@ -1409,6 +1426,7 @@ void APP_TimeSlice500ms(void)
gReducedService = true; gReducedService = true;
FUNCTION_Select(FUNCTION_POWER_SAVE); FUNCTION_Select(FUNCTION_POWER_SAVE);
ST7565_Configure_GPIO_B11(); ST7565_Configure_GPIO_B11();
//if (gEeprom.BACKLIGHT < 5) //if (gEeprom.BACKLIGHT < 5)
GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT); GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BACKLIGHT);
} }
@ -1440,7 +1458,7 @@ void APP_TimeSlice500ms(void)
if (--gDTMF_AUTO_RESET_TIME == 0) if (--gDTMF_AUTO_RESET_TIME == 0)
{ {
gDTMF_CallState = DTMF_CALL_STATE_NONE; 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) void CHANNEL_Next(bool bFlag, int8_t Direction)
{ {
RADIO_SelectVfos(); RADIO_SelectVfos();
gNextMrChannel = gRxVfo->CHANNEL_SAVE; gNextMrChannel = gRxVfo->CHANNEL_SAVE;
gCurrentScanList = 0; gCurrentScanList = 0;
gScanState = Direction; gScanState = Direction;
if (IS_MR_CHANNEL(gNextMrChannel)) if (IS_MR_CHANNEL(gNextMrChannel))
{ {
if (bFlag) if (bFlag)
@ -1513,7 +1533,8 @@ void CHANNEL_Next(bool bFlag, int8_t Direction)
gRestoreFrequency = gRxVfo->ConfigRX.Frequency; gRestoreFrequency = gRxVfo->ConfigRX.Frequency;
FREQ_NextChannel(); FREQ_NextChannel();
} }
ScanPauseDelayIn10msec = 50;
ScanPauseDelayIn10msec = 50; // 500ms
gScheduleScanListen = false; gScheduleScanListen = false;
gRxReceptionMode = RX_MODE_NONE; gRxReceptionMode = RX_MODE_NONE;
gScanPauseMode = false; gScanPauseMode = false;

View File

@ -344,6 +344,7 @@ void DTMF_Reply(void)
if (gEeprom.DTMF_SIDE_TONE) if (gEeprom.DTMF_SIDE_TONE)
{ {
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gEnableSpeaker = true; gEnableSpeaker = true;
Delay = gEeprom.DTMF_PRELOAD_TIME; Delay = gEeprom.DTMF_PRELOAD_TIME;

569
app/fm.c
View File

@ -30,36 +30,36 @@
#include "ui/inputbox.h" #include "ui/inputbox.h"
#include "ui/ui.h" #include "ui/ui.h"
uint16_t gFM_Channels[20]; #ifndef ARRAY_SIZE
bool gFmRadioMode; #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
uint8_t gFmRadioCountdown; #endif
uint16_t gFM_Channels[20];
bool gFmRadioMode;
uint8_t gFmRadioCountdown;
volatile uint16_t gFmPlayCountdown; volatile uint16_t gFmPlayCountdown;
volatile int8_t gFM_ScanState; volatile int8_t gFM_ScanState;
bool gFM_AutoScan; bool gFM_AutoScan;
uint8_t gFM_ChannelPosition; uint8_t gFM_ChannelPosition;
bool gFM_FoundFrequency; bool gFM_FoundFrequency;
bool gFM_AutoScan; bool gFM_AutoScan;
uint8_t gFM_ResumeCountdown; uint8_t gFM_ResumeCountdown;
uint16_t gFM_RestoreCountdown; uint16_t gFM_RestoreCountdown;
bool FM_CheckValidChannel(uint8_t Channel) bool FM_CheckValidChannel(uint8_t Channel)
{ {
if (Channel < 20 && (gFM_Channels[Channel] >= 760 && gFM_Channels[Channel] < 1080)) { return (Channel < ARRAY_SIZE(gFM_Channels) && (gFM_Channels[Channel] >= 760 && gFM_Channels[Channel] < 1080)) ? true : false;
return true;
}
return false;
} }
uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction) uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction)
{ {
uint8_t i; unsigned int i;
for (i = 0; i < 20; i++) { for (i = 0; i < ARRAY_SIZE(gFM_Channels); i++)
Channel %= 20; {
if (FM_CheckValidChannel(Channel)) { Channel %= ARRAY_SIZE(gFM_Channels);
if (FM_CheckValidChannel(Channel))
return Channel; return Channel;
}
Channel += Direction; Channel += Direction;
} }
@ -68,16 +68,17 @@ uint8_t FM_FindNextChannel(uint8_t Channel, uint8_t Direction)
int FM_ConfigureChannelState(void) int FM_ConfigureChannelState(void)
{ {
uint8_t Channel;
gEeprom.FM_FrequencyPlaying = gEeprom.FM_SelectedFrequency; gEeprom.FM_FrequencyPlaying = gEeprom.FM_SelectedFrequency;
if (gEeprom.FM_IsMrMode) {
Channel = FM_FindNextChannel(gEeprom.FM_SelectedChannel, FM_CHANNEL_UP); if (gEeprom.FM_IsMrMode)
if (Channel == 0xFF) { {
const uint8_t Channel = FM_FindNextChannel(gEeprom.FM_SelectedChannel, FM_CHANNEL_UP);
if (Channel == 0xFF)
{
gEeprom.FM_IsMrMode = false; gEeprom.FM_IsMrMode = false;
return -1; return -1;
} }
gEeprom.FM_SelectedChannel = Channel; gEeprom.FM_SelectedChannel = Channel;
gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel]; gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel];
} }
@ -86,24 +87,27 @@ int FM_ConfigureChannelState(void)
void FM_TurnOff(void) void FM_TurnOff(void)
{ {
gFmRadioMode = false; gFmRadioMode = false;
gFM_ScanState = FM_SCAN_OFF; gFM_ScanState = FM_SCAN_OFF;
gFM_RestoreCountdown = 0; gFM_RestoreCountdown = 0;
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gEnableSpeaker = false; gEnableSpeaker = false;
BK1080_Init(0, false); BK1080_Init(0, false);
gUpdateStatus = true;
gUpdateStatus = true;
} }
void FM_EraseChannels(void) void FM_EraseChannels(void)
{ {
uint8_t i; unsigned int i;
uint8_t Template[8]; uint8_t Template[8];
memset(Template, 0xFF, sizeof(Template)); memset(Template, 0xFF, sizeof(Template));
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++)
EEPROM_WriteBuffer(0x0E40 + (i * 8), Template); EEPROM_WriteBuffer(0x0E40 + (i * 8), Template);
}
memset(gFM_Channels, 0xFF, sizeof(gFM_Channels)); 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) void FM_Tune(uint16_t Frequency, int8_t Step, bool bFlag)
{ {
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gEnableSpeaker = false; gEnableSpeaker = false;
if (gFM_ScanState == FM_SCAN_OFF) {
gFmPlayCountdown = 120; gFmPlayCountdown = (gFM_ScanState == FM_SCAN_OFF) ? 120 : 10;
} else {
gFmPlayCountdown = 10; gScheduleFM = false;
} gFM_FoundFrequency = false;
gScheduleFM = false; gAskToSave = false;
gFM_FoundFrequency = false; gAskToDelete = false;
gAskToSave = false;
gAskToDelete = false;
gEeprom.FM_FrequencyPlaying = Frequency; gEeprom.FM_FrequencyPlaying = Frequency;
if (!bFlag) {
if (!bFlag)
{
Frequency += Step; Frequency += Step;
if (Frequency < gEeprom.FM_LowerLimit) { if (Frequency < gEeprom.FM_LowerLimit)
Frequency = gEeprom.FM_UpperLimit; Frequency = gEeprom.FM_UpperLimit;
} else if (Frequency > gEeprom.FM_UpperLimit) { else
if (Frequency > gEeprom.FM_UpperLimit)
Frequency = gEeprom.FM_LowerLimit; Frequency = gEeprom.FM_LowerLimit;
}
gEeprom.FM_FrequencyPlaying = Frequency; gEeprom.FM_FrequencyPlaying = Frequency;
} }
gFM_ScanState = Step; gFM_ScanState = Step;
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
} }
void FM_PlayAndUpdate(void) void FM_PlayAndUpdate(void)
{ {
gFM_ScanState = FM_SCAN_OFF; gFM_ScanState = FM_SCAN_OFF;
if (gFM_AutoScan) {
gEeprom.FM_IsMrMode = true; if (gFM_AutoScan)
{
gEeprom.FM_IsMrMode = true;
gEeprom.FM_SelectedChannel = 0; gEeprom.FM_SelectedChannel = 0;
} }
FM_ConfigureChannelState(); FM_ConfigureChannelState();
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
SETTINGS_SaveFM(); SETTINGS_SaveFM();
gFmPlayCountdown = 0; gFmPlayCountdown = 0;
gScheduleFM = false; gScheduleFM = false;
gAskToSave = false; gAskToSave = false;
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gEnableSpeaker = true;
gEnableSpeaker = true;
} }
int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit) int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit)
{ {
uint16_t Test2;
uint16_t Deviation;
int ret = -1; 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 // 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) { if (BK1080_REG_07_GET_SNR(Test2) >= 2)
uint16_t Status; {
const uint16_t Status = BK1080_ReadRegister(BK1080_REG_10);
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 ((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 > -281 && Deviation < 280)
if (Deviation < 280 || Deviation > 3815) { if (Deviation < 280 || Deviation > 3815)
{
// not BLE(less than or equal) // 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; goto Bail;
}
if (BK1080_FrequencyDeviation < 20) { if (BK1080_FrequencyDeviation < 20)
goto Bail; goto Bail;
}
} }
// not BLT(less than) // 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; goto Bail;
}
// if (BK1080_FrequencyDeviation > -21) { // if (BK1080_FrequencyDeviation > -21)
if (BK1080_FrequencyDeviation > 4075) { if (BK1080_FrequencyDeviation > 4075)
goto Bail; goto Bail;
}
} }
ret = 0; ret = 0;
} }
} }
@ -196,73 +213,97 @@ int FM_CheckFrequencyLock(uint16_t Frequency, uint16_t LowerLimit)
Bail: Bail:
BK1080_FrequencyDeviation = Deviation; BK1080_FrequencyDeviation = Deviation;
BK1080_BaseFrequency = Frequency; BK1080_BaseFrequency = Frequency;
return ret; return ret;
} }
static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
#define STATE_FREQ_MODE 0 #define STATE_FREQ_MODE 0
#define STATE_MR_MODE 1 #define STATE_MR_MODE 1
#define STATE_SAVE 2 #define STATE_SAVE 2
if (!bKeyHeld && bKeyPressed) { if (!bKeyHeld && bKeyPressed)
if (!gWasFKeyPressed) { {
if (!gWasFKeyPressed)
{
uint8_t State; uint8_t State;
if (gAskToDelete) { if (gAskToDelete)
{
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
} }
if (gAskToSave) {
if (gAskToSave)
{
State = STATE_SAVE; State = STATE_SAVE;
} else { }
if (gFM_ScanState != FM_SCAN_OFF) { else
{
if (gFM_ScanState != FM_SCAN_OFF)
{
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
} }
if (gEeprom.FM_IsMrMode) {
State = STATE_MR_MODE; State = gEeprom.FM_IsMrMode ? STATE_MR_MODE : STATE_FREQ_MODE;
} else {
State = STATE_FREQ_MODE;
}
} }
INPUTBOX_Append(Key); INPUTBOX_Append(Key);
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
if (State == STATE_FREQ_MODE) {
if (gInputBoxIndex == 1) { if (State == STATE_FREQ_MODE)
if (gInputBox[0] > 1) { {
if (gInputBoxIndex == 1)
{
if (gInputBox[0] > 1)
{
gInputBox[1] = gInputBox[0]; gInputBox[1] = gInputBox[0];
gInputBox[0] = 0; gInputBox[0] = 0;
gInputBoxIndex = 2; gInputBoxIndex = 2;
} }
} else if (gInputBoxIndex > 3) { }
else
if (gInputBoxIndex > 3)
{
uint32_t Frequency; uint32_t Frequency;
gInputBoxIndex = 0; gInputBoxIndex = 0;
NUMBER_Get(gInputBox, &Frequency); NUMBER_Get(gInputBox, &Frequency);
Frequency = Frequency / 10000; Frequency /= 10000;
if (Frequency < gEeprom.FM_LowerLimit || gEeprom.FM_UpperLimit < Frequency) {
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; if (Frequency < gEeprom.FM_LowerLimit || gEeprom.FM_UpperLimit < Frequency)
{
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
return; return;
} }
gEeprom.FM_SelectedFrequency = (uint16_t)Frequency; gEeprom.FM_SelectedFrequency = (uint16_t)Frequency;
#ifndef DISABLE_VOICE #ifndef DISABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; gAnotherVoiceID = (VOICE_ID_t)Key;
#endif #endif
gEeprom.FM_FrequencyPlaying = gEeprom.FM_SelectedFrequency; gEeprom.FM_FrequencyPlaying = gEeprom.FM_SelectedFrequency;
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
gRequestSaveFM = true; gRequestSaveFM = true;
return; return;
} }
} else if (gInputBoxIndex == 2) { }
else
if (gInputBoxIndex == 2)
{
uint8_t Channel; uint8_t Channel;
gInputBoxIndex = 0; gInputBoxIndex = 0;
Channel = ((gInputBox[0] * 10) + gInputBox[1]) - 1; Channel = ((gInputBox[0] * 10) + gInputBox[1]) - 1;
if (State == STATE_MR_MODE) {
if (State == STATE_MR_MODE)
{
if (FM_CheckValidChannel(Channel)) if (FM_CheckValidChannel(Channel))
{ {
#ifndef DISABLE_VOICE #ifndef DISABLE_VOICE
@ -286,6 +327,7 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gFM_ChannelPosition = Channel; gFM_ChannelPosition = Channel;
return; return;
} }
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
} }
@ -296,70 +338,87 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
return; return;
} }
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gWasFKeyPressed = false; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gUpdateStatus = true; gWasFKeyPressed = false;
gUpdateStatus = true;
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
switch (Key) {
case KEY_0:
ACTION_FM();
break;
case KEY_1: switch (Key)
gEeprom.FM_IsMrMode = !gEeprom.FM_IsMrMode; {
if (!FM_ConfigureChannelState()) { case KEY_0:
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); ACTION_FM();
gRequestSaveFM = true; break;
} else {
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; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
} break;
break;
case KEY_2:
ACTION_Scan(true);
break;
case KEY_3:
ACTION_Scan(false);
break;
default:
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
break;
} }
} }
} }
static void FM_Key_EXIT(bool bKeyPressed, bool bKeyHeld) static void FM_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
{ {
if (bKeyHeld) { if (bKeyHeld)
return; return;
}
if (!bKeyPressed) { if (!bKeyPressed)
return; return;
}
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (gFM_ScanState == FM_SCAN_OFF) {
if (gInputBoxIndex == 0) { if (gFM_ScanState == FM_SCAN_OFF)
if (!gAskToSave && !gAskToDelete) { {
if (gInputBoxIndex == 0)
{
if (!gAskToSave && !gAskToDelete)
{
ACTION_FM(); ACTION_FM();
return; return;
} }
gAskToSave = false;
gAskToSave = false;
gAskToDelete = false; gAskToDelete = false;
} else { }
gInputBoxIndex--; else
gInputBox[gInputBoxIndex] = 10; {
if (gInputBoxIndex) { gInputBox[--gInputBoxIndex] = 10;
if (gInputBoxIndex != 1) {
if (gInputBoxIndex)
{
if (gInputBoxIndex != 1)
{
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
return; return;
} }
if (gInputBox[0] != 0) {
if (gInputBox[0] != 0)
{
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
return; return;
} }
} }
gInputBoxIndex = 0; gInputBoxIndex = 0;
} }
@ -380,184 +439,224 @@ static void FM_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
static void FM_Key_MENU(bool bKeyPressed, bool bKeyHeld) static void FM_Key_MENU(bool bKeyPressed, bool bKeyHeld)
{ {
if (bKeyHeld) { if (bKeyHeld)
return; return;
}
if (!bKeyPressed) { if (!bKeyPressed)
return; return;
}
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (gFM_ScanState == FM_SCAN_OFF) { if (gFM_ScanState == FM_SCAN_OFF)
if (!gEeprom.FM_IsMrMode) { {
if (gAskToSave) { if (!gEeprom.FM_IsMrMode)
{
if (gAskToSave)
{
gFM_Channels[gFM_ChannelPosition] = gEeprom.FM_FrequencyPlaying; gFM_Channels[gFM_ChannelPosition] = gEeprom.FM_FrequencyPlaying;
gAskToSave = false; gAskToSave = false;
gRequestSaveFM = true; gRequestSaveFM = true;
} else {
gAskToSave = true;
} }
} else { else
if (gAskToDelete) { gAskToSave = true;
}
else
{
if (gAskToDelete)
{
gFM_Channels[gEeprom.FM_SelectedChannel] = 0xFFFF; gFM_Channels[gEeprom.FM_SelectedChannel] = 0xFFFF;
FM_ConfigureChannelState(); FM_ConfigureChannelState();
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
gRequestSaveFM = true; gRequestSaveFM = true;
gAskToDelete = false; gAskToDelete = false;
} else {
gAskToDelete = true;
} }
else
gAskToDelete = true;
} }
} else { }
if (gFM_AutoScan || !gFM_FoundFrequency) { else
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; {
if (gFM_AutoScan || !gFM_FoundFrequency)
{
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
gInputBoxIndex = 0; gInputBoxIndex = 0;
return; 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) static void FM_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Step)
{ {
if (bKeyHeld || !bKeyPressed) { if (bKeyHeld || !bKeyPressed)
if (gInputBoxIndex) { {
if (gInputBoxIndex)
return; return;
}
if (!bKeyPressed) { if (!bKeyPressed)
return; return;
} }
} else { else
if (gInputBoxIndex) { {
if (gInputBoxIndex)
{
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
} }
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
} }
if (gAskToSave) {
if (gAskToSave)
{
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
gFM_ChannelPosition = NUMBER_AddWithWraparound(gFM_ChannelPosition, Step, 0, 19); gFM_ChannelPosition = NUMBER_AddWithWraparound(gFM_ChannelPosition, Step, 0, 19);
return; 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; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
} }
FM_Tune(gEeprom.FM_FrequencyPlaying, Step, false); FM_Tune(gEeprom.FM_FrequencyPlaying, Step, false);
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
return; return;
} }
if (gEeprom.FM_IsMrMode) {
uint8_t Channel;
Channel = FM_FindNextChannel(gEeprom.FM_SelectedChannel + Step, Step); if (gEeprom.FM_IsMrMode)
if (Channel == 0xFF || gEeprom.FM_SelectedChannel == Channel) { {
const uint8_t Channel = FM_FindNextChannel(gEeprom.FM_SelectedChannel + Step, Step);
if (Channel == 0xFF || gEeprom.FM_SelectedChannel == Channel)
goto Bail; goto Bail;
}
gEeprom.FM_SelectedChannel = Channel;
gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel];
} else {
uint16_t Frequency;
Frequency = gEeprom.FM_SelectedFrequency + Step; gEeprom.FM_SelectedChannel = Channel;
if (Frequency < gEeprom.FM_LowerLimit) { gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel];
}
else
{
uint16_t Frequency = gEeprom.FM_SelectedFrequency + Step;
if (Frequency < gEeprom.FM_LowerLimit)
Frequency = gEeprom.FM_UpperLimit; Frequency = gEeprom.FM_UpperLimit;
} else if (Frequency > gEeprom.FM_UpperLimit) { else
if (Frequency > gEeprom.FM_UpperLimit)
Frequency = gEeprom.FM_LowerLimit; Frequency = gEeprom.FM_LowerLimit;
}
gEeprom.FM_FrequencyPlaying = Frequency; gEeprom.FM_FrequencyPlaying = Frequency;
gEeprom.FM_SelectedFrequency = gEeprom.FM_FrequencyPlaying; gEeprom.FM_SelectedFrequency = gEeprom.FM_FrequencyPlaying;
} }
gRequestSaveFM = true; gRequestSaveFM = true;
Bail: Bail:
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying); BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
gRequestDisplayScreen = DISPLAY_FM; gRequestDisplayScreen = DISPLAY_FM;
} }
void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) void FM_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
{ {
switch (Key) { 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_0:
case KEY_8: case KEY_9: case KEY_1:
FM_Key_DIGITS(Key, bKeyPressed, bKeyHeld); case KEY_2:
break; case KEY_3:
case KEY_MENU: case KEY_4:
FM_Key_MENU(bKeyPressed, bKeyHeld); case KEY_5:
return; case KEY_6:
case KEY_UP: case KEY_7:
FM_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1); case KEY_8:
break; case KEY_9:
case KEY_DOWN: FM_Key_DIGITS(Key, bKeyPressed, bKeyHeld);
FM_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1); break;
break;; case KEY_MENU:
case KEY_EXIT: FM_Key_MENU(bKeyPressed, bKeyHeld);
FM_Key_EXIT(bKeyPressed, bKeyHeld); return;
break; case KEY_UP:
case KEY_F: FM_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1);
GENERIC_Key_F(bKeyPressed, bKeyHeld); break;
break; case KEY_DOWN:
case KEY_PTT: FM_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1);
GENERIC_Key_PTT(bKeyPressed); break;;
break; case KEY_EXIT:
default: FM_Key_EXIT(bKeyPressed, bKeyHeld);
if (!bKeyHeld && bKeyPressed) { break;
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; case KEY_F:
} GENERIC_Key_F(bKeyPressed, bKeyHeld);
break; 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) void FM_Play(void)
{ {
if (!FM_CheckFrequencyLock(gEeprom.FM_FrequencyPlaying, gEeprom.FM_LowerLimit)) { if (!FM_CheckFrequencyLock(gEeprom.FM_FrequencyPlaying, gEeprom.FM_LowerLimit))
if (!gFM_AutoScan) { {
gFmPlayCountdown = 0; if (!gFM_AutoScan)
{
gFmPlayCountdown = 0;
gFM_FoundFrequency = true; gFM_FoundFrequency = true;
if (!gEeprom.FM_IsMrMode) {
if (!gEeprom.FM_IsMrMode)
gEeprom.FM_SelectedFrequency = gEeprom.FM_FrequencyPlaying; gEeprom.FM_SelectedFrequency = gEeprom.FM_FrequencyPlaying;
}
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
gEnableSpeaker = true; gEnableSpeaker = true;
GUI_SelectNextDisplay(DISPLAY_FM); GUI_SelectNextDisplay(DISPLAY_FM);
return; return;
} }
if (gFM_ChannelPosition < 20) {
if (gFM_ChannelPosition < 20)
gFM_Channels[gFM_ChannelPosition++] = gEeprom.FM_FrequencyPlaying; gFM_Channels[gFM_ChannelPosition++] = gEeprom.FM_FrequencyPlaying;
}
if (gFM_ChannelPosition >= 20) { if (gFM_ChannelPosition >= 20)
{
FM_PlayAndUpdate(); FM_PlayAndUpdate();
GUI_SelectNextDisplay(DISPLAY_FM); GUI_SelectNextDisplay(DISPLAY_FM);
return; return;
} }
} }
if (gFM_AutoScan && gEeprom.FM_FrequencyPlaying >= gEeprom.FM_UpperLimit) { if (gFM_AutoScan && gEeprom.FM_FrequencyPlaying >= gEeprom.FM_UpperLimit)
FM_PlayAndUpdate(); FM_PlayAndUpdate();
} else { else
FM_Tune(gEeprom.FM_FrequencyPlaying, gFM_ScanState, false); FM_Tune(gEeprom.FM_FrequencyPlaying, gFM_ScanState, false);
}
GUI_SelectNextDisplay(DISPLAY_FM); GUI_SelectNextDisplay(DISPLAY_FM);
} }
void FM_Start(void) void FM_Start(void)
{ {
gFmRadioMode = true; gFmRadioMode = true;
gFM_ScanState = FM_SCAN_OFF; gFM_ScanState = FM_SCAN_OFF;
gFM_RestoreCountdown = 0; 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;
}

View File

@ -341,6 +341,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
if (!bKeyHeld && bKeyPressed) if (!bKeyHeld && bKeyPressed)
{ {
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (!gFmRadioMode) if (!gFmRadioMode)
{ {
if (gScanState == SCAN_OFF) if (gScanState == SCAN_OFF)
@ -348,6 +349,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
if (gInputBoxIndex == 0) if (gInputBoxIndex == 0)
return; return;
gInputBox[--gInputBoxIndex] = 10; gInputBox[--gInputBoxIndex] = 10;
#ifndef DISABLE_VOICE #ifndef DISABLE_VOICE
if (gInputBoxIndex == 0) if (gInputBoxIndex == 0)
gAnotherVoiceID = VOICE_ID_CANCEL; gAnotherVoiceID = VOICE_ID_CANCEL;
@ -356,6 +358,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
else else
{ {
SCANNER_Stop(); SCANNER_Stop();
#ifndef DISABLE_VOICE #ifndef DISABLE_VOICE
gAnotherVoiceID = VOICE_ID_SCANNING_STOP; gAnotherVoiceID = VOICE_ID_SCANNING_STOP;
#endif #endif
@ -364,6 +367,7 @@ static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;
return; return;
} }
ACTION_FM(); ACTION_FM();
} }
} }

View File

@ -642,10 +642,7 @@ void MENU_SelectNextCode(void)
RADIO_SetupRegisters(true); RADIO_SetupRegisters(true);
if (gSelectedCodeType == CODE_TYPE_CONTINUOUS_TONE) ScanPauseDelayIn10msec = (gSelectedCodeType == CODE_TYPE_CONTINUOUS_TONE) ? 20 : 30;
ScanPauseDelayIn10msec = 20;
else
ScanPauseDelayIn10msec = 30;
gUpdateDisplay = true; gUpdateDisplay = true;
} }

View File

@ -108,6 +108,7 @@ static void SCANNER_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
gRequestDisplayScreen = DISPLAY_SCANNER; gRequestDisplayScreen = DISPLAY_SCANNER;
break; break;
} }
// Fallthrough // Fallthrough
case 2: case 2:
@ -159,14 +160,10 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld)
case 0: case 0:
if (!gScanSingleFrequency) if (!gScanSingleFrequency)
{ {
uint32_t Freq250;
uint32_t Freq625;
int16_t Delta250;
int16_t Delta625; int16_t Delta625;
uint32_t Freq250 = FREQUENCY_FloorToStep(gScanFrequency, 250, 0);
Freq250 = FREQUENCY_FloorToStep(gScanFrequency, 250, 0); uint32_t Freq625 = FREQUENCY_FloorToStep(gScanFrequency, 625, 0);
Freq625 = FREQUENCY_FloorToStep(gScanFrequency, 625, 0); int16_t Delta250 = (int16_t)gScanFrequency - (int16_t)Freq250;
Delta250 = (short)gScanFrequency - (short)Freq250;
if (125 < Delta250) if (125 < Delta250)
{ {
@ -174,7 +171,7 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld)
Freq250 += 250; Freq250 += 250;
} }
Delta625 = (short)gScanFrequency - (short)Freq625; Delta625 = (int16_t)gScanFrequency - (int16_t)Freq625;
if (312 < Delta625) if (312 < Delta625)
{ {
@ -239,6 +236,7 @@ static void SCANNER_Key_MENU(bool bKeyPressed, bool bKeyHeld)
{ {
RADIO_ConfigureChannel(0, 2); RADIO_ConfigureChannel(0, 2);
RADIO_ConfigureChannel(1, 2); RADIO_ConfigureChannel(1, 2);
gTxVfo->ConfigRX.CodeType = gScanCssResultType; gTxVfo->ConfigRX.CodeType = gScanCssResultType;
gTxVfo->ConfigRX.Code = gScanCssResultCode; gTxVfo->ConfigRX.Code = gScanCssResultCode;
gTxVfo->ConfigTX.CodeType = gScanCssResultType; 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) 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; gFlagStartScan = true;
} }
return; return;
@ -328,7 +326,7 @@ void SCANNER_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
SCANNER_Key_MENU(bKeyPressed, bKeyHeld); SCANNER_Key_MENU(bKeyPressed, bKeyHeld);
break; break;
case KEY_UP: case KEY_UP:
SCANNER_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1); SCANNER_Key_UP_DOWN(bKeyPressed, bKeyHeld, 1);
break; break;
case KEY_DOWN: case KEY_DOWN:
SCANNER_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1); SCANNER_Key_UP_DOWN(bKeyPressed, bKeyHeld, -1);
@ -355,6 +353,7 @@ void SCANNER_Start(void)
uint16_t BackupFrequency; uint16_t BackupFrequency;
BK4819_StopScan(); BK4819_StopScan();
RADIO_SelectVfos(); RADIO_SelectVfos();
#ifndef DISABLE_NOAA #ifndef DISABLE_NOAA
@ -392,7 +391,7 @@ void SCANNER_Start(void)
BK4819_EnableFrequencyScan(); BK4819_EnableFrequencyScan();
} }
gScanDelay = 21; gScanDelay = g_scan_delay;
gScanCssResultCode = 0xFF; gScanCssResultCode = 0xFF;
gScanCssResultType = 0xFF; gScanCssResultType = 0xFF;
gScanHitCount = 0; gScanHitCount = 0;
@ -410,7 +409,7 @@ void SCANNER_Start(void)
void SCANNER_Stop(void) void SCANNER_Stop(void)
{ {
uint8_t Previous = gRestoreMrChannel; const uint8_t Previous = gRestoreMrChannel;
gScanState = SCAN_OFF; gScanState = SCAN_OFF;

View File

@ -21,17 +21,16 @@
#include "driver/system.h" #include "driver/system.h"
#include "misc.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[] = { static const uint16_t BK1080_RegisterTable[] =
0x0008, 0x1080, 0x0201, 0x0000, {
0x40C0, 0x0A1F, 0x002E, 0x02FF, 0x0008, 0x1080, 0x0201, 0x0000, 0x40C0, 0x0A1F, 0x002E, 0x02FF,
0x5B11, 0x0000, 0x411E, 0x0000, 0x5B11, 0x0000, 0x411E, 0x0000, 0xCE00, 0x0000, 0x0000, 0x1000,
0xCE00, 0x0000, 0x0000, 0x1000, 0x3197, 0x0000, 0x13FF, 0x9852, 0x0000, 0x0000, 0x0008, 0x0000,
0x3197, 0x0000, 0x13FF, 0x9852, 0x51E1, 0xA8BC, 0x2645, 0x00E4, 0x1CD8, 0x3A50, 0xEAE0, 0x3000,
0x0000, 0x0000, 0x0008, 0x0000,
0x51E1, 0xA8BC, 0x2645, 0x00E4,
0x1CD8, 0x3A50, 0xEAE0, 0x3000,
0x0200, 0x0000, 0x0200, 0x0000,
}; };
@ -42,28 +41,40 @@ uint16_t BK1080_FrequencyDeviation;
void BK1080_Init(uint16_t Frequency, bool bDoScan) 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); GPIO_ClearBit(&GPIOB->DATA, GPIOB_PIN_BK1080);
if (!gIsInitBK1080) { if (!gIsInitBK1080)
for (i = 0; i < ARRAY_SIZE(BK1080_RegisterTable); i++) { {
for (i = 0; i < ARRAY_SIZE(BK1080_RegisterTable); i++)
BK1080_WriteRegister(i, BK1080_RegisterTable[i]); BK1080_WriteRegister(i, BK1080_RegisterTable[i]);
}
SYSTEM_DelayMs(250); SYSTEM_DelayMs(250);
BK1080_WriteRegister(BK1080_REG_25_INTERNAL, 0xA83C); BK1080_WriteRegister(BK1080_REG_25_INTERNAL, 0xA83C);
BK1080_WriteRegister(BK1080_REG_25_INTERNAL, 0xA8BC); BK1080_WriteRegister(BK1080_REG_25_INTERNAL, 0xA8BC);
SYSTEM_DelayMs(60); SYSTEM_DelayMs(60);
gIsInitBK1080 = true; gIsInitBK1080 = true;
} else { }
else
{
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x0201); BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x0201);
} }
BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, 0x0A5F); BK1080_WriteRegister(BK1080_REG_05_SYSTEM_CONFIGURATION2, 0x0A5F);
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, Frequency - 760); BK1080_WriteRegister(BK1080_REG_03_CHANNEL, Frequency - 760);
SYSTEM_DelayMs(10); SYSTEM_DelayMs(10);
BK1080_WriteRegister(BK1080_REG_03_CHANNEL, (Frequency - 760) | 0x8000); BK1080_WriteRegister(BK1080_REG_03_CHANNEL, (Frequency - 760) | 0x8000);
} else { }
else
{
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x0241); BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x0241);
GPIO_SetBit(&GPIOB->DATA, GPIOB_PIN_BK1080); 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_Write((Register << 1) | I2C_READ);
I2C_ReadBuffer(Value, sizeof(Value)); I2C_ReadBuffer(Value, sizeof(Value));
I2C_Stop(); I2C_Stop();
return (Value[0] << 8) | Value[1]; 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) void BK1080_Mute(bool Mute)
{ {
if (Mute) { BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, Mute ? 0x4201 : 0x0201);
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x4201);
} else {
BK1080_WriteRegister(BK1080_REG_02_POWER_CONFIGURATION, 0x0201);
}
} }
void BK1080_SetFrequency(uint16_t Frequency) void BK1080_SetFrequency(uint16_t Frequency)
@ -109,7 +117,6 @@ void BK1080_SetFrequency(uint16_t Frequency)
void BK1080_GetFrequencyDeviation(uint16_t Frequency) void BK1080_GetFrequencyDeviation(uint16_t Frequency)
{ {
BK1080_BaseFrequency = Frequency; BK1080_BaseFrequency = Frequency;
BK1080_FrequencyDeviation = BK1080_ReadRegister(BK1080_REG_07) / 16; BK1080_FrequencyDeviation = BK1080_ReadRegister(BK1080_REG_07) / 16;
} }

View File

@ -102,15 +102,16 @@ uint16_t BK4819_ReadRegister(BK4819_REGISTER_t Register)
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCN); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCN);
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCL); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCL);
SYSTICK_DelayUs(1); SYSTICK_DelayUs(1);
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCN); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCN);
BK4819_WriteU8(Register | 0x80); BK4819_WriteU8(Register | 0x80);
Value = BK4819_ReadU16(); Value = BK4819_ReadU16();
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCN); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCN);
SYSTICK_DelayUs(1); SYSTICK_DelayUs(1);
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCL); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCL);
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SDA); 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_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCN);
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCL); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCL);
SYSTICK_DelayUs(1); SYSTICK_DelayUs(1);
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCN); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCN);
BK4819_WriteU8(Register); BK4819_WriteU8(Register);
SYSTICK_DelayUs(1); SYSTICK_DelayUs(1);
BK4819_WriteU16(Data); BK4819_WriteU16(Data);
SYSTICK_DelayUs(1); SYSTICK_DelayUs(1);
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCN); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCN);
SYSTICK_DelayUs(1); SYSTICK_DelayUs(1);
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCL); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCL);
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SDA); 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); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCL);
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
{ {
if ((Data & 0x80U) == 0) if ((Data & 0x80) == 0)
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SDA); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SDA);
else else
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SDA); 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); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCL);
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
{ {
if ((Data & 0x8000U) == 0U) if ((Data & 0x8000) == 0)
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SDA); GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SDA);
else else
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SDA); 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 CDCSS Bw Mode
// Enable Auto CTCSS Bw Mode // Enable Auto CTCSS Bw Mode
// CTCSS/CDCSS Tx Gain1 Tuning = 51 // CTCSS/CDCSS Tx Gain1 Tuning = 51
BK4819_WriteRegister(BK4819_REG_51, 0 BK4819_WriteRegister(BK4819_REG_51,
| BK4819_REG_51_ENABLE_CxCSS BK4819_REG_51_ENABLE_CxCSS
| BK4819_REG_51_GPIO6_PIN2_NORMAL | BK4819_REG_51_GPIO6_PIN2_NORMAL
| BK4819_REG_51_TX_CDCSS_POSITIVE | BK4819_REG_51_TX_CDCSS_POSITIVE
| BK4819_REG_51_MODE_CDCSS | BK4819_REG_51_MODE_CDCSS
@ -238,16 +247,14 @@ void BK4819_SetCDCSSCodeWord(uint32_t CodeWord)
| BK4819_REG_51_1050HZ_NO_DETECTION | BK4819_REG_51_1050HZ_NO_DETECTION
| BK4819_REG_51_AUTO_CDCSS_BW_ENABLE | BK4819_REG_51_AUTO_CDCSS_BW_ENABLE
| BK4819_REG_51_AUTO_CTCSS_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 // CTC1 Frequency Control Word = 2775
BK4819_WriteRegister(BK4819_REG_07, 0 BK4819_WriteRegister(BK4819_REG_07, BK4819_REG_07_MODE_CTC1 | (2775u << BK4819_REG_07_SHIFT_FREQUENCY));
| BK4819_REG_07_MODE_CTC1
| (2775u << BK4819_REG_07_SHIFT_FREQUENCY));
// Set the code word // Set the code word
BK4819_WriteRegister(BK4819_REG_08, 0x0000 | ((CodeWord >> 0) & 0xFFF)); BK4819_WriteRegister(BK4819_REG_08, 0x0000 | ((CodeWord >> 0) & 0x0FFF));
BK4819_WriteRegister(BK4819_REG_08, 0x8000 | ((CodeWord >> 12) & 0xFFF)); BK4819_WriteRegister(BK4819_REG_08, 0x8000 | ((CodeWord >> 12) & 0x0FFF));
} }
void BK4819_SetCTCSSFrequency(uint32_t FreqControlWord) void BK4819_SetCTCSSFrequency(uint32_t FreqControlWord)
@ -255,7 +262,7 @@ void BK4819_SetCTCSSFrequency(uint32_t FreqControlWord)
uint16_t Config; uint16_t Config;
if (FreqControlWord == 2625) if (FreqControlWord == 2625)
{ // Enables 1050Hz detection mode { // Enables 1050Hz detection mode
// Enable TxCTCSS // Enable TxCTCSS
// CTCSS Mode // CTCSS Mode
// 1050/4 Detect Enable // 1050/4 Detect Enable
@ -265,8 +272,7 @@ void BK4819_SetCTCSSFrequency(uint32_t FreqControlWord)
Config = 0x944A; Config = 0x944A;
} }
else else
{ { // Enable TxCTCSS
// Enable TxCTCSS
// CTCSS Mode // CTCSS Mode
// Enable Auto CDCSS Bw Mode // Enable Auto CDCSS Bw Mode
// Enable Auto CTCSS Bw Mode // Enable Auto CTCSS Bw Mode
@ -276,15 +282,13 @@ void BK4819_SetCTCSSFrequency(uint32_t FreqControlWord)
BK4819_WriteRegister(BK4819_REG_51, Config); BK4819_WriteRegister(BK4819_REG_51, Config);
// CTC1 Frequency Control Word // CTC1 Frequency Control Word
BK4819_WriteRegister(BK4819_REG_07, 0 BK4819_WriteRegister(BK4819_REG_07, BK4819_REG_07_MODE_CTC1 | ((FreqControlWord * 2065) / 1000) << BK4819_REG_07_SHIFT_FREQUENCY);
| BK4819_REG_07_MODE_CTC1
| ((FreqControlWord * 2065) / 1000) << BK4819_REG_07_SHIFT_FREQUENCY);
} }
void BK4819_Set55HzTailDetection(void) void BK4819_Set55HzTailDetection(void)
{ {
// CTC2 Frequency Control Word = round_nearest(25391 / 55) = 462 // 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) void BK4819_EnableVox(uint16_t VoxEnableThreshold, uint16_t VoxDisableThreshold)
@ -356,15 +360,14 @@ void BK4819_SetupSquelch(uint8_t SquelchOpenRSSIThresh, uint8_t SquelchCloseRSSI
#if 1 #if 1
BK4819_WriteRegister(BK4819_REG_4D, 0xA000 | SquelchCloseGlitchThresh); BK4819_WriteRegister(BK4819_REG_4D, 0xA000 | SquelchCloseGlitchThresh);
#else #else
// fastest squelch, https://github.com/fagci/uv-k5-firmware-fagci-mod // fastest squelch, https://github.com/fagci/uv-k5-firmware-fagci-mod this doesn't work
// this doesn't work !
BK4819_WriteRegister(BK4819_REG_4D, 0b01000000 | SquelchCloseGlitchThresh); BK4819_WriteRegister(BK4819_REG_4D, 0b01000000 | SquelchCloseGlitchThresh);
#endif #endif
// 0x6f = 0110 1111 meaning the default sql delays from the datasheet are used (101 and 111) // 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_4E, 0x6F00 | SquelchOpenGlitchThresh);
BK4819_WriteRegister(BK4819_REG_4F, (SquelchCloseNoiseThresh << 8) | SquelchOpenNoiseThresh); 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); BK4819_SetAF(BK4819_AF_MUTE);
@ -456,8 +459,8 @@ void BK4819_DisableDTMF(void)
void BK4819_EnableDTMF(void) void BK4819_EnableDTMF(void)
{ {
BK4819_WriteRegister(BK4819_REG_21, 0x06D8); BK4819_WriteRegister(BK4819_REG_21, 0x06D8);
BK4819_WriteRegister(BK4819_REG_24, 0 BK4819_WriteRegister(BK4819_REG_24,
| (1U << BK4819_REG_24_SHIFT_UNKNOWN_15) (1U << BK4819_REG_24_SHIFT_UNKNOWN_15)
| (24 << BK4819_REG_24_SHIFT_THRESHOLD) | (24 << BK4819_REG_24_SHIFT_THRESHOLD)
| (1U << BK4819_REG_24_SHIFT_UNKNOWN_6) | (1U << BK4819_REG_24_SHIFT_UNKNOWN_6)
| BK4819_REG_24_ENABLE | BK4819_REG_24_ENABLE
@ -473,16 +476,13 @@ void BK4819_PlayTone(uint16_t Frequency, bool bTuningGainSwitch)
BK4819_SetAF(BK4819_AF_BEEP); BK4819_SetAF(BK4819_AF_BEEP);
if (bTuningGainSwitch == 0) 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 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_70, ToneConfig);
BK4819_WriteRegister(BK4819_REG_30, 0); BK4819_WriteRegister(BK4819_REG_30, 0);
BK4819_WriteRegister(BK4819_REG_30, 0 BK4819_WriteRegister(BK4819_REG_30, BK4819_REG_30_ENABLE_AF_DAC | BK4819_REG_30_ENABLE_DISC_MODE | BK4819_REG_30_ENABLE_TX_DSP);
| 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)); BK4819_WriteRegister(BK4819_REG_71, scale_freq(Frequency));
} }
@ -507,9 +507,12 @@ void BK4819_TurnsOffTones_TurnsOnRX(void)
{ {
BK4819_WriteRegister(BK4819_REG_70, 0); BK4819_WriteRegister(BK4819_REG_70, 0);
BK4819_SetAF(BK4819_AF_MUTE); BK4819_SetAF(BK4819_AF_MUTE);
BK4819_ExitTxMute(); BK4819_ExitTxMute();
BK4819_WriteRegister(BK4819_REG_30, 0); 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_VCO_CALIB
| BK4819_REG_30_ENABLE_RX_LINK | BK4819_REG_30_ENABLE_RX_LINK
| BK4819_REG_30_ENABLE_AF_DAC | BK4819_REG_30_ENABLE_AF_DAC
@ -521,20 +524,22 @@ void BK4819_TurnsOffTones_TurnsOnRX(void)
#ifndef DISABLE_AIRCOPY #ifndef DISABLE_AIRCOPY
void BK4819_SetupAircopy(void) void BK4819_SetupAircopy(void)
{ {
BK4819_WriteRegister(BK4819_REG_70, 0x00E0); // Enable Tone2, tuning gain 48 BK4819_WriteRegister(BK4819_REG_70, 0x00E0); // Enable Tone2, tuning gain 48
BK4819_WriteRegister(BK4819_REG_72, 0x3065); // Tone2 baudrate 1200 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 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 // (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_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_5D, 0x4700); // FSK Data Length 72 Bytes (0xabcd + 2 byte length + 64 byte payload + 2 byte CRC + 0xdcba)
} }
#endif #endif
void BK4819_ResetFSK(void) void BK4819_ResetFSK(void)
{ {
BK4819_WriteRegister(BK4819_REG_3F, 0x0000); // Disable interrupts 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_59, 0x0068); // Sync length 4 bytes, 7 byte preamble
SYSTEM_DelayMs(30); SYSTEM_DelayMs(30);
BK4819_Idle(); BK4819_Idle();
} }
@ -583,7 +588,8 @@ void BK4819_EnterDTMF_TX(bool bLocalLoopback)
BK4819_EnableDTMF(); BK4819_EnableDTMF();
BK4819_EnterTxMute(); BK4819_EnterTxMute();
BK4819_SetAF(bLocalLoopback ? BK4819_AF_BEEP : BK4819_AF_MUTE); 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 | BK4819_REG_70_MASK_ENABLE_TONE1
| (83 << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN) | (83 << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN)
| BK4819_REG_70_MASK_ENABLE_TONE2 | BK4819_REG_70_MASK_ENABLE_TONE2
@ -605,7 +611,8 @@ void BK4819_ExitDTMF_TX(bool bKeep)
void BK4819_EnableTXLink(void) 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_VCO_CALIB
| BK4819_REG_30_ENABLE_UNKNOWN | BK4819_REG_30_ENABLE_UNKNOWN
| BK4819_REG_30_DISABLE_RX_LINK | 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) void BK4819_TransmitTone(bool bLocalLoopback, uint32_t Frequency)
{ {
BK4819_EnterTxMute(); 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_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_WriteRegister(BK4819_REG_71, scale_freq(Frequency));
BK4819_SetAF(bLocalLoopback ? BK4819_AF_BEEP : BK4819_AF_MUTE); BK4819_SetAF(bLocalLoopback ? BK4819_AF_BEEP : BK4819_AF_MUTE);
BK4819_EnableTXLink(); BK4819_EnableTXLink();
SYSTEM_DelayMs(50); SYSTEM_DelayMs(50);
BK4819_ExitTxMute(); BK4819_ExitTxMute();
} }
@ -897,18 +909,27 @@ void BK4819_PrepareFSKReceive(void)
void BK4819_PlayRoger(void) void BK4819_PlayRoger(void)
{ {
BK4819_EnterTxMute(); BK4819_EnterTxMute();
BK4819_SetAF(BK4819_AF_MUTE); BK4819_SetAF(BK4819_AF_MUTE);
BK4819_WriteRegister(BK4819_REG_70, 0xE000); BK4819_WriteRegister(BK4819_REG_70, 0xE000);
BK4819_EnableTXLink(); BK4819_EnableTXLink();
SYSTEM_DelayMs(50); SYSTEM_DelayMs(50);
BK4819_WriteRegister(BK4819_REG_71, 0x142A); BK4819_WriteRegister(BK4819_REG_71, 0x142A);
BK4819_ExitTxMute(); BK4819_ExitTxMute();
SYSTEM_DelayMs(80); SYSTEM_DelayMs(80);
BK4819_EnterTxMute(); BK4819_EnterTxMute();
BK4819_WriteRegister(BK4819_REG_71, 0x1C3B); BK4819_WriteRegister(BK4819_REG_71, 0x1C3B);
BK4819_ExitTxMute(); BK4819_ExitTxMute();
SYSTEM_DelayMs(80); SYSTEM_DelayMs(80);
BK4819_EnterTxMute(); BK4819_EnterTxMute();
BK4819_WriteRegister(BK4819_REG_70, 0x0000); BK4819_WriteRegister(BK4819_REG_70, 0x0000);
BK4819_WriteRegister(BK4819_REG_30, 0xC1FE); BK4819_WriteRegister(BK4819_REG_30, 0xC1FE);
} }
@ -966,10 +987,15 @@ void BK4819_PlayDTMFEx(bool bLocalLoopback, char Code)
{ {
BK4819_EnableDTMF(); BK4819_EnableDTMF();
BK4819_EnterTxMute(); BK4819_EnterTxMute();
BK4819_SetAF(bLocalLoopback ? BK4819_AF_BEEP : BK4819_AF_MUTE); BK4819_SetAF(bLocalLoopback ? BK4819_AF_BEEP : BK4819_AF_MUTE);
BK4819_WriteRegister(BK4819_REG_70, 0xD3D3); BK4819_WriteRegister(BK4819_REG_70, 0xD3D3);
BK4819_EnableTXLink(); BK4819_EnableTXLink();
SYSTEM_DelayMs(50); SYSTEM_DelayMs(50);
BK4819_PlayDTMF(Code); BK4819_PlayDTMF(Code);
BK4819_ExitTxMute(); BK4819_ExitTxMute();
} }

View File

@ -37,7 +37,6 @@ void EEPROM_ReadBuffer(uint16_t Address, void *pBuffer, uint8_t Size)
} }
void EEPROM_WriteBuffer(uint16_t Address, const void *pBuffer) void EEPROM_WriteBuffer(uint16_t Address, const void *pBuffer)
{ {
I2C_Start(); I2C_Start();
@ -52,4 +51,3 @@ void EEPROM_WriteBuffer(uint16_t Address, const void *pBuffer)
SYSTEM_DelayMs(10); SYSTEM_DelayMs(10);
} }

View File

@ -15,6 +15,7 @@
*/ */
#include <stdint.h> #include <stdint.h>
#include "bsp/dp32g030/gpio.h" #include "bsp/dp32g030/gpio.h"
#include "bsp/dp32g030/spi.h" #include "bsp/dp32g030/spi.h"
#include "driver/gpio.h" #include "driver/gpio.h"

View File

@ -27,9 +27,7 @@ void SYSTEM_DelayMs(uint32_t Delay)
void SYSTEM_ConfigureClocks(void) void SYSTEM_ConfigureClocks(void)
{ {
// Set source clock from external crystal // 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 = (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_RCHF_SEL_BITS_48MHZ
| PMU_SRC_CFG_RCHF_EN_BITS_ENABLE;
// Divide by 2 // Divide by 2
SYSCON_CLK_SEL = SYSCON_CLK_SEL_DIV_BITS_2; SYSCON_CLK_SEL = SYSCON_CLK_SEL_DIV_BITS_2;
@ -37,4 +35,3 @@ void SYSTEM_ConfigureClocks(void)
// Disable division clock gate // 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; 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;
} }

BIN
firmware

Binary file not shown.

Binary file not shown.

Binary file not shown.

47
font.c
View File

@ -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} {0x10, 0x18, 0x08, 0x18, 0x10, 0x18, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
}; };
const uint8_t gFontBigDigits[11][26] = #if 0
{ // original font
{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}, const uint8_t gFontBigDigits[11][26] =
{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, 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, 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, 0x30, 0x30, 0xFC, 0xFC, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x00},
{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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 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] = const uint8_t gFontSmallDigits[11][7] =
{ {

View File

@ -69,6 +69,7 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode)
gMenuCursor = MENU_350TX; gMenuCursor = MENU_350TX;
gSubMenuSelection = gSetting_350TX; gSubMenuSelection = gSetting_350TX;
GUI_SelectNextDisplay(DISPLAY_MENU); GUI_SelectNextDisplay(DISPLAY_MENU);
gF_LOCK = true;
gMenuListCount = 57; gMenuListCount = 57;
#ifdef DISABLE_VOICE #ifdef DISABLE_VOICE
gMenuListCount--; gMenuListCount--;
@ -76,7 +77,6 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode)
#ifdef DISABLE_NOAA #ifdef DISABLE_NOAA
gMenuListCount--; gMenuListCount--;
#endif #endif
gF_LOCK = true;
} }
#ifndef DISABLE_AIRCOPY #ifndef DISABLE_AIRCOPY
else else
@ -107,7 +107,6 @@ void BOOT_ProcessMode(BOOT_Mode_t Mode)
gAircopyState = AIRCOPY_READY; gAircopyState = AIRCOPY_READY;
GUI_SelectNextDisplay(DISPLAY_AIRCOPY); GUI_SelectNextDisplay(DISPLAY_AIRCOPY);
} }
#endif #endif
else else

22
misc.c
View File

@ -18,6 +18,15 @@
#include "misc.h" #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 *gUpperLimitFrequencyBandTable;
const uint32_t *gLowerLimitFrequencyBandTable; const uint32_t *gLowerLimitFrequencyBandTable;
@ -29,19 +38,6 @@ bool gSetting_350EN;
uint8_t gSetting_F_LOCK; uint8_t gSetting_F_LOCK;
bool gSetting_ScrambleEnable; 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]; uint32_t gCustomAesKey[4];
bool bHasCustomAesKey; bool bHasCustomAesKey;
uint32_t gChallenge[4]; uint32_t gChallenge[4];

46
misc.h
View File

@ -30,51 +30,53 @@
#endif #endif
enum { enum {
MR_CHANNEL_FIRST = 0U, MR_CHANNEL_FIRST = 0U,
MR_CHANNEL_LAST = 199U, MR_CHANNEL_LAST = 199U,
FREQ_CHANNEL_FIRST = 200U, FREQ_CHANNEL_FIRST = 200U,
FREQ_CHANNEL_LAST = 206U, FREQ_CHANNEL_LAST = 206U,
NOAA_CHANNEL_FIRST = 207U, NOAA_CHANNEL_FIRST = 207U,
NOAA_CHANNEL_LAST = 216U NOAA_CHANNEL_LAST = 216U
}; };
enum { enum {
FLASHLIGHT_OFF = 0U, FLASHLIGHT_OFF = 0,
FLASHLIGHT_ON = 1U, FLASHLIGHT_ON,
FLASHLIGHT_BLINK = 2U FLASHLIGHT_BLINK
}; };
enum { enum {
VFO_CONFIGURE_0 = 0U, VFO_CONFIGURE_0 = 0,
VFO_CONFIGURE_1 = 1U, VFO_CONFIGURE_1,
VFO_CONFIGURE_RELOAD = 2U VFO_CONFIGURE_RELOAD
}; };
enum AlarmState_t { enum AlarmState_t {
ALARM_STATE_OFF = 0U, ALARM_STATE_OFF = 0,
ALARM_STATE_TXALARM = 1U, ALARM_STATE_TXALARM,
ALARM_STATE_ALARM = 2U, ALARM_STATE_ALARM,
ALARM_STATE_TX1750 = 3U ALARM_STATE_TX1750
}; };
typedef enum AlarmState_t AlarmState_t; typedef enum AlarmState_t AlarmState_t;
enum ReceptionMode_t { enum ReceptionMode_t {
RX_MODE_NONE = 0U, RX_MODE_NONE = 0,
RX_MODE_DETECTED = 1U, RX_MODE_DETECTED,
RX_MODE_LISTENING = 2U RX_MODE_LISTENING
}; };
typedef enum ReceptionMode_t ReceptionMode_t; typedef enum ReceptionMode_t ReceptionMode_t;
enum CssScanMode_t { enum CssScanMode_t {
CSS_SCAN_MODE_OFF = 0U, CSS_SCAN_MODE_OFF = 0,
CSS_SCAN_MODE_SCANNING = 1U, CSS_SCAN_MODE_SCANNING,
CSS_SCAN_MODE_FOUND = 2U, CSS_SCAN_MODE_FOUND,
}; };
typedef enum CssScanMode_t CssScanMode_t; typedef enum CssScanMode_t CssScanMode_t;
extern const uint8_t g_scan_delay;
extern const uint16_t gMax_bat_v; extern const uint16_t gMax_bat_v;
extern const uint16_t gMin_bat_v; extern const uint16_t gMin_bat_v;

View File

@ -744,6 +744,11 @@ void RADIO_SetTxParameters(void)
switch (gCurrentVfo->pTX->CodeType) switch (gCurrentVfo->pTX->CodeType)
{ {
default:
case CODE_TYPE_OFF:
BK4819_ExitSubAu();
break;
case CODE_TYPE_CONTINUOUS_TONE: case CODE_TYPE_CONTINUOUS_TONE:
BK4819_SetCTCSSFrequency(CTCSS_Options[gCurrentVfo->pTX->Code]); BK4819_SetCTCSSFrequency(CTCSS_Options[gCurrentVfo->pTX->Code]);
break; break;
@ -754,10 +759,6 @@ void RADIO_SetTxParameters(void)
DCS_GetGolayCodeWord(gCurrentVfo->pTX->CodeType, gCurrentVfo->pTX->Code) DCS_GetGolayCodeWord(gCurrentVfo->pTX->CodeType, gCurrentVfo->pTX->Code)
); );
break; break;
default:
BK4819_ExitSubAu();
break;
} }
} }

110
ui/main.c
View File

@ -59,7 +59,8 @@ void UI_DisplayMain(void)
uint32_t frequency_Hz = 0; uint32_t frequency_Hz = 0;
if (single_vfo) if (single_vfo)
{ { // we're in single VFO mode
if (!bIsSameVfo) if (!bIsSameVfo)
continue; // skip the unused vfo .. screen is dedicated to just a single VFO 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 (Channel != vfo_num)
{ {
if (gDTMF_CallState != DTMF_CALL_STATE_NONE || gDTMF_IsTx || gDTMF_InputMode) if (gDTMF_CallState != DTMF_CALL_STATE_NONE || gDTMF_IsTx || gDTMF_InputMode)
{ { // show DTMF stuff
char Contact[16]; char Contact[16];
if (!gDTMF_InputMode) if (!gDTMF_InputMode)
@ -98,14 +100,10 @@ void UI_DisplayMain(void)
{ {
memset(Contact, 0, sizeof(Contact)); memset(Contact, 0, sizeof(Contact));
if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT) if (gDTMF_CallState == DTMF_CALL_STATE_CALL_OUT)
{
sprintf(String, ">%s", (DTMF_FindContact(gDTMF_String, Contact)) ? Contact : gDTMF_String); sprintf(String, ">%s", (DTMF_FindContact(gDTMF_String, Contact)) ? Contact : gDTMF_String);
}
else else
if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED) if (gDTMF_CallState == DTMF_CALL_STATE_RECEIVED)
{
sprintf(String, ">%s", (DTMF_FindContact(gDTMF_Callee, Contact)) ? Contact : gDTMF_Callee); sprintf(String, ">%s", (DTMF_FindContact(gDTMF_Callee, Contact)) ? Contact : gDTMF_Callee);
}
else else
if (gDTMF_IsTx) if (gDTMF_IsTx)
sprintf(String, ">%s", gDTMF_String); sprintf(String, ">%s", gDTMF_String);
@ -128,11 +126,11 @@ void UI_DisplayMain(void)
//memcpy(pLine0 + 2, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault)); //memcpy(pLine0 + 2, BITMAP_VFO_NotDefault, sizeof(BITMAP_VFO_NotDefault));
} }
// 0x8EE2
uint32_t SomeValue = 0; uint32_t SomeValue = 0;
if (gCurrentFunction == FUNCTION_TRANSMIT) if (gCurrentFunction == FUNCTION_TRANSMIT)
{ { // transmitting
#ifndef DISABLE_ALARM #ifndef DISABLE_ALARM
if (gAlarmState == ALARM_STATE_ALARM) if (gAlarmState == ALARM_STATE_ALARM)
{ {
@ -157,8 +155,12 @@ void UI_DisplayMain(void)
} }
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num])) 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)); memcpy(pLine1 + 2, BITMAP_M, sizeof(BITMAP_M));
// show the memory channel number
if (gInputBoxIndex == 0 || gEeprom.TX_CHANNEL != vfo_num) if (gInputBoxIndex == 0 || gEeprom.TX_CHANNEL != vfo_num)
NUMBER_ToDigits(gEeprom.ScreenChannel[vfo_num] + 1, String); NUMBER_ToDigits(gEeprom.ScreenChannel[vfo_num] + 1, String);
else else
@ -167,7 +169,8 @@ void UI_DisplayMain(void)
} }
else else
if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num])) if (IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
{ // show the frequency band number {
// show the frequency band number
char c; char c;
memcpy(pLine1 + 14, BITMAP_F, sizeof(BITMAP_F)); memcpy(pLine1 + 14, BITMAP_F, sizeof(BITMAP_F));
c = (gEeprom.ScreenChannel[vfo_num] - FREQ_CHANNEL_FIRST) + 1; 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); UI_DisplaySmallDigits(2, String + 6, 15, Line + 1);
} }
// 0x8FEC
uint8_t State = VfoState[vfo_num]; uint8_t State = VfoState[vfo_num];
#ifndef DISABLE_ALARM #ifndef DISABLE_ALARM
@ -213,7 +214,7 @@ void UI_DisplayMain(void)
{ {
case VFO_STATE_BUSY: case VFO_STATE_BUSY:
strcpy(String, "BUSY"); strcpy(String, "BUSY");
Width = 15; //Width = 15;
break; break;
case VFO_STATE_BAT_LOW: case VFO_STATE_BAT_LOW:
strcpy(String, "BAT LOW"); strcpy(String, "BAT LOW");
@ -237,14 +238,16 @@ void UI_DisplayMain(void)
} }
else else
{ // normal state { // normal state
if (gInputBoxIndex && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_CHANNEL == vfo_num) 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); UI_DisplayFrequency(gInputBox, 31, vfo_num * 4, true, false);
} }
else else
{ {
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num])) if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num]))
{ { // channel mode#
frequency_Hz = gEeprom.VfoInfo[vfo_num].pRX->Frequency; frequency_Hz = gEeprom.VfoInfo[vfo_num].pRX->Frequency;
if (gCurrentFunction == FUNCTION_TRANSMIT) if (gCurrentFunction == FUNCTION_TRANSMIT)
{ // transmitting { // transmitting
@ -253,24 +256,28 @@ void UI_DisplayMain(void)
frequency_Hz = gEeprom.VfoInfo[vfo_num].pTX->Frequency; 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) switch (gEeprom.CHANNEL_DISPLAY_MODE)
{ {
case MDF_FREQUENCY: // show the channel frequency case MDF_FREQUENCY: // show the channel frequency
NUMBER_ToDigits(frequency_Hz, String); #ifdef BIG_FREQ_FONT
NUMBER_ToDigits(frequency_Hz, String);
// show the first lot of the frequency digits // show the main large frequency digits
UI_DisplayFrequency(String, 31, vfo_num * 4, false, false); UI_DisplayFrequency(String, 31, vfo_num * 4, false, false);
// show the remaining 2 frequency digits // show the remaining 2 small frequency digits
UI_DisplaySmallDigits(2, String + 6, 112, Line + 1); UI_DisplaySmallDigits(2, String + 6, 112, Line + 1);
#else
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num])) // show the frequency in the main font
{ sprintf(String, "%9.5f", frequency_Hz * 0.00001);
const uint8_t Attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; UI_PrintString(String, 31, 112, vfo_num * 4, 8, true);
if (Attributes & MR_CH_SCANLIST1) #endif
memcpy(pLine0 + 113, BITMAP_ScanList, sizeof(BITMAP_ScanList));
if (Attributes & MR_CH_SCANLIST2)
memcpy(pLine0 + 120, BITMAP_ScanList, sizeof(BITMAP_ScanList));
}
frequency_Hz = 0; frequency_Hz = 0;
break; break;
@ -283,7 +290,7 @@ void UI_DisplayMain(void)
case MDF_NAME: // show the channel name case MDF_NAME: // show the channel name
if (gEeprom.VfoInfo[vfo_num].Name[0] == 0 || gEeprom.VfoInfo[vfo_num].Name[0] == 0xFF) 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); sprintf(String, "CH-%03d", gEeprom.ScreenChannel[vfo_num] + 1);
UI_PrintString(String, 31, 112, vfo_num * 4, 8, true); UI_PrintString(String, 31, 112, vfo_num * 4, 8, true);
} }
@ -297,22 +304,23 @@ void UI_DisplayMain(void)
#ifdef CHAN_NAME_FREQ #ifdef CHAN_NAME_FREQ
case MDF_NAME_FREQ: // show the channel name and frequency 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) 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); 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 else
{ // channel name { // channel name
memset(String, 0, sizeof(String)); memset(String, 0, sizeof(String));
memcpy(String, gEeprom.VfoInfo[vfo_num].Name, 8); 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; break;
#endif #endif
} }
} }
else else
{ { // frequency mode
frequency_Hz = gEeprom.VfoInfo[vfo_num].pRX->Frequency; frequency_Hz = gEeprom.VfoInfo[vfo_num].pRX->Frequency;
if (gCurrentFunction == FUNCTION_TRANSMIT) if (gCurrentFunction == FUNCTION_TRANSMIT)
{ // transmitting { // transmitting
@ -321,21 +329,17 @@ void UI_DisplayMain(void)
frequency_Hz = gEeprom.VfoInfo[vfo_num].pTX->Frequency; frequency_Hz = gEeprom.VfoInfo[vfo_num].pTX->Frequency;
} }
NUMBER_ToDigits(frequency_Hz, String); // 8 digits #ifdef BIG_FREQ_FONT
NUMBER_ToDigits(frequency_Hz, String); // 8 digits
// show main part of frequency // show the main large frequency digits
UI_DisplayFrequency(String, 31, vfo_num * 4, false, false); UI_DisplayFrequency(String, 31, vfo_num * 4, false, false);
// show the remaing 2 small frequency digits // show the remaining 2 small frequency digits
UI_DisplaySmallDigits(2, String + 6, 112, Line + 1); UI_DisplaySmallDigits(2, String + 6, 112, Line + 1);
#else
if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo_num])) // show the frequency in the main font
{ sprintf(String, "%9.5f", frequency_Hz * 0.00001);
const uint8_t Attributes = gMR_ChannelAttributes[gEeprom.ScreenChannel[vfo_num]]; UI_PrintString(String, 31, 112, vfo_num * 4, 8, true);
if (Attributes & MR_CH_SCANLIST1) #endif
memcpy(pLine0 + 113, BITMAP_ScanList, sizeof(BITMAP_ScanList));
if (Attributes & MR_CH_SCANLIST2)
memcpy(pLine0 + 120, BITMAP_ScanList, sizeof(BITMAP_ScanList));
}
frequency_Hz = 0; frequency_Hz = 0;
} }
@ -407,7 +411,7 @@ void UI_DisplayMain(void)
} }
switch (gEeprom.VfoInfo[vfo_num].OUTPUT_POWER) switch (gEeprom.VfoInfo[vfo_num].OUTPUT_POWER)
{ // show the TX power symbol { // show the TX power level symbol
case OUTPUT_POWER_LOW: case OUTPUT_POWER_LOW:
memcpy(pLine1 + 128 + 44, BITMAP_PowerLow, sizeof(BITMAP_PowerLow)); memcpy(pLine1 + 128 + 44, BITMAP_PowerLow, sizeof(BITMAP_PowerLow));
break; break;
@ -446,12 +450,12 @@ void UI_DisplayMain(void)
#ifdef CHAN_NAME_FREQ #ifdef CHAN_NAME_FREQ
if (frequency_Hz > 0) if (frequency_Hz > 0)
{ // show the channel frequency below the channel number/name { // show the channel frequency below the channel number/name
#if 0 #if 1
NUMBER_ToDigits(frequency_Hz, String); // 8 digits NUMBER_ToDigits(frequency_Hz, String); // 8 digits
UI_DisplayFrequencySmall(String, 31 + 8, (vfo_num * 4) + 1, false); UI_DisplayFrequencySmall(String, 31 + 8, (vfo_num * 4) + 1, false);
#else #else
sprintf(String, "%9.5f", frequency_Hz * 0.00001); 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
} }
#endif #endif

View File

@ -2,5 +2,5 @@
#ifdef GIT_HASH #ifdef GIT_HASH
const char Version[] = "OEFW-" GIT_HASH; const char Version[] = "OEFW-" GIT_HASH;
#else #else
const char Version[] = "OEFW-230910"; const char Version[] = "OEFW-230911";
#endif #endif

View File

@ -13,7 +13,7 @@ del /S /Q *.o >nul 2>nul
del /S /Q *.d >nul 2>nul del /S /Q *.d >nul 2>nul
::python -m pip install --upgrade pip crcmod ::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 ::arm-none-eabi-size firmware