From ea9e848a7f99903d2632f1dd1547b5e2cd7aa4db Mon Sep 17 00:00:00 2001 From: Risto Date: Thu, 13 Jun 2024 16:41:53 +0200 Subject: [PATCH 1/2] feat(lua): Exposes screenshot functionality to Lua --- radio/src/lua/api_general.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index 1b722e78112..e8207542fb2 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -1631,6 +1631,27 @@ static int luaPlayTone(lua_State * L) return 0; } +/*luadoc +@function screenshot() + +Takes a screenshot + +@retval none + +@status current Introduced in 2.11 + +// targets: BW, COLOR +// +// EXAMPLES: +// screenshot() +*/ +static int luaScreenshot(lua_State * L) +{ + UNUSED(L); + writeScreenshot(); + return 0; +} + /*luadoc @function playHaptic(duration, pause [, flags]) @@ -2930,6 +2951,7 @@ LROT_BEGIN(etxlib, NULL, 0) LROT_FUNCENTRY( playTone, luaPlayTone ) LROT_FUNCENTRY( playHaptic, luaPlayHaptic ) LROT_FUNCENTRY( flushAudio, luaFlushAudio ) + LROT_FUNCENTRY( screenshot, luaScreenshot ) #if defined(ENABLE_LUA_POPUP_INPUT) LROT_FUNCENTRY( popupInput, luaPopupInput ) #endif From 5dba195cb99a2bc3b7b68e586660ecb4f874198d Mon Sep 17 00:00:00 2001 From: Peter Feerick Date: Tue, 20 Aug 2024 01:39:59 +0000 Subject: [PATCH 2/2] chore: update comment --- radio/src/lua/api_general.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index e8207542fb2..7cc1f962b21 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -1632,18 +1632,21 @@ static int luaPlayTone(lua_State * L) } /*luadoc -@function screenshot() +@name screenshot -Takes a screenshot +@description Takes a screenshot, which is saved to the SCREENSHOTS folder on the radio SD card. -@retval none +@syntax screenshot() -@status current Introduced in 2.11 +@return none -// targets: BW, COLOR -// -// EXAMPLES: -// screenshot() +@notes This command is currently not rate limited, so repeated frequent calls will slow down the UI and can even freeze the entire radio, so should be used with care. + +@target [BW] +@target [GS] +@target [COLOR] + +@status current Introduced in 2.11 */ static int luaScreenshot(lua_State * L) {