feat(power): 1Hz chunked light-sleep; meter backoff; log throttling
- Replace delay() with light_sleep_chunked_ms() in sender idle path (100ms chunks preserve UART FIFO safety at 9600 baud) - Add ENABLE_LIGHT_SLEEP_IDLE build flag (default: on, fallback: =0) - Meter reader task: exponential backoff on consecutive poll failures (METER_FAIL_BACKOFF_BASE_MS..MAX_MS) to reduce idle Core-0 wakeups - Configurable SENDER_DIAG_LOG_INTERVAL_MS (5s debug / 30s prod) - Configurable METER_FRAME_TIMEOUT_CFG_MS, SENDER_CPU_MHZ - New PlatformIO envs: lowpower, 868-lowpower, lowpower-debug - Add docs/POWER_OPTIMIZATION.md with measurement plan and Go/No-Go
This commit is contained in:
@@ -71,6 +71,31 @@ constexpr bool ENABLE_HA_DISCOVERY = true;
|
||||
constexpr bool SERIAL_DEBUG_MODE = SERIAL_DEBUG_MODE_FLAG != 0;
|
||||
constexpr bool SERIAL_DEBUG_DUMP_JSON = false;
|
||||
constexpr bool LORA_SEND_BYPASS = false;
|
||||
|
||||
// --- Power management (sender) ---
|
||||
// Light-sleep between 1 Hz samples: saves ~25 mA vs active delay().
|
||||
// UART HW FIFO is 128 bytes; at 9600 baud (~960 B/s) max safe chunk ≈133 ms.
|
||||
#ifndef ENABLE_LIGHT_SLEEP_IDLE
|
||||
#define ENABLE_LIGHT_SLEEP_IDLE 1
|
||||
#endif
|
||||
constexpr bool LIGHT_SLEEP_IDLE = ENABLE_LIGHT_SLEEP_IDLE != 0;
|
||||
constexpr uint32_t LIGHT_SLEEP_CHUNK_MS = 100;
|
||||
|
||||
// CPU frequency for sender (MHz). 80 = default, 40 = aggressive savings.
|
||||
#ifndef SENDER_CPU_MHZ
|
||||
#define SENDER_CPU_MHZ 80
|
||||
#endif
|
||||
|
||||
// Log-throttle interval for sender diagnostics (ms). Higher = less serial TX.
|
||||
constexpr uint32_t SENDER_DIAG_LOG_INTERVAL_MS = SERIAL_DEBUG_MODE ? 5000 : 30000;
|
||||
|
||||
// Meter driver: max time (ms) to wait for a complete frame before discarding.
|
||||
// Lower values recover faster from broken frames and save wasted polling.
|
||||
constexpr uint32_t METER_FRAME_TIMEOUT_CFG_MS = 3000;
|
||||
|
||||
// Meter driver: backoff ceiling on consecutive frame failures (ms).
|
||||
constexpr uint32_t METER_FAIL_BACKOFF_MAX_MS = 500;
|
||||
constexpr uint32_t METER_FAIL_BACKOFF_BASE_MS = 10;
|
||||
constexpr bool ENABLE_SD_LOGGING = true;
|
||||
constexpr uint8_t PIN_SD_CS = 13;
|
||||
constexpr uint8_t PIN_SD_MOSI = 15;
|
||||
|
||||
Reference in New Issue
Block a user