Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
472 changes: 472 additions & 0 deletions docs/companion_cli.md

Large diffs are not rendered by default.

102 changes: 102 additions & 0 deletions examples/companion_radio/MyMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2209,6 +2209,108 @@ bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, char*
}
return true;
}
#ifdef DISPLAY_CLASS
if (memcmp(command, "set ui.show_clock", 17) == 0) {
_prefs.ui_show_clock = atoi(&command[17]) ? 1 : 0;
savePrefs();
sprintf(reply, "> now %d", _prefs.ui_show_clock);
return true;
}
if (memcmp(command, "set ui.auto_off_delay", 21) == 0) {
_prefs.ui_auto_off_delay = atoi(&command[21]);
savePrefs();
sprintf(reply, "> now %d seconds", _prefs.ui_auto_off_delay);
return true;
}
if (memcmp(command, "set ui.backlight_delay", 22) == 0) {
_prefs.ui_backlight_delay = atoi(&command[22]);
savePrefs();
if (_prefs.ui_backlight_delay >= 0)
sprintf(reply, "> now %d seconds", _prefs.ui_backlight_delay);
else if (_prefs.ui_backlight_delay == -1)
sprintf(reply, "> now always on (-1)");
else
sprintf(reply, "> now disabled (<-1)");
return true;
}
if (memcmp(command, "set ui.backlight_on_keys", 24) == 0) {
_prefs.ui_backlight_on_keys = atoi(&command[24]);
savePrefs();
sprintf(reply, "> now %d", _prefs.ui_backlight_on_keys);
return true;
}
if (memcmp(command, "set ui.backlight_on_msgs", 24) == 0) {
_prefs.ui_backlight_on_msgs = atoi(&command[24]);
savePrefs();
sprintf(reply, "> now %d", _prefs.ui_backlight_on_msgs);
return true;
}
if (memcmp(command, "set ui.auto_off_blank", 21) == 0) {
_prefs.ui_auto_off_blank = atoi(&command[21]);
savePrefs();
sprintf(reply, "> now %d", _prefs.ui_auto_off_blank);
return true;
}
if (memcmp(command, "set ui.auto_off_keep_msgs", 25) == 0) {
_prefs.ui_auto_off_keep_msgs = atoi(&command[25]);
savePrefs();
sprintf(reply, "> now %d", _prefs.ui_auto_off_keep_msgs);
return true;
}
if (memcmp(command, "set ui.max_partial", 18) == 0) {
_prefs.ui_max_partial = atoi(&command[18]);
savePrefs();
sprintf(reply, "> now %d (applied at next screen wakeup)", _prefs.ui_max_partial);
return true;
}
if (memcmp(command, "set ui.nd_name", 14) == 0) {
_prefs.ui_nd_name = atoi(&command[14]);
savePrefs();
sprintf(reply, "> ui.nd_name is now %d", _prefs.ui_nd_name);
return true;
}
if (memcmp(command, "get ui.show_clock", 17) == 0) {
sprintf(reply, "> %d", _prefs.ui_show_clock);
return true;
}
if (memcmp(command, "get ui.auto_off_delay", 21) == 0) {
sprintf(reply, "> %d seconds", _prefs.ui_auto_off_delay);
return true;
}
if (memcmp(command, "get ui.backlight_delay", 22) == 0) {
if (_prefs.ui_backlight_delay >= 0)
sprintf(reply, "> %d seconds", _prefs.ui_backlight_delay);
else if (_prefs.ui_backlight_delay == -1)
sprintf(reply, "> always on (-1)");
else
sprintf(reply, "> disabled (<-1)");
return true;
}
if (memcmp(command, "get ui.backlight_on_keys", 24) == 0) {
sprintf(reply, "> %d", _prefs.ui_backlight_on_keys);
return true;
}
if (memcmp(command, "get ui.backlight_on_msgs", 24) == 0) {
sprintf(reply, "> %d", _prefs.ui_backlight_on_msgs);
return true;
}
if (memcmp(command, "get ui.auto_off_blank", 21) == 0) {
sprintf(reply, "> %d", _prefs.ui_auto_off_blank);
return true;
}
if (memcmp(command, "get ui.auto_off_keep_msgs", 25) == 0) {
sprintf(reply, "> %d", _prefs.ui_auto_off_keep_msgs);
return true;
}
if (memcmp(command, "get ui.max_partial", 18) == 0) {
sprintf(reply, "> %d", _prefs.ui_max_partial);
return true;
}
if (memcmp(command, "get ui.nd_name", 14) == 0) {
sprintf(reply, "> %d", _prefs.ui_nd_name);
return true;
}
#endif

return false; // not handled
}
Expand Down
55 changes: 55 additions & 0 deletions examples/companion_radio/NodePrefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,34 @@ class NodePrefs : public ConfigSerializer { // persisted to file
// use ssid from prefs, or fallback to ssid from build flags
const char* getWifiSSID() const { return wifi_ssid[0] ? wifi_ssid : WIFI_SSID; }
#endif
#ifdef DISPLAY_CLASS
#ifndef UI_SHOW_CLOCK
#define UI_SHOW_CLOCK 0
#endif
#ifndef AUTO_OFF_MILLIS
#define AUTO_OFF_MILLIS 15000
#endif
#ifndef EINK_MAX_PARTIAL_REFRESH
#define EINK_MAX_PARTIAL_REFRESH 0
#endif
uint8_t ui_show_clock = UI_SHOW_CLOCK;
uint32_t ui_auto_off_delay = AUTO_OFF_MILLIS / 1000;
int32_t ui_backlight_delay = 5;
#if defined(BACKLIGHT_BTN)
uint8_t ui_backlight_on_keys = 0;
#else
uint8_t ui_backlight_on_keys = 1;
#endif
uint8_t ui_backlight_on_msgs = 0;
#ifdef UI_SCREENOFF_BLANK
uint8_t ui_auto_off_blank = 1;
#else
uint8_t ui_auto_off_blank = 0;
#endif
uint8_t ui_auto_off_keep_msgs = 1;
uint8_t ui_max_partial = EINK_MAX_PARTIAL_REFRESH;
uint8_t ui_nd_name = 1;
#endif

private:
class RadioPrefs : public CommonRadioPrefs {
Expand Down Expand Up @@ -189,6 +217,27 @@ class NodePrefs : public ConfigSerializer { // persisted to file
WiFiPrefs wifi;
#endif

#ifdef DISPLAY_CLASS
class UI_Prefs : public ConfigSerializer {
NodePrefs* _parent;
protected:
void structure() override {
def("show_clock", _parent->ui_show_clock);
def("auto_off", _parent->ui_auto_off_delay);
def("bl_dly", _parent->ui_backlight_delay);
def("bl_keys", _parent->ui_backlight_on_keys);
def("bl_msgs", _parent->ui_backlight_on_msgs);
def("max_partial", _parent->ui_max_partial);
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);
}
public:
UI_Prefs(NodePrefs* parent) : _parent(parent) {}
};
UI_Prefs ui;
#endif

protected:
void structure() override {
def("name", node_name, sizeof(node_name));
Expand All @@ -203,12 +252,18 @@ class NodePrefs : public ConfigSerializer { // persisted to file
def("custom", custom);
#ifdef ENABLE_WIFI_INTERFACE
def("wifi", wifi);
#endif
#ifdef DISPLAY_CLASS
def("ui", ui);
#endif
}
public:
NodePrefs() : radio(this), gps(this), companion(this), custom(&radio)
#ifdef ENABLE_WIFI_INTERFACE
, wifi(this)
#endif
#ifdef DISPLAY_CLASS
, ui(this)
#endif
{
node_name[0] = 0;
Expand Down
Loading
Loading