From 7c343a2b3e51210832604e069a1e68b23a5d189b Mon Sep 17 00:00:00 2001 From: mrkusypl Date: Fri, 20 Mar 2026 18:44:57 +0100 Subject: [PATCH] Enable beeps for Aircopy, minor code refactoring --- App/app/aircopy.c | 63 ++++++++++++++++++++--------------------------- App/app/main.c | 6 +++-- App/app/menu.c | 2 +- App/audio.c | 7 +----- App/screenshot.c | 8 +++--- 5 files changed, 37 insertions(+), 49 deletions(-) diff --git a/App/app/aircopy.c b/App/app/aircopy.c index 62d63e19..a2ec1322 100644 --- a/App/app/aircopy.c +++ b/App/app/aircopy.c @@ -312,16 +312,27 @@ void AIRCOPY_StorePacket(void) AIRCOPY_CheckComplete(); } +static void AIRCOPY_InitTransfer(bool isSendMode) +{ + gAircopyStep = 1; + gFSKWriteIndex = 0; + gAirCopyBlockNumber = 0; + gInputBoxIndex = 0; + gAirCopyIsSendMode = isSendMode; + + AIRCOPY_clear(); + + gAircopyState = AIRCOPY_TRANSFER; +} + // ============================================================================ // Key Processing // ============================================================================ -static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) +static void AIRCOPY_Key_DIGITS(KEY_Code_t Key) { INPUTBOX_Append(Key); - gRequestDisplayScreen = DISPLAY_AIRCOPY; - if (gInputBoxIndex < 6) { #ifdef ENABLE_VOICE gAnotherVoiceID = (VOICE_ID_t)Key; @@ -356,51 +367,31 @@ static void AIRCOPY_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) BK4819_ResetFSK(); return; } - - gRequestDisplayScreen = DISPLAY_AIRCOPY; } -static void AIRCOPY_Key_EXIT(bool bKeyPressed, bool bKeyHeld) +static void AIRCOPY_Key_EXIT() { if (gInputBoxIndex == 0) { - gAircopyStep = 1; - gFSKWriteIndex = 0; - gAirCopyBlockNumber = 0; - gInputBoxIndex = 0; + AIRCOPY_InitTransfer(0); // Mode: Receive gErrorsDuringAirCopy = lErrorsDuringAirCopy = 0; - gAirCopyIsSendMode = 0; - - AIRCOPY_clear(); BK4819_PrepareFSKReceive(); - - gAircopyState = AIRCOPY_TRANSFER; + } else { gInputBox[--gInputBoxIndex] = 10; } - - gRequestDisplayScreen = DISPLAY_AIRCOPY; } -static void AIRCOPY_Key_MENU(bool bKeyPressed, bool bKeyHeld) +static void AIRCOPY_Key_MENU() { - gAircopyStep = 1; - gFSKWriteIndex = 0; - gAirCopyBlockNumber = 0; - gInputBoxIndex = 0; - gAirCopyIsSendMode = 1; + AIRCOPY_InitTransfer(1); // Mode: Send + g_FSK_Buffer[0] = 0xABCD; g_FSK_Buffer[1] = 0; g_FSK_Buffer[35] = 0xDCBA; - - AIRCOPY_clear(); - - GUI_DisplayScreen(); - - gAircopyState = AIRCOPY_TRANSFER; } -static void AIRCOPY_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction) +static void AIRCOPY_Key_UP_DOWN(int8_t Direction) { if (!gEeprom.SET_NAV) { Direction = -Direction; @@ -415,8 +406,6 @@ static void AIRCOPY_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Directio gAircopyCurrentMapIndex = (gAircopyCurrentMapIndex + AIRCOPY_NUM_MAPS - 1) % AIRCOPY_NUM_MAPS; break; } - - gRequestDisplayScreen = DISPLAY_AIRCOPY; } void AIRCOPY_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) @@ -431,17 +420,17 @@ void AIRCOPY_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) switch (Key) { case KEY_0...KEY_9: - AIRCOPY_Key_DIGITS(Key, bKeyPressed, bKeyHeld); + AIRCOPY_Key_DIGITS(Key); break; case KEY_MENU: - AIRCOPY_Key_MENU(bKeyPressed, bKeyHeld); + AIRCOPY_Key_MENU(); break; case KEY_EXIT: - AIRCOPY_Key_EXIT(bKeyPressed, bKeyHeld); + AIRCOPY_Key_EXIT(); break; case KEY_UP: case KEY_DOWN: - AIRCOPY_Key_UP_DOWN(bKeyPressed, bKeyHeld, Key == KEY_UP ? 1 : -1); + AIRCOPY_Key_UP_DOWN(Key == KEY_UP ? 1 : -1); break; case KEY_PTT: break; @@ -449,6 +438,8 @@ void AIRCOPY_ProcessKeys(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld) gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; break; } + + gRequestDisplayScreen = DISPLAY_AIRCOPY; } #endif \ No newline at end of file diff --git a/App/app/main.c b/App/app/main.c index 46f65e70..7ff59a43 100644 --- a/App/app/main.c +++ b/App/app/main.c @@ -294,8 +294,9 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) } gWasFKeyPressed = false; + + break; } - break; case KEY_SIDE1: case KEY_SIDE2: { @@ -313,8 +314,9 @@ static void processFKeyFunction(const KEY_Code_t Key, const bool beep) } gWasFKeyPressed = false; + + break; } - break; #endif default: diff --git a/App/app/menu.c b/App/app/menu.c index 6d58b49a..fdaaf997 100644 --- a/App/app/menu.c +++ b/App/app/menu.c @@ -1785,7 +1785,7 @@ static void MENU_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) UI_DisplayMenu(); - if (UI_MENU_GetCurrentMenuId() == MENU_RESET) + if (m == MENU_RESET) { #ifdef ENABLE_VOICE AUDIO_SetVoiceID(0, VOICE_ID_CONFIRM); diff --git a/App/audio.c b/App/audio.c index bb2c6073..022515b8 100644 --- a/App/audio.c +++ b/App/audio.c @@ -53,12 +53,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep) #endif !gEeprom.BEEP_CONTROL) return; - -#ifdef ENABLE_AIRCOPY - if (gScreenToDisplay == DISPLAY_AIRCOPY) - return; -#endif - + if (gCurrentFunction == FUNCTION_RECEIVE) return; diff --git a/App/screenshot.c b/App/screenshot.c index 8ca66c2c..b56e44a9 100644 --- a/App/screenshot.c +++ b/App/screenshot.c @@ -52,14 +52,14 @@ static void SCREENSHOT_Send(const uint8_t *buf, uint16_t len) } } -void SCREENSHOT_Line(uint8_t *src, uint8_t *dest, uint16_t *idx, bool inv) { +void SCREENSHOT_Line(uint8_t *src, uint8_t *dest, uint16_t *idx) { for (uint8_t b = 0; b < 8; b++) { for (uint8_t i = 0; i < 128; i += 8) { uint8_t acc = 0; for (uint8_t k = 0; k < 8; k++) { if (src[i + k] & (1 << b)) acc |= (1 << k); } - dest[(*idx)++] = inv ? ~acc : acc; + dest[(*idx)++] = gSetting_set_inv ? ~acc : acc; } } } @@ -95,11 +95,11 @@ void SCREENSHOT_Update(bool force) // ==== BUILD FRAME ONCE ==== // Status line: 8 bit layers × 128 columns - SCREENSHOT_Line(gStatusLine, frameBuffer, &index, gSetting_set_inv); + SCREENSHOT_Line(gStatusLine, frameBuffer, &index); // Frame buffer: 7 lines × 8 bit layers × 128 columns for (uint8_t l = 0; l < 7; l++) { - SCREENSHOT_Line(gFrameBuffer[l], frameBuffer, &index, gSetting_set_inv); + SCREENSHOT_Line(gFrameBuffer[l], frameBuffer, &index); } if (bitCount > 0)