From 14b5f6988db12df5ec96d72d147355efcbafdc1c Mon Sep 17 00:00:00 2001 From: Jasper Date: Sun, 13 Mar 2022 20:01:46 +0100 Subject: [PATCH] Use both buttons to toggle driver & testing view --- lib/FT18_STW_DISPLAY/FT18_STW_DISPLAY.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/FT18_STW_DISPLAY/FT18_STW_DISPLAY.cpp b/lib/FT18_STW_DISPLAY/FT18_STW_DISPLAY.cpp index 2e0f441..a5877c7 100644 --- a/lib/FT18_STW_DISPLAY/FT18_STW_DISPLAY.cpp +++ b/lib/FT18_STW_DISPLAY/FT18_STW_DISPLAY.cpp @@ -214,8 +214,12 @@ void update_display(){ } uint32_t now = millis(); - if(Stw_data.button1_rises > 0){ - Stw_data.button1_rises--; + // Both buttons have to be pressed at the same time, but we also use the + // debounced rises to ensure we don't keep toggling between the pages + if (Stw_data.buttonState1 && Stw_data.buttonState4 && + (Stw_data.button1_rises > 0|| Stw_data.button4_rises > 0)){ + Stw_data.button1_rises = 0; + Stw_data.button4_rises = 0; page = (DisplayPage) ((page + 1) % DISPLAY_PAGES); tft.clear(); last_cleared = now; @@ -306,6 +310,14 @@ void update_page_driver() { left_box_value = (Value) (left_box_value + 1); } left_box.update_label(get_label(left_box_value)); + if (Stw_data.button1_rises > 0) { + Stw_data.button1_rises--; + if (left_box_value == VAL_FIRST_LEFT_BOX) { + left_box_value = VAL_LAST; + } else { + left_box_value = (Value) (left_box_value - 1); + } + left_box.update_label(get_label(left_box_value)); } gear_box.update_value(get_value(VAL_GEAR)); @@ -318,10 +330,10 @@ void update_page_driver() { } void redraw_page_testing() { - + } -void update_page_testing() {} +void update_page_testing() {} DataBox::DataBox(int x1, int y1, int x2, int y2, int text_x, int text_y, int font, int size_x, int size_y, uint8_t justification)