Skip to content

Commit 4449fd3

Browse files
author
Scott Powell
committed
Merge branch 'dev'
2 parents a29b099 + 0bad7ee commit 4449fd3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1904
-355
lines changed

boards/nano-g2-ultra.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"build": {
3+
"arduino": {
4+
"ldscript": "nrf52840_s140_v6.ld"
5+
},
6+
"core": "nRF5",
7+
"cpu": "cortex-m4",
8+
"extra_flags": "-DARDUINO_NRF52840_FEATHER -DNRF52840_XXAA",
9+
"f_cpu": "64000000L",
10+
"hwids": [
11+
[
12+
"0x239A",
13+
"0x8029"
14+
],
15+
[
16+
"0x239A",
17+
"0x0029"
18+
],
19+
[
20+
"0x239A",
21+
"0x002A"
22+
],
23+
[
24+
"0x239A",
25+
"0x802A"
26+
]
27+
],
28+
"usb_product": "BQ nRF52840",
29+
"mcu": "nrf52840",
30+
"variant": "nano-g2-ultra",
31+
"bsp": {
32+
"name": "adafruit"
33+
},
34+
"softdevice": {
35+
"sd_flags": "-DS140",
36+
"sd_name": "s140",
37+
"sd_version": "6.1.1",
38+
"sd_fwid": "0x00B6"
39+
},
40+
"bootloader": {
41+
"settings_addr": "0xFF000"
42+
}
43+
},
44+
"connectivity": [
45+
"bluetooth"
46+
],
47+
"debug": {
48+
"jlink_device": "nRF52840_xxAA",
49+
"svd_path": "nrf52840.svd"
50+
},
51+
"frameworks": [
52+
"arduino"
53+
],
54+
"name": "BQ nRF52840",
55+
"upload": {
56+
"maximum_ram_size": 248832,
57+
"maximum_size": 815104,
58+
"speed": 115200,
59+
"protocol": "nrfutil",
60+
"protocols": [
61+
"jlink",
62+
"nrfjprog",
63+
"nrfutil",
64+
"stlink"
65+
],
66+
"use_1200bps_touch": true,
67+
"require_upload_port": true,
68+
"wait_for_upload_port": true
69+
},
70+
"url": "https://wiki.uniteng.com/en/meshtastic/nano-g2-ultra",
71+
"vendor": "BQ Consulting"
72+
}

boards/rak3172.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"build": {
3+
"arduino": {
4+
"variant_h": "variant_RAK3172_MODULE.h"
5+
},
6+
"core": "stm32",
7+
"cpu": "cortex-m4",
8+
"extra_flags": "-DSTM32WL -DSTM32WLxx -DSTM32WLE5xx",
9+
"framework_extra_flags": {
10+
"arduino": "-DUSE_CM4_STARTUP_FILE -DARDUINO_RAK3172_MODULE"
11+
},
12+
"f_cpu": "48000000L",
13+
"mcu": "stm32wle5ccu",
14+
"product_line": "STM32WLE5xx",
15+
"variant": "STM32WLxx/WL54CCU_WL55CCU_WLE4C(8-B-C)U_WLE5C(8-B-C)U"
16+
},
17+
"debug": {
18+
"default_tools": ["stlink"],
19+
"jlink_device": "STM32WLE5CC",
20+
"openocd_target": "stm32wlx",
21+
"svd_path": "STM32WLE5_CM4.svd"
22+
},
23+
"frameworks": ["arduino"],
24+
"name": "BB-STM32WL",
25+
"upload": {
26+
"maximum_ram_size": 65536,
27+
"maximum_size": 262144,
28+
"protocol": "stlink",
29+
"protocols": ["stlink", "jlink"]
30+
},
31+
"url": "https://store.rakwireless.com/products/wisduo-lpwan-module-rak3172",
32+
"vendor": "RAK"
33+
}

examples/companion_radio/NodePrefs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ struct NodePrefs { // persisted to file
1919
uint8_t tx_power_dbm;
2020
uint8_t telemetry_mode_base;
2121
uint8_t telemetry_mode_loc;
22+
uint8_t telemetry_mode_env;
2223
float rx_delay_base;
2324
uint32_t ble_pin;
2425
};

