Build and push server image / build-and-push (push) Successful in 32s
Battery (firmware + server, disabled by default): new battery.c reads a 2x200k voltage divider via ADC oneshot with curve-fitting calibration (the ESP32-C6's scheme), maps through a piecewise LiPo discharge curve, and restores the pin to button duty after each read -- the settled XIAO ESP32-C6 design shares the back button's GPIO0/A0, time-shared per wake. Skipped entirely when on mains (a 2x100k VBUS divider into a spare digital pin -- the 5V pin is dead on battery power, so presence = mains, where the charging voltage would read misleadingly full) or when the reading is implausible. The manage overlay gains a battery region (static outline glyph + "NN%", below the manage QR, all menu levels), and the device POSTs to the new /frame/battery endpoint after a successful fetch; the server stores percent + as-of timestamp, exposed via /api/queue and shown in the web UI. FRAME_BATTERY_ADC_GPIO / FRAME_VBUS_SENSE_GPIO default to -1 (fully inert on the dev board); compile-verified both disabled and enabled, hardware bring-up deferred until the ordered XIAO + batteries arrive. Orientation (server-side only): new config setting + web UI dropdown (landscape / portrait / landscape_flipped / portrait_flipped). Photos are composed/cropped at the logical hanging shape (portrait crops at 480x800, so face-aware crops match how the frame actually hangs), then rotated losslessly into the panel's native 800x480 byte layout after dithering -- the device never knows. Face-label anchors are transformed through the same rotation (logical_to_native()) so they stay attached to faces on rotated frames. Known documented limitation: the on-device manage overlay still renders in native orientation, so it appears sideways on a portrait-hung frame (QRs scan at any rotation; text reads sideways).
20 lines
859 B
C
20 lines
859 B
C
#pragma once
|
|
|
|
/**
|
|
* Reads the battery level via the ADC voltage divider
|
|
* (CONFIG_FRAME_BATTERY_ADC_GPIO -- see Kconfig for the expected XIAO
|
|
* ESP32-C6 wiring). Returns 0-100, or -1 for any of:
|
|
* - feature disabled (CONFIG_FRAME_BATTERY_ADC_GPIO < 0),
|
|
* - running on mains (CONFIG_FRAME_VBUS_SENSE_GPIO reads high),
|
|
* - reading outside the plausible LiPo range (catches "no battery
|
|
* attached" and a button held on a shared pin, which reads ~0V),
|
|
* - any ADC setup/read error.
|
|
*
|
|
* The battery pin is expected to be shared with a button (the settled
|
|
* XIAO design shares the back button's GPIO0/A0): call this AFTER the
|
|
* button checks at boot, since the ADC read temporarily reconfigures
|
|
* the pin. On return the pin is always restored to button duty (input +
|
|
* pull-up + deep-sleep wake armed).
|
|
*/
|
|
int battery_read_percent(void);
|