Refactor
This commit is contained in:
31
app/app.c
31
app/app.c
@@ -1906,22 +1906,16 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (Key != KEY_SIDE1 && Key != KEY_SIDE2)
|
else if (Key != KEY_SIDE1 && Key != KEY_SIDE2) {
|
||||||
{
|
switch (gScreenToDisplay) {
|
||||||
switch (gScreenToDisplay)
|
|
||||||
{
|
|
||||||
case DISPLAY_MAIN:
|
case DISPLAY_MAIN:
|
||||||
|
|
||||||
MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
MAIN_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
||||||
// bKeyHeld = false; // allow the channel setting to be saved
|
|
||||||
break;
|
break;
|
||||||
|
#ifdef ENABLE_FMRADIO
|
||||||
#ifdef ENABLE_FMRADIO
|
case DISPLAY_FM:
|
||||||
case DISPLAY_FM:
|
FM_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
||||||
FM_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
break;
|
||||||
break;
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
case DISPLAY_MENU:
|
case DISPLAY_MENU:
|
||||||
MENU_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
MENU_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
||||||
break;
|
break;
|
||||||
@@ -1930,12 +1924,11 @@ static void ProcessKey(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
SCANNER_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
SCANNER_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef ENABLE_AIRCOPY
|
#ifdef ENABLE_AIRCOPY
|
||||||
case DISPLAY_AIRCOPY:
|
case DISPLAY_AIRCOPY:
|
||||||
AIRCOPY_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
AIRCOPY_ProcessKeys(Key, bKeyPressed, bKeyHeld);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case DISPLAY_INVALID:
|
case DISPLAY_INVALID:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
81
app/fm.c
81
app/fm.c
@@ -225,30 +225,22 @@ Bail:
|
|||||||
|
|
||||||
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
|
enum { STATE_FREQ_MODE, STATE_MR_MODE, STATE_SAVE };
|
||||||
#define STATE_MR_MODE 1
|
|
||||||
#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
|
else {
|
||||||
{
|
if (gFM_ScanState != FM_SCAN_OFF) {
|
||||||
if (gFM_ScanState != FM_SCAN_OFF)
|
|
||||||
{
|
|
||||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -260,59 +252,47 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
|
|
||||||
gRequestDisplayScreen = DISPLAY_FM;
|
gRequestDisplayScreen = DISPLAY_FM;
|
||||||
|
|
||||||
if (State == STATE_FREQ_MODE)
|
if (State == STATE_FREQ_MODE) {
|
||||||
{
|
if (gInputBoxIndex == 1) {
|
||||||
if (gInputBoxIndex == 1)
|
if (gInputBox[0] > 1) {
|
||||||
{
|
|
||||||
if (gInputBox[0] > 1)
|
|
||||||
{
|
|
||||||
gInputBox[1] = gInputBox[0];
|
gInputBox[1] = gInputBox[0];
|
||||||
gInputBox[0] = 0;
|
gInputBox[0] = 0;
|
||||||
gInputBoxIndex = 2;
|
gInputBoxIndex = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (gInputBoxIndex > 3) {
|
||||||
if (gInputBoxIndex > 3)
|
|
||||||
{
|
|
||||||
uint32_t Frequency;
|
uint32_t Frequency;
|
||||||
|
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
Frequency = StrToUL(INPUTBOX_GetAscii());
|
Frequency = StrToUL(INPUTBOX_GetAscii());
|
||||||
|
|
||||||
if (Frequency < gEeprom.FM_LowerLimit || gEeprom.FM_UpperLimit < Frequency)
|
if (Frequency < gEeprom.FM_LowerLimit || gEeprom.FM_UpperLimit < Frequency) {
|
||||||
{
|
|
||||||
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
|
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;
|
||||||
|
#ifdef ENABLE_VOICE
|
||||||
#ifdef ENABLE_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
|
else if (gInputBoxIndex == 2) {
|
||||||
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))
|
#ifdef ENABLE_VOICE
|
||||||
{
|
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||||
#ifdef ENABLE_VOICE
|
#endif
|
||||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
|
||||||
#endif
|
|
||||||
gEeprom.FM_SelectedChannel = Channel;
|
gEeprom.FM_SelectedChannel = Channel;
|
||||||
gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel];
|
gEeprom.FM_FrequencyPlaying = gFM_Channels[Channel];
|
||||||
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
|
BK1080_SetFrequency(gEeprom.FM_FrequencyPlaying);
|
||||||
@@ -320,12 +300,10 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (Channel < 20) {
|
||||||
if (Channel < 20)
|
#ifdef ENABLE_VOICE
|
||||||
{
|
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||||
#ifdef ENABLE_VOICE
|
#endif
|
||||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
|
||||||
#endif
|
|
||||||
gRequestDisplayScreen = DISPLAY_FM;
|
gRequestDisplayScreen = DISPLAY_FM;
|
||||||
gInputBoxIndex = 0;
|
gInputBoxIndex = 0;
|
||||||
gFM_ChannelPosition = Channel;
|
gFM_ChannelPosition = Channel;
|
||||||
@@ -336,9 +314,9 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_VOICE
|
#ifdef ENABLE_VOICE
|
||||||
gAnotherVoiceID = (VOICE_ID_t)Key;
|
gAnotherVoiceID = (VOICE_ID_t)Key;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -348,8 +326,7 @@ static void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
|
|||||||
gUpdateStatus = true;
|
gUpdateStatus = true;
|
||||||
gRequestDisplayScreen = DISPLAY_FM;
|
gRequestDisplayScreen = DISPLAY_FM;
|
||||||
|
|
||||||
switch (Key)
|
switch (Key) {
|
||||||
{
|
|
||||||
case KEY_0:
|
case KEY_0:
|
||||||
ACTION_FM();
|
ACTION_FM();
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user