examples/companion_radio/UITask.cpp

Lines changed: 71 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,31 @@ void UITask::begin(DisplayDriver* display, NodePrefs* node_prefs, const char* bu
5353

5454
// v1.2.3 (1 Jan 2025)
5555
sprintf(_version_info, "%s (%s)", version, build_date);
56+
57+
#ifdef PIN_BUZZER
58+
buzzer.begin();
59+
#endif
60+
}
61+
62+
void UITask::soundBuzzer(UIEventType bet) {
63+
#if defined(PIN_BUZZER)
64+
switch(bet){
65+
case UIEventType::contactMessage:
66+
// gemini's pick
67+
buzzer.play("MsgRcv3:d=4,o=6,b=200:32e,32g,32b,16c7");
68+
break;
69+
case UIEventType::channelMessage:
70+
buzzer.play("kerplop:d=16,o=6,b=120:32g#,32c#");
71+
break;
72+
case UIEventType::roomMessage:
73+
case UIEventType::newContactMessage:
74+
case UIEventType::none:
75+
default:
76+
break;
77+
}
78+
#endif
79+
// Serial.print("DBG: Buzzzzzz -> ");
80+
// Serial.println((int) bet);
5681
}
5782

5883
void UITask::msgRead(int msgcount) {
@@ -85,7 +110,7 @@ void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, i
85110
}
86111
}
87112

88-
void renderBatteryIndicator(DisplayDriver* _display, uint16_t batteryMilliVolts) {
113+
void UITask::renderBatteryIndicator(uint16_t batteryMilliVolts) {
89114
// Convert millivolts to percentage
90115
const int minMilliVolts = 3000; // Minimum voltage (e.g., 3.0V)
91116
const int maxMilliVolts = 4200; // Maximum voltage (e.g., 4.2V)
@@ -107,8 +132,8 @@ void renderBatteryIndicator(DisplayDriver* _display, uint16_t batteryMilliVolts)
107132
_display->fillRect(iconX + iconWidth, iconY + (iconHeight / 4), 3, iconHeight / 2);
108133

109134
// fill the battery based on the percentage
110-
int fillWidth = (batteryPercentage * (iconWidth - 2)) / 100;
111-
_display->fillRect(iconX + 1, iconY + 1, fillWidth, iconHeight - 2);
135+
int fillWidth = (batteryPercentage * (iconWidth - 4)) / 100;
136+
_display->fillRect(iconX + 2, iconY + 2, fillWidth, iconHeight - 4);
112137
}
113138

114139
void UITask::renderCurrScreen() {
@@ -155,7 +180,7 @@ void UITask::renderCurrScreen() {
155180
_display->print(_node_prefs->node_name);
156181

157182
// battery voltage
158-
renderBatteryIndicator(_display, _board->getBattMilliVolts());
183+
renderBatteryIndicator(_board->getBattMilliVolts());
159184

160185
// freq / sf
161186
_display->setCursor(0, 20);
@@ -209,45 +234,58 @@ void UITask::userLedHandler() {
209234
}
210235

211236
void UITask::buttonHandler() {
212-
#ifdef PIN_USER_BTN
213-
static int prev_btn_state = !USER_BTN_PRESSED;
214-
static unsigned long btn_state_change_time = 0;
215-
static unsigned long next_read = 0;
216-
int cur_time = millis();
217-
if (cur_time >= next_read) {
218-
int btn_state = digitalRead(PIN_USER_BTN);
219-
if (btn_state != prev_btn_state) {
220-
if (btn_state == USER_BTN_PRESSED) { // pressed?
221-
if (_display != NULL) {
222-
if (_display->isOn()) {
223-
clearMsgPreview();
224-
} else {
225-
_display->turnOn();
226-
_need_refresh = true;
237+
#if defined(PIN_USER_BTN) || defined(PIN_USER_BTN_ANA)
238+
static int prev_btn_state = !USER_BTN_PRESSED;
239+
static int prev_btn_state_ana = !USER_BTN_PRESSED;
240+
static unsigned long btn_state_change_time = 0;
241+
static unsigned long next_read = 0;
242+
int cur_time = millis();
243+
if (cur_time >= next_read) {
244+
int btn_state = 0;
245+
int btn_state_ana = 0;
246+
#ifdef PIN_USER_BTN
247+
btn_state = digitalRead(PIN_USER_BTN);
248+
#endif
249+
#ifdef PIN_USER_BTN_ANA
250+
btn_state_ana = (analogRead(PIN_USER_BTN_ANA) < 20); // analogRead returns a value hopefully below 20 when button is pressed.
251+
#endif
252+
if (btn_state != prev_btn_state || btn_state_ana != prev_btn_state_ana) { // check for either digital or analogue button change of state
253+
if (btn_state == USER_BTN_PRESSED || btn_state_ana == USER_BTN_PRESSED) { // pressed?
254+
if (_display != NULL) {
255+
if (_display->isOn()) {
256+
clearMsgPreview();
257+
} else {
258+
_display->turnOn();
259+
_need_refresh = true;
260+
}
261+
_auto_off = cur_time + AUTO_OFF_MILLIS; // extend auto-off timer
262+
}
263+
} else { // unpressed ? check pressed time ...
264+
if ((cur_time - btn_state_change_time) > 5000) {
265+
#ifdef PIN_STATUS_LED
266+
digitalWrite(PIN_STATUS_LED, LOW);
267+
delay(10);
268+
#endif
269+
_board->powerOff();
227270
}
228-
_auto_off = cur_time + AUTO_OFF_MILLIS; // extend auto-off timer
229-
}
230-
} else { // unpressed ? check pressed time ...
231-
if ((cur_time - btn_state_change_time) > 5000) {
232-
#ifdef PIN_STATUS_LED
233-
digitalWrite(PIN_STATUS_LED, LOW);
234-
delay(10);
235-
#endif
236-
_board->powerOff();
237271
}
272+
btn_state_change_time = millis();
273+
prev_btn_state = btn_state;
274+
prev_btn_state_ana = btn_state_ana;
238275
}
239-
btn_state_change_time = millis();
240-
prev_btn_state = btn_state;
276+
next_read = millis() + 100; // 10 reads per second
241277
}
242-
next_read = millis() + 100; // 10 reads per second
278+
#endif
243279
}
244-
#endif
245-
}
246280

247281
void UITask::loop() {
248282
buttonHandler();
249283
userLedHandler();
250284

285+
#ifdef PIN_BUZZER
286+
if (buzzer.isPlaying()) buzzer.loop();
287+
#endif
288+
251289
if (_display != NULL && _display->isOn()) {
252290
static bool _firstBoot = true;
253291
if(_firstBoot && millis() >= BOOT_SCREEN_MILLIS) {

examples/companion_radio/UITask.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,27 @@
44
#include <helpers/ui/DisplayDriver.h>
55
#include <stddef.h>
66

7+
#ifdef PIN_BUZZER
8+
#include <helpers/ui/buzzer.h>
9+
#endif
10+
711
#include "NodePrefs.h"
812

13+
enum class UIEventType
14+
{
15+
none,
16+
contactMessage,
17+
channelMessage,
18+
roomMessage,
19+
newContactMessage
20+
};
21+
922
class UITask {
1023
DisplayDriver* _display;
1124
mesh::MainBoard* _board;
25+
#ifdef PIN_BUZZER
26+
genericBuzzer buzzer;
27+
#endif
1228
unsigned long _next_refresh, _auto_off;
1329
bool _connected;
1430
uint32_t _pin_code;
@@ -22,7 +38,9 @@ class UITask {
2238
void renderCurrScreen();
2339
void buttonHandler();
2440
void userLedHandler();
41+
void renderBatteryIndicator(uint16_t batteryMilliVolts);
2542

43+
2644
public:
2745

2846
UITask(mesh::MainBoard* board) : _board(board), _display(NULL) {
@@ -36,5 +54,6 @@ class UITask {
3654
void clearMsgPreview();
3755
void msgRead(int msgcount);
3856
void newMsg(uint8_t path_len, const char* from_name, const char* text, int msgcount);
57+
void soundBuzzer(UIEventType bet = UIEventType::none);
3958
void loop();
4059
};

0 commit comments

Comments
 (0)