sh: add videocapture function (x² key) in debug mode

This commit is contained in:
Lephenixnoir 2024-02-04 23:03:05 +01:00
parent af8bacd271
commit b1e39d3ab6
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
5 changed files with 40 additions and 4 deletions

View File

@ -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 */

View File

@ -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 */

View File

@ -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 ===//

View File

@ -7,6 +7,7 @@
#include "py/runtime.h"
#include "py/obj.h"
#include "debug.h"
#include <gint/display.h>
#include <stdlib.h>
#include <string.h>
@ -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;
}

View File

@ -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;
}