Files
ZephCore/zephcore/include/mesh/Board.h
T
liquidraver d37b401033 battery: centralized LiPo OCV curve + ADC multiplier corrections
Add a board-aware battery SOC system replacing the two independent
linear approximations that existed in the UI helpers.

New helpers/battery_curve.{h,c}: a 21-point (5% step) OCV lookup table
with integer linear interpolation. The default generic LiPo curve is a
weak symbol — any board can override it by dropping a battery_curve.c
into its board directory. CMakeLists.txt selects the board-specific file
when present, falling back to the generic.

Board.h gains getBattPercent() (default 0); ZephyrBoard implements it
via battery_curve_lookup().

Board-specific curves added for boards with measured cell data:
t1000_e, rak_wismesh_tag, thinknode_m6, sensecap_solar, wio_tracker_l1.

ADC multiplier corrections applied across all nRF52840 boards:
- Boards using a correctly-derived 3600×ratio formula get +0.5% to
  compensate for nRF SAADC gain error (7200→7236, 6300→6332, etc.)
- rak_wismesh_tag, rak3401_1watt, gat562_30s had multipliers copied
  from Arduino's 3.0V AREF formula; corrected to 3600×1.73×1.005=6259
- xiao_nrf52840 (10911) left unchanged — empirically calibrated value
  above the theoretical, assumed already correct for that hardware

get adc.multiplier now reports current mV reading and the board's
curve 100% target, making field calibration self-guiding.
2026-06-03 13:21:06 +02:00

45 lines
1.5 KiB
C++

/*
* SPDX-License-Identifier: Apache-2.0
* ZephCore MainBoard interface
*/
#pragma once
#include <stdint.h>
#include <stddef.h>
#include <math.h>
namespace mesh {
#define BD_STARTUP_NORMAL 0
#define BD_STARTUP_RX_PACKET 1
class MainBoard {
public:
virtual uint16_t getBattMilliVolts() = 0;
virtual uint8_t getBattPercent() { return 0; }
virtual float getMCUTemperature() { return NAN; }
virtual bool setAdcMultiplier(float multiplier) { (void)multiplier; return false; }
virtual float getAdcMultiplier() const { return 0.0f; }
virtual const char *getManufacturerName() const = 0;
virtual void onBeforeTransmit() {}
virtual void onAfterTransmit() {}
virtual void reboot() = 0;
virtual void powerOff() {}
virtual void sleep(uint32_t secs) { (void)secs; }
virtual uint32_t getGpio() { return 0; }
virtual void setGpio(uint32_t values) { (void)values; }
virtual uint8_t getStartupReason() const = 0;
virtual bool getBootloaderVersion(char *version, size_t max_len) { (void)version; (void)max_len; return false; }
virtual bool startOTAUpdate(const char *id, char reply[]) { (void)id; (void)reply; return false; }
virtual bool isExternalPowered() { return false; }
virtual uint16_t getBootVoltage() { return 0; }
virtual uint32_t getResetReason() const { return 0; }
virtual const char *getResetReasonString(uint32_t reason) { (void)reason; return "Not available"; }
virtual uint8_t getShutdownReason() const { return 0; }
virtual const char *getShutdownReasonString(uint8_t reason) { (void)reason; return "Not available"; }
};
} /* namespace mesh */