From 34abc0f93d4a9247b1ed415f576fe61bde98a9b9 Mon Sep 17 00:00:00 2001 From: Mikhail Yudin Date: Wed, 8 Nov 2023 03:12:58 +0700 Subject: [PATCH] feat: numbers long press instead of F+, dcznlist editor fullscreen --- app/app.c | 4 +- app/main.c | 232 ++++++++++++++++++++++++------------------------ apps/scanlist.c | 41 +++++---- ui/ui.c | 4 +- 4 files changed, 144 insertions(+), 137 deletions(-) diff --git a/app/app.c b/app/app.c index 708780a..d3da328 100644 --- a/app/app.c +++ b/app/app.c @@ -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; @@ -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); } diff --git a/app/main.c b/app/main.c index a879eda..a2441a8 100644 --- a/app/main.c +++ b/app/main.c @@ -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; @@ -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) { diff --git a/apps/scanlist.c b/apps/scanlist.c index 6b654fa..fd3a5a3 100644 --- a/apps/scanlist.c +++ b/apps/scanlist.c @@ -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; } @@ -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; } @@ -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; @@ -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); diff --git a/ui/ui.c b/ui/ui.c index 61cfb27..d3ccc9c 100644 --- a/ui/ui.c +++ b/ui/ui.c @@ -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)