diff --git a/App/CMakeLists.txt b/App/CMakeLists.txt index a3016818..ff065bdb 100644 --- a/App/CMakeLists.txt +++ b/App/CMakeLists.txt @@ -95,8 +95,7 @@ if(ENABLE_AIRCOPY OR ENABLE_UART OR ENABLE_USB) endif() enable_feature(ENABLE_UART - driver/uart.c - app/uart.c + driver/uart.c # driver/aes.c ) @@ -177,6 +176,14 @@ enable_feature(ENABLE_EXTRA_UART_CMD) # ---- F4HWN MODS ---- +if(NOT ENABLE_UART AND NOT ENABLE_USB) + if(ENABLE_FEAT_F4HWN_K5VIEWER OR ENABLE_FEAT_F4HWN_RXTX_LOG_K5VIEWER) + message(STATUS "Disabling K5Viewer because both ENABLE_UART and ENABLE_USB are OFF.") + endif() + set(ENABLE_FEAT_F4HWN_K5VIEWER OFF) + set(ENABLE_FEAT_F4HWN_RXTX_LOG_K5VIEWER OFF) +endif() + enable_feature(ENABLE_FEAT_F4HWN) enable_feature(ENABLE_FEAT_F4HWN_GAME app/breakout.c diff --git a/App/app/app.c b/App/app/app.c index 5165646f..dddf1076 100644 --- a/App/app/app.c +++ b/App/app/app.c @@ -1654,7 +1654,9 @@ void APP_TimeSlice10ms(void) } #ifdef ENABLE_FEAT_F4HWN_LOGO_SAV +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER bool screenSaverRendered = false; +#endif if (gScreenSaverDisplayed) { if (gUpdateDisplayCurrent) { @@ -1668,13 +1670,17 @@ void APP_TimeSlice10ms(void) if (++gScreenSaverTick >= 8u) { gScreenSaverTick = 0; ScreenSaverRenderMatrix(false); +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER screenSaverRendered = true; +#endif } } else if (gSetting_set_sav == SET_SAV_LOGO_PLUS) { if (++gScreenSaverTick >= 16u) { gScreenSaverTick = 0; ScreenSaverRenderLogoPlus(false); +#ifdef ENABLE_FEAT_F4HWN_K5VIEWER screenSaverRendered = true; +#endif } } } diff --git a/App/app/uart.c b/App/app/uart.c index 177666b5..db9b8994 100644 --- a/App/app/uart.c +++ b/App/app/uart.c @@ -260,6 +260,7 @@ static void SendReply(uint32_t Port, void *pReply, uint16_t Size) } #endif +#if defined(ENABLE_UART) Header_t Header; Footer_t Footer; @@ -290,6 +291,7 @@ static void SendReply(uint32_t Port, void *pReply, uint16_t Size) Footer.ID = 0xBADC; UART_Send(&Footer, sizeof(Footer)); +#endif } static void SendVersion(uint32_t Port) diff --git a/App/k5viewer.c b/App/k5viewer.c index 5752ad34..2167dc40 100644 --- a/App/k5viewer.c +++ b/App/k5viewer.c @@ -18,7 +18,12 @@ #include "driver/st7565.h" #include "k5viewer.h" #include "misc.h" +#ifdef ENABLE_UART +#include "driver/uart.h" +#endif +#ifdef ENABLE_USB #include "driver/vcp.h" +#endif #include "driver/keyboard.h" #include "driver/bk4819.h" #ifdef ENABLE_FEAT_F4HWN_RXTX_LOG_K5VIEWER @@ -67,26 +72,41 @@ void K5VIEWER_ParseInput(void) if (K5VIEWER_IsLocked()) return; +#ifdef ENABLE_UART if (UART_IsCableConnected()) { keepAlive = 15; hasConnectionPing = true; gUSB_K5ViewerEnabled = false; + return; } - else if (VCP_K5ViewerPing()) { +#endif + +#ifdef ENABLE_USB + if (VCP_K5ViewerPing()) { keepAlive = 15; hasConnectionPing = true; gUSB_K5ViewerEnabled = true; } +#endif } static void K5VIEWER_Send(const uint8_t *buf, uint16_t len) { +#if defined(ENABLE_UART) && defined(ENABLE_USB) if (gUSB_K5ViewerEnabled) { cdc_acm_data_send_with_dtr(buf, len); } else { UART_Send(buf, len); } +#elif defined(ENABLE_USB) + cdc_acm_data_send_with_dtr(buf, len); +#elif defined(ENABLE_UART) + UART_Send(buf, len); +#else + (void)buf; + (void)len; +#endif } enum {