Files
MeshCore/variants/thinknode_m2/ThinknodeM2Board.cpp
T
mikecarper ab6412e73c Add persistent battery ADC calibration across boards
Add meter-reference calibration with saved ADC corrections, checked persistence and rollback. Preserve existing board coefficients and nRF52 voltage policy, and merge the Mini Repeater feature gates.

Validation: 69 focused tests, hosted documentation checks, and four firmware builds passed. Mini Repeater retains calibration and its existing filesystem with 376 flash bytes free; earlier Mini Sensor size failures remain documented.
2026-10-22 18:56:32 -07:00

31 lines
976 B
C++

#include "ThinknodeM2Board.h"
void ThinknodeM2Board::begin() {
pinMode(PIN_VEXT_EN, OUTPUT);
digitalWrite(PIN_VEXT_EN, !PIN_VEXT_EN_ACTIVE); // force power cycle
delay(20); // allow power rail to discharge
digitalWrite(PIN_VEXT_EN, PIN_VEXT_EN_ACTIVE); // turn backlight back on
delay(120); // give display time to bias on cold boot
ESP32Board::begin();
pinMode(PIN_STATUS_LED, OUTPUT); // init power led
}
uint16_t ThinknodeM2Board::getBattMilliVolts() {
analogReadResolution(12);
analogSetPinAttenuation(PIN_VBAT_READ, ADC_11db);
uint32_t mv = 0;
for (int i = 0; i < 8; ++i) {
mv += analogReadMilliVolts(PIN_VBAT_READ);
delayMicroseconds(200);
}
mv /= 8;
analogReadResolution(10);
return calibrateBatteryMillivolts(static_cast<uint16_t>(mv * ADC_MULTIPLIER));
}
const char *ThinknodeM2Board::getManufacturerName() const {
return "Elecrow ThinkNode M2";
}