mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-11-01 10:21:59 +00:00
Add files via upload
keypad improvements
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "SimpsonKeypad.h"
|
||||
|
||||
static const uint32_t SIMPSON_LONG_PRESS_MS = 1200;
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
namespace {
|
||||
@@ -55,12 +57,32 @@ uint8_t SimpsonKeypad::poll() {
|
||||
uint8_t key = _keypad.getChar();
|
||||
if (key == I2C_KEYPAD_THRESHOLD) return SIMPSON_KEY_NONE;
|
||||
if (key == SIMPSON_KEY_NONE) {
|
||||
if (_last_key == SIMPSON_KEY_ENTER && !_enter_long_sent) {
|
||||
_last_key = SIMPSON_KEY_NONE;
|
||||
_enter_pressed_at = 0;
|
||||
return SIMPSON_KEY_ENTER;
|
||||
}
|
||||
_last_key = SIMPSON_KEY_NONE;
|
||||
_enter_pressed_at = 0;
|
||||
_enter_long_sent = false;
|
||||
return SIMPSON_KEY_NONE;
|
||||
}
|
||||
if (key == SIMPSON_KEY_ENTER && _last_key == SIMPSON_KEY_ENTER) {
|
||||
if (!_enter_long_sent && millis() - _enter_pressed_at >= SIMPSON_LONG_PRESS_MS) {
|
||||
_enter_long_sent = true;
|
||||
return SIMPSON_KEY_ENTER_LONG;
|
||||
}
|
||||
return SIMPSON_KEY_NONE;
|
||||
}
|
||||
if (key == _last_key) return SIMPSON_KEY_NONE;
|
||||
_last_key = key;
|
||||
|
||||
if (key == SIMPSON_KEY_ENTER) {
|
||||
_enter_pressed_at = millis();
|
||||
_enter_long_sent = false;
|
||||
return SIMPSON_KEY_NONE;
|
||||
}
|
||||
|
||||
if (key == SIMPSON_KEY_FN) {
|
||||
_mode = static_cast<SimpsonKeypadMode>((_mode + 1) % 4);
|
||||
loadModeMap();
|
||||
|
||||
@@ -30,13 +30,16 @@ enum SimpsonKeypadKey : uint8_t {
|
||||
SIMPSON_KEY_FN,
|
||||
SIMPSON_KEY_GPS,
|
||||
SIMPSON_KEY_BACKSPACE,
|
||||
SIMPSON_KEY_MODE_CHANGED
|
||||
SIMPSON_KEY_MODE_CHANGED,
|
||||
SIMPSON_KEY_ENTER_LONG
|
||||
};
|
||||
|
||||
class SimpsonKeypad {
|
||||
I2CKeyPad _keypad;
|
||||
SimpsonKeypadMode _mode = SIMPSON_KEYPAD_CONTROL;
|
||||
uint8_t _last_key = SIMPSON_KEY_NONE;
|
||||
uint32_t _enter_pressed_at = 0;
|
||||
bool _enter_long_sent = false;
|
||||
bool _ready = false;
|
||||
|
||||
void loadModeMap();
|
||||
|
||||
@@ -11,6 +11,7 @@ build_flags = ${Promicro.build_flags}
|
||||
-D ADC_MULTIPLIER=1.71
|
||||
-D SIMPSON_KEYPAD_ADDR=0x20
|
||||
-D DISPLAY_ROTATION=2
|
||||
-D ENV_INCLUDE_GPS=1
|
||||
-D ENV_SKIP_GPS_DETECT
|
||||
build_src_filter = ${nrf52_base.build_src_filter}
|
||||
+<helpers/sensors>
|
||||
|
||||
Reference in New Issue
Block a user