ViezeVingertjes opened a new pull request, #4158:
URL: https://github.com/apache/nuttx-apps/pull/4158
## Summary
**system/batterydump: Fix gauge units and build without battery monitor.**
* The battery gauge interface reports plain integers since the upper
half moved away from b16_t/b8_t (voltage in mV, capacity in percent,
current in mA, temperature in 0.1 degrees Celsius), but batterydump
still decoded them as b16/b8 fixed point, printing e.g. 4096 mV as
"vol:0.0625". Read and print them as integers with their units.
* The monitor dump uses struct battery_monitor_current_s, which only
exists with CONFIG_BATTERY_MONITOR, so batterydump failed to build
without it. Only build the monitor dump when it is enabled.
* Terminate the error messages with a newline.
Tested on Waveshare ESP32-S3-Touch-AMOLED-2.16 (AXP2101 gauge):
"vol:4161mV, capacity:100%, current:0mA, temperature:38.7C" (current
reported as unsupported), built without CONFIG_BATTERY_MONITOR.
The last commit fixes the pre-existing nxstyle errors in the touched file
(whitespace only, no functional change), as CI checks whole files.
## Impact
* Is new feature added? Is existing feature changed? NO
* Impact on user (will user need to adapt to change)? YES: gauge values
printed with their real units.
* Impact on build (will build process change)? NO
* Impact on hardware (will arch(s) / board(s) / driver(s) change)? NO
* Impact on documentation (is update required / provided)? NO
* Impact on security (any sort of implications)? NO
* Impact on compatibility (backward/forward/interoperability)? NO
## Testing
I confirm that changes are verified on local setup and works as intended:
* Build Host(s): Linux x86_64, xtensa-esp-elf GCC 15.2.0
(esp-15.2.0_20251204), riscv32-esp-elf GCC 15.2.0 for the ESP32-C3 build.
* Target(s): Waveshare ESP32-S3-Touch-AMOLED-2.16 (ESP32-S3R8, 16 MB flash,
8 MB PSRAM).
* batterydump -t 1 /dev/gauge0 with an AXP2101 gauge, built without
CONFIG_BATTERY_MONITOR.
Builds (each on current master plus this PR only):
* PASS pr/batterydump-units devkit esp32s3-devkit:nsh (warnings: 0)
Testing logs before change:
```
vol:0.0625 (b16 decoding of 4096 mV); build failed without
CONFIG_BATTERY_MONITOR.
```
Testing logs after change:
```
vol:4161mV, capacity:100%, current:0mA, temperature:38.7C
```
## PR verification Self-Check
* [x] This PR introduces only one functional change.
* [x] I have updated all required description fields above.
* [x] My PR adheres to Contributing Guidelines and Documentation (git commit
title and message, coding standard, etc).
* [ ] My PR is still work in progress (not ready for review).
* [x] My PR is ready for review and can be safely merged into a codebase.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]