From b1e39d3ab635ba85f8c77cc6677c69f57e996755 Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Sun, 4 Feb 2024 23:03:05 +0100 Subject: [PATCH] =?UTF-8?q?sh:=20add=20videocapture=20function=20(x=C2=B2?= =?UTF-8?q?=20key)=20in=20debug=20mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ports/sh/debug.c | 15 +++++++++++++++ ports/sh/debug.h | 16 ++++++++++++---- ports/sh/main.c | 9 +++++++++ ports/sh/modcasioplot.c | 2 ++ ports/sh/modgint.c | 2 ++ 5 files changed, 40 insertions(+), 4 deletions(-) diff --git a/ports/sh/debug.c b/ports/sh/debug.c index 32225ce4c..3c2b436b0 100644 --- a/ports/sh/debug.c +++ b/ports/sh/debug.c @@ -49,6 +49,8 @@ static bool timeout_popup(void) } #endif +static bool videocapture = false; + void pe_debug_init(void) { usb_interface_t const *intf[] = { &usb_ff_bulk, NULL }; @@ -110,4 +112,17 @@ void pe_debug_screenshot(void) usb_fxlink_screenshot(true); } +void pe_debug_toggle_videocapture(void) +{ + videocapture = !videocapture; +} + +void pe_debug_run_videocapture(void) +{ + if(videocapture) { + usb_open_wait(); + usb_fxlink_videocapture(true); + } +} + #endif /* PE_DEBUG */ diff --git a/ports/sh/debug.h b/ports/sh/debug.h index a90821dee..293169817 100644 --- a/ports/sh/debug.h +++ b/ports/sh/debug.h @@ -33,12 +33,20 @@ void pe_debug_kmalloc(char const *prefix); /* Take a screenshot. */ void pe_debug_screenshot(void); +/* Toggle video capture. */ +void pe_debug_toggle_videocapture(void); + +/* Send a video capture frame if video capture is enabled. */ +void pe_debug_run_videocapture(void); + #if !PE_DEBUG #define PE_DEBUG_NOOP do {} while(0) -#define pe_debug_init(...) PE_DEBUG_NOOP -#define pe_debug_printf(...) PE_DEBUG_NOOP -#define pe_debug_kmalloc(...) PE_DEBUG_NOOP -#define pe_debug_screenshot(...) PE_DEBUG_NOOP +#define pe_debug_init(...) PE_DEBUG_NOOP +#define pe_debug_printf(...) PE_DEBUG_NOOP +#define pe_debug_kmalloc(...) PE_DEBUG_NOOP +#define pe_debug_screenshot(...) PE_DEBUG_NOOP +#define pe_debug_toggle_videocapture(...) PE_DEBUG_NOOP +#define pe_debug_run_videocapture(...) PE_DEBUG_NOOP #endif #endif /* __PYTHONEXTRA_DEBUG_H */ diff --git a/ports/sh/main.c b/ports/sh/main.c index 3123012f2..9223ad9af 100644 --- a/ports/sh/main.c +++ b/ports/sh/main.c @@ -130,6 +130,14 @@ static bool async_filter(key_event_t ev) return false; } +#if PE_DEBUG + if(ev.key == KEY_SQUARE) { + if(ev.type == KEYEV_DOWN) + pe_debug_toggle_videocapture(); + return false; + } +#endif + return true; } @@ -181,6 +189,7 @@ void pe_draw(void) DIMAGE_NONE); #endif dupdate(); + pe_debug_run_videocapture(); } //=== Application control functions ===// diff --git a/ports/sh/modcasioplot.c b/ports/sh/modcasioplot.c index fcea85f9f..abda99289 100644 --- a/ports/sh/modcasioplot.c +++ b/ports/sh/modcasioplot.c @@ -7,6 +7,7 @@ #include "py/runtime.h" #include "py/obj.h" +#include "debug.h" #include #include #include @@ -72,6 +73,7 @@ static mp_obj_t show_screen(void) void pe_enter_graphics_mode(void); pe_enter_graphics_mode(); dupdate(); + pe_debug_run_videocapture(); return mp_const_none; } diff --git a/ports/sh/modgint.c b/ports/sh/modgint.c index 941f2591b..06489c041 100644 --- a/ports/sh/modgint.c +++ b/ports/sh/modgint.c @@ -9,6 +9,7 @@ // considered relevant for high-level Python development). //--- +#include "debug.h" #include "py/runtime.h" #include "py/objtuple.h" #include "objgintimage.h" @@ -229,6 +230,7 @@ STATIC mp_obj_t modgint_dupdate(void) { pe_enter_graphics_mode(); dupdate(); + pe_debug_run_videocapture(); return mp_const_none; }