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
1 change: 1 addition & 0 deletions examples/companion_radio/MyMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ MyMesh::MyMesh(mesh::Radio &radio, mesh::RNG &rng, mesh::RTCClock &rtc, SimpleMe
_prefs.bw = LORA_BW;
_prefs.cr = LORA_CR;
_prefs.tx_power_dbm = LORA_TX_POWER;
_prefs.display_wake_mode = DISPLAY_WAKE_AUTO;
//_prefs.rx_delay_base = 10.0f; enable once new algo fixed
}

Expand Down
5 changes: 5 additions & 0 deletions examples/companion_radio/NodePrefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#define ADVERT_LOC_NONE 0
#define ADVERT_LOC_SHARE 1

#define DISPLAY_WAKE_AUTO 0
#define DISPLAY_WAKE_MANUAL 1
#define DISPLAY_WAKE_ALWAYS_ON 2

struct NodePrefs { // persisted to file
float airtime_factor;
char node_name[32];
Expand All @@ -25,4 +29,5 @@ struct NodePrefs { // persisted to file
uint32_t ble_pin;
uint8_t advert_loc_policy;
uint8_t buzzer_quiet;
uint8_t display_wake_mode;
};
37 changes: 35 additions & 2 deletions examples/companion_radio/ui-new/UITask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class HomeScreen : public UIScreen {
RADIO,
BLUETOOTH,
ADVERT,
DISPLAY_SETTINGS,
#if ENV_INCLUDE_GPS == 1
GPS,
#endif
Expand Down Expand Up @@ -257,6 +258,23 @@ class HomeScreen : public UIScreen {
display.setColor(DisplayDriver::GREEN);
display.drawXbm((display.width() - 32) / 2, 18, advert_icon, 32, 32);
display.drawTextCentered(display.width() / 2, 64 - 11, "advert: " PRESS_LABEL);
} else if (_page == HomePage::DISPLAY_SETTINGS) {
display.setColor(DisplayDriver::YELLOW);
display.setTextSize(1);
display.drawTextCentered(display.width() / 2, 20, "Wake Screen:");

display.setColor(DisplayDriver::GREEN);
display.setTextSize(2);
if (_node_prefs->display_wake_mode == DISPLAY_WAKE_MANUAL) {
display.drawTextCentered(display.width() / 2, 40, "MANUAL");
} else if (_node_prefs->display_wake_mode == DISPLAY_WAKE_ALWAYS_ON) {
display.drawTextCentered(display.width() / 2, 40, "ALWAYS ON");
} else {
display.drawTextCentered(display.width() / 2, 40, "AUTO");
}
display.setColor(DisplayDriver::LIGHT);
display.setTextSize(1);
display.drawTextCentered(display.width() / 2, 64 - 11, "change: " PRESS_LABEL);
#if ENV_INCLUDE_GPS == 1
} else if (_page == HomePage::GPS) {
LocationProvider* nmea = sensors.getLocationProvider();
Expand Down Expand Up @@ -410,6 +428,20 @@ class HomeScreen : public UIScreen {
}
return true;
}
if (c == KEY_ENTER && _page == HomePage::DISPLAY_SETTINGS) {
if (_node_prefs->display_wake_mode == DISPLAY_WAKE_AUTO) {
_node_prefs->display_wake_mode = DISPLAY_WAKE_MANUAL;
_task->showAlert("Wake: Manual", 800);
} else if (_node_prefs->display_wake_mode == DISPLAY_WAKE_MANUAL) {
_node_prefs->display_wake_mode = DISPLAY_WAKE_ALWAYS_ON;
_task->showAlert("Wake: Always On", 800);
} else {
_node_prefs->display_wake_mode = DISPLAY_WAKE_AUTO;
_task->showAlert("Wake: Auto", 800);
}
the_mesh.savePrefs();
return true;
}
#if ENV_INCLUDE_GPS == 1
if (c == KEY_ENTER && _page == HomePage::GPS) {
_task->toggleGPS();
Expand Down Expand Up @@ -608,7 +640,8 @@ void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, i
setCurrScreen(msg_preview);

if (_display != NULL) {
if (!_display->isOn()) _display->turnOn();
bool shouldWake = (_node_prefs->display_wake_mode == DISPLAY_WAKE_AUTO);
if (shouldWake && !_display->isOn()) _display->turnOn();
_auto_off = millis() + AUTO_OFF_MILLIS; // extend the auto-off timer
_next_refresh = 100; // trigger refresh
}
Expand Down Expand Up @@ -773,7 +806,7 @@ void UITask::loop() {
_display->endFrame();
}
#if AUTO_OFF_MILLIS > 0
if (millis() > _auto_off) {
if (_node_prefs->display_wake_mode != DISPLAY_WAKE_ALWAYS_ON && millis() > _auto_off) {
_display->turnOff();
}
#endif
Expand Down