Merge pull request #2436 from chrisdavis2110/rak3401-comp-ana-button

feat: Add support for PIN_USER_BTN_ANA on rak3401 companion usb and companion ble envs
This commit is contained in:
Liam Cottle
2026-04-30 16:57:00 +12:00
committed by GitHub
2 changed files with 11 additions and 8 deletions

View File

@@ -154,7 +154,7 @@ class HomeScreen : public UIScreen {
bool sensors_scroll = false; bool sensors_scroll = false;
int sensors_scroll_offset = 0; int sensors_scroll_offset = 0;
int next_sensors_refresh = 0; int next_sensors_refresh = 0;
void refresh_sensors() { void refresh_sensors() {
if (millis() > next_sensors_refresh) { if (millis() > next_sensors_refresh) {
sensors_lpp.reset(); sensors_lpp.reset();
@@ -178,7 +178,7 @@ class HomeScreen : public UIScreen {
public: public:
HomeScreen(UITask* task, mesh::RTCClock* rtc, SensorManager* sensors, NodePrefs* node_prefs) HomeScreen(UITask* task, mesh::RTCClock* rtc, SensorManager* sensors, NodePrefs* node_prefs)
: _task(task), _rtc(rtc), _sensors(sensors), _node_prefs(node_prefs), _page(0), : _task(task), _rtc(rtc), _sensors(sensors), _node_prefs(node_prefs), _page(0),
_shutdown_init(false), sensors_lpp(200) { } _shutdown_init(false), sensors_lpp(200) { }
void poll() override { void poll() override {
@@ -221,7 +221,7 @@ public:
IPAddress ip = WiFi.localIP(); IPAddress ip = WiFi.localIP();
snprintf(tmp, sizeof(tmp), "IP: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); snprintf(tmp, sizeof(tmp), "IP: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
display.setTextSize(1); display.setTextSize(1);
display.drawTextCentered(display.width() / 2, 54, tmp); display.drawTextCentered(display.width() / 2, 54, tmp);
#endif #endif
if (_task->hasConnection()) { if (_task->hasConnection()) {
display.setColor(DisplayDriver::GREEN); display.setColor(DisplayDriver::GREEN);
@@ -249,10 +249,10 @@ public:
} else { } else {
sprintf(tmp, "%dh", secs / (60*60)); sprintf(tmp, "%dh", secs / (60*60));
} }
int timestamp_width = display.getTextWidth(tmp); int timestamp_width = display.getTextWidth(tmp);
int max_name_width = display.width() - timestamp_width - 1; int max_name_width = display.width() - timestamp_width - 1;
char filtered_recent_name[sizeof(a->name)]; char filtered_recent_name[sizeof(a->name)];
display.translateUTF8ToBlocks(filtered_recent_name, a->name, sizeof(filtered_recent_name)); display.translateUTF8ToBlocks(filtered_recent_name, a->name, sizeof(filtered_recent_name));
display.drawTextEllipsized(0, y, max_name_width, filtered_recent_name); display.drawTextEllipsized(0, y, max_name_width, filtered_recent_name);
@@ -318,7 +318,7 @@ public:
display.drawTextRightAlign(display.width()-1, y, buf); display.drawTextRightAlign(display.width()-1, y, buf);
y = y + 12; y = y + 12;
display.drawTextLeftAlign(0, y, "pos"); display.drawTextLeftAlign(0, y, "pos");
sprintf(buf, "%.4f %.4f", sprintf(buf, "%.4f %.4f",
nmea->getLatitude()/1000000., nmea->getLongitude()/1000000.); nmea->getLatitude()/1000000., nmea->getLongitude()/1000000.);
display.drawTextRightAlign(display.width()-1, y, buf); display.drawTextRightAlign(display.width()-1, y, buf);
y = y + 12; y = y + 12;
@@ -749,7 +749,7 @@ void UITask::loop() {
#endif #endif
#if defined(PIN_USER_BTN_ANA) #if defined(PIN_USER_BTN_ANA)
if (abs(millis() - _analogue_pin_read_millis) > 10) { if (abs(millis() - _analogue_pin_read_millis) > 10) {
ev = analog_btn.check(); int ev = analog_btn.check();
if (ev == BUTTON_EVENT_CLICK) { if (ev == BUTTON_EVENT_CLICK) {
c = checkDisplayOn(KEY_NEXT); c = checkDisplayOn(KEY_NEXT);
} else if (ev == BUTTON_EVENT_LONG_PRESS) { } else if (ev == BUTTON_EVENT_LONG_PRESS) {
@@ -886,7 +886,7 @@ bool UITask::getGPSState() {
return !strcmp(_sensors->getSettingValue(i), "1"); return !strcmp(_sensors->getSettingValue(i), "1");
} }
} }
} }
return false; return false;
} }

View File

@@ -64,6 +64,8 @@ board_upload.maximum_size = 712704
build_flags = build_flags =
${rak3401.build_flags} ${rak3401.build_flags}
-I examples/companion_radio/ui-new -I examples/companion_radio/ui-new
-D PIN_USER_BTN_ANA=31
-D PIN_GPS_EN=-1
-D DISPLAY_CLASS=SSD1306Display -D DISPLAY_CLASS=SSD1306Display
-D MAX_CONTACTS=350 -D MAX_CONTACTS=350
-D MAX_GROUP_CHANNELS=40 -D MAX_GROUP_CHANNELS=40
@@ -83,6 +85,7 @@ board_upload.maximum_size = 712704
build_flags = build_flags =
${rak3401.build_flags} ${rak3401.build_flags}
-I examples/companion_radio/ui-new -I examples/companion_radio/ui-new
-D PIN_USER_BTN_ANA=31
-D PIN_GPS_EN=-1 -D PIN_GPS_EN=-1
-D DISPLAY_CLASS=SSD1306Display -D DISPLAY_CLASS=SSD1306Display
-D MAX_CONTACTS=350 -D MAX_CONTACTS=350