ui_task: let user choose if enter in gps screen toggles or triggers gps

This commit is contained in:
Florent committed 2026-11-08 08:47:35 -04:00
1 parent 6c9600e1e7
commit 6eea5e7185
5 files changed
+43 -1

No files matched your search

+14
View File
@@ -452,6 +452,20 @@ Radio parameters are common to all roles and handled by `CommonRadioPrefs`.
---
#### GPS key action
**Usage:**
- `set ui.gps_action <action>`
- `get ui.gps_action`
**Parameters:**
- `action`: `toggle` (or `0`) to switch the GPS on and off, `once` (or `trigger`, `1`) to acquire a fix on demand, as `gps once`
**Default:** `toggle`, or `once` on boards with a GPS switch
**Note:** Only used by the `ui-new` screens for now.
---
#### Node discovery screen shows nodes names
**Usage:**
- `set ui.nd_name <state>`
+12
View File
@@ -2291,6 +2291,18 @@ bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, char*
sprintf(reply, "> ui.nd_name is now %d", _prefs.ui_nd_name);
return true;
}
if (memcmp(command, "set ui.gps_action", 17) == 0) {
const char* v = &command[17];
while (*v == ' ') v++;
_prefs.ui_gps_action = (memcmp(v, "once", 4) == 0 || memcmp(v, "trigger", 7) == 0 || *v == '1') ? 1 : 0; // anything else: toggle
savePrefs();
sprintf(reply, "> now %s", _prefs.ui_gps_action ? "once" : "toggle");
return true;
}
if (memcmp(command, "get ui.gps_action", 17) == 0) {
sprintf(reply, "> %s", _prefs.ui_gps_action ? "once" : "toggle");
return true;
}
if (memcmp(command, "get ui.show_clock", 17) == 0) {
sprintf(reply, "> %d", _prefs.ui_show_clock);
return true;
+6
View File
@@ -87,6 +87,11 @@ public:
uint8_t ui_auto_off_keep_msgs = 1;
uint8_t ui_max_partial = EINK_MAX_PARTIAL_REFRESH;
uint8_t ui_nd_name = 1;
#ifdef PIN_GPS_SWITCH
uint8_t ui_gps_action = 1;
#else
uint8_t ui_gps_action = 0;
#endif
#endif
private:
@@ -238,6 +243,7 @@ private:
def("off_blank", _parent->ui_auto_off_blank);
def("off_keep_msgs", _parent->ui_auto_off_keep_msgs);
def("nd_name", _parent->ui_nd_name);
def("gps_act", _parent->ui_gps_action);
}
public:
UI_Prefs(NodePrefs* parent) : _parent(parent) {}
+10 -1
View File
@@ -632,7 +632,7 @@ public:
}
#if ENV_INCLUDE_GPS == 1
if (c == KEY_ENTER && _page == HomePage::GPS) {
_task->toggleGPS();
if (_node_prefs->ui_gps_action == 1) _task->triggerGPS(); else _task->toggleGPS();
return true;
}
#endif
@@ -1232,6 +1232,15 @@ void UITask::toggleGPS() {
}
}
void UITask::triggerGPS() {
LocationProvider* location = _sensors != NULL ? _sensors->getLocationProvider() : NULL;
if (location != NULL && !(location->hasHardwareEnableState() && !location->isHardwareEnabled())
&& location->startOnce()) {
notify(UIEventType::ack);
}
_next_refresh = 0;
}
void UITask::toggleBuzzer() {
// Toggle buzzer quiet mode
#ifdef PIN_BUZZER
+1
View File
@@ -114,6 +114,7 @@ public:
void toggleBuzzer();
bool getGPSState();
void toggleGPS();
void triggerGPS();
// MyMesh::Listener
void onMessageRecv(mesh::Packet *pkt, const ContactInfo &from, uint8_t txt_type, uint32_t sender_timestamp, const char* text) override;