From 2e41fe6f6168a6c7f0a8de8d5d58d01fff128350 Mon Sep 17 00:00:00 2001 From: cepetr Date: Thu, 19 Dec 2024 14:48:43 +0100 Subject: [PATCH] TEMP - test powerctl_suspend --- core/embed/upymod/modtrezorio/modtrezorio-poll.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/embed/upymod/modtrezorio/modtrezorio-poll.h b/core/embed/upymod/modtrezorio/modtrezorio-poll.h index 2d97e491e7..a6c5876dc1 100644 --- a/core/embed/upymod/modtrezorio/modtrezorio-poll.h +++ b/core/embed/upymod/modtrezorio/modtrezorio-poll.h @@ -27,6 +27,10 @@ #include #endif +#ifdef USE_POWERCTL +#include // --- experimental --- +#endif + #include "embed/upymod/trezorobj.h" #ifdef TREZOR_EMULATOR @@ -150,6 +154,15 @@ STATIC mp_obj_t mod_trezorio_poll(mp_obj_t ifaces, mp_obj_t list_ref, #if USE_BUTTON else if (iface == BUTTON_IFACE) { const uint32_t evt = button_get_event(); + + // --- experimental --- +#ifdef USE_POWERCTL + if (((evt & 0xFFFF) == BTN_POWER) && ((evt & BTN_EVT_UP) != 0)) { + powerctl_suspend(); + } +#endif // USE_POWERCTL + // ---- + if (evt & (BTN_EVT_DOWN | BTN_EVT_UP)) { mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR(mp_obj_new_tuple(2, NULL)); uint32_t etype = (evt >> 24) & 0x3U; // button down/up