Merge pull request #226 from mrkusypl/v5_refactor

Enable beeps for Aircopy, minor code refactoring
This commit is contained in:
Armel FAUVEAU authored and GitHub committed 2026-03-20 23:52:00 +01:00
commit 06907f9b67
5 files changed
+37 -49

No files matched your search

+27 -36
View File
@@ -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
+4 -2
View File
@@ -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:
+1 -1
View File
@@ -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);
+1 -6
View File
@@ -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;
+4 -4
View File
@@ -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)