mirror of
https://github.com/liquidraver/ZephCore.git
synced 2026-09-09 18:55:36 +00:00
set leds on/off
This commit is contained in:
@@ -30,6 +30,7 @@ LOG_MODULE_REGISTER(zephcore_main, CONFIG_ZEPHCORE_MAIN_LOG_LEVEL);
|
||||
#include "ui_task.h"
|
||||
#include "ui_mesh_actions.h"
|
||||
#include "oled_power.h"
|
||||
#include "led_gate.h"
|
||||
#if IS_ENABLED(CONFIG_ZEPHCORE_UI_BUZZER)
|
||||
#include "buzzer.h"
|
||||
#endif
|
||||
@@ -1518,9 +1519,11 @@ int main(void)
|
||||
#endif
|
||||
|
||||
/* Restore LED enabled/disabled state from persisted prefs.
|
||||
* If LEDs were disabled, stop the heartbeat LED cycle. */
|
||||
* If LEDs were disabled, stop the heartbeat LED cycle. Straight to the gate
|
||||
* rather than via ui_set_leds_disabled(): the gate also governs the LoRa TX
|
||||
* LED and is linked into every build, UI or not. */
|
||||
bool leds_off = companion_mesh.prefs.leds_disabled != 0;
|
||||
ui_set_leds_disabled(leds_off);
|
||||
zephcore_leds_set_disabled(leds_off);
|
||||
ui_set_heartbeat_led(!leds_off);
|
||||
LOG_INF("LEDs: %s (from prefs)", leds_off ? "disabled" : "enabled");
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ LOG_MODULE_REGISTER(zephcore_repeater_main, CONFIG_ZEPHCORE_MAIN_LOG_LEVEL);
|
||||
#include <zephyr/drivers/hwinfo.h>
|
||||
#include <zephyr/sys/reboot.h>
|
||||
#include "oled_power.h"
|
||||
#include "led_gate.h"
|
||||
|
||||
/* BLE controller assert handler — BT is compiled even for repeater (via zephcore_common.conf) */
|
||||
#if IS_ENABLED(CONFIG_BT_CTLR_ASSERT_HANDLER)
|
||||
@@ -438,6 +439,17 @@ static mesh::SimpleMeshTables mesh_tables;
|
||||
/* RepeaterMesh requires: board, radio, ms_clock, rng, rtc, tables */
|
||||
static RepeaterMesh repeater_mesh(zephyr_board, lora_radio, ms_clock, zephyr_rng, rtc_clock, mesh_tables);
|
||||
|
||||
/* Strong override of the weak stub in ui_mesh_actions_stubs.c: keep the prefs
|
||||
* copy in step when the LEDs page toggles, so "get leds" reports what the node
|
||||
* is actually doing. RAM only — a repeater has no deferred-save path off the UI
|
||||
* thread, so a UI toggle lasts until reboot; "set leds" is what persists. */
|
||||
extern "C" void mesh_set_leds_disabled(bool disabled)
|
||||
{
|
||||
if (repeater_mesh_ptr) {
|
||||
repeater_mesh_ptr->getNodePrefs()->leds_disabled = disabled ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void refresh_repeater_ui_radio_state(void)
|
||||
{
|
||||
if (!repeater_mesh_ptr) {
|
||||
@@ -659,6 +671,15 @@ int main(void)
|
||||
oled_sleep();
|
||||
#endif
|
||||
|
||||
/* Apply the persisted LED master switch ("set leds on|off"). After ui_init()
|
||||
* so the heartbeat cycle exists to be stopped; before the radio starts so the
|
||||
* first transmit already honours it. */
|
||||
{
|
||||
bool leds_off = repeater_mesh.getNodePrefs()->leds_disabled != 0;
|
||||
zephcore_leds_set_disabled(leds_off);
|
||||
LOG_INF("LEDs: %s (from prefs)", leds_off ? "disabled" : "enabled");
|
||||
}
|
||||
|
||||
/* Log environment sensor availability */
|
||||
if (env_sensors_available()) {
|
||||
LOG_INF("Environment sensors available");
|
||||
|
||||
@@ -22,6 +22,7 @@ LOG_MODULE_REGISTER(zephcore_room_main, CONFIG_ZEPHCORE_MAIN_LOG_LEVEL);
|
||||
#include <zephyr/drivers/hwinfo.h>
|
||||
#include <zephyr/sys/reboot.h>
|
||||
#include "oled_power.h"
|
||||
#include "led_gate.h"
|
||||
|
||||
/* BLE controller assert handler — BT is compiled even for repeater (via zephcore_common.conf) */
|
||||
#if IS_ENABLED(CONFIG_BT_CTLR_ASSERT_HANDLER)
|
||||
@@ -373,6 +374,17 @@ static mesh::SimpleMeshTables mesh_tables;
|
||||
static RoomServerMesh room_mesh(zephyr_board, lora_radio, ms_clock, zephyr_rng, rtc_clock, mesh_tables);
|
||||
#endif
|
||||
|
||||
/* Strong override of the weak stub in ui_mesh_actions_stubs.c: keep the prefs
|
||||
* copy in step when the LEDs page toggles, so "get leds" reports what the node
|
||||
* is actually doing. RAM only — there is no deferred-save path off the UI
|
||||
* thread, so a UI toggle lasts until reboot; "set leds" is what persists. */
|
||||
extern "C" void mesh_set_leds_disabled(bool disabled)
|
||||
{
|
||||
if (room_mesh_ptr) {
|
||||
room_mesh_ptr->getNodePrefs()->leds_disabled = disabled ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Repeater event loop */
|
||||
static void room_event_loop(void)
|
||||
{
|
||||
@@ -548,6 +560,15 @@ int main(void)
|
||||
oled_sleep();
|
||||
#endif
|
||||
|
||||
/* Apply the persisted LED master switch ("set leds on|off"). After ui_init()
|
||||
* so the heartbeat cycle exists to be stopped; before the radio starts so the
|
||||
* first transmit already honours it. */
|
||||
{
|
||||
bool leds_off = room_mesh.getNodePrefs()->leds_disabled != 0;
|
||||
zephcore_leds_set_disabled(leds_off);
|
||||
LOG_INF("LEDs: %s (from prefs)", leds_off ? "disabled" : "enabled");
|
||||
}
|
||||
|
||||
/* Log environment sensor availability */
|
||||
if (env_sensors_available()) {
|
||||
LOG_INF("Environment sensors available");
|
||||
|
||||
Reference in New Issue
Block a user