Files
MeshCore-Solo/variants/wio-tracker-l1/WioTrackerL1Board.h
Jakub 4d46abb2c1 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>
2026-05-13 21:09:46 +02:00

42 lines
998 B
C++

#pragma once
#include <MeshCore.h>
#include <Arduino.h>
#include <helpers/NRF52Board.h>
class WioTrackerL1Board : public NRF52BoardDCDC {
protected:
uint8_t btn_prev_state;
public:
WioTrackerL1Board() : NRF52Board("WioTrackerL1 OTA") {}
void begin();
#if defined(P_LORA_TX_LED)
void onBeforeTransmit() override {
digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED on
}
void onAfterTransmit() override {
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
}
#endif
uint16_t getBattMilliVolts() override {
digitalWrite(VBAT_ENABLE, HIGH);
analogReadResolution(12);
analogReference(AR_INTERNAL);
delay(10); // allow voltage divider to stabilize
int adcvalue = analogRead(PIN_VBAT_READ);
digitalWrite(VBAT_ENABLE, LOW);
return (adcvalue * ADC_MULTIPLIER * AREF_VOLTAGE) / 4.096;
}
const char* getManufacturerName() const override {
return "Seeed Wio Tracker L1";
}
void powerOff() override {
sd_power_system_off();
}
};