Skip to content

Commit

Permalink
COLOR_UI: Wake up on any feedback
Browse files Browse the repository at this point in the history
rename TouchButtons object to avoid conflicts with tft/touch one
  • Loading branch information
tpruvot committed Aug 26, 2021
1 parent 0934241 commit 6c719fd
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ void setup() {
#endif

#if HAS_TOUCH_BUTTONS
SETUP_RUN(touch.init());
SETUP_RUN(touchBt.init());
#endif

TERN_(HAS_M206_COMMAND, current_position += home_offset); // Init current position based on home_offset
Expand Down
7 changes: 5 additions & 2 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,10 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
}

void MarlinUI::quick_feedback(const bool clear_buttons/*=true*/) {

#if ENABLED(TOUCH_SCREEN) && defined(TOUCH_IDLE_SLEEP)
// Wake up, if needed, the TFT from any button or encoder
touch.wakeUp();
#endif
TERN_(HAS_LCD_MENU, refresh());

#if HAS_ENCODER_ACTION
Expand Down Expand Up @@ -916,7 +919,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;

if (on_status_screen()) next_lcd_update_ms += (LCD_UPDATE_INTERVAL) * 2;

TERN_(HAS_ENCODER_ACTION, touch_buttons = touch.read_buttons());
TERN_(HAS_ENCODER_ACTION, touch_buttons = touchBt.read_buttons());

#endif

Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/lcd/marlinui.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
#include "tft_io/touch_calibration.h"
#endif

#if ENABLED(TOUCH_SCREEN) && defined(TOUCH_IDLE_SLEEP)
#include "tft/touch.h"
#endif

#if ANY(HAS_LCD_MENU, ULTIPANEL_FEEDMULTIPLY, SOFT_RESET_ON_KILL)
#define HAS_ENCODER_ACTION 1
#endif
Expand Down
6 changes: 6 additions & 0 deletions Marlin/src/lcd/tft/touch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,12 @@ bool Touch::isSleeping() {
#endif
}

void Touch::wakeUp() {
#if ENABLED(TFT_TOUCH_DEVICE_XPT2046)
if (io.isSleeping()) io.doWakeUp();
#endif
}

Touch touch;

bool MarlinUI::touch_pressed() {
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/tft/touch.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class Touch {
static void enable() { enabled = true; }

static bool isSleeping();
static void wakeUp();

static void add_control(TouchControlType type, uint16_t x, uint16_t y, uint16_t width, uint16_t height, intptr_t data = 0);
};
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/touch/touch_buttons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#define BUTTON_AREA_TOP BUTTON_Y_LO
#define BUTTON_AREA_BOT BUTTON_Y_HI

TouchButtons touch;
TouchButtons touchBt;

void TouchButtons::init() { touchIO.Init(); }

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/touch/touch_buttons.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ class TouchButtons {
static uint8_t read_buttons();
};

extern TouchButtons touch;
extern TouchButtons touchBt;

0 comments on commit 6c719fd

Please sign in to comment.