mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-26 23:08:11 +00:00
feat(wio-tracker-l1): energy optimizations
- CPU sleep: board.sleep(0) in main loop puts NRF52 into WFE/sd_app_evt_wait between iterations; wakes on any interrupt (radio, BLE, timer). Largest power saving of the three changes. - VBAT_ENABLE gating: voltage divider now powered only during ADC read (HIGH for 10ms, then LOW). Previously stayed HIGH continuously. Fixed in both variant.cpp (init) and WioTrackerL1Board::getBattMilliVolts(). - LED off with display: PIN_LED is cleared when auto-off triggers and restored (handed back to userLedHandler) when display wakes. Avoids idle LED current draw during screen-off periods. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -229,4 +229,5 @@ void loop() {
|
|||||||
ui_task.loop();
|
ui_task.loop();
|
||||||
#endif
|
#endif
|
||||||
rtc_clock.tick();
|
rtc_clock.tick();
|
||||||
|
board.sleep(0); // CPU sleeps until next interrupt (radio, timer, BLE); nRF52 ignores the seconds param
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1129,6 +1129,9 @@ void UITask::loop() {
|
|||||||
#if AUTO_OFF_MILLIS > 0
|
#if AUTO_OFF_MILLIS > 0
|
||||||
if (autoOffMillis() > 0 && millis() > _auto_off) {
|
if (autoOffMillis() > 0 && millis() > _auto_off) {
|
||||||
_display->turnOff();
|
_display->turnOff();
|
||||||
|
#ifdef PIN_LED
|
||||||
|
digitalWrite(PIN_LED, LOW); // turn off status LED with display to save power
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1163,7 +1166,10 @@ void UITask::loop() {
|
|||||||
char UITask::checkDisplayOn(char c) {
|
char UITask::checkDisplayOn(char c) {
|
||||||
if (_display != NULL) {
|
if (_display != NULL) {
|
||||||
if (!_display->isOn()) {
|
if (!_display->isOn()) {
|
||||||
_display->turnOn(); // turn display on and consume event
|
_display->turnOn();
|
||||||
|
#ifdef PIN_LED
|
||||||
|
digitalWrite(PIN_LED, LOW); // ensure LED is off when waking display (userLedHandler takes over)
|
||||||
|
#endif
|
||||||
c = 0;
|
c = 0;
|
||||||
}
|
}
|
||||||
{ uint32_t aoff = autoOffMillis(); if (aoff > 0) _auto_off = millis() + aoff; } // extend auto-off timer
|
{ uint32_t aoff = autoOffMillis(); if (aoff > 0) _auto_off = millis() + aoff; } // extend auto-off timer
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ void WioTrackerL1Board::begin() {
|
|||||||
btn_prev_state = HIGH;
|
btn_prev_state = HIGH;
|
||||||
|
|
||||||
pinMode(PIN_VBAT_READ, INPUT); // VBAT ADC input
|
pinMode(PIN_VBAT_READ, INPUT); // VBAT ADC input
|
||||||
|
pinMode(VBAT_ENABLE, OUTPUT);
|
||||||
|
digitalWrite(VBAT_ENABLE, LOW); // keep voltage divider off; enabled only during ADC read
|
||||||
// Set all button pins to INPUT_PULLUP
|
// Set all button pins to INPUT_PULLUP
|
||||||
pinMode(PIN_BUTTON1, INPUT_PULLUP);
|
pinMode(PIN_BUTTON1, INPUT_PULLUP);
|
||||||
pinMode(PIN_BUTTON2, INPUT_PULLUP);
|
pinMode(PIN_BUTTON2, INPUT_PULLUP);
|
||||||
|
|||||||
@@ -22,11 +22,12 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint16_t getBattMilliVolts() override {
|
uint16_t getBattMilliVolts() override {
|
||||||
int adcvalue = 0;
|
digitalWrite(VBAT_ENABLE, HIGH);
|
||||||
analogReadResolution(12);
|
analogReadResolution(12);
|
||||||
analogReference(AR_INTERNAL);
|
analogReference(AR_INTERNAL);
|
||||||
delay(10);
|
delay(10); // allow voltage divider to stabilize
|
||||||
adcvalue = analogRead(PIN_VBAT_READ);
|
int adcvalue = analogRead(PIN_VBAT_READ);
|
||||||
|
digitalWrite(VBAT_ENABLE, LOW);
|
||||||
return (adcvalue * ADC_MULTIPLIER * AREF_VOLTAGE) / 4.096;
|
return (adcvalue * ADC_MULTIPLIER * AREF_VOLTAGE) / 4.096;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,9 +67,9 @@ void initVariant() {
|
|||||||
pinMode(PIN_QSPI_CS, OUTPUT);
|
pinMode(PIN_QSPI_CS, OUTPUT);
|
||||||
digitalWrite(PIN_QSPI_CS, HIGH);
|
digitalWrite(PIN_QSPI_CS, HIGH);
|
||||||
|
|
||||||
// VBAT_ENABLE
|
// VBAT_ENABLE: keep LOW by default, WioTrackerL1Board::getBattMilliVolts() toggles it
|
||||||
pinMode(VBAT_ENABLE, OUTPUT);
|
pinMode(VBAT_ENABLE, OUTPUT);
|
||||||
digitalWrite(VBAT_ENABLE, HIGH);
|
digitalWrite(VBAT_ENABLE, LOW);
|
||||||
|
|
||||||
// set LED pin as output and set it low
|
// set LED pin as output and set it low
|
||||||
pinMode(PIN_LED, OUTPUT);
|
pinMode(PIN_LED, OUTPUT);
|
||||||
|
|||||||
Reference in New Issue
Block a user