From 7dfc008b851398dcfe57819519efe5f958c77f65 Mon Sep 17 00:00:00 2001 From: Aemiii91 <44569252+Aemiii91@users.noreply.github.com> Date: Mon, 24 Jun 2024 22:34:40 +0200 Subject: [PATCH] Fix brightness and screenshot shortcuts in MainUI (#1616) Fix regression bug in `keymon` causing brightness and screenshot to not work in MainUI. Fixes #1613 --- Makefile | 2 +- src/keymon/keymon.c | 28 +++++++++------------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index c99c7ffdd9..1a1b402327 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ ########################################################### TARGET=Onion -VERSION=4.3.1 +VERSION=4.3.1-1 RA_SUBVERSION=1.15.0.13 ########################################################### diff --git a/src/keymon/keymon.c b/src/keymon/keymon.c index 703a6bef9c..abb746d126 100644 --- a/src/keymon/keymon.c +++ b/src/keymon/keymon.c @@ -1,7 +1,6 @@ #include #include #include -#include #include #include #include @@ -58,7 +57,6 @@ void takeScreenshot(void) { super_short_pulse(); display_setBrightnessRaw(0); - display_reset(); msleep(10); osd_hideBar(); screenshot_recent(); @@ -337,16 +335,6 @@ void turnOffScreen(void) suspend_exec(stay_awake ? -1 : timeout); } -static void *runWritingSettingsThread(void *param) -{ - bool *isWritingSettingsThreadActive = (bool *)param; - *isWritingSettingsThreadActive = true; - settings_shm_write(); - settings_save(); - *isWritingSettingsThreadActive = false; - return 0; -} - // // Main // @@ -410,9 +398,8 @@ int main(void) bool delete_flag = false; bool settings_changed = false; + int save_settings_timestamp = 0; volatile bool needWriteSettings = false; - volatile bool isWritingSettingsThreadActive = false; - pthread_t writingSettingsThread; time_t fav_last_modified = time(NULL); @@ -764,12 +751,15 @@ int main(void) else if (volDown_state == RELEASED && volUp_state == RELEASED) comboKey_volume = false; - if (settings_changed || needWriteSettings) { + if (settings_changed) { + settings_shm_write(); needWriteSettings = true; - if (!isWritingSettingsThreadActive) { - needWriteSettings = false; - pthread_create(&writingSettingsThread, NULL, runWritingSettingsThread, &isWritingSettingsThreadActive); - } + save_settings_timestamp = ticks; + } + + if (needWriteSettings && (ticks - save_settings_timestamp) > 150) { + settings_save(); + needWriteSettings = false; } if ((val == PRESSED) && (system_state == MODE_MAIN_UI)) {