From f67d070f3f33d8b1a7fc709efeca4c89c722b619 Mon Sep 17 00:00:00 2001 From: Stian Kristensen Date: Sun, 24 Nov 2024 15:56:21 +0100 Subject: [PATCH 01/16] Allow bluelight filter check to run on Miyoo Mini as well --- src/keymon/keymon.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/keymon/keymon.c b/src/keymon/keymon.c index abb746d12..f1d2c9c60 100644 --- a/src/keymon/keymon.c +++ b/src/keymon/keymon.c @@ -823,9 +823,7 @@ int main(void) } // Check bluelight filter - if (DEVICE_ID == MIYOO354) { - system("/mnt/SDCARD/.tmp_update/script/blue_light.sh check"); - } + system("/mnt/SDCARD/.tmp_update/script/blue_light.sh check"); // Quit RetroArch / auto-save when battery too low if (settings.low_battery_autosave_at && battery_getPercentage() <= settings.low_battery_autosave_at && check_autosave()) { From 8e7a01b971ced5b2528946d21b9d4c787adb2d1a Mon Sep 17 00:00:00 2001 From: Stian Kristensen Date: Sun, 24 Nov 2024 16:04:20 +0100 Subject: [PATCH 02/16] Removed mini plus and network requirements from schedule options menu --- src/tweaks/menus.h | 79 ++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 45 deletions(-) diff --git a/src/tweaks/menus.h b/src/tweaks/menus.h index 57badc51d..9cf0b0873 100644 --- a/src/tweaks/menus.h +++ b/src/tweaks/menus.h @@ -484,13 +484,11 @@ void menu_blueLight(void *_) if (!_menu_user_blue_light._created) { network_loadState(); _menu_user_blue_light = list_createWithTitle(6, LIST_SMALL, "Blue light filter"); - if (DEVICE_ID == MIYOO354) { - list_addItem(&_menu_user_blue_light, - (ListItem){ - .label = "[DATESTRING]", - .disabled = 1, - .action = NULL}); - } + list_addItem(&_menu_user_blue_light, + (ListItem){ + .label = "[DATESTRING]", + .disabled = 1, + .action = NULL}); list_addItemWithInfoNote(&_menu_user_blue_light, (ListItem){ .label = "State", @@ -500,16 +498,13 @@ void menu_blueLight(void *_) .value = (int)settings.blue_light_state || exists("/tmp/.blfOn"), .action = action_blueLight}, "Set the selected strength now\n"); - if (DEVICE_ID == MIYOO354) { - list_addItemWithInfoNote(&_menu_user_blue_light, - (ListItem){ - .label = "", - .disabled = !network_state.ntp, - .item_type = TOGGLE, - .value = (int)settings.blue_light_schedule, - .action = action_blueLightSchedule}, - "Enable or disable the bluelight filter schedule\n"); - } + list_addItemWithInfoNote(&_menu_user_blue_light, + (ListItem){ + .label = "", + .item_type = TOGGLE, + .value = (int)settings.blue_light_schedule, + .action = action_blueLightSchedule}, + "Enable or disable the bluelight filter schedule\n"); list_addItemWithInfoNote(&_menu_user_blue_light, (ListItem){ .label = "Strength", @@ -522,35 +517,29 @@ void menu_blueLight(void *_) .value = value_blueLightLevel()}, "Change the strength of the \n" "Blue light filter"); - if (DEVICE_ID == MIYOO354) { - list_addItemWithInfoNote(&_menu_user_blue_light, - (ListItem){ - .label = "Time (On)", - .disabled = !network_state.ntp, - .item_type = MULTIVALUE, - .value_max = 95, - .value_formatter = formatter_Time, - .action = action_blueLightTimeOn, - .value = value_blueLightTimeOn()}, - "Time schedule for the bluelight filter"); - list_addItemWithInfoNote(&_menu_user_blue_light, - (ListItem){ - .label = "Time (Off)", - .disabled = !network_state.ntp, - .item_type = MULTIVALUE, - .value_max = 95, - .value_formatter = formatter_Time, - .action = action_blueLightTimeOff, - .value = value_blueLightTimeOff()}, - "Time schedule for the bluelight filter"); - } - } - if (DEVICE_ID == MIYOO354) { - _writeDateString(_menu_user_blue_light.items[0].label); - char scheduleToggleLabel[100]; - strcpy(scheduleToggleLabel, exists("/tmp/.blfIgnoreSchedule") ? "Schedule (ignored)" : "Schedule"); - strcpy(_menu_user_blue_light.items[2].label, scheduleToggleLabel); + list_addItemWithInfoNote(&_menu_user_blue_light, + (ListItem){ + .label = "Time (On)", + .item_type = MULTIVALUE, + .value_max = 95, + .value_formatter = formatter_Time, + .action = action_blueLightTimeOn, + .value = value_blueLightTimeOn()}, + "Time schedule for the bluelight filter"); + list_addItemWithInfoNote(&_menu_user_blue_light, + (ListItem){ + .label = "Time (Off)", + .item_type = MULTIVALUE, + .value_max = 95, + .value_formatter = formatter_Time, + .action = action_blueLightTimeOff, + .value = value_blueLightTimeOff()}, + "Time schedule for the bluelight filter"); } + _writeDateString(_menu_user_blue_light.items[0].label); + char scheduleToggleLabel[100]; + strcpy(scheduleToggleLabel, exists("/tmp/.blfIgnoreSchedule") ? "Schedule (ignored)" : "Schedule"); + strcpy(_menu_user_blue_light.items[2].label, scheduleToggleLabel); menu_stack[++menu_level] = &_menu_user_blue_light; header_changed = true; } From dbd76576c2cc4fd7749f82a7d347774077b854a2 Mon Sep 17 00:00:00 2001 From: Stian Kristensen Date: Sun, 24 Nov 2024 16:34:25 +0100 Subject: [PATCH 03/16] Remove unused duplicate function --- static/build/.tmp_update/script/blue_light.sh | 31 +------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/static/build/.tmp_update/script/blue_light.sh b/static/build/.tmp_update/script/blue_light.sh index 381e5ddfb..e4fa0f310 100644 --- a/static/build/.tmp_update/script/blue_light.sh +++ b/static/build/.tmp_update/script/blue_light.sh @@ -68,35 +68,6 @@ set_intensity() { rm $lockfile } -disable_blue_light_filter() { - sync - - combinedBGR=$(cat $sysdir/config/display/blueLightRGB) - combinedBGR=$(echo "$combinedBGR" | tr -d '[:space:]/#') - - echo $combinedBGR > $sysdir/config/display/blueLightRGBtemp - - lastR=$(( (combinedBGR >> 16) & 0xFF )) - lastG=$(( (combinedBGR >> 8) & 0xFF )) - lastB=$(( combinedBGR & 0xFF )) - - # echo "Last BGR: B: $lastB, G: $lastG, R: $lastR" - # echo "Target BGR: B: 128, G: 128, R: 128" - - for i in $(seq 0 20); do - newR=$(( lastR + (128 - lastR) * i / 20 )) - newG=$(( lastG + (128 - lastG) * i / 20 )) - newB=$(( lastB + (128 - lastB) * i / 20 )) - - echo "colortemp 0 0 0 0 $newB $newG $newR" > /proc/mi_modules/mi_disp/mi_disp0 - usleep 50000 - done - - echo ":: Blue Light Filter: Disabled" - rm -f $blf_key_on - rm -f $blf_key_on_user -} - check_disp_init() { if [ -z "$sysdir" ] || [ ! -x "$sysdir/bin/disp_init" ]; then echo "Error: disp_init not found or not executable" @@ -192,7 +163,7 @@ disable_blue_light_filter() { echo ":: Blue Light Filter: Disabled" rm -f $blf_key_on - rm -f $sysdir/config/.blfOn + rm -f $blf_key_on_user } check_blf() { From e2a542cee4e84d715343a37016157027c18b075f Mon Sep 17 00:00:00 2001 From: Stian Kristensen Date: Sun, 24 Nov 2024 16:38:59 +0100 Subject: [PATCH 04/16] Dont turn on blue light just to wait for it to be turned off by schedule --- static/build/.tmp_update/runtime.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/static/build/.tmp_update/runtime.sh b/static/build/.tmp_update/runtime.sh index 1ea129576..f2f2549a8 100644 --- a/static/build/.tmp_update/runtime.sh +++ b/static/build/.tmp_update/runtime.sh @@ -60,7 +60,9 @@ main() { touch /tmp/no_charging_ui # Check if blf needs enabling - if [ -f $sysdir/config/.blfOn ]; then + if [ -f $sysdir/config/.blf ]; then + /mnt/SDCARD/.tmp_update/script/blue_light.sh check & + elif [ -f $sysdir/config/.blfOn ]; then /mnt/SDCARD/.tmp_update/script/blue_light.sh enable & fi From 2177c17d6d2814783f94062096a690c61b172dfd Mon Sep 17 00:00:00 2001 From: Stian Kristensen Date: Sun, 24 Nov 2024 16:42:35 +0100 Subject: [PATCH 05/16] Moved blf key check, removed network check, removed setting of blf_key_on as it is handled by functions, remove blf_key_on_user if blue light not on during check --- static/build/.tmp_update/script/blue_light.sh | 45 +++++++++---------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/static/build/.tmp_update/script/blue_light.sh b/static/build/.tmp_update/script/blue_light.sh index e4fa0f310..468eeffd9 100644 --- a/static/build/.tmp_update/script/blue_light.sh +++ b/static/build/.tmp_update/script/blue_light.sh @@ -168,9 +168,10 @@ disable_blue_light_filter() { check_blf() { sync - if [ ! -f "$ignore_schedule" ]; then - if [ ! -f "$sysdir/config/.ntpState" ]; then - return + if [ -f "$blf_key" ] || [ ! -f "$ignore_schedule" ]; then + + if [ ! -f "$blf_key_on" ] && [ -f "$blf_key_on_user" ]; then + rm -f $blf_key_on_user fi blueLightTimeOnFile="$sysdir/config/display/blueLightTime" @@ -189,30 +190,24 @@ check_blf() { blueLightTimeOnMinutes=$(to_minutes_since_midnight "$blueLightTimeOn") blueLightTimeOffMinutes=$(to_minutes_since_midnight "$blueLightTimeOff") - if [ -f "$blf_key" ]; then - if [ "$blueLightTimeOffMinutes" -lt "$blueLightTimeOnMinutes" ]; then - if [ "$currentTimeMinutes" -ge "$blueLightTimeOnMinutes" ] || [ "$currentTimeMinutes" -lt "$blueLightTimeOffMinutes" ]; then - if [ ! -f $blf_key_on ]; then - enable_blue_light_filter - touch $blf_key_on - fi - else - if [ -f $blf_key_on ]; then - disable_blue_light_filter - rm $blf_key_on - fi + if [ "$blueLightTimeOffMinutes" -lt "$blueLightTimeOnMinutes" ]; then + if [ "$currentTimeMinutes" -ge "$blueLightTimeOnMinutes" ] || [ "$currentTimeMinutes" -lt "$blueLightTimeOffMinutes" ]; then + if [ ! -f $blf_key_on ]; then + enable_blue_light_filter + fi + else + if [ -f $blf_key_on ]; then + disable_blue_light_filter + fi + fi + else + if [ "$currentTimeMinutes" -ge "$blueLightTimeOnMinutes" ] && [ "$currentTimeMinutes" -lt "$blueLightTimeOffMinutes" ]; then + if [ ! -f $blf_key_on ]; then + enable_blue_light_filter fi else - if [ "$currentTimeMinutes" -ge "$blueLightTimeOnMinutes" ] && [ "$currentTimeMinutes" -lt "$blueLightTimeOffMinutes" ]; then - if [ ! -f $blf_key_on ]; then - enable_blue_light_filter - touch $blf_key_on - fi - else - if [ -f $blf_key_on ]; then - disable_blue_light_filter - rm $blf_key_on - fi + if [ -f $blf_key_on ]; then + disable_blue_light_filter fi fi fi From 9af9e9ec3486cbc83f9d8f82b8c2706bcbfdaeca Mon Sep 17 00:00:00 2001 From: Stian Kristensen Date: Sun, 24 Nov 2024 16:51:47 +0100 Subject: [PATCH 06/16] Update blue light filter doc --- website/docs/07-apps/01-included-in-onion/blue-light-filter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/07-apps/01-included-in-onion/blue-light-filter.md b/website/docs/07-apps/01-included-in-onion/blue-light-filter.md index 4f1a36c8f..3941c92d0 100644 --- a/website/docs/07-apps/01-included-in-onion/blue-light-filter.md +++ b/website/docs/07-apps/01-included-in-onion/blue-light-filter.md @@ -40,7 +40,7 @@ You'll find it in Tweaks app: [`Appearance` -› `Blue light filter...`](/docs/a 5. **Time (Off)** - Time Blue light filter will be disabled :::note -To use Schedule you'll need a Miyoo Mini Plus with "[Set time automatically via internet](/docs/apps/tweaks#set-automatically-via-the-internet)" enabled. +Schedule requires a Miyoo Mini Plus with "[Set time automatically via internet](/docs/apps/tweaks#set-automatically-via-the-internet)" enabled or a Miyoo Mini with RTC and .noTimeRestore (to prevent clock from overwriting the time) in order to function properly. ::: ### Hotkeys From 591773a6435e1166fd9a7530552345d922f8f520 Mon Sep 17 00:00:00 2001 From: Stian Kristensen Date: Sun, 24 Nov 2024 18:26:43 +0100 Subject: [PATCH 07/16] Revert "Allow bluelight filter check to run on Miyoo Mini as well" This reverts commit f67d070f3f33d8b1a7fc709efeca4c89c722b619. --- src/keymon/keymon.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/keymon/keymon.c b/src/keymon/keymon.c index f1d2c9c60..abb746d12 100644 --- a/src/keymon/keymon.c +++ b/src/keymon/keymon.c @@ -823,7 +823,9 @@ int main(void) } // Check bluelight filter - system("/mnt/SDCARD/.tmp_update/script/blue_light.sh check"); + if (DEVICE_ID == MIYOO354) { + system("/mnt/SDCARD/.tmp_update/script/blue_light.sh check"); + } // Quit RetroArch / auto-save when battery too low if (settings.low_battery_autosave_at && battery_getPercentage() <= settings.low_battery_autosave_at && check_autosave()) { From 2913be953e46aa624a9c1ef9cd3e471805e0e603 Mon Sep 17 00:00:00 2001 From: Stian Kristensen Date: Sun, 24 Nov 2024 18:27:37 +0100 Subject: [PATCH 08/16] Revert "Removed mini plus and network requirements from schedule options menu" This reverts commit 8e7a01b971ced5b2528946d21b9d4c787adb2d1a. --- src/tweaks/menus.h | 79 ++++++++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 34 deletions(-) diff --git a/src/tweaks/menus.h b/src/tweaks/menus.h index 9cf0b0873..57badc51d 100644 --- a/src/tweaks/menus.h +++ b/src/tweaks/menus.h @@ -484,11 +484,13 @@ void menu_blueLight(void *_) if (!_menu_user_blue_light._created) { network_loadState(); _menu_user_blue_light = list_createWithTitle(6, LIST_SMALL, "Blue light filter"); - list_addItem(&_menu_user_blue_light, - (ListItem){ - .label = "[DATESTRING]", - .disabled = 1, - .action = NULL}); + if (DEVICE_ID == MIYOO354) { + list_addItem(&_menu_user_blue_light, + (ListItem){ + .label = "[DATESTRING]", + .disabled = 1, + .action = NULL}); + } list_addItemWithInfoNote(&_menu_user_blue_light, (ListItem){ .label = "State", @@ -498,13 +500,16 @@ void menu_blueLight(void *_) .value = (int)settings.blue_light_state || exists("/tmp/.blfOn"), .action = action_blueLight}, "Set the selected strength now\n"); - list_addItemWithInfoNote(&_menu_user_blue_light, - (ListItem){ - .label = "", - .item_type = TOGGLE, - .value = (int)settings.blue_light_schedule, - .action = action_blueLightSchedule}, - "Enable or disable the bluelight filter schedule\n"); + if (DEVICE_ID == MIYOO354) { + list_addItemWithInfoNote(&_menu_user_blue_light, + (ListItem){ + .label = "", + .disabled = !network_state.ntp, + .item_type = TOGGLE, + .value = (int)settings.blue_light_schedule, + .action = action_blueLightSchedule}, + "Enable or disable the bluelight filter schedule\n"); + } list_addItemWithInfoNote(&_menu_user_blue_light, (ListItem){ .label = "Strength", @@ -517,29 +522,35 @@ void menu_blueLight(void *_) .value = value_blueLightLevel()}, "Change the strength of the \n" "Blue light filter"); - list_addItemWithInfoNote(&_menu_user_blue_light, - (ListItem){ - .label = "Time (On)", - .item_type = MULTIVALUE, - .value_max = 95, - .value_formatter = formatter_Time, - .action = action_blueLightTimeOn, - .value = value_blueLightTimeOn()}, - "Time schedule for the bluelight filter"); - list_addItemWithInfoNote(&_menu_user_blue_light, - (ListItem){ - .label = "Time (Off)", - .item_type = MULTIVALUE, - .value_max = 95, - .value_formatter = formatter_Time, - .action = action_blueLightTimeOff, - .value = value_blueLightTimeOff()}, - "Time schedule for the bluelight filter"); + if (DEVICE_ID == MIYOO354) { + list_addItemWithInfoNote(&_menu_user_blue_light, + (ListItem){ + .label = "Time (On)", + .disabled = !network_state.ntp, + .item_type = MULTIVALUE, + .value_max = 95, + .value_formatter = formatter_Time, + .action = action_blueLightTimeOn, + .value = value_blueLightTimeOn()}, + "Time schedule for the bluelight filter"); + list_addItemWithInfoNote(&_menu_user_blue_light, + (ListItem){ + .label = "Time (Off)", + .disabled = !network_state.ntp, + .item_type = MULTIVALUE, + .value_max = 95, + .value_formatter = formatter_Time, + .action = action_blueLightTimeOff, + .value = value_blueLightTimeOff()}, + "Time schedule for the bluelight filter"); + } + } + if (DEVICE_ID == MIYOO354) { + _writeDateString(_menu_user_blue_light.items[0].label); + char scheduleToggleLabel[100]; + strcpy(scheduleToggleLabel, exists("/tmp/.blfIgnoreSchedule") ? "Schedule (ignored)" : "Schedule"); + strcpy(_menu_user_blue_light.items[2].label, scheduleToggleLabel); } - _writeDateString(_menu_user_blue_light.items[0].label); - char scheduleToggleLabel[100]; - strcpy(scheduleToggleLabel, exists("/tmp/.blfIgnoreSchedule") ? "Schedule (ignored)" : "Schedule"); - strcpy(_menu_user_blue_light.items[2].label, scheduleToggleLabel); menu_stack[++menu_level] = &_menu_user_blue_light; header_changed = true; } From f947559ed3adf9edbae850ae3a7614730db0d624 Mon Sep 17 00:00:00 2001 From: Stian Kristensen Date: Sun, 24 Nov 2024 18:58:27 +0100 Subject: [PATCH 09/16] Check for noTimeRestore flag instead of only checking for mini plus with network. --- src/common/system/settings.h | 1 + src/keymon/keymon.c | 2 +- src/tweaks/menus.h | 14 +++++++------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/common/system/settings.h b/src/common/system/settings.h index 0015419e7..396430ab9 100644 --- a/src/common/system/settings.h +++ b/src/common/system/settings.h @@ -206,6 +206,7 @@ void settings_load(void) settings.blue_light_schedule = config_flag_get(".blf"); settings.rec_indicator = config_flag_get(".recIndicator"); settings.rec_hotkey = config_flag_get(".recHotkey"); + settings.noTimeRestore = config_flag_get(".noTimeRestore"); if (config_flag_get(".noLowBatteryAutoSave")) // flag is deprecated, but keep compatibility settings.low_battery_autosave_at = 0; diff --git a/src/keymon/keymon.c b/src/keymon/keymon.c index abb746d12..e82d4fed2 100644 --- a/src/keymon/keymon.c +++ b/src/keymon/keymon.c @@ -823,7 +823,7 @@ int main(void) } // Check bluelight filter - if (DEVICE_ID == MIYOO354) { + if (DEVICE_ID == MIYOO354 || settings.noTimeRestore) { system("/mnt/SDCARD/.tmp_update/script/blue_light.sh check"); } diff --git a/src/tweaks/menus.h b/src/tweaks/menus.h index 57badc51d..9fccbe077 100644 --- a/src/tweaks/menus.h +++ b/src/tweaks/menus.h @@ -484,7 +484,7 @@ void menu_blueLight(void *_) if (!_menu_user_blue_light._created) { network_loadState(); _menu_user_blue_light = list_createWithTitle(6, LIST_SMALL, "Blue light filter"); - if (DEVICE_ID == MIYOO354) { + if (DEVICE_ID == MIYOO354 || settings.noTimeRestore) { list_addItem(&_menu_user_blue_light, (ListItem){ .label = "[DATESTRING]", @@ -500,11 +500,11 @@ void menu_blueLight(void *_) .value = (int)settings.blue_light_state || exists("/tmp/.blfOn"), .action = action_blueLight}, "Set the selected strength now\n"); - if (DEVICE_ID == MIYOO354) { + if (DEVICE_ID == MIYOO354 || settings.noTimeRestore) { list_addItemWithInfoNote(&_menu_user_blue_light, (ListItem){ .label = "", - .disabled = !network_state.ntp, + .disabled = (!settings.noTimeRestore && !network_state.ntp), .item_type = TOGGLE, .value = (int)settings.blue_light_schedule, .action = action_blueLightSchedule}, @@ -522,11 +522,11 @@ void menu_blueLight(void *_) .value = value_blueLightLevel()}, "Change the strength of the \n" "Blue light filter"); - if (DEVICE_ID == MIYOO354) { + if (DEVICE_ID == MIYOO354 || settings.noTimeRestore) { list_addItemWithInfoNote(&_menu_user_blue_light, (ListItem){ .label = "Time (On)", - .disabled = !network_state.ntp, + .disabled = (!settings.noTimeRestore && !network_state.ntp), .item_type = MULTIVALUE, .value_max = 95, .value_formatter = formatter_Time, @@ -536,7 +536,7 @@ void menu_blueLight(void *_) list_addItemWithInfoNote(&_menu_user_blue_light, (ListItem){ .label = "Time (Off)", - .disabled = !network_state.ntp, + .disabled = (!settings.noTimeRestore && !network_state.ntp), .item_type = MULTIVALUE, .value_max = 95, .value_formatter = formatter_Time, @@ -545,7 +545,7 @@ void menu_blueLight(void *_) "Time schedule for the bluelight filter"); } } - if (DEVICE_ID == MIYOO354) { + if (DEVICE_ID == MIYOO354 || settings.noTimeRestore) { _writeDateString(_menu_user_blue_light.items[0].label); char scheduleToggleLabel[100]; strcpy(scheduleToggleLabel, exists("/tmp/.blfIgnoreSchedule") ? "Schedule (ignored)" : "Schedule"); From f1092f37d86d6600b02d60edda904b391131cbc9 Mon Sep 17 00:00:00 2001 From: Stian Kristensen Date: Sun, 24 Nov 2024 19:04:45 +0100 Subject: [PATCH 10/16] Revert "Update blue light filter doc" This reverts commit 9af9e9ec3486cbc83f9d8f82b8c2706bcbfdaeca. --- website/docs/07-apps/01-included-in-onion/blue-light-filter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/07-apps/01-included-in-onion/blue-light-filter.md b/website/docs/07-apps/01-included-in-onion/blue-light-filter.md index 3941c92d0..4f1a36c8f 100644 --- a/website/docs/07-apps/01-included-in-onion/blue-light-filter.md +++ b/website/docs/07-apps/01-included-in-onion/blue-light-filter.md @@ -40,7 +40,7 @@ You'll find it in Tweaks app: [`Appearance` -› `Blue light filter...`](/docs/a 5. **Time (Off)** - Time Blue light filter will be disabled :::note -Schedule requires a Miyoo Mini Plus with "[Set time automatically via internet](/docs/apps/tweaks#set-automatically-via-the-internet)" enabled or a Miyoo Mini with RTC and .noTimeRestore (to prevent clock from overwriting the time) in order to function properly. +To use Schedule you'll need a Miyoo Mini Plus with "[Set time automatically via internet](/docs/apps/tweaks#set-automatically-via-the-internet)" enabled. ::: ### Hotkeys From af1702e62d9f06ac1c136f7663efcf2da5c37789 Mon Sep 17 00:00:00 2001 From: Stian Kristensen Date: Sun, 24 Nov 2024 19:06:34 +0100 Subject: [PATCH 11/16] Updated doc --- website/docs/07-apps/01-included-in-onion/blue-light-filter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/07-apps/01-included-in-onion/blue-light-filter.md b/website/docs/07-apps/01-included-in-onion/blue-light-filter.md index 4f1a36c8f..14e1c6344 100644 --- a/website/docs/07-apps/01-included-in-onion/blue-light-filter.md +++ b/website/docs/07-apps/01-included-in-onion/blue-light-filter.md @@ -40,7 +40,7 @@ You'll find it in Tweaks app: [`Appearance` -› `Blue light filter...`](/docs/a 5. **Time (Off)** - Time Blue light filter will be disabled :::note -To use Schedule you'll need a Miyoo Mini Plus with "[Set time automatically via internet](/docs/apps/tweaks#set-automatically-via-the-internet)" enabled. +To use Schedule you'll need a Miyoo Mini with RTC or a Miyoo Mini Plus with "[Set time automatically via internet](/docs/apps/tweaks#set-automatically-via-the-internet)" enabled. ::: ### Hotkeys From 58a8ebbf59ebc7e31b38f8d6f6a526d6cc7468ab Mon Sep 17 00:00:00 2001 From: Stian Kristensen Date: Sun, 24 Nov 2024 19:08:30 +0100 Subject: [PATCH 12/16] Added note about noTimeRestore --- website/docs/07-apps/01-included-in-onion/blue-light-filter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/07-apps/01-included-in-onion/blue-light-filter.md b/website/docs/07-apps/01-included-in-onion/blue-light-filter.md index 14e1c6344..daedc8e5f 100644 --- a/website/docs/07-apps/01-included-in-onion/blue-light-filter.md +++ b/website/docs/07-apps/01-included-in-onion/blue-light-filter.md @@ -40,7 +40,7 @@ You'll find it in Tweaks app: [`Appearance` -› `Blue light filter...`](/docs/a 5. **Time (Off)** - Time Blue light filter will be disabled :::note -To use Schedule you'll need a Miyoo Mini with RTC or a Miyoo Mini Plus with "[Set time automatically via internet](/docs/apps/tweaks#set-automatically-via-the-internet)" enabled. +To use Schedule you'll need a Miyoo Mini with RTC and .noTimeRestore set in config or a Miyoo Mini Plus with "[Set time automatically via internet](/docs/apps/tweaks#set-automatically-via-the-internet)" enabled. ::: ### Hotkeys From 789724617ad2a6e83f58e8636e909fd91c2170f8 Mon Sep 17 00:00:00 2001 From: Stian Kristensen Date: Sun, 24 Nov 2024 22:38:21 +0100 Subject: [PATCH 13/16] AND not OR --- static/build/.tmp_update/script/blue_light.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/build/.tmp_update/script/blue_light.sh b/static/build/.tmp_update/script/blue_light.sh index 468eeffd9..455f922aa 100644 --- a/static/build/.tmp_update/script/blue_light.sh +++ b/static/build/.tmp_update/script/blue_light.sh @@ -168,7 +168,7 @@ disable_blue_light_filter() { check_blf() { sync - if [ -f "$blf_key" ] || [ ! -f "$ignore_schedule" ]; then + if [ -f "$blf_key" ] && [ ! -f "$ignore_schedule" ]; then if [ ! -f "$blf_key_on" ] && [ -f "$blf_key_on_user" ]; then rm -f $blf_key_on_user From 76a9dff9e6b4cd7bac30f842fe729f80e6be219a Mon Sep 17 00:00:00 2001 From: Stian Kristensen Date: Sun, 24 Nov 2024 22:59:23 +0100 Subject: [PATCH 14/16] Always allow turning off/adjusting the blue light schedule if it is currently active --- src/tweaks/menus.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/tweaks/menus.h b/src/tweaks/menus.h index 9fccbe077..93b589e62 100644 --- a/src/tweaks/menus.h +++ b/src/tweaks/menus.h @@ -481,10 +481,12 @@ void menu_themeOverrides(void *_) void menu_blueLight(void *_) { + bool schedule_show = (DEVICE_ID == MIYOO354 || settings.noTimeRestore || settings.blue_light_schedule); + bool schedule_disable = (!settings.noTimeRestore && !network_state.ntp && !settings.blue_light_schedule); if (!_menu_user_blue_light._created) { network_loadState(); _menu_user_blue_light = list_createWithTitle(6, LIST_SMALL, "Blue light filter"); - if (DEVICE_ID == MIYOO354 || settings.noTimeRestore) { + if (schedule_show) { list_addItem(&_menu_user_blue_light, (ListItem){ .label = "[DATESTRING]", @@ -500,11 +502,11 @@ void menu_blueLight(void *_) .value = (int)settings.blue_light_state || exists("/tmp/.blfOn"), .action = action_blueLight}, "Set the selected strength now\n"); - if (DEVICE_ID == MIYOO354 || settings.noTimeRestore) { + if (schedule_show) { list_addItemWithInfoNote(&_menu_user_blue_light, (ListItem){ .label = "", - .disabled = (!settings.noTimeRestore && !network_state.ntp), + .disabled = schedule_disable, .item_type = TOGGLE, .value = (int)settings.blue_light_schedule, .action = action_blueLightSchedule}, @@ -522,11 +524,11 @@ void menu_blueLight(void *_) .value = value_blueLightLevel()}, "Change the strength of the \n" "Blue light filter"); - if (DEVICE_ID == MIYOO354 || settings.noTimeRestore) { + if (schedule_show) { list_addItemWithInfoNote(&_menu_user_blue_light, (ListItem){ .label = "Time (On)", - .disabled = (!settings.noTimeRestore && !network_state.ntp), + .disabled = schedule_disable, .item_type = MULTIVALUE, .value_max = 95, .value_formatter = formatter_Time, @@ -536,7 +538,7 @@ void menu_blueLight(void *_) list_addItemWithInfoNote(&_menu_user_blue_light, (ListItem){ .label = "Time (Off)", - .disabled = (!settings.noTimeRestore && !network_state.ntp), + .disabled = schedule_disable, .item_type = MULTIVALUE, .value_max = 95, .value_formatter = formatter_Time, @@ -545,7 +547,7 @@ void menu_blueLight(void *_) "Time schedule for the bluelight filter"); } } - if (DEVICE_ID == MIYOO354 || settings.noTimeRestore) { + if (schedule_show) { _writeDateString(_menu_user_blue_light.items[0].label); char scheduleToggleLabel[100]; strcpy(scheduleToggleLabel, exists("/tmp/.blfIgnoreSchedule") ? "Schedule (ignored)" : "Schedule"); From c32e56850ae8475a2ed616e538d3b8a0307c3aa8 Mon Sep 17 00:00:00 2001 From: Stian Kristensen Date: Sun, 24 Nov 2024 23:11:50 +0100 Subject: [PATCH 15/16] Check blue light schedule if blue light schedule setting is on. --- src/keymon/keymon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/keymon/keymon.c b/src/keymon/keymon.c index e82d4fed2..331f88af2 100644 --- a/src/keymon/keymon.c +++ b/src/keymon/keymon.c @@ -823,7 +823,7 @@ int main(void) } // Check bluelight filter - if (DEVICE_ID == MIYOO354 || settings.noTimeRestore) { + if (settings.blue_light_schedule) { system("/mnt/SDCARD/.tmp_update/script/blue_light.sh check"); } From 1b9d1129a81586a62ee4f69f124a5fef769d4fa4 Mon Sep 17 00:00:00 2001 From: Stian Kristensen Date: Sun, 24 Nov 2024 23:50:27 +0100 Subject: [PATCH 16/16] Added missing initiation of no_time_restore in settings (also renamed settings.noTimeRestore to use snakecase instead) --- src/common/system/settings.h | 4 +++- src/tweaks/menus.h | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/common/system/settings.h b/src/common/system/settings.h index 396430ab9..62ae77430 100644 --- a/src/common/system/settings.h +++ b/src/common/system/settings.h @@ -66,6 +66,7 @@ typedef struct settings_s { int blue_light_rgb; char blue_light_time[16]; char blue_light_time_off[16]; + bool no_time_restore; char mainui_button_x[JSON_STRING_LEN]; char mainui_button_y[JSON_STRING_LEN]; @@ -103,6 +104,7 @@ static settings_s __default_settings = (settings_s){ .vibration = 2, .startup_tab = 0, .startup_application = 0, + .no_time_restore = false, // Menu button actions .mainui_single_press = 1, .mainui_long_press = 0, @@ -206,7 +208,7 @@ void settings_load(void) settings.blue_light_schedule = config_flag_get(".blf"); settings.rec_indicator = config_flag_get(".recIndicator"); settings.rec_hotkey = config_flag_get(".recHotkey"); - settings.noTimeRestore = config_flag_get(".noTimeRestore"); + settings.no_time_restore = config_flag_get(".noTimeRestore"); if (config_flag_get(".noLowBatteryAutoSave")) // flag is deprecated, but keep compatibility settings.low_battery_autosave_at = 0; diff --git a/src/tweaks/menus.h b/src/tweaks/menus.h index 93b589e62..487fdfd47 100644 --- a/src/tweaks/menus.h +++ b/src/tweaks/menus.h @@ -481,8 +481,8 @@ void menu_themeOverrides(void *_) void menu_blueLight(void *_) { - bool schedule_show = (DEVICE_ID == MIYOO354 || settings.noTimeRestore || settings.blue_light_schedule); - bool schedule_disable = (!settings.noTimeRestore && !network_state.ntp && !settings.blue_light_schedule); + bool schedule_show = (DEVICE_ID == MIYOO354 || settings.no_time_restore || settings.blue_light_schedule); + bool schedule_disable = (!settings.no_time_restore && !network_state.ntp && !settings.blue_light_schedule); if (!_menu_user_blue_light._created) { network_loadState(); _menu_user_blue_light = list_createWithTitle(6, LIST_SMALL, "Blue light filter");