Touch on T-Echo to refresh e-ink screen

pull/1069/head
Erik R Norell 2022-01-07 09:57:29 +03:00
rodzic b6eb927ad2
commit 17dfb7d152
3 zmienionych plików z 54 dodań i 0 usunięć

Wyświetl plik

@ -84,6 +84,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define BUTTON_PIN_ALT PIN_BUTTON2 #define BUTTON_PIN_ALT PIN_BUTTON2
#endif #endif
#ifdef PIN_BUTTON_TOUCH
#define BUTTON_PIN_TOUCH PIN_BUTTON_TOUCH
#endif
// FIXME, use variant.h defs for all of this!!! (even on the ESP32 targets) // FIXME, use variant.h defs for all of this!!! (even on the ESP32 targets)
#elif defined(CubeCell_BoardPlus) #elif defined(CubeCell_BoardPlus)

Wyświetl plik

@ -187,6 +187,9 @@ class ButtonThread : public OSThread
#endif #endif
#ifdef BUTTON_PIN_ALT #ifdef BUTTON_PIN_ALT
OneButton userButtonAlt; OneButton userButtonAlt;
#endif
#ifdef BUTTON_PIN_TOUCH
OneButton userButtonTouch;
#endif #endif
static bool shutdown_on_long_stop; static bool shutdown_on_long_stop;
@ -222,6 +225,21 @@ class ButtonThread : public OSThread
userButtonAlt.attachLongPressStop(userButtonPressedLongStop); userButtonAlt.attachLongPressStop(userButtonPressedLongStop);
wakeOnIrq(BUTTON_PIN_ALT, FALLING); wakeOnIrq(BUTTON_PIN_ALT, FALLING);
#endif #endif
#ifdef BUTTON_PIN_TOUCH
userButtonTouch = OneButton(BUTTON_PIN_TOUCH, true, true);
#ifdef INPUT_PULLUP_SENSE
// Some platforms (nrf52) have a SENSE variant which allows wake from sleep - override what OneButton did
pinMode(BUTTON_PIN_TOUCH, INPUT_PULLUP_SENSE);
#endif
userButtonTouch.attachClick(touchPressed);
userButtonTouch.attachDuringLongPress(touchPressedLong);
userButtonTouch.attachDoubleClick(touchDoublePressed);
userButtonTouch.attachLongPressStart(touchPressedLongStart);
userButtonTouch.attachLongPressStop(touchPressedLongStop);
wakeOnIrq(BUTTON_PIN_TOUCH, FALLING);
#endif
} }
protected: protected:
@ -237,6 +255,10 @@ class ButtonThread : public OSThread
#ifdef BUTTON_PIN_ALT #ifdef BUTTON_PIN_ALT
userButtonAlt.tick(); userButtonAlt.tick();
canSleep &= userButtonAlt.isIdle(); canSleep &= userButtonAlt.isIdle();
#endif
#ifdef BUTTON_PIN_TOUCH
userButtonTouch.tick();
canSleep &= userButtonTouch.isIdle();
#endif #endif
// if (!canSleep) DEBUG_MSG("Supressing sleep!\n"); // if (!canSleep) DEBUG_MSG("Supressing sleep!\n");
// else DEBUG_MSG("sleep ok\n"); // else DEBUG_MSG("sleep ok\n");
@ -245,6 +267,33 @@ class ButtonThread : public OSThread
} }
private: private:
static void touchPressed()
{
screen->forceDisplay();
DEBUG_MSG("touch press!\n");
}
static void touchDoublePressed()
{
DEBUG_MSG("touch double press!\n");
}
static void touchPressedLong()
{
DEBUG_MSG("touch press long!\n");
}
static void touchDoublePressedLong()
{
DEBUG_MSG("touch double pressed!\n");
}
static void touchPressedLongStart()
{
DEBUG_MSG("touch long press start!\n");
}
static void touchPressedLongStop()
{
DEBUG_MSG("touch long press stop!\n");
}
static void userButtonPressed() static void userButtonPressed()
{ {
// DEBUG_MSG("press!\n"); // DEBUG_MSG("press!\n");

Wyświetl plik

@ -120,6 +120,7 @@ extern "C" {
*/ */
#define PIN_BUTTON1 (32 + 10) #define PIN_BUTTON1 (32 + 10)
#define PIN_BUTTON2 (0 + 18) // 0.18 is labeled on the board as RESET but we configure it in the bootloader as a regular GPIO #define PIN_BUTTON2 (0 + 18) // 0.18 is labeled on the board as RESET but we configure it in the bootloader as a regular GPIO
#define PIN_BUTTON_TOUCH (0 + 11) // 0.11 is the soft touch button on T-Echo
/* /*
* Analog pins * Analog pins