-
Couldn't load subscription status.
- Fork 7.7k
Description
Board
Multiple - e.g. Lilygo T3S3
Device Description
None (attached to laptop, but not relevant)
Hardware Configuration
No
Version
latest stable Release (if not listed below)
Type
Task
IDE Name
PlatformIO
Operating System
N/A
Flash frequency
N/A
PSRAM enabled
yes
Upload speed
N/A
Description
The variant files contain at least 15 different ways of telling you on which pin the battery voltage can be measured.
Try grep BAT /Users/mitra/.platformio/packages/framework-arduinoespressif32/variants/*/pins_arduino.h
VBAT_VOLTAGE BAT_VOLTS BAT_VOLT BAT_MEASURE VBAT_SENSE BATT_ADC_PIN BAT_ADC_PIN BAT_ADC BATT_MONITOR BAT_MEASURE BAT_LV WS_BAT_ADC PIN_VBAT PIN_BATTERY BATTERY_PIN
What is worse is that these are mostly (though not all) static const uint8_t so it is next to impossible to write board independent (library) code without testing by board name
I am sure there is code that depends on most of these different definitions, so I would suggest we pick one and progressively add #defines to all variant files that define one common value.
I don't particularly care which is used but suggest it indicates its an ADC as for example VBAT_VOLTAGE could imply its the voltage level, so if we chose VBAT_BUILTIN
then e.g. on lilygo_t3_s3_sx1262/pins_arduino.h we could add #define VBAT_BUILTIN BAT_VOLT
I'm sure someone could write a quick python script to make all the changes, but I don't want to submit this as a PR if there is likely to be (reasonable) pushback.
Sketch
#ifdef ARDUINO_LILYGO_T3_S3_V1_X
analogRead(BAT_VOLT); // Specific to a few boards
#elif defined(xxxxx)
analogRead(VBAT_SENSE)
#elif ... repeat for every board that has built in battery measurement
#endifDebug Message
n/a
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
- I confirm I have checked existing issues, online documentation and Troubleshooting guide.