Skip to content

Commit

Permalink
feat: numbers long press instead of F+<num>, dcznlist editor fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
fagci committed Nov 7, 2023
1 parent 30d8753 commit 34abc0f
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 137 deletions.
4 changes: 2 additions & 2 deletions app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ void APP_Update(void) {
}
}

#define KEY_HOLD_TIME 50
#define KEY_HOLD_TIME 30

void APP_CheckKeys(void) {
KEY_Code_t Key;
Expand Down Expand Up @@ -852,7 +852,7 @@ void APP_CheckKeys(void) {
// NOTE: Here keys to process hold start
if (Key == KEY_STAR || Key == KEY_F || Key == KEY_SIDE2 ||
Key == KEY_SIDE1 || Key == KEY_UP || Key == KEY_DOWN ||
Key == KEY_MENU) {
Key == KEY_MENU || (Key >= KEY_0 && Key <= KEY_9)) {
gKeyBeingHeld = true;
APP_ProcessKey(Key, true, true);
}
Expand Down
232 changes: 114 additions & 118 deletions app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,124 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
uint8_t Vfo = gEeprom.TX_VFO;
uint8_t Band;

if (bKeyHeld) {
return;
}
if (!bKeyPressed) {
if (bKeyPressed && bKeyHeld) {
gUpdateStatus = true;
VFO_Info_t *vfoInfo = &gEeprom.VfoInfo[Vfo];
switch (Key) {
case KEY_0:
#if defined(ENABLE_FMRADIO)
ACTION_FM();
#endif
break;

case KEY_1:
if (!IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
gWasFKeyPressed = false;
gUpdateStatus = true;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return;
}
Band = gTxVfo->Band + 1;
if (BAND7_470MHz < Band) {
Band = BAND1_50MHz;
}
gTxVfo->Band = Band;
gEeprom.ScreenChannel[Vfo] = FREQ_CHANNEL_FIRST + Band;
gEeprom.FreqChannel[Vfo] = FREQ_CHANNEL_FIRST + Band;
gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gRequestDisplayScreen = DISPLAY_MAIN;
break;

case KEY_2:
SwitchActiveVFO();
break;

case KEY_3:
if (gEeprom.VFO_OPEN && IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
uint8_t Channel;

if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_VFO];
gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
break;
}
Channel = RADIO_FindNextChannel(gEeprom.MrChannel[gEeprom.TX_VFO], 1,
false, 0);
if (Channel != 0xFF) {
gEeprom.ScreenChannel[Vfo] = Channel;
gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
break;
}
}
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
break;

case KEY_4:
gWasFKeyPressed = false;
gUpdateStatus = true;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gFlagStartScan = true;
gScanSingleFrequency = false;
gBackupCROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX;
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
break;

case KEY_5:
gCurrentFunction = 0;
APP_RunSpectrum();
gRequestDisplayScreen = DISPLAY_MAIN;
break;

case KEY_6:
ACTION_Power();
break;

case KEY_7:
if (vfoInfo->AM_CHANNEL_MODE == MOD_RAW) {
vfoInfo->AM_CHANNEL_MODE = MOD_FM;
} else {
vfoInfo->AM_CHANNEL_MODE++;
}
gRequestSaveChannel = 1;
gRequestDisplayScreen = gScreenToDisplay;
break;

case KEY_8:
gTxVfo->FrequencyReverse = gTxVfo->FrequencyReverse == false;
gRequestSaveChannel = 1;
break;

case KEY_9:
if (RADIO_CheckValidChannel(gEeprom.CHAN_1_CALL, false, 0)) {
gEeprom.MrChannel[Vfo] = gEeprom.CHAN_1_CALL;
gEeprom.ScreenChannel[Vfo] = gEeprom.CHAN_1_CALL;
gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
break;
}
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
break;

case KEY_F:
break;

default:
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gUpdateStatus = true;
gWasFKeyPressed = false;
break;
}
return;
}

gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
if (!bKeyHeld && !bKeyPressed) {

gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;

if (!gWasFKeyPressed) {
gRequestDisplayScreen = DISPLAY_MAIN;
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
uint16_t Channel;
Expand Down Expand Up @@ -123,118 +231,6 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
gWasFKeyPressed = false;
gUpdateStatus = true;
VFO_Info_t *vfoInfo = &gEeprom.VfoInfo[Vfo];
switch (Key) {
case KEY_0:
#if defined(ENABLE_FMRADIO)
ACTION_FM();
#endif
break;

case KEY_1:
if (!IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
gWasFKeyPressed = false;
gUpdateStatus = true;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
return;
}
Band = gTxVfo->Band + 1;
if (BAND7_470MHz < Band) {
Band = BAND1_50MHz;
}
gTxVfo->Band = Band;
gEeprom.ScreenChannel[Vfo] = FREQ_CHANNEL_FIRST + Band;
gEeprom.FreqChannel[Vfo] = FREQ_CHANNEL_FIRST + Band;
gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gRequestDisplayScreen = DISPLAY_MAIN;
break;

case KEY_2:
SwitchActiveVFO();
break;

case KEY_3:
if (gEeprom.VFO_OPEN && IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
uint8_t Channel;

if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) {
gEeprom.ScreenChannel[Vfo] = gEeprom.FreqChannel[gEeprom.TX_VFO];
gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
break;
}
Channel =
RADIO_FindNextChannel(gEeprom.MrChannel[gEeprom.TX_VFO], 1, false, 0);
if (Channel != 0xFF) {
gEeprom.ScreenChannel[Vfo] = Channel;
gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
break;
}
}
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
break;

case KEY_4:
gWasFKeyPressed = false;
gUpdateStatus = true;
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gFlagStartScan = true;
gScanSingleFrequency = false;
gBackupCROSS_BAND_RX_TX = gEeprom.CROSS_BAND_RX_TX;
gEeprom.CROSS_BAND_RX_TX = CROSS_BAND_OFF;
break;

case KEY_5:
gCurrentFunction = 0;
APP_RunSpectrum();
gRequestDisplayScreen = DISPLAY_MAIN;
break;

case KEY_6:
ACTION_Power();
break;

case KEY_7:
// ACTION_Vox();
if (vfoInfo->AM_CHANNEL_MODE == MOD_RAW) {
vfoInfo->AM_CHANNEL_MODE = MOD_FM;
} else {
vfoInfo->AM_CHANNEL_MODE++;
}
gRequestSaveChannel = 1;
gRequestDisplayScreen = gScreenToDisplay;
break;

case KEY_8:
gTxVfo->FrequencyReverse = gTxVfo->FrequencyReverse == false;
gRequestSaveChannel = 1;
break;

case KEY_9:
if (RADIO_CheckValidChannel(gEeprom.CHAN_1_CALL, false, 0)) {
gEeprom.MrChannel[Vfo] = gEeprom.CHAN_1_CALL;
gEeprom.ScreenChannel[Vfo] = gEeprom.CHAN_1_CALL;
gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
break;
}
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
break;

case KEY_F:
break;

default:
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
gUpdateStatus = true;
gWasFKeyPressed = false;
break;
}
}

static void MAIN_Key_EXIT(bool bKeyPressed, bool bKeyHeld) {
Expand Down
41 changes: 25 additions & 16 deletions apps/scanlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@ void scanListUpdate(uint8_t Channel, uint8_t val) {
uint8_t State[8];
uint16_t Offset = 0x0D60 + (Channel & ~7U);

bool s1 = val & 1;
bool s2 = val & 2;

gMR_ChannelAttributes[Channel] &= ~(MR_CH_SCANLIST1 | MR_CH_SCANLIST2);
if (s1) {
if (val & 1) {
gMR_ChannelAttributes[Channel] |= MR_CH_SCANLIST1;
}
if (s2) {
if (val & 2) {
gMR_ChannelAttributes[Channel] |= MR_CH_SCANLIST2;
}

Expand All @@ -34,15 +31,29 @@ void SCANLIST_key(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
if (bKeyPressed) {
switch (Key) {
case KEY_DOWN:
if (cursor < 199) {
cursor++;
} else {
if (cursor == 199) {
cursor = 0;
} else {
cursor++;
}
break;
case KEY_UP:
if (cursor > 0) {
if (cursor == 0) {
cursor = 199;
} else {
cursor--;
}
break;
case KEY_F:
if (cursor < 189) {
cursor += 10;
} else {
cursor = 0;
}
break;
case KEY_STAR:
if (cursor > 10) {
cursor -= 10;
} else {
cursor = 199;
}
Expand All @@ -53,7 +64,6 @@ void SCANLIST_key(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
case KEY_3:
scanListUpdate(cursor, Key - KEY_0);
break;
case KEY_MENU:
case KEY_EXIT:
gAppToDisplay = APP_SPLIT;
gRequestDisplayScreen = DISPLAY_MAIN;
Expand All @@ -68,19 +78,18 @@ void SCANLIST_key(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) {
void SCANLIST_render() {
char String[32];
char channelName[16];
UI_ClearAppScreen();
memset(gFrameBuffer, 0, sizeof(gFrameBuffer));

const uint8_t count = 200;
const uint8_t perScreen = 3;
const uint8_t perScreen = 7;
const uint8_t offset = Clamp(cursor - 2, 0, count - perScreen);
for (uint8_t i = 0; i < perScreen; ++i) {
uint8_t itemIndex = i + offset;
uint8_t chPos = 4 + i;
uint8_t chNum = itemIndex + 1;
uint8_t y = 33 + i * 8;
uint8_t *pLine = gFrameBuffer[chPos];
uint8_t y = i * 8 + 1;
uint8_t *pLine = gFrameBuffer[i];

bool isCurrent = cursor == i + offset;
bool isCurrent = cursor == itemIndex;

if (isCurrent) {
memset(pLine, 127, LCD_WIDTH);
Expand Down
4 changes: 3 additions & 1 deletion ui/ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ void UI_DisplayApp(void) {
void GUI_DisplayScreen(void) {
switch (gScreenToDisplay) {
case DISPLAY_MAIN:
UI_DisplayMain();
if (gAppToDisplay != APP_SCANLIST) {
UI_DisplayMain();
}
UI_DisplayApp();
break;
#if defined(ENABLE_FMRADIO)
Expand Down

0 comments on commit 34abc0f

Please sign in to comment.