Files
MeshCore/variants/heltec_v4_r8/HeltecV4R8Board.h
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

51 lines
1.4 KiB
C++

#pragma once
#include <Arduino.h>
#include <driver/rtc_io.h>
#include <helpers/ESP32Board.h>
#include <helpers/RefCountedDigitalPin.h>
#include "LoRaFEMControl.h"
#ifndef ADC_MULTIPLIER
#define ADC_MULTIPLIER (4.9f * 1.035f)
#endif
class HeltecV4R8Board : public ESP32Board {
protected:
float adc_mult = ADC_MULTIPLIER;
uint32_t last_power_check_ms = 0;
bool power_voltage_sampled = false;
bool voltage_external_power = false;
public:
RefCountedDigitalPin periph_power;
LoRaFEMControl loRaFEMControl;
HeltecV4R8Board() : periph_power(PIN_VEXT_EN, PIN_VEXT_EN_ACTIVE) { }
void begin();
void onBeforeTransmit(void) override;
void onAfterTransmit(void) override;
void powerOff() override;
void shutdownPeripherals() override;
bool setLoRaFemLnaEnabled(bool enable) override;
bool canControlLoRaFemLna() const override;
bool isLoRaFemLnaEnabled() const override;
bool supportsBatteryCalibration() const override { return true; }
uint16_t getBattMilliVolts() override;
bool isExternalPowered() override;
bool setAdcMultiplier(float multiplier) override {
if (!isfinite(multiplier) || multiplier < 0.0f || multiplier > 10.0f) return false;
if (multiplier == 0.0f) {
adc_mult = ADC_MULTIPLIER;
} else {
adc_mult = multiplier;
}
return true;
}
float getAdcMultiplier() const override { return adc_mult; }
const char* getManufacturerName() const override;
};