diff --git a/App/driver/bk4819.c b/App/driver/bk4819.c index 3483e1f9..168adf45 100644 --- a/App/driver/bk4819.c +++ b/App/driver/bk4819.c @@ -411,6 +411,11 @@ void BK4819_ToggleGpioOut(BK4819_GPIO_PIN_t Pin, bool bSet) BK4819_WriteRegister(BK4819_REG_33, gBK4819_GpioOutState); } +bool BK4819_IsGpioOutSet(BK4819_GPIO_PIN_t Pin) +{ + return (gBK4819_GpioOutState & (0x40u >> Pin)) != 0; +} + void BK4819_SetCDCSSCodeWord(uint32_t CodeWord) { // REG_51 diff --git a/App/driver/bk4819.h b/App/driver/bk4819.h index f98e2e91..9bbab159 100644 --- a/App/driver/bk4819.h +++ b/App/driver/bk4819.h @@ -77,6 +77,7 @@ void BK4819_SetAGC(bool enable); void BK4819_InitAGC(bool amModulation); void BK4819_ToggleGpioOut(BK4819_GPIO_PIN_t Pin, bool bSet); +bool BK4819_IsGpioOutSet(BK4819_GPIO_PIN_t Pin); void BK4819_SetCDCSSCodeWord(uint32_t CodeWord); void BK4819_SetCTCSSFrequency(uint32_t BaudRate); diff --git a/App/driver/bk4829.c b/App/driver/bk4829.c index 2676f35d..78c38c9e 100644 --- a/App/driver/bk4829.c +++ b/App/driver/bk4829.c @@ -441,6 +441,11 @@ void BK4819_ToggleGpioOut(BK4819_GPIO_PIN_t Pin, bool bSet) BK4819_WriteRegister(BK4819_REG_33, gBK4819_GpioOutState); } +bool BK4819_IsGpioOutSet(BK4819_GPIO_PIN_t Pin) +{ + return (gBK4819_GpioOutState & (0x40u >> Pin)) != 0; +} + void BK4819_SetCDCSSCodeWord(uint32_t CodeWord) { // REG_51 diff --git a/App/screenshot.c b/App/screenshot.c index df836eac..ebe63720 100644 --- a/App/screenshot.c +++ b/App/screenshot.c @@ -20,6 +20,7 @@ #include "misc.h" #include "driver/vcp.h" #include "driver/keyboard.h" +#include "driver/bk4819.h" // SRAM optimization: minimize static allocations // - previousHash: one fingerprint per 8-byte chunk instead of a full @@ -76,8 +77,30 @@ enum { SCREENSHOT_CHUNK_SIZE = 8, SCREENSHOT_CHUNKS_PER_LINE = 16, SCREENSHOT_HALF_LINE_COLUMNS = LCD_WIDTH / 2, + SCREENSHOT_MARKER_BASE = 0xF0, + SCREENSHOT_FLAG_DEEP_SLEEP = 1 << 0, + SCREENSHOT_FLAG_LED_RED = 1 << 1, + SCREENSHOT_FLAG_LED_GREEN = 1 << 2, }; +static uint8_t SCREENSHOT_StateFlags(void) +{ + uint8_t flags = 0; + +#ifdef ENABLE_FEAT_F4HWN_SLEEP + if (gWakeUp) + flags |= SCREENSHOT_FLAG_DEEP_SLEEP; +#endif + + if (BK4819_IsGpioOutSet(BK4819_GPIO5_PIN1_RED)) + flags |= SCREENSHOT_FLAG_LED_RED; + + if (BK4819_IsGpioOutSet(BK4819_GPIO6_PIN2_GREEN)) + flags |= SCREENSHOT_FLAG_LED_GREEN; + + return flags; +} + // 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. @@ -149,10 +172,9 @@ void SCREENSHOT_Update(bool force) if (gKeyReading0 != KEY_INVALID) return; - // ==== Send version marker (for backward compatibility detection) ==== - // New format: sends 0xFF before header - // Old format: doesn't exist, so viewers can differentiate - uint8_t versionMarker = 0xFF; + // ==== Send version marker and state flags ==== + // 0xF0 keeps a resync-safe marker before the standard AA 55 header. + uint8_t versionMarker = SCREENSHOT_MARKER_BASE | SCREENSHOT_StateFlags(); SCREENSHOT_Send(&versionMarker, 1); // ==== Send header ====