mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-26 01:52:48 +00:00
Improved button-click accuracy (#3188)
* IRQ triggers button fsm * revert change that causes raspbian compile-error
This commit is contained in:
parent
8130b1cf43
commit
54e52ae05f
@ -9,6 +9,7 @@
|
|||||||
"f_cpu": "64000000L",
|
"f_cpu": "64000000L",
|
||||||
"hwids": [
|
"hwids": [
|
||||||
["0x239A", "0x4405"],
|
["0x239A", "0x4405"],
|
||||||
|
["0x239A", "0x0029"],
|
||||||
["0x239A", "0x002A"]
|
["0x239A", "0x002A"]
|
||||||
],
|
],
|
||||||
"usb_product": "TTGO_eink",
|
"usb_product": "TTGO_eink",
|
||||||
|
@ -54,15 +54,18 @@ class ButtonThread : public concurrency::OSThread
|
|||||||
if (settingsMap.count(user) != 0 && settingsMap[user] != RADIOLIB_NC)
|
if (settingsMap.count(user) != 0 && settingsMap[user] != RADIOLIB_NC)
|
||||||
userButton = OneButton(settingsMap[user], true, true);
|
userButton = OneButton(settingsMap[user], true, true);
|
||||||
#elif defined(BUTTON_PIN)
|
#elif defined(BUTTON_PIN)
|
||||||
|
int pin = config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN;
|
||||||
userButton = OneButton(config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN, true, true);
|
userButton = OneButton(pin, true, true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef INPUT_PULLUP_SENSE
|
#ifdef INPUT_PULLUP_SENSE
|
||||||
// Some platforms (nrf52) have a SENSE variant which allows wake from sleep - override what OneButton did
|
// Some platforms (nrf52) have a SENSE variant which allows wake from sleep - override what OneButton did
|
||||||
pinMode(config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN, INPUT_PULLUP_SENSE);
|
pinMode(pin, INPUT_PULLUP_SENSE);
|
||||||
#endif
|
#endif
|
||||||
userButton.attachClick(userButtonPressed);
|
userButton.attachClick(userButtonPressed);
|
||||||
userButton.setClickMs(300);
|
userButton.setClickMs(400);
|
||||||
|
userButton.setPressMs(1000);
|
||||||
|
userButton.setDebounceMs(10);
|
||||||
userButton.attachDuringLongPress(userButtonPressedLong);
|
userButton.attachDuringLongPress(userButtonPressedLong);
|
||||||
userButton.attachDoubleClick(userButtonDoublePressed);
|
userButton.attachDoubleClick(userButtonDoublePressed);
|
||||||
userButton.attachMultiClick(userButtonMultiPressed);
|
userButton.attachMultiClick(userButtonMultiPressed);
|
||||||
@ -72,7 +75,15 @@ class ButtonThread : public concurrency::OSThread
|
|||||||
if (settingsMap.count(user) != 0 && settingsMap[user] != RADIOLIB_NC)
|
if (settingsMap.count(user) != 0 && settingsMap[user] != RADIOLIB_NC)
|
||||||
wakeOnIrq(settingsMap[user], FALLING);
|
wakeOnIrq(settingsMap[user], FALLING);
|
||||||
#else
|
#else
|
||||||
wakeOnIrq(config.device.button_gpio ? config.device.button_gpio : BUTTON_PIN, FALLING);
|
static OneButton *pBtn = &userButton; // only one instance of ButtonThread is created, so static is safe
|
||||||
|
attachInterrupt(
|
||||||
|
pin,
|
||||||
|
[]() {
|
||||||
|
BaseType_t higherWake = 0;
|
||||||
|
mainDelay.interruptFromISR(&higherWake);
|
||||||
|
pBtn->tick();
|
||||||
|
},
|
||||||
|
CHANGE);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef BUTTON_PIN_ALT
|
#ifdef BUTTON_PIN_ALT
|
||||||
@ -194,6 +205,7 @@ class ButtonThread : public concurrency::OSThread
|
|||||||
{
|
{
|
||||||
if (!config.device.disable_triple_click && (gps != nullptr)) {
|
if (!config.device.disable_triple_click && (gps != nullptr)) {
|
||||||
gps->toggleGpsMode();
|
gps->toggleGpsMode();
|
||||||
|
screen->forceDisplay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ debug_tool = jlink
|
|||||||
|
|
||||||
# add -DCFG_SYSVIEW if you want to use the Segger systemview tool for OS profiling.
|
# add -DCFG_SYSVIEW if you want to use the Segger systemview tool for OS profiling.
|
||||||
build_flags = ${nrf52840_base.build_flags} -Ivariants/t-echo
|
build_flags = ${nrf52840_base.build_flags} -Ivariants/t-echo
|
||||||
|
-DGPS_POWER_TOGGLE
|
||||||
-L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard"
|
-L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard"
|
||||||
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/t-echo>
|
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/t-echo>
|
||||||
lib_deps =
|
lib_deps =
|
||||||
|
Loading…
Reference in New Issue
Block a user