Skip to content

Commit

Permalink
Merge pull request #482 from zigad/feature/disableTouch
Browse files Browse the repository at this point in the history
Enable / Disable Touchscreen
  • Loading branch information
ArjanOnwezen committed Apr 8, 2022
2 parents a81d630 + a9d2b2f commit 1f27af6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
5 changes: 4 additions & 1 deletion firmware/application/apps/ui_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,17 @@ SetFrequencyCorrectionModel SetRadioView::form_collect() {
SetUIView::SetUIView(NavigationView& nav) {
add_children({
//&checkbox_login,
&checkbox_disable_touchscreen,
&checkbox_speaker,
&checkbox_bloff,
&options_bloff,
&checkbox_showsplash,
&checkbox_showclock,
&options_clockformat,
&options_clockformat,
&button_ok
});

checkbox_disable_touchscreen.set_value(persistent_memory::disable_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());
Expand Down Expand Up @@ -278,6 +280,7 @@ SetUIView::SetUIView(NavigationView& nav) {
}
persistent_memory::set_config_splash(checkbox_showsplash.value());
persistent_memory::set_clock_hidden(!checkbox_showclock.value());
persistent_memory::set_disable_touchscreen(checkbox_disable_touchscreen.value());
//persistent_memory::set_config_login(checkbox_login.value());
nav.pop();
};
Expand Down
6 changes: 6 additions & 0 deletions firmware/application/apps/ui_settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ class SetUIView : public View {

private:

Checkbox checkbox_disable_touchscreen {
{ 3 * 8, 2 * 16 },
20,
"Disable touchscreen"
};

Checkbox checkbox_speaker {
{ 3 * 8, 4 * 16 },
20,
Expand Down
2 changes: 1 addition & 1 deletion firmware/application/touch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void Manager::feed(const Frame& frame) {

switch(state) {
case State::NoTouch:
if( touch_stable && touch_pressure ) {
if( touch_stable && touch_pressure && !persistent_memory::disable_touchscreen()) {
if( point_stable() ) {
state = State::TouchDetected;
touch_started();
Expand Down
10 changes: 9 additions & 1 deletion firmware/common/portapack_persistent_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,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 disable_touchscreen() { // Option to disable touch screen
return data->ui_config & (1 << 24);
}

bool show_bigger_qr_code() { // show bigger QR code
return data->ui_config & (1 << 23);
}
Expand Down Expand Up @@ -270,6 +274,10 @@ uint32_t config_backlight_timer() {
return timer_seconds[data->ui_config & 7]; //first three bits, 8 possible values
}

void set_disable_touchscreen(bool v) {
data->ui_config = (data->ui_config & ~(1 << 24)) | (v << 24);
}

void set_show_bigger_qr_code(bool v) {
data->ui_config = (data->ui_config & ~(1 << 23)) | (v << 23);
}
Expand Down
2 changes: 2 additions & 0 deletions firmware/common/portapack_persistent_memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ bool clock_with_date();
bool config_login();
bool config_speaker();
uint32_t config_backlight_timer();
bool disable_touchscreen();

void set_config_splash(bool v);
void set_show_bigger_qr_code(bool v);
Expand All @@ -92,6 +93,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_disable_touchscreen(bool v);

//uint8_t ui_config_textentry();
//void set_config_textentry(uint8_t new_value);
Expand Down

0 comments on commit 1f27af6

Please sign in to comment.