Skip to content

Commit

Permalink
COLOR_UI: Use common touch class
Browse files Browse the repository at this point in the history
  • Loading branch information
tpruvot committed Aug 26, 2021
1 parent d7b9756 commit 0934241
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
9 changes: 9 additions & 0 deletions Marlin/src/lcd/tft/touch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,15 @@ bool Touch::get_point(int16_t *x, int16_t *y) {

return is_touched;
}

bool Touch::isSleeping() {
#if ENABLED(TFT_TOUCH_DEVICE_XPT2046)
return io.isSleeping();
#else
return false;
#endif
}

Touch touch;

bool MarlinUI::touch_pressed() {
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/lcd/tft/touch.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ class Touch {
static void disable() { enabled = false; }
static void enable() { enabled = true; }

static bool isSleeping();

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/tft/ui_1024x600.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void MarlinUI::tft_idle() {
#if ENABLED(TOUCH_SCREEN)
#if HAS_TOUCH_SLEEP
static bool sleepCleared;
if (touchIO.isSleeping()) {
if (touch.isSleeping()) {
tft.queue.reset();
if (!sleepCleared) {
sleepCleared = true;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/tft/ui_320x240.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void MarlinUI::tft_idle() {
#if ENABLED(TOUCH_SCREEN)
#if HAS_TOUCH_SLEEP
static bool sleepCleared;
if (touchIO.isSleeping()) {
if (touch.isSleeping()) {
tft.queue.reset();
if (!sleepCleared) {
sleepCleared = true;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/tft/ui_480x320.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void MarlinUI::tft_idle() {
#if ENABLED(TOUCH_SCREEN)
#if HAS_TOUCH_SLEEP
static bool sleepCleared;
if (touchIO.isSleeping()) {
if (touch.isSleeping()) {
tft.queue.reset();
if (!sleepCleared) {
sleepCleared = true;
Expand Down
3 changes: 0 additions & 3 deletions Marlin/src/lcd/tft/ui_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
#if ENABLED(TOUCH_SCREEN)
#include "touch.h"
extern bool draw_menu_navigation;
#if HAS_TOUCH_SLEEP
extern XPT2046 touchIO;
#endif
#endif

#if HAS_UI_320x240
Expand Down

0 comments on commit 0934241

Please sign in to comment.