Skip to content

Commit b863a1a

Browse files
authored
Merge pull request #6 from Quency-D/dev
merge Dev
2 parents ee194a7 + 637891b commit b863a1a

File tree

11 files changed

+51
-13
lines changed

11 files changed

+51
-13
lines changed

examples/companion_radio/MyMesh.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
#define FIRMWARE_VER_CODE 7
99

1010
#ifndef FIRMWARE_BUILD_DATE
11-
#define FIRMWARE_BUILD_DATE "31 Aug 2025"
11+
#define FIRMWARE_BUILD_DATE "1 Sep 2025"
1212
#endif
1313

1414
#ifndef FIRMWARE_VERSION
15-
#define FIRMWARE_VERSION "v1.8.0"
15+
#define FIRMWARE_VERSION "v1.8.1"
1616
#endif
1717

1818
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)

examples/companion_radio/ui-new/UITask.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no
354354
#if defined(PIN_USER_BTN)
355355
user_btn.begin();
356356
#endif
357+
#if defined(PIN_USER_BTN_ANA)
358+
analog_btn.begin();
359+
#endif
357360

358361
_node_prefs = node_prefs;
359362
if (_display != NULL) {
@@ -508,6 +511,14 @@ void UITask::loop() {
508511
c = handleLongPress(KEY_RIGHT);
509512
}
510513
#endif
514+
#if defined(PIN_USER_BTN_ANA)
515+
ev = analog_btn.check();
516+
if (ev == BUTTON_EVENT_CLICK) {
517+
c = checkDisplayOn(KEY_SELECT);
518+
} else if (ev == BUTTON_EVENT_LONG_PRESS) {
519+
c = handleLongPress(KEY_ENTER);
520+
}
521+
#endif
511522

512523
if (c != 0 && curr) {
513524
curr->handleInput(c);

examples/simple_repeater/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
/* ------------------------------ Config -------------------------------- */
2323

2424
#ifndef FIRMWARE_BUILD_DATE
25-
#define FIRMWARE_BUILD_DATE "31 Aug 2025"
25+
#define FIRMWARE_BUILD_DATE "1 Sep 2025"
2626
#endif
2727

2828
#ifndef FIRMWARE_VERSION
29-
#define FIRMWARE_VERSION "v1.8.0"
29+
#define FIRMWARE_VERSION "v1.8.1"
3030
#endif
3131

3232
#ifndef LORA_FREQ

examples/simple_room_server/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
/* ------------------------------ Config -------------------------------- */
2323

2424
#ifndef FIRMWARE_BUILD_DATE
25-
#define FIRMWARE_BUILD_DATE "31 Aug 2025"
25+
#define FIRMWARE_BUILD_DATE "1 Sep 2025"
2626
#endif
2727

2828
#ifndef FIRMWARE_VERSION
29-
#define FIRMWARE_VERSION "v1.8.0"
29+
#define FIRMWARE_VERSION "v1.8.1"
3030
#endif
3131

3232
#ifndef LORA_FREQ

examples/simple_sensor/SensorMesh.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ struct ContactInfo {
4949
};
5050

5151
#ifndef FIRMWARE_BUILD_DATE
52-
#define FIRMWARE_BUILD_DATE "31 Aug 2025"
52+
#define FIRMWARE_BUILD_DATE "1 Sep 2025"
5353
#endif
5454

5555
#ifndef FIRMWARE_VERSION
56-
#define FIRMWARE_VERSION "v1.8.0"
56+
#define FIRMWARE_VERSION "v1.8.1"
5757
#endif
5858

5959
#define FIRMWARE_ROLE "sensor"

src/helpers/ui/MomentaryButton.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,39 @@ MomentaryButton::MomentaryButton(int8_t pin, int long_press_millis, bool reverse
88
prev = _reverse ? HIGH : LOW;
99
cancel = 0;
1010
_long_millis = long_press_millis;
11+
_threshold = 0;
12+
}
13+
14+
MomentaryButton::MomentaryButton(int8_t pin, int long_press_millis, int analog_threshold) {
15+
_pin = pin;
16+
_reverse = false;
17+
_pull = false;
18+
down_at = 0;
19+
prev = LOW;
20+
cancel = 0;
21+
_long_millis = long_press_millis;
22+
_threshold = analog_threshold;
1123
}
1224

1325
void MomentaryButton::begin() {
14-
if (_pin >= 0) {
26+
if (_pin >= 0 && _threshold == 0) {
1527
pinMode(_pin, _pull ? (_reverse ? INPUT_PULLUP : INPUT_PULLDOWN) : INPUT);
1628
}
1729
}
1830

1931
bool MomentaryButton::isPressed() const {
20-
return isPressed(digitalRead(_pin));
32+
int btn = _threshold > 0 ? (analogRead(_pin) < _threshold) : digitalRead(_pin);
33+
return isPressed(btn);
2134
}
2235

2336
void MomentaryButton::cancelClick() {
2437
cancel = 1;
2538
}
2639

2740
bool MomentaryButton::isPressed(int level) const {
41+
if (_threshold > 0) {
42+
return level;
43+
}
2844
if (_reverse) {
2945
return level == LOW;
3046
} else {
@@ -36,7 +52,7 @@ int MomentaryButton::check(bool repeat_click) {
3652
if (_pin < 0) return BUTTON_EVENT_NONE;
3753

3854
int event = BUTTON_EVENT_NONE;
39-
int btn = digitalRead(_pin);
55+
int btn = _threshold > 0 ? (analogRead(_pin) < _threshold) : digitalRead(_pin);
4056
if (btn != prev) {
4157
if (isPressed(btn)) {
4258
down_at = millis();

src/helpers/ui/MomentaryButton.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ class MomentaryButton {
1111
int8_t prev, cancel;
1212
bool _reverse, _pull;
1313
int _long_millis;
14+
int _threshold; // analog mode
1415
unsigned long down_at;
1516

1617
bool isPressed(int level) const;
1718

1819
public:
1920
MomentaryButton(int8_t pin, int long_press_mills=0, bool reverse=false, bool pulldownup=false);
21+
MomentaryButton(int8_t pin, int long_press_mills, int analog_threshold);
2022
void begin();
2123
int check(bool repeat_click=false); // returns one of BUTTON_EVENT_*
2224
void cancelClick(); // suppress next BUTTON_EVENT_CLICK (if already in DOWN state)

variants/heltec_v3/platformio.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ build_flags =
1717
-D PIN_VEXT_EN=36
1818
-D SX126X_DIO2_AS_RF_SWITCH=true
1919
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
20-
-D SX126X_CURRENT_LIMIT=160
20+
-D SX126X_CURRENT_LIMIT=140
2121
-D SX126X_RX_BOOSTED_GAIN=1
2222
-D PIN_GPS_RX=47
2323
-D PIN_GPS_TX=48

variants/meshadventurer/platformio.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ extends = Meshadventurer
8080
build_src_filter = ${Meshadventurer.build_src_filter}
8181
+<../examples/companion_radio/*.cpp>
8282
+<helpers/ui/SSD1306Display.cpp>
83+
+<../examples/companion_radio/*.cpp>
84+
+<../examples/companion_radio/ui-new/*.cpp>
8385
build_flags =
8486
${Meshadventurer.build_flags}
8587
-I examples/companion_radio/ui-new

variants/rak4631/target.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ RAK4631Board board;
1010

1111
#ifdef DISPLAY_CLASS
1212
DISPLAY_CLASS display;
13-
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
13+
MomentaryButton user_btn(PIN_USER_BTN, 1000, true, true);
14+
15+
#if defined(PIN_USER_BTN_ANA)
16+
MomentaryButton analog_btn(PIN_USER_BTN_ANA, 1000, 20);
17+
#endif
1418
#endif
1519

1620
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);

0 commit comments

Comments
 (0)