* UITask: new UI_HAS_JOYSTICK
* MomentaryButton: new constructor 'multiclick' param * WIoTrackerL1: now just use joystick, joystick press for KEY_ENTER, no multi-click for snappier UI
This commit is contained in:
@@ -20,7 +20,11 @@
|
|||||||
#define UI_RECENT_LIST_SIZE 4
|
#define UI_RECENT_LIST_SIZE 4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PRESS_LABEL "long press"
|
#if UI_HAS_JOYSTICK
|
||||||
|
#define PRESS_LABEL "press Enter"
|
||||||
|
#else
|
||||||
|
#define PRESS_LABEL "long press"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "icons.h"
|
#include "icons.h"
|
||||||
|
|
||||||
@@ -360,7 +364,7 @@ public:
|
|||||||
display.drawTextCentered(display.width() / 2, 34, "hibernating...");
|
display.drawTextCentered(display.width() / 2, 34, "hibernating...");
|
||||||
} else {
|
} else {
|
||||||
display.drawXbm((display.width() - 32) / 2, 18, power_icon, 32, 32);
|
display.drawXbm((display.width() - 32) / 2, 18, power_icon, 32, 32);
|
||||||
display.drawTextCentered(display.width() / 2, 64 - 11, "hibernate: " PRESS_LABEL);
|
display.drawTextCentered(display.width() / 2, 64 - 11, "hibernate:" PRESS_LABEL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 5000; // next render after 5000 ms
|
return 5000; // next render after 5000 ms
|
||||||
@@ -660,19 +664,13 @@ bool UITask::isButtonPressed() const {
|
|||||||
|
|
||||||
void UITask::loop() {
|
void UITask::loop() {
|
||||||
char c = 0;
|
char c = 0;
|
||||||
#if defined(PIN_USER_BTN)
|
#if UI_HAS_JOYSTICK
|
||||||
int ev = user_btn.check();
|
int ev = user_btn.check();
|
||||||
if (ev == BUTTON_EVENT_CLICK) {
|
if (ev == BUTTON_EVENT_CLICK) {
|
||||||
c = checkDisplayOn(KEY_NEXT);
|
c = checkDisplayOn(KEY_ENTER);
|
||||||
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
|
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
|
||||||
c = handleLongPress(KEY_ENTER);
|
c = handleLongPress(KEY_ENTER); // REVISIT: could be mapped to different key code
|
||||||
} else if (ev == BUTTON_EVENT_DOUBLE_CLICK) {
|
|
||||||
c = handleDoubleClick(KEY_PREV);
|
|
||||||
} else if (ev == BUTTON_EVENT_TRIPLE_CLICK) {
|
|
||||||
c = handleTripleClick(KEY_SELECT);
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#if defined(WIO_TRACKER_L1)
|
|
||||||
ev = joystick_left.check();
|
ev = joystick_left.check();
|
||||||
if (ev == BUTTON_EVENT_CLICK) {
|
if (ev == BUTTON_EVENT_CLICK) {
|
||||||
c = checkDisplayOn(KEY_LEFT);
|
c = checkDisplayOn(KEY_LEFT);
|
||||||
@@ -685,6 +683,17 @@ void UITask::loop() {
|
|||||||
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
|
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
|
||||||
c = handleLongPress(KEY_RIGHT);
|
c = handleLongPress(KEY_RIGHT);
|
||||||
}
|
}
|
||||||
|
#elif defined(PIN_USER_BTN)
|
||||||
|
int ev = user_btn.check();
|
||||||
|
if (ev == BUTTON_EVENT_CLICK) {
|
||||||
|
c = checkDisplayOn(KEY_NEXT);
|
||||||
|
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
|
||||||
|
c = handleLongPress(KEY_ENTER);
|
||||||
|
} else if (ev == BUTTON_EVENT_DOUBLE_CLICK) {
|
||||||
|
c = handleDoubleClick(KEY_PREV);
|
||||||
|
} else if (ev == BUTTON_EVENT_TRIPLE_CLICK) {
|
||||||
|
c = handleTripleClick(KEY_SELECT);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#if defined(PIN_USER_BTN_ANA)
|
#if defined(PIN_USER_BTN_ANA)
|
||||||
ev = analog_btn.check();
|
ev = analog_btn.check();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#define MULTI_CLICK_WINDOW_MS 280
|
#define MULTI_CLICK_WINDOW_MS 280
|
||||||
|
|
||||||
MomentaryButton::MomentaryButton(int8_t pin, int long_press_millis, bool reverse, bool pulldownup) {
|
MomentaryButton::MomentaryButton(int8_t pin, int long_press_millis, bool reverse, bool pulldownup, bool multiclick) {
|
||||||
_pin = pin;
|
_pin = pin;
|
||||||
_reverse = reverse;
|
_reverse = reverse;
|
||||||
_pull = pulldownup;
|
_pull = pulldownup;
|
||||||
@@ -13,7 +13,7 @@ MomentaryButton::MomentaryButton(int8_t pin, int long_press_millis, bool reverse
|
|||||||
_threshold = 0;
|
_threshold = 0;
|
||||||
_click_count = 0;
|
_click_count = 0;
|
||||||
_last_click_time = 0;
|
_last_click_time = 0;
|
||||||
_multi_click_window = MULTI_CLICK_WINDOW_MS;
|
_multi_click_window = multiclick ? MULTI_CLICK_WINDOW_MS : 0;
|
||||||
_pending_click = false;
|
_pending_click = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class MomentaryButton {
|
|||||||
bool isPressed(int level) const;
|
bool isPressed(int level) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MomentaryButton(int8_t pin, int long_press_mills=0, bool reverse=false, bool pulldownup=false);
|
MomentaryButton(int8_t pin, int long_press_mills=0, bool reverse=false, bool pulldownup=false, bool multiclick=true);
|
||||||
MomentaryButton(int8_t pin, int long_press_mills, int analog_threshold);
|
MomentaryButton(int8_t pin, int long_press_mills, int analog_threshold);
|
||||||
void begin();
|
void begin();
|
||||||
int check(bool repeat_click=false); // returns one of BUTTON_EVENT_*
|
int check(bool repeat_click=false); // returns one of BUTTON_EVENT_*
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ build_flags = ${WioTrackerL1.build_flags}
|
|||||||
-D MAX_CONTACTS=350
|
-D MAX_CONTACTS=350
|
||||||
-D MAX_GROUP_CHANNELS=40
|
-D MAX_GROUP_CHANNELS=40
|
||||||
-D DISPLAY_CLASS=SH1106Display
|
-D DISPLAY_CLASS=SH1106Display
|
||||||
|
-D UI_HAS_JOYSTICK=1
|
||||||
-D OFFLINE_QUEUE_SIZE=256
|
-D OFFLINE_QUEUE_SIZE=256
|
||||||
-D PIN_BUZZER=12
|
-D PIN_BUZZER=12
|
||||||
-D QSPIFLASH=1
|
-D QSPIFLASH=1
|
||||||
@@ -91,6 +92,7 @@ build_flags = ${WioTrackerL1.build_flags}
|
|||||||
-D BLE_DEBUG_LOGGING=1
|
-D BLE_DEBUG_LOGGING=1
|
||||||
-D OFFLINE_QUEUE_SIZE=256
|
-D OFFLINE_QUEUE_SIZE=256
|
||||||
-D DISPLAY_CLASS=SH1106Display
|
-D DISPLAY_CLASS=SH1106Display
|
||||||
|
-D UI_HAS_JOYSTICK=1
|
||||||
-D PIN_BUZZER=12
|
-D PIN_BUZZER=12
|
||||||
-D QSPIFLASH=1
|
-D QSPIFLASH=1
|
||||||
; -D MESH_PACKET_LOGGING=1
|
; -D MESH_PACKET_LOGGING=1
|
||||||
|
|||||||
@@ -21,9 +21,10 @@ EnvironmentSensorManager sensors = EnvironmentSensorManager();
|
|||||||
|
|
||||||
#ifdef DISPLAY_CLASS
|
#ifdef DISPLAY_CLASS
|
||||||
DISPLAY_CLASS display;
|
DISPLAY_CLASS display;
|
||||||
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
|
MomentaryButton user_btn(PIN_USER_BTN, 1000, true, false, false);
|
||||||
MomentaryButton joystick_left(JOYSTICK_LEFT, 1000, true);
|
MomentaryButton joystick_left(JOYSTICK_LEFT, 1000, true, false, false);
|
||||||
MomentaryButton joystick_right(JOYSTICK_RIGHT, 1000, true);
|
MomentaryButton joystick_right(JOYSTICK_RIGHT, 1000, true, false, false);
|
||||||
|
MomentaryButton back_btn(PIN_BACK_BTN, 1000, true, false, false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool radio_init() {
|
bool radio_init() {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ extern EnvironmentSensorManager sensors;
|
|||||||
extern MomentaryButton user_btn;
|
extern MomentaryButton user_btn;
|
||||||
extern MomentaryButton joystick_left;
|
extern MomentaryButton joystick_left;
|
||||||
extern MomentaryButton joystick_right;
|
extern MomentaryButton joystick_right;
|
||||||
|
extern MomentaryButton back_btn;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool radio_init();
|
bool radio_init();
|
||||||
|
|||||||
@@ -31,12 +31,13 @@
|
|||||||
#define PIN_BUTTON4 (27) // Joystick Left
|
#define PIN_BUTTON4 (27) // Joystick Left
|
||||||
#define PIN_BUTTON5 (28) // Joystick Right
|
#define PIN_BUTTON5 (28) // Joystick Right
|
||||||
#define PIN_BUTTON6 (29) // Joystick Press
|
#define PIN_BUTTON6 (29) // Joystick Press
|
||||||
#define PIN_USER_BTN PIN_BUTTON1
|
#define PIN_BACK_BTN PIN_BUTTON1
|
||||||
#define JOYSTICK_UP PIN_BUTTON2
|
#define JOYSTICK_UP PIN_BUTTON2
|
||||||
#define JOYSTICK_DOWN PIN_BUTTON3
|
#define JOYSTICK_DOWN PIN_BUTTON3
|
||||||
#define JOYSTICK_LEFT PIN_BUTTON4
|
#define JOYSTICK_LEFT PIN_BUTTON4
|
||||||
#define JOYSTICK_RIGHT PIN_BUTTON5
|
#define JOYSTICK_RIGHT PIN_BUTTON5
|
||||||
#define JOYSTICK_PRESS PIN_BUTTON6
|
#define JOYSTICK_PRESS PIN_BUTTON6
|
||||||
|
#define PIN_USER_BTN PIN_BUTTON6
|
||||||
|
|
||||||
// Buzzer
|
// Buzzer
|
||||||
// #define PIN_BUZZER (12) // Buzzer pin (defined per firmware type)
|
// #define PIN_BUZZER (12) // Buzzer pin (defined per firmware type)
|
||||||
|
|||||||
Reference in New Issue
Block a user