From 4a0d42ed345467201403bc42aa9ad68a5954f8de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=BDiga=20Deisinger?= Date: Wed, 26 Jan 2022 21:52:08 +0100 Subject: [PATCH] Add code for feature "Disable Touch" --- firmware/application/apps/ui_settings.cpp | 6 ++++-- firmware/application/apps/ui_settings.hpp | 6 ++++++ firmware/application/touch.cpp | 2 +- .../common/portapack_persistent_memory.cpp | 18 +++++++++--------- .../common/portapack_persistent_memory.hpp | 4 ++-- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/firmware/application/apps/ui_settings.cpp b/firmware/application/apps/ui_settings.cpp index b9fd06a8..2fe2be92 100644 --- a/firmware/application/apps/ui_settings.cpp +++ b/firmware/application/apps/ui_settings.cpp @@ -281,20 +281,21 @@ void SetPlayDeadView::focus() { SetUIView::SetUIView(NavigationView& nav) { add_children({ //&checkbox_login, + &checkbox_enable_touchscreen, &checkbox_speaker, &checkbox_bloff, &options_bloff, &checkbox_showsplash, &checkbox_showclock, - &options_clockformat, + &options_clockformat, &button_ok }); + checkbox_enable_touchscreen.set_value(persistent_memory::enable_touchscreen()); checkbox_speaker.set_value(persistent_memory::config_speaker()); checkbox_showsplash.set_value(persistent_memory::config_splash()); checkbox_showclock.set_value(!persistent_memory::hide_clock()); //checkbox_login.set_value(persistent_memory::config_login()); - //Add code for touch disabled uint32_t backlight_timer = persistent_memory::config_backlight_timer(); if (backlight_timer) { @@ -333,6 +334,7 @@ SetUIView::SetUIView(NavigationView& nav) { } persistent_memory::set_config_splash(checkbox_showsplash.value()); persistent_memory::set_clock_hidden(!checkbox_showclock.value()); + persistent_memory::set_enable_touchscreen(checkbox_enable_touchscreen.value()); //persistent_memory::set_config_login(checkbox_login.value()); nav.pop(); }; diff --git a/firmware/application/apps/ui_settings.hpp b/firmware/application/apps/ui_settings.hpp index 30acd820..4cf42054 100644 --- a/firmware/application/apps/ui_settings.hpp +++ b/firmware/application/apps/ui_settings.hpp @@ -224,6 +224,12 @@ private: 20, "Login with play dead" };*/ + + Checkbox checkbox_enable_touchscreen { + { 3 * 8, 2 * 16 }, + 20, + "Enable touchscreen" + }; Checkbox checkbox_speaker { { 3 * 8, 4 * 16 }, diff --git a/firmware/application/touch.cpp b/firmware/application/touch.cpp index 98f2a0a4..72f45058 100644 --- a/firmware/application/touch.cpp +++ b/firmware/application/touch.cpp @@ -109,7 +109,7 @@ void Manager::feed(const Frame& frame) { switch(state) { case State::NoTouch: - if( touch_stable && touch_pressure ) {//Add code for touch disabled + if( touch_stable && touch_pressure && persistent_memory::enable_touchscreen()) { if( point_stable() ) { state = State::TouchDetected; touch_started(); diff --git a/firmware/common/portapack_persistent_memory.cpp b/firmware/common/portapack_persistent_memory.cpp index 367d1609..aefb0852 100644 --- a/firmware/common/portapack_persistent_memory.cpp +++ b/firmware/common/portapack_persistent_memory.cpp @@ -224,9 +224,13 @@ void set_playdead_sequence(const uint32_t new_value) { // ui_config is an uint32_t var storing information bitwise // bits 0,1,2 store the backlight timer -// bits 31, 30,29,28,27, 26, 25 stores the different single bit configs depicted below +// bits 31, 30,29,28,27, 26, 25, 24 stores the different single bit configs depicted below // bits on position 4 to 19 (16 bits) store the clkout frequency +bool enable_touchscreen() { // Option to disable touch screen + return data->ui_config & (1 << 24); +} + bool hide_clock() { // clock hidden from main menu return data->ui_config & (1 << 25); } @@ -254,15 +258,15 @@ bool config_splash() { return data->ui_config & (1 << 31); } -bool touch_screen_enabled() { - return data->ui_config & (1 << 32); -} - uint32_t config_backlight_timer() { const uint32_t timer_seconds[8] = { 0, 5, 15, 30, 60, 180, 300, 600 }; return timer_seconds[data->ui_config & 7]; //first three bits, 8 possible values } +void set_enable_touchscreen(bool v) { + data->ui_config = (data->ui_config & ~(1 << 24)) | (v << 24); +} + void set_clock_hidden(bool v) { data->ui_config = (data->ui_config & ~(1 << 25)) | (v << 25); } @@ -295,10 +299,6 @@ void set_config_backlight_timer(uint32_t i) { data->ui_config = (data->ui_config & ~7) | (i & 7); } -void set_touch_screen_enabled(bool v) { - data->ui_config = (data->ui_config & ~(1 << 32)) | (v << 32); -} - /*void set_config_textentry(uint8_t new_value) { data->ui_config = (data->ui_config & ~0b100) | ((new_value & 1) << 2); } diff --git a/firmware/common/portapack_persistent_memory.hpp b/firmware/common/portapack_persistent_memory.hpp index 45936f55..97ac4c1b 100644 --- a/firmware/common/portapack_persistent_memory.hpp +++ b/firmware/common/portapack_persistent_memory.hpp @@ -80,7 +80,7 @@ bool clock_with_date(); bool config_login(); bool config_speaker(); uint32_t config_backlight_timer(); -bool touch_screen_enabled(); +bool enable_touchscreen(); void set_config_splash(bool v); void set_clock_hidden(bool v); @@ -88,7 +88,7 @@ void set_clock_with_date(bool v); void set_config_login(bool v); void set_config_speaker(bool v); void set_config_backlight_timer(uint32_t i); -void set_touch_screen_enabled(bool v); +void set_enable_touchscreen(bool v); //uint8_t ui_config_textentry(); //void set_config_textentry(uint8_t new_value);