From 46034ec39f123a64dc499bfc052a277e2637bdeb Mon Sep 17 00:00:00 2001 From: Armel FAUVEAU Date: Thu, 9 Jul 2026 05:22:39 +0200 Subject: [PATCH] Rename screenshot module to k5viewer --- App/CMakeLists.txt | 8 +-- App/app/aircopy.c | 16 ++--- App/app/app.c | 20 +++--- App/app/breakout.c | 12 ++-- App/app/spectrum.c | 14 ++-- App/app/uart.c | 4 +- App/driver/keyboard.c | 4 +- App/driver/keyboard.h | 2 +- App/driver/st7565.c | 6 +- App/driver/uart.c | 4 +- App/driver/uart.h | 2 +- App/driver/vcp.c | 8 +-- App/driver/vcp.h | 4 +- App/{screenshot.c => k5viewer.c} | 108 +++++++++++++++---------------- App/{screenshot.h => k5viewer.h} | 10 +-- App/misc.c | 14 ++-- App/misc.h | 8 +-- App/ui/welcome.c | 8 +-- CMakePresets.json | 14 ++-- 19 files changed, 133 insertions(+), 133 deletions(-) rename App/{screenshot.c => k5viewer.c} (72%) rename App/{screenshot.h => k5viewer.h} (80%) diff --git a/App/CMakeLists.txt b/App/CMakeLists.txt index e5060527..0fdd20ce 100644 --- a/App/CMakeLists.txt +++ b/App/CMakeLists.txt @@ -180,8 +180,8 @@ enable_feature(ENABLE_FEAT_F4HWN) enable_feature(ENABLE_FEAT_F4HWN_GAME app/breakout.c ) -enable_feature(ENABLE_FEAT_F4HWN_SCREENSHOT - screenshot.c +enable_feature(ENABLE_FEAT_F4HWN_K5VIEWER + k5viewer.c ) enable_feature(ENABLE_FEAT_F4HWN_SPECTRUM) enable_feature(ENABLE_FEAT_F4HWN_RX_TX_TIMER) @@ -213,8 +213,8 @@ enable_feature(ENABLE_FEAT_F4HWN_RXTX_LOG enable_feature(ENABLE_FEAT_F4HWN_RXTX_LOG_WRAP) enable_feature(ENABLE_FEAT_F4HWN_RXTX_LOG_K5VIEWER) -if(ENABLE_FEAT_F4HWN_RXTX_LOG_K5VIEWER AND NOT (ENABLE_FEAT_F4HWN_RXTX_LOG AND ENABLE_FEAT_F4HWN_SCREENSHOT)) - message(FATAL_ERROR "ENABLE_FEAT_F4HWN_RXTX_LOG_K5VIEWER requires ENABLE_FEAT_F4HWN_RXTX_LOG (log data) and ENABLE_FEAT_F4HWN_SCREENSHOT (serial transport).") +if(ENABLE_FEAT_F4HWN_RXTX_LOG_K5VIEWER AND NOT (ENABLE_FEAT_F4HWN_RXTX_LOG AND ENABLE_FEAT_F4HWN_K5VIEWER)) + message(FATAL_ERROR "ENABLE_FEAT_F4HWN_RXTX_LOG_K5VIEWER requires ENABLE_FEAT_F4HWN_RXTX_LOG (log data) and ENABLE_FEAT_F4HWN_K5VIEWER (serial transport).") endif() if(ENABLE_FEAT_F4HWN_BEAM AND NOT ENABLE_AIRCOPY) diff --git a/App/app/aircopy.c b/App/app/aircopy.c index 884ff90c..8ff485e5 100644 --- a/App/app/aircopy.c +++ b/App/app/aircopy.c @@ -30,8 +30,8 @@ #include "settings.h" #include -#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT -#include "screenshot.h" +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER +#include "k5viewer.h" #endif static const uint16_t Obfuscation[8] = { 0x6C16, 0xE614, 0x912E, 0x400D, 0x3521, 0x40D5, 0x0313, 0x80E9 }; @@ -140,8 +140,8 @@ static void AIRCOPY_clear() { crc[i] = 0; } - #ifdef ENABLE_FEAT_F4HWN_SCREENSHOT - SCREENSHOT_Update(true); + #ifdef ENABLE_FEAT_F4HWN_K5VIEWER + K5VIEWER_Update(true); #endif } @@ -170,8 +170,8 @@ static inline void AIRCOPY_CheckComplete(uint16_t *num) if (done >= map->total_blocks) { gAircopyState = AIRCOPY_COMPLETE; -#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT - SCREENSHOT_Update(false); +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER + K5VIEWER_Update(false); #endif } } @@ -222,8 +222,8 @@ bool AIRCOPY_SendMessage(void) // Check if transfer is complete if (CurrentSegmentIndex >= map->num_segments) { gAircopyState = AIRCOPY_COMPLETE; - #ifdef ENABLE_FEAT_F4HWN_SCREENSHOT - SCREENSHOT_Update(false); + #ifdef ENABLE_FEAT_F4HWN_K5VIEWER + K5VIEWER_Update(false); #endif return 0; } diff --git a/App/app/app.c b/App/app/app.c index 84890f2a..b6b02ecf 100644 --- a/App/app/app.c +++ b/App/app/app.c @@ -83,8 +83,8 @@ #include "ui/ui.h" #include "ui/welcome.h" -#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT - #include "screenshot.h" +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER + #include "k5viewer.h" #endif static bool flagSaveVfo; @@ -230,8 +230,8 @@ static void ScreenSaverRenderLogoPlus(bool reset) static void ScreenSaverUpdateViewer(void) { -#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT - SCREENSHOT_Update(false); +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER + K5VIEWER_Update(false); #endif } @@ -1121,10 +1121,10 @@ static void HandleVox(void) void APP_Update(void) { -#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER // Parse incoming packets on every tick so serial keys are never missed, // regardless of whether the screen needs redrawing. - SCREENSHOT_ParseInput(); + K5VIEWER_ParseInput(); #endif #ifdef ENABLE_VOICE @@ -1666,15 +1666,15 @@ void APP_TimeSlice10ms(void) UI_DisplayStatus(); } - #ifdef ENABLE_FEAT_F4HWN_SCREENSHOT + #ifdef ENABLE_FEAT_F4HWN_K5VIEWER if (gUpdateDisplayCurrent || gUpdateStatusCurrent #ifdef ENABLE_FEAT_F4HWN_LOGO_SAV || screenSaverRendered #endif ) { - SCREENSHOT_Update(false); - } else if (SCREENSHOT_HasPendingStateChange()) { - SCREENSHOT_Update(false); + K5VIEWER_Update(false); + } else if (K5VIEWER_HasPendingStateChange()) { + K5VIEWER_Update(false); } #endif diff --git a/App/app/breakout.c b/App/app/breakout.c index e9867a25..6059eb63 100644 --- a/App/app/breakout.c +++ b/App/app/breakout.c @@ -16,8 +16,8 @@ #include "app/breakout.h" -#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT -#include "screenshot.h" +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER +#include "k5viewer.h" #endif static uint32_t randSeed = 1; @@ -304,10 +304,10 @@ static void OnKeyDown(uint8_t key) // HandleUserInput static bool HandleUserInput() { -#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER // Parse incoming packets on every tick so serial keys are never missed, // regardless of whether the screen needs redrawing. - SCREENSHOT_ParseInput(); + K5VIEWER_ParseInput(); #endif kbd.prev = kbd.current; @@ -388,10 +388,10 @@ void APP_RunBreakout(void) { ST7565_BlitStatusLine(); // Blank status line ST7565_BlitFullScreen(); - #ifdef ENABLE_FEAT_F4HWN_SCREENSHOT + #ifdef ENABLE_FEAT_F4HWN_K5VIEWER if(isPaused || swap == 0) { - SCREENSHOT_Update(false); + K5VIEWER_Update(false); } #endif } diff --git a/App/app/spectrum.c b/App/app/spectrum.c index a57a552e..29b51a52 100644 --- a/App/app/spectrum.c +++ b/App/app/spectrum.c @@ -27,8 +27,8 @@ #include "ui/helper.h" #include "ui/main.h" -#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT -#include "screenshot.h" +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER +#include "k5viewer.h" #endif #ifdef ENABLE_FEAT_F4HWN_SPECTRUM @@ -2461,10 +2461,10 @@ static void UpdateListening() static void Tick() { -#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER // Parse incoming packets on every tick so serial keys are never missed, // regardless of whether the screen needs redrawing. - SCREENSHOT_ParseInput(); + K5VIEWER_ParseInput(); #endif if (gNextTimeslice) @@ -2532,9 +2532,9 @@ static void Tick() if (redrawScreen || ++renderTimer >= RENDER_PERIOD_TICKS) { Render(); - // For screenshot - #ifdef ENABLE_FEAT_F4HWN_SCREENSHOT - SCREENSHOT_Update(false); + // For K5Viewer + #ifdef ENABLE_FEAT_F4HWN_K5VIEWER + K5VIEWER_Update(false); #endif redrawScreen = false; renderTimer = 0; diff --git a/App/app/uart.c b/App/app/uart.c index 8f7d592b..7d14e65e 100644 --- a/App/app/uart.c +++ b/App/app/uart.c @@ -863,7 +863,7 @@ void UART_HandleCommand(uint32_t Port) #endif } // switch - #ifdef ENABLE_FEAT_F4HWN_SCREENSHOT - gUART_LockScreenshot = 20; // lock screenshot + #ifdef ENABLE_FEAT_F4HWN_K5VIEWER + gUART_LockK5Viewer = 20; // lock the K5Viewer stream #endif } \ No newline at end of file diff --git a/App/driver/keyboard.c b/App/driver/keyboard.c index b8a8d983..42ca3c3b 100644 --- a/App/driver/keyboard.c +++ b/App/driver/keyboard.c @@ -27,7 +27,7 @@ KEY_Code_t gKeyReading1 = KEY_INVALID; uint16_t gDebounceCounter = 0; bool gWasFKeyPressed = false; -#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER // Short press: hold key for SERIAL_KEY_SHORT_POLLS calls. // Must exceed key_debounce_10ms (2) to trigger ProcessKey(key, true, false). #define SERIAL_KEY_SHORT_POLLS 5 @@ -184,7 +184,7 @@ static const KEY_Code_t keyboard[5][4] = { KEY_Code_t KEYBOARD_Poll(void) { -#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER // Serial-injected key: hold it for SHORT or LONG polls depending on press type, // so the debounce counter in app.c reaches the right threshold: // - Short: key_debounce_10ms (2) → ProcessKey(key, true, false) diff --git a/App/driver/keyboard.h b/App/driver/keyboard.h index 7450308e..579063b4 100644 --- a/App/driver/keyboard.h +++ b/App/driver/keyboard.h @@ -64,7 +64,7 @@ extern KEY_Code_t gKeyReading1; extern uint16_t gDebounceCounter; extern bool gWasFKeyPressed; -#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER // Serial-injected key (written by UART/VCP parser, consumed by KEYBOARD_Poll). extern volatile KEY_Code_t gKeyFromSerial; diff --git a/App/driver/st7565.c b/App/driver/st7565.c index b6b0a655..c488bb68 100644 --- a/App/driver/st7565.c +++ b/App/driver/st7565.c @@ -24,7 +24,7 @@ #include "driver/st7565.h" #include "driver/system.h" #include "misc.h" -#include "screenshot.h" +#include "k5viewer.h" #define SPIx SPI1 @@ -164,8 +164,8 @@ void ST7565_DrawLine(const unsigned int Column, const unsigned int Line, const u void ST7565_BlitLine(unsigned line) { ST7565_BlitScreen(line + 1); - #ifdef ENABLE_FEAT_F4HWN_SCREENSHOT - SCREENSHOT_Update(true); // Force immediate capture + #ifdef ENABLE_FEAT_F4HWN_K5VIEWER + K5VIEWER_Update(true); // Force immediate capture #endif } diff --git a/App/driver/uart.c b/App/driver/uart.c index b9b0e2a6..661bdb98 100644 --- a/App/driver/uart.c +++ b/App/driver/uart.c @@ -23,7 +23,7 @@ #include "py32f071_ll_gpio.h" #include "py32f071_ll_usart.h" -#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER #include "driver/keyboard.h" #endif @@ -150,7 +150,7 @@ void UART_LogSend(const void *pBuffer, uint32_t Size) } } -#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER bool UART_IsCableConnected(void) { static uint8_t read_ptr = 0; static ParseState_t state = STATE_IDLE; diff --git a/App/driver/uart.h b/App/driver/uart.h index 70bd401c..c1f27269 100644 --- a/App/driver/uart.h +++ b/App/driver/uart.h @@ -27,7 +27,7 @@ void UART_Init(void); void UART_Send(const void *pBuffer, uint32_t Size); void UART_LogSend(const void *pBuffer, uint32_t Size); -#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER bool UART_IsCableConnected(void); #endif diff --git a/App/driver/vcp.c b/App/driver/vcp.c index e514ea73..4f96d560 100644 --- a/App/driver/vcp.c +++ b/App/driver/vcp.c @@ -18,7 +18,7 @@ #include "usb_config.h" #include "py32f071_ll_bus.h" -#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER #include "driver/keyboard.h" #endif @@ -42,8 +42,8 @@ void VCP_Init() NVIC_EnableIRQ(USBD_IRQn); } -#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT -bool VCP_ScreenshotPing(void) +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER +bool VCP_K5ViewerPing(void) { // State machine for parsing incoming packets: // Keepalive: 0x55 0xAA 0x00 0x00 → viewer alive, no extensions @@ -93,4 +93,4 @@ bool VCP_ScreenshotPing(void) return connected; } -#endif // ENABLE_FEAT_F4HWN_SCREENSHOT +#endif // ENABLE_FEAT_F4HWN_K5VIEWER diff --git a/App/driver/vcp.h b/App/driver/vcp.h index 0346dca1..4d5fdd1d 100644 --- a/App/driver/vcp.h +++ b/App/driver/vcp.h @@ -29,8 +29,8 @@ extern volatile uint32_t VCP_RxBufPointer; void VCP_Init(); -#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT -bool VCP_ScreenshotPing(void); +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER +bool VCP_K5ViewerPing(void); #endif static inline void VCP_Send(const uint8_t *Buf, uint32_t Size) diff --git a/App/screenshot.c b/App/k5viewer.c similarity index 72% rename from App/screenshot.c rename to App/k5viewer.c index 1fb09b50..3f2f367c 100644 --- a/App/screenshot.c +++ b/App/k5viewer.c @@ -16,7 +16,7 @@ #include "debugging.h" #include "driver/st7565.h" -#include "screenshot.h" +#include "k5viewer.h" #include "misc.h" #include "driver/vcp.h" #include "driver/keyboard.h" @@ -50,7 +50,7 @@ static bool rfLogSent = false; #endif // FNV-1a over one 8-byte chunk, folded to 16 bits -static uint16_t SCREENSHOT_Hash(const uint8_t *data) +static uint16_t K5VIEWER_Hash(const uint8_t *data) { uint32_t h = 2166136261u; for (uint8_t i = 0; i < 8; i++) { @@ -59,26 +59,26 @@ static uint16_t SCREENSHOT_Hash(const uint8_t *data) return (uint16_t)(h ^ (h >> 16)); } -void SCREENSHOT_ParseInput(void) +void K5VIEWER_ParseInput(void) { - if (SCREENSHOT_IsLocked()) + if (K5VIEWER_IsLocked()) return; if (UART_IsCableConnected()) { keepAlive = 15; hasConnectionPing = true; - gUSB_ScreenshotEnabled = false; + gUSB_K5ViewerEnabled = false; } - else if (VCP_ScreenshotPing()) { + else if (VCP_K5ViewerPing()) { keepAlive = 15; hasConnectionPing = true; - gUSB_ScreenshotEnabled = true; + gUSB_K5ViewerEnabled = true; } } -static void SCREENSHOT_Send(const uint8_t *buf, uint16_t len) +static void K5VIEWER_Send(const uint8_t *buf, uint16_t len) { - if (gUSB_ScreenshotEnabled) { + if (gUSB_K5ViewerEnabled) { cdc_acm_data_send_with_dtr(buf, len); } else { UART_Send(buf, len); @@ -86,37 +86,37 @@ static void SCREENSHOT_Send(const uint8_t *buf, uint16_t len) } enum { - SCREENSHOT_CHUNK_SIZE = 8, - SCREENSHOT_CHUNKS_PER_LINE = 16, - SCREENSHOT_HALF_LINE_COLUMNS = LCD_WIDTH / 2, - SCREENSHOT_MARKER_BASE = 0xF0, - SCREENSHOT_TYPE_DIFF = 0x02, - SCREENSHOT_TYPE_RXTX_LOG = 0x05, - SCREENSHOT_FLAG_DEEP_SLEEP = 1 << 0, - SCREENSHOT_FLAG_LED_RED = 1 << 1, - SCREENSHOT_FLAG_LED_GREEN = 1 << 2, + K5VIEWER_CHUNK_SIZE = 8, + K5VIEWER_CHUNKS_PER_LINE = 16, + K5VIEWER_HALF_LINE_COLUMNS = LCD_WIDTH / 2, + K5VIEWER_MARKER_BASE = 0xF0, + K5VIEWER_TYPE_DIFF = 0x02, + K5VIEWER_TYPE_RXTX_LOG = 0x05, + K5VIEWER_FLAG_DEEP_SLEEP = 1 << 0, + K5VIEWER_FLAG_LED_RED = 1 << 1, + K5VIEWER_FLAG_LED_GREEN = 1 << 2, }; -static uint8_t SCREENSHOT_StateFlags(void) +static uint8_t K5VIEWER_StateFlags(void) { uint8_t flags = 0; #ifdef ENABLE_FEAT_F4HWN_SLEEP if (gWakeUp) - flags |= SCREENSHOT_FLAG_DEEP_SLEEP; + flags |= K5VIEWER_FLAG_DEEP_SLEEP; #endif if (BK4819_IsGpioOutSet(BK4819_GPIO5_PIN1_RED)) - flags |= SCREENSHOT_FLAG_LED_RED; + flags |= K5VIEWER_FLAG_LED_RED; if (BK4819_IsGpioOutSet(BK4819_GPIO6_PIN2_GREEN)) - flags |= SCREENSHOT_FLAG_LED_GREEN; + flags |= K5VIEWER_FLAG_LED_GREEN; return flags; } #ifdef ENABLE_FEAT_F4HWN_RXTX_LOG_K5VIEWER -static bool SCREENSHOT_HasPendingRfLogUpdate(void) +static bool K5VIEWER_HasPendingRfLogUpdate(void) { if ((gSerialViewerFeatures & SERIAL_VIEWER_FEATURE_RF_LOG) == 0) return false; @@ -124,7 +124,7 @@ static bool SCREENSHOT_HasPendingRfLogUpdate(void) return !rfLogSent || RXTX_LOG_K5ViewerSignature() != previousRfLogSignature; } -static void SCREENSHOT_SendRfLog(void) +static void K5VIEWER_SendRfLog(void) { // Capture the signature before streaming: a state change landing // during the blocking send still differs afterwards and triggers a @@ -134,56 +134,56 @@ static void SCREENSHOT_SendRfLog(void) const uint16_t len = RXTX_LOG_K5VIEWER_PACKET_SIZE; uint8_t header[5] = { - 0xAA, 0x55, SCREENSHOT_TYPE_RXTX_LOG, + 0xAA, 0x55, K5VIEWER_TYPE_RXTX_LOG, (uint8_t)(len >> 8), (uint8_t)(len & 0xFF) }; - SCREENSHOT_Send(header, 5); - RXTX_LOG_SendK5ViewerPacket(SCREENSHOT_Send); + K5VIEWER_Send(header, 5); + RXTX_LOG_SendK5ViewerPacket(K5VIEWER_Send); uint8_t end = 0x0A; - SCREENSHOT_Send(&end, 1); + K5VIEWER_Send(&end, 1); } #endif -bool SCREENSHOT_HasPendingStateChange(void) +bool K5VIEWER_HasPendingStateChange(void) { - if (gUART_LockScreenshot > 0 || keepAlive == 0 || !hasConnectionPing) + if (gUART_LockK5Viewer > 0 || keepAlive == 0 || !hasConnectionPing) return false; #ifdef ENABLE_FEAT_F4HWN_RXTX_LOG_K5VIEWER - if (SCREENSHOT_HasPendingRfLogUpdate()) + if (K5VIEWER_HasPendingRfLogUpdate()) return true; #endif - return !wasConnected || SCREENSHOT_StateFlags() != previousStateFlags; + return !wasConnected || K5VIEWER_StateFlags() != previousStateFlags; } // Compute one 8-byte output chunk directly from the display buffers. // Frame layout: per line (status + 7 frame lines), 8 bit layers of // 16 bytes each. Each bit layer is split into two 64-column chunks. -static void SCREENSHOT_Chunk(uint8_t chunkIdx, uint8_t *dest) +static void K5VIEWER_Chunk(uint8_t chunkIdx, uint8_t *dest) { - const uint8_t chunkInLine = chunkIdx % SCREENSHOT_CHUNKS_PER_LINE; - const uint8_t line = chunkIdx / SCREENSHOT_CHUNKS_PER_LINE; + const uint8_t chunkInLine = chunkIdx % K5VIEWER_CHUNKS_PER_LINE; + const uint8_t line = chunkIdx / K5VIEWER_CHUNKS_PER_LINE; const uint8_t bit = chunkInLine / 2; - const uint8_t columnBase = (chunkInLine % 2) * SCREENSHOT_HALF_LINE_COLUMNS; + const uint8_t columnBase = (chunkInLine % 2) * K5VIEWER_HALF_LINE_COLUMNS; const uint8_t *src = (line == 0 ? gStatusLine : gFrameBuffer[line - 1]) + columnBase; - for (uint8_t j = 0; j < SCREENSHOT_CHUNK_SIZE; j++) { + for (uint8_t j = 0; j < K5VIEWER_CHUNK_SIZE; j++) { uint8_t acc = 0; - for (uint8_t k = 0; k < SCREENSHOT_CHUNK_SIZE; k++) { - if (src[j * SCREENSHOT_CHUNK_SIZE + k] & (1 << bit)) acc |= (1 << k); + for (uint8_t k = 0; k < K5VIEWER_CHUNK_SIZE; k++) { + if (src[j * K5VIEWER_CHUNK_SIZE + k] & (1 << bit)) acc |= (1 << k); } dest[j] = gSetting_set_inv ? ~acc : acc; } } -void SCREENSHOT_Update(bool force) +void K5VIEWER_Update(bool force) { - if (SCREENSHOT_IsLocked()) + if (K5VIEWER_IsLocked()) return; if (keepAlive > 0) { @@ -207,10 +207,10 @@ void SCREENSHOT_Update(bool force) force = true; } - const uint8_t stateFlags = SCREENSHOT_StateFlags(); + const uint8_t stateFlags = K5VIEWER_StateFlags(); const bool stateChanged = (stateFlags != previousStateFlags); #ifdef ENABLE_FEAT_F4HWN_RXTX_LOG_K5VIEWER - const bool rfLogPending = SCREENSHOT_HasPendingRfLogUpdate(); + const bool rfLogPending = K5VIEWER_HasPendingRfLogUpdate(); #else const bool rfLogPending = false; #endif @@ -221,9 +221,9 @@ void SCREENSHOT_Update(bool force) uint8_t chunk[9]; // [0] = index, [1..8] = payload for (uint8_t chunkIdx = 0; chunkIdx < 128; chunkIdx++) { - SCREENSHOT_Chunk(chunkIdx, &chunk[1]); + K5VIEWER_Chunk(chunkIdx, &chunk[1]); - bool changed = SCREENSHOT_Hash(&chunk[1]) != previousHash[chunkIdx]; + bool changed = K5VIEWER_Hash(&chunk[1]) != previousHash[chunkIdx]; bool isForced = (chunkIdx == forcedBlock); if (changed || isForced || force) { @@ -251,17 +251,17 @@ void SCREENSHOT_Update(bool force) { // ==== Send version marker and state flags ==== // 0xF0 keeps a resync-safe marker before the standard AA 55 header. - uint8_t versionMarker = SCREENSHOT_MARKER_BASE | stateFlags; - SCREENSHOT_Send(&versionMarker, 1); + uint8_t versionMarker = K5VIEWER_MARKER_BASE | stateFlags; + K5VIEWER_Send(&versionMarker, 1); // ==== Send header ==== uint8_t header[5] = { - 0xAA, 0x55, SCREENSHOT_TYPE_DIFF, + 0xAA, 0x55, K5VIEWER_TYPE_DIFF, (uint8_t)(deltaLen >> 8), (uint8_t)(deltaLen & 0xFF) }; - SCREENSHOT_Send(header, 5); + K5VIEWER_Send(header, 5); // ==== SECOND PASS: Send only changed chunks ==== for (uint8_t chunkIdx = 0; chunkIdx < 128; chunkIdx++) { @@ -269,24 +269,24 @@ void SCREENSHOT_Update(bool force) continue; chunk[0] = chunkIdx; - SCREENSHOT_Chunk(chunkIdx, &chunk[1]); + K5VIEWER_Chunk(chunkIdx, &chunk[1]); - SCREENSHOT_Send(chunk, 9); + K5VIEWER_Send(chunk, 9); // Update the fingerprint only once the chunk is actually sent, // so chunks skipped by an early return stay marked as changed. // Hashing the recomputed payload also keeps the fingerprint in // sync if the display buffer changed between the two passes. - previousHash[chunkIdx] = SCREENSHOT_Hash(&chunk[1]); + previousHash[chunkIdx] = K5VIEWER_Hash(&chunk[1]); } uint8_t end = 0x0A; - SCREENSHOT_Send(&end, 1); + K5VIEWER_Send(&end, 1); } #ifdef ENABLE_FEAT_F4HWN_RXTX_LOG_K5VIEWER if (rfLogPending) - SCREENSHOT_SendRfLog(); + K5VIEWER_SendRfLog(); #endif previousStateFlags = stateFlags; diff --git a/App/screenshot.h b/App/k5viewer.h similarity index 80% rename from App/screenshot.h rename to App/k5viewer.h index a78eb892..55f2af23 100644 --- a/App/screenshot.h +++ b/App/k5viewer.h @@ -14,11 +14,11 @@ * limitations under the License. */ -#ifndef SCREENSHOT_H -#define SCREENSHOT_H +#ifndef K5VIEWER_H +#define K5VIEWER_H -void SCREENSHOT_Update(bool force); -void SCREENSHOT_ParseInput(void); -bool SCREENSHOT_HasPendingStateChange(void); +void K5VIEWER_Update(bool force); +void K5VIEWER_ParseInput(void); +bool K5VIEWER_HasPendingStateChange(void); #endif diff --git a/App/misc.c b/App/misc.c index a68e35db..5adf4648 100644 --- a/App/misc.c +++ b/App/misc.c @@ -210,9 +210,9 @@ volatile bool gTxTimeoutReached; #ifdef ENABLE_FEAT_F4HWN_RX_TX_TIMER volatile uint16_t gRxTimerCountdown_500ms; #endif - #ifdef ENABLE_FEAT_F4HWN_SCREENSHOT - volatile uint8_t gUART_LockScreenshot = 0; // lock screenshot if Chirp is used - bool gUSB_ScreenshotEnabled = false; + #ifdef ENABLE_FEAT_F4HWN_K5VIEWER + volatile uint8_t gUART_LockK5Viewer = 0; // lock the K5Viewer stream if Chirp is used + bool gUSB_K5ViewerEnabled = false; #endif #endif @@ -646,11 +646,11 @@ void MR_PrintCacheStats(void) #endif -#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT - bool SCREENSHOT_IsLocked(void) +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER + bool K5VIEWER_IsLocked(void) { - if (gUART_LockScreenshot > 0) { - gUART_LockScreenshot--; + if (gUART_LockK5Viewer > 0) { + gUART_LockK5Viewer--; return true; } diff --git a/App/misc.h b/App/misc.h index bf57cf27..9d904dd1 100644 --- a/App/misc.h +++ b/App/misc.h @@ -336,11 +336,11 @@ extern volatile bool gTxTimeoutReached; #ifdef ENABLE_FEAT_F4HWN_RX_TX_TIMER extern volatile uint16_t gRxTimerCountdown_500ms; #endif - #ifdef ENABLE_FEAT_F4HWN_SCREENSHOT - extern volatile uint8_t gUART_LockScreenshot; // lock screenshot if Chirp is used - extern bool gUSB_ScreenshotEnabled; + #ifdef ENABLE_FEAT_F4HWN_K5VIEWER + extern volatile uint8_t gUART_LockK5Viewer; // lock the K5Viewer stream if Chirp is used + extern bool gUSB_K5ViewerEnabled; - bool SCREENSHOT_IsLocked(void); + bool K5VIEWER_IsLocked(void); #endif #endif diff --git a/App/ui/welcome.c b/App/ui/welcome.c index d80d08a4..798526c5 100644 --- a/App/ui/welcome.c +++ b/App/ui/welcome.c @@ -29,8 +29,8 @@ #include "version.h" #include "bitmaps.h" -#ifdef ENABLE_FEAT_F4HWN_SCREENSHOT - #include "screenshot.h" +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER + #include "k5viewer.h" #endif #ifdef ENABLE_FEAT_F4HWN_LOGO @@ -355,7 +355,7 @@ void UI_DisplayWelcome(void) ST7565_BlitStatusLine(); ST7565_BlitFullScreen(); - #ifdef ENABLE_FEAT_F4HWN_SCREENSHOT - SCREENSHOT_Update(true); + #ifdef ENABLE_FEAT_F4HWN_K5VIEWER + K5VIEWER_Update(true); #endif } diff --git a/CMakePresets.json b/CMakePresets.json index 43895a67..13320be2 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -47,7 +47,7 @@ "ENABLE_EXTRA_UART_CMD": false, "ENABLE_FEAT_F4HWN": true, "ENABLE_FEAT_F4HWN_GAME": false, - "ENABLE_FEAT_F4HWN_SCREENSHOT": false, + "ENABLE_FEAT_F4HWN_K5VIEWER": false, "ENABLE_FEAT_F4HWN_SPECTRUM": true, "ENABLE_FEAT_F4HWN_RX_TX_TIMER": true, "ENABLE_FEAT_F4HWN_CHARGING_C": false, @@ -100,7 +100,7 @@ "ENABLE_FMRADIO": false, "ENABLE_VOX": false, "ENABLE_AIRCOPY": true, - "ENABLE_FEAT_F4HWN_SCREENSHOT": true, + "ENABLE_FEAT_F4HWN_K5VIEWER": true, "ENABLE_FEAT_F4HWN_GAME": false, "ENABLE_FEAT_F4HWN_PMR": true, "ENABLE_FEAT_F4HWN_GMRS_FRS_MURS": true, @@ -117,7 +117,7 @@ "ENABLE_FMRADIO": true, "ENABLE_VOX": true, "ENABLE_AIRCOPY": true, - "ENABLE_FEAT_F4HWN_SCREENSHOT": true, + "ENABLE_FEAT_F4HWN_K5VIEWER": true, "ENABLE_FEAT_F4HWN_GAME": false, "ENABLE_FEAT_F4HWN_PMR": true, "ENABLE_FEAT_F4HWN_GMRS_FRS_MURS": true, @@ -134,7 +134,7 @@ "ENABLE_FMRADIO": true, "ENABLE_VOX": false, "ENABLE_AIRCOPY": false, - "ENABLE_FEAT_F4HWN_SCREENSHOT": false, + "ENABLE_FEAT_F4HWN_K5VIEWER": false, "ENABLE_FEAT_F4HWN_GAME": false, "ENABLE_FEAT_F4HWN_SPECTRUM": false, "ENABLE_FEAT_F4HWN_PMR": true, @@ -158,7 +158,7 @@ "ENABLE_FMRADIO": false, "ENABLE_VOX": true, "ENABLE_AIRCOPY": true, - "ENABLE_FEAT_F4HWN_SCREENSHOT": true, + "ENABLE_FEAT_F4HWN_K5VIEWER": true, "ENABLE_FEAT_F4HWN_GAME": false, "ENABLE_FEAT_F4HWN_PMR": true, "ENABLE_FEAT_F4HWN_GMRS_FRS_MURS": true, @@ -176,7 +176,7 @@ "ENABLE_FMRADIO": true, "ENABLE_VOX": false, "ENABLE_AIRCOPY": true, - "ENABLE_FEAT_F4HWN_SCREENSHOT": true, + "ENABLE_FEAT_F4HWN_K5VIEWER": true, "ENABLE_FEAT_F4HWN_GAME": true, "ENABLE_FEAT_F4HWN_PMR": true, "ENABLE_FEAT_F4HWN_GMRS_FRS_MURS": true, @@ -193,7 +193,7 @@ "ENABLE_FMRADIO": true, "ENABLE_VOX": true, "ENABLE_AIRCOPY": true, - "ENABLE_FEAT_F4HWN_SCREENSHOT": true, + "ENABLE_FEAT_F4HWN_K5VIEWER": true, "ENABLE_FEAT_F4HWN_GAME": true, "ENABLE_FEAT_F4HWN_PMR": true, "ENABLE_FEAT_F4HWN_GMRS_FRS_MURS": true,