mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
commit
b863a1a673
11 changed files with 51 additions and 13 deletions
|
|
@ -8,11 +8,11 @@
|
||||||
#define FIRMWARE_VER_CODE 7
|
#define FIRMWARE_VER_CODE 7
|
||||||
|
|
||||||
#ifndef FIRMWARE_BUILD_DATE
|
#ifndef FIRMWARE_BUILD_DATE
|
||||||
#define FIRMWARE_BUILD_DATE "31 Aug 2025"
|
#define FIRMWARE_BUILD_DATE "1 Sep 2025"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FIRMWARE_VERSION
|
#ifndef FIRMWARE_VERSION
|
||||||
#define FIRMWARE_VERSION "v1.8.0"
|
#define FIRMWARE_VERSION "v1.8.1"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||||
|
|
|
||||||
|
|
@ -354,6 +354,9 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no
|
||||||
#if defined(PIN_USER_BTN)
|
#if defined(PIN_USER_BTN)
|
||||||
user_btn.begin();
|
user_btn.begin();
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(PIN_USER_BTN_ANA)
|
||||||
|
analog_btn.begin();
|
||||||
|
#endif
|
||||||
|
|
||||||
_node_prefs = node_prefs;
|
_node_prefs = node_prefs;
|
||||||
if (_display != NULL) {
|
if (_display != NULL) {
|
||||||
|
|
@ -508,6 +511,14 @@ void UITask::loop() {
|
||||||
c = handleLongPress(KEY_RIGHT);
|
c = handleLongPress(KEY_RIGHT);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(PIN_USER_BTN_ANA)
|
||||||
|
ev = analog_btn.check();
|
||||||
|
if (ev == BUTTON_EVENT_CLICK) {
|
||||||
|
c = checkDisplayOn(KEY_SELECT);
|
||||||
|
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
|
||||||
|
c = handleLongPress(KEY_ENTER);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (c != 0 && curr) {
|
if (c != 0 && curr) {
|
||||||
curr->handleInput(c);
|
curr->handleInput(c);
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,11 @@
|
||||||
/* ------------------------------ Config -------------------------------- */
|
/* ------------------------------ Config -------------------------------- */
|
||||||
|
|
||||||
#ifndef FIRMWARE_BUILD_DATE
|
#ifndef FIRMWARE_BUILD_DATE
|
||||||
#define FIRMWARE_BUILD_DATE "31 Aug 2025"
|
#define FIRMWARE_BUILD_DATE "1 Sep 2025"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FIRMWARE_VERSION
|
#ifndef FIRMWARE_VERSION
|
||||||
#define FIRMWARE_VERSION "v1.8.0"
|
#define FIRMWARE_VERSION "v1.8.1"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef LORA_FREQ
|
#ifndef LORA_FREQ
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,11 @@
|
||||||
/* ------------------------------ Config -------------------------------- */
|
/* ------------------------------ Config -------------------------------- */
|
||||||
|
|
||||||
#ifndef FIRMWARE_BUILD_DATE
|
#ifndef FIRMWARE_BUILD_DATE
|
||||||
#define FIRMWARE_BUILD_DATE "31 Aug 2025"
|
#define FIRMWARE_BUILD_DATE "1 Sep 2025"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FIRMWARE_VERSION
|
#ifndef FIRMWARE_VERSION
|
||||||
#define FIRMWARE_VERSION "v1.8.0"
|
#define FIRMWARE_VERSION "v1.8.1"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef LORA_FREQ
|
#ifndef LORA_FREQ
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,11 @@ struct ContactInfo {
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef FIRMWARE_BUILD_DATE
|
#ifndef FIRMWARE_BUILD_DATE
|
||||||
#define FIRMWARE_BUILD_DATE "31 Aug 2025"
|
#define FIRMWARE_BUILD_DATE "1 Sep 2025"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FIRMWARE_VERSION
|
#ifndef FIRMWARE_VERSION
|
||||||
#define FIRMWARE_VERSION "v1.8.0"
|
#define FIRMWARE_VERSION "v1.8.1"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FIRMWARE_ROLE "sensor"
|
#define FIRMWARE_ROLE "sensor"
|
||||||
|
|
|
||||||
|
|
@ -8,16 +8,29 @@ MomentaryButton::MomentaryButton(int8_t pin, int long_press_millis, bool reverse
|
||||||
prev = _reverse ? HIGH : LOW;
|
prev = _reverse ? HIGH : LOW;
|
||||||
cancel = 0;
|
cancel = 0;
|
||||||
_long_millis = long_press_millis;
|
_long_millis = long_press_millis;
|
||||||
|
_threshold = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
MomentaryButton::MomentaryButton(int8_t pin, int long_press_millis, int analog_threshold) {
|
||||||
|
_pin = pin;
|
||||||
|
_reverse = false;
|
||||||
|
_pull = false;
|
||||||
|
down_at = 0;
|
||||||
|
prev = LOW;
|
||||||
|
cancel = 0;
|
||||||
|
_long_millis = long_press_millis;
|
||||||
|
_threshold = analog_threshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MomentaryButton::begin() {
|
void MomentaryButton::begin() {
|
||||||
if (_pin >= 0) {
|
if (_pin >= 0 && _threshold == 0) {
|
||||||
pinMode(_pin, _pull ? (_reverse ? INPUT_PULLUP : INPUT_PULLDOWN) : INPUT);
|
pinMode(_pin, _pull ? (_reverse ? INPUT_PULLUP : INPUT_PULLDOWN) : INPUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MomentaryButton::isPressed() const {
|
bool MomentaryButton::isPressed() const {
|
||||||
return isPressed(digitalRead(_pin));
|
int btn = _threshold > 0 ? (analogRead(_pin) < _threshold) : digitalRead(_pin);
|
||||||
|
return isPressed(btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MomentaryButton::cancelClick() {
|
void MomentaryButton::cancelClick() {
|
||||||
|
|
@ -25,6 +38,9 @@ void MomentaryButton::cancelClick() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MomentaryButton::isPressed(int level) const {
|
bool MomentaryButton::isPressed(int level) const {
|
||||||
|
if (_threshold > 0) {
|
||||||
|
return level;
|
||||||
|
}
|
||||||
if (_reverse) {
|
if (_reverse) {
|
||||||
return level == LOW;
|
return level == LOW;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -36,7 +52,7 @@ int MomentaryButton::check(bool repeat_click) {
|
||||||
if (_pin < 0) return BUTTON_EVENT_NONE;
|
if (_pin < 0) return BUTTON_EVENT_NONE;
|
||||||
|
|
||||||
int event = BUTTON_EVENT_NONE;
|
int event = BUTTON_EVENT_NONE;
|
||||||
int btn = digitalRead(_pin);
|
int btn = _threshold > 0 ? (analogRead(_pin) < _threshold) : digitalRead(_pin);
|
||||||
if (btn != prev) {
|
if (btn != prev) {
|
||||||
if (isPressed(btn)) {
|
if (isPressed(btn)) {
|
||||||
down_at = millis();
|
down_at = millis();
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,14 @@ class MomentaryButton {
|
||||||
int8_t prev, cancel;
|
int8_t prev, cancel;
|
||||||
bool _reverse, _pull;
|
bool _reverse, _pull;
|
||||||
int _long_millis;
|
int _long_millis;
|
||||||
|
int _threshold; // analog mode
|
||||||
unsigned long down_at;
|
unsigned long down_at;
|
||||||
|
|
||||||
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);
|
||||||
|
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_*
|
||||||
void cancelClick(); // suppress next BUTTON_EVENT_CLICK (if already in DOWN state)
|
void cancelClick(); // suppress next BUTTON_EVENT_CLICK (if already in DOWN state)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ build_flags =
|
||||||
-D PIN_VEXT_EN=36
|
-D PIN_VEXT_EN=36
|
||||||
-D SX126X_DIO2_AS_RF_SWITCH=true
|
-D SX126X_DIO2_AS_RF_SWITCH=true
|
||||||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
||||||
-D SX126X_CURRENT_LIMIT=160
|
-D SX126X_CURRENT_LIMIT=140
|
||||||
-D SX126X_RX_BOOSTED_GAIN=1
|
-D SX126X_RX_BOOSTED_GAIN=1
|
||||||
-D PIN_GPS_RX=47
|
-D PIN_GPS_RX=47
|
||||||
-D PIN_GPS_TX=48
|
-D PIN_GPS_TX=48
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,8 @@ extends = Meshadventurer
|
||||||
build_src_filter = ${Meshadventurer.build_src_filter}
|
build_src_filter = ${Meshadventurer.build_src_filter}
|
||||||
+<../examples/companion_radio/*.cpp>
|
+<../examples/companion_radio/*.cpp>
|
||||||
+<helpers/ui/SSD1306Display.cpp>
|
+<helpers/ui/SSD1306Display.cpp>
|
||||||
|
+<../examples/companion_radio/*.cpp>
|
||||||
|
+<../examples/companion_radio/ui-new/*.cpp>
|
||||||
build_flags =
|
build_flags =
|
||||||
${Meshadventurer.build_flags}
|
${Meshadventurer.build_flags}
|
||||||
-I examples/companion_radio/ui-new
|
-I examples/companion_radio/ui-new
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,11 @@ RAK4631Board board;
|
||||||
|
|
||||||
#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, true);
|
||||||
|
|
||||||
|
#if defined(PIN_USER_BTN_ANA)
|
||||||
|
MomentaryButton analog_btn(PIN_USER_BTN_ANA, 1000, 20);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
|
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,9 @@
|
||||||
extern DISPLAY_CLASS display;
|
extern DISPLAY_CLASS display;
|
||||||
#include <helpers/ui/MomentaryButton.h>
|
#include <helpers/ui/MomentaryButton.h>
|
||||||
extern MomentaryButton user_btn;
|
extern MomentaryButton user_btn;
|
||||||
|
#if defined(PIN_USER_BTN_ANA)
|
||||||
|
extern MomentaryButton analog_btn;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern RAK4631Board board;
|
extern RAK4631Board board;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue