Add automatic red and black night mode for color screens
Default to one hour after sunset through sunrise, using fresh cached GPS or recent direct RF neighbor locations. Provide saved CLI and WebConfig controls with a small integer solar approximation and no additional framebuffer.
This commit is contained in:
1 parent
94139c79be
commit
fb73e3afac
49 files changed
+4072
-2421
No files matched your search
@@ -95,6 +95,10 @@ MESH_COMPANION_HELP_BEGIN
|
||||
" memory\r\n"
|
||||
#endif
|
||||
" get/set display.rotation <0|90|180|270>\r\n"
|
||||
#ifdef MESHCORE_HAS_COLOR_DISPLAY
|
||||
" get/set display.night <auto|on|off>\r\n"
|
||||
" get/set display.night.delay <-180..180> (minutes after sunset; default 60)\r\n"
|
||||
#endif
|
||||
#if defined(OLED_AUTO_DETECT) && OLED_AUTO_DETECT && defined(DISPLAY_CLASS)
|
||||
" get/set display.controller <auto|ssd1306|sh1106> (saved; restart to apply)\r\n"
|
||||
#endif
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#endif
|
||||
#include <helpers/LedSettings.h>
|
||||
#include <helpers/ui/DisplayPowerSettings.h>
|
||||
#include <helpers/ui/DisplayNightLocation.h>
|
||||
#if defined(OLED_AUTO_DETECT) && OLED_AUTO_DETECT && defined(DISPLAY_CLASS)
|
||||
#include <helpers/ui/OLEDControllerSettings.h>
|
||||
#endif
|
||||
@@ -1892,14 +1893,24 @@ void MyMesh::onGroupDataRecv(mesh::Packet* packet, uint8_t type,
|
||||
BaseChatMesh::onGroupDataRecv(packet, type, key, data, len);
|
||||
}
|
||||
|
||||
#ifdef COMPANION_MESH_CLOCK_SYNC
|
||||
#if defined(COMPANION_MESH_CLOCK_SYNC) || defined(MESHCORE_HAS_COLOR_DISPLAY)
|
||||
void MyMesh::onAdvertRecv(mesh::Packet* packet, const mesh::Identity& id,
|
||||
uint32_t timestamp, const uint8_t* app_data,
|
||||
size_t app_data_len) {
|
||||
#if defined(MESHCORE_HAS_COLOR_DISPLAY)
|
||||
if (!isLocalContactImport(packet)) {
|
||||
mesh::ui::observeDisplayNightAdvert(packet, id, self_id, app_data,
|
||||
app_data_len, millis());
|
||||
}
|
||||
#endif
|
||||
BaseChatMesh::onAdvertRecv(packet, id, timestamp, app_data, app_data_len);
|
||||
#ifdef COMPANION_MESH_CLOCK_SYNC
|
||||
_clock_sync.observeVerifiedAdvert(packet, id, timestamp);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef COMPANION_MESH_CLOCK_SYNC
|
||||
void MyMesh::onGroupPacketRecv(mesh::Packet* packet) {
|
||||
_clock_sync.observeGroupPacket(packet);
|
||||
}
|
||||
@@ -11562,6 +11573,11 @@ void MyMesh::loop() {
|
||||
);
|
||||
#endif
|
||||
BaseChatMesh::loop();
|
||||
#if defined(MESHCORE_HAS_COLOR_DISPLAY)
|
||||
if (!mesh::morseTimingActive(_radio)) {
|
||||
mesh::ui::refreshDisplayNightLocation(sensors, getRTCClock()->getCurrentTime(), millis());
|
||||
}
|
||||
#endif
|
||||
#ifdef COMPANION_MESH_CLOCK_SYNC
|
||||
if (!mesh::morseTimingActive(_radio)) _clock_sync.loop();
|
||||
#endif
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "CompanionFeatures.h"
|
||||
#include <helpers/CompanionReader.h>
|
||||
#include <helpers/PowerSavingDiagnostics.h>
|
||||
#include <helpers/ui/DisplayBuildFlags.h>
|
||||
|
||||
/*------------ Frame Protocol --------------*/
|
||||
#define FIRMWARE_VER_CODE 14
|
||||
@@ -481,10 +482,12 @@ protected:
|
||||
bool allowFloodRetry(const mesh::Packet* packet) const override;
|
||||
uint8_t getFloodRetryMaxPathLength(const mesh::Packet* packet) const override;
|
||||
uint8_t getFloodRetryMaxAttempts(const mesh::Packet* packet) const override;
|
||||
#ifdef COMPANION_MESH_CLOCK_SYNC
|
||||
#if defined(COMPANION_MESH_CLOCK_SYNC) || defined(MESHCORE_HAS_COLOR_DISPLAY)
|
||||
void onAdvertRecv(mesh::Packet* packet, const mesh::Identity& id,
|
||||
uint32_t timestamp, const uint8_t* app_data,
|
||||
size_t app_data_len) override;
|
||||
#endif
|
||||
#ifdef COMPANION_MESH_CLOCK_SYNC
|
||||
void onGroupPacketRecv(mesh::Packet* packet) override;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "MyMesh.h"
|
||||
#include <helpers/ui/DisplayNightLocation.h>
|
||||
|
||||
#if FLOOD_ADVERT_RTC_FAST_SLOTS
|
||||
alignas(4) RTC_FAST_ATTR static mesh::FloodAdvertLimiter::Entry
|
||||
@@ -2951,6 +2952,10 @@ static bool isShare(const mesh::Packet *packet) {
|
||||
|
||||
void MyMesh::onAdvertRecv(mesh::Packet *packet, const mesh::Identity &id, uint32_t timestamp,
|
||||
const uint8_t *app_data, size_t app_data_len) {
|
||||
#if defined(MESHCORE_HAS_COLOR_DISPLAY)
|
||||
mesh::ui::observeDisplayNightAdvert(packet, id, self_id, app_data,
|
||||
app_data_len, millis());
|
||||
#endif
|
||||
mesh::Mesh::onAdvertRecv(packet, id, timestamp, app_data, app_data_len); // chain to super impl
|
||||
|
||||
// Mesh calls this hook only after verifying the advert's Ed25519 signature.
|
||||
@@ -13315,6 +13320,11 @@ void MyMesh::loop() {
|
||||
// Check radio FIRST to ensure we don't miss incoming packets
|
||||
// MQTT processing runs in a separate FreeRTOS task on Core 0, so we don't call bridge.loop() here
|
||||
mesh::Mesh::loop();
|
||||
#if defined(MESHCORE_HAS_COLOR_DISPLAY)
|
||||
if (!mesh::morseTimingActive(_radio)) {
|
||||
mesh::ui::refreshDisplayNightLocation(sensors, getRTCClock()->getCurrentTime(), millis());
|
||||
}
|
||||
#endif
|
||||
#if MESH_USB_CONSOLE_COOPERATIVE
|
||||
servicePendingSerialOutput();
|
||||
#endif
|
||||
|
||||
@@ -875,8 +875,15 @@ void UITask::loop() {
|
||||
_startup_complete = true;
|
||||
}
|
||||
const bool morse_timing = mesh::morseTimingActive(the_mesh.getProfileRadio());
|
||||
#ifdef MESHCORE_HAS_COLOR_DISPLAY
|
||||
const bool screen_was_on = _display->isOn();
|
||||
#endif
|
||||
if (_display->servicePower(board.isExternalPowered() || board.isUsbHostConnected())) {
|
||||
if (_display->isOn()) resetRadioProfileDisplayPage();
|
||||
if (_display->isOn()
|
||||
#ifdef MESHCORE_HAS_COLOR_DISPLAY
|
||||
&& !screen_was_on
|
||||
#endif
|
||||
) resetRadioProfileDisplayPage();
|
||||
_next_refresh = 0;
|
||||
#ifdef DISPLAY_REDRAW_ON_CHANGE
|
||||
_frame_valid = false;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "MyMesh.h"
|
||||
#include <helpers/ui/DisplayNightLocation.h>
|
||||
#include <helpers/DefaultPasswordWarning.h>
|
||||
#if defined(HELTEC_V4_R8_TFT) && defined(HELTEC_TFT_RUNTIME_ROTATION) \
|
||||
&& HELTEC_TFT_RUNTIME_ROTATION == 1
|
||||
@@ -2396,6 +2397,10 @@ void MyMesh::onAckRecv(mesh::Packet *packet, uint32_t ack_crc) {
|
||||
void MyMesh::onAdvertRecv(mesh::Packet* packet, const mesh::Identity& id,
|
||||
uint32_t timestamp, const uint8_t* app_data,
|
||||
size_t app_data_len) {
|
||||
#if defined(MESHCORE_HAS_COLOR_DISPLAY)
|
||||
mesh::ui::observeDisplayNightAdvert(packet, id, self_id, app_data,
|
||||
app_data_len, millis());
|
||||
#endif
|
||||
mesh::Mesh::onAdvertRecv(packet, id, timestamp, app_data, app_data_len);
|
||||
_clock_sync.observeVerifiedAdvert(packet, id, timestamp);
|
||||
|
||||
@@ -4091,6 +4096,11 @@ void MyMesh::loop() {
|
||||
// Check radio FIRST to ensure we don't miss incoming packets
|
||||
// MQTT processing can take time, so we prioritize radio reception
|
||||
mesh::Mesh::loop();
|
||||
#if defined(MESHCORE_HAS_COLOR_DISPLAY)
|
||||
if (!mesh::morseTimingActive(_radio)) {
|
||||
mesh::ui::refreshDisplayNightLocation(sensors, getRTCClock()->getCurrentTime(), millis());
|
||||
}
|
||||
#endif
|
||||
#if MESH_USB_CONSOLE_COOPERATIVE
|
||||
servicePendingSerialOutput();
|
||||
#endif
|
||||
|
||||
@@ -526,7 +526,13 @@ void UITask::loop() {
|
||||
_startup_complete = true;
|
||||
}
|
||||
const bool morse_timing = mesh::morseTimingActive(the_mesh.getProfileRadio());
|
||||
#ifdef MESHCORE_HAS_COLOR_DISPLAY
|
||||
const bool screen_was_on = _display->isOn();
|
||||
#endif
|
||||
if (_display->servicePower(board.isExternalPowered() || board.isUsbHostConnected())) {
|
||||
#ifdef MESHCORE_HAS_COLOR_DISPLAY
|
||||
if (screen_was_on != _display->isOn())
|
||||
#endif
|
||||
resetRadioProfileDisplayPage();
|
||||
_next_refresh = 0;
|
||||
#ifdef DISPLAY_REDRAW_ON_CHANGE
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "SensorMesh.h"
|
||||
#include <helpers/ui/DisplayNightLocation.h>
|
||||
#include <helpers/CLICommandUtils.h>
|
||||
#include <helpers/ClientACLCLI.h>
|
||||
#include <helpers/ClientACLResponse.h>
|
||||
@@ -851,6 +852,10 @@ void SensorMesh::handleCommand(uint32_t sender_timestamp, char* command, char* r
|
||||
void SensorMesh::onAdvertRecv(mesh::Packet* packet, const mesh::Identity& id,
|
||||
uint32_t timestamp, const uint8_t* app_data,
|
||||
size_t app_data_len) {
|
||||
#if defined(MESHCORE_HAS_COLOR_DISPLAY)
|
||||
mesh::ui::observeDisplayNightAdvert(packet, id, self_id, app_data,
|
||||
app_data_len, millis());
|
||||
#endif
|
||||
mesh::Mesh::onAdvertRecv(packet, id, timestamp, app_data, app_data_len);
|
||||
_clock_sync.observeVerifiedAdvert(packet, id, timestamp);
|
||||
#if MESH_ENABLE_SENSOR_TRACKER
|
||||
@@ -1519,6 +1524,11 @@ void SensorMesh::loop() {
|
||||
#endif
|
||||
_cli.loop();
|
||||
mesh::Mesh::loop();
|
||||
#if defined(MESHCORE_HAS_COLOR_DISPLAY)
|
||||
if (!mesh::morseTimingActive(_radio)) {
|
||||
mesh::ui::refreshDisplayNightLocation(sensors, getRTCClock()->getCurrentTime(), millis());
|
||||
}
|
||||
#endif
|
||||
// Do not consume sensor/advert/write deadlines during timed Morse capture.
|
||||
// USB command service and the physical radio continue on every pass.
|
||||
if (mesh::morseTimingActive(_radio)) return;
|
||||
|
||||
@@ -234,7 +234,13 @@ void UITask::loop() {
|
||||
_startup_complete = true;
|
||||
}
|
||||
const bool morse_timing = mesh::morseTimingActive(activeSensorMesh().getProfileRadio());
|
||||
#ifdef MESHCORE_HAS_COLOR_DISPLAY
|
||||
const bool screen_was_on = _display->isOn();
|
||||
#endif
|
||||
if (_display->servicePower(board.isExternalPowered() || board.isUsbHostConnected())) {
|
||||
#ifdef MESHCORE_HAS_COLOR_DISPLAY
|
||||
if (screen_was_on != _display->isOn())
|
||||
#endif
|
||||
resetRadioProfileDisplayPage();
|
||||
_last_refresh = millis() - 1000u;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user