Skip to content

stats: floor energy at 1 when on USB power#28

Open
Swissola wants to merge 3 commits into
anthropics:mainfrom
Swissola:fix/energy-floor
Open

stats: floor energy at 1 when on USB power#28
Swissola wants to merge 3 commits into
anthropics:mainfrom
Swissola:fix/energy-floor

Conversation

@Swissola
Copy link
Copy Markdown

Summary

  • Add bool onUsb = false parameter to statsEnergyTier()
  • Floor energy at 1 (not 0) when the device is on USB power
  • Pass _onUsb at the single call site in main.cpp

Motivation

The pet could show fully depleted energy (0/5) even while plugged in. This looks wrong — a device sitting on a desk charging should never appear dead. When USB power is detected the energy display floors at 1 so it always shows at least a trace of life.

_onUsb is already tracked via M5.Axp.GetVBusVoltage() > 4.0f in clockRefreshRtc(); no new state is introduced.

Behaviour after this change

  • Plugged in with no recent nap: energy shows 1/5 rather than 0/5
  • Unplugged: behaviour unchanged — can drain to 0 normally
  • Normal nap/wake cycle: unaffected

Test plan

  • Leave device unplugged for several hours — energy drains to 0 normally
  • Plug in when energy is at 0 — bar shows 1/5 immediately
  • Nap + wake cycle while plugged in — energy tops up to 5 as before

🤖 Generated with Claude Code

Swissola and others added 3 commits May 22, 2026 17:37
sleep=Donald Duck, idle=Bongo Cat, busy=SpongeBob multitasking,
attention=Surprised Pikachu (Nouns glasses), celebrate=Peanuts party,
dizzy=Powerpuff Girls spiral eyes, heart=heart eyes ghost.

Source GIFs in characters/memes-src/, device-ready pack in characters/memes/.
Built with prep_character.py at 96x98px, 64 colours per frame.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Track the current peer BD address in onConnect (extended overload).
bleRemoveCurrentBond() removes only that peer's LTK from NVS. The
"unpair" JSON command now calls this instead of bleClearBonds(), so
each host unpairs itself independently. bleClearBonds() is reserved
for factory reset only.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The pet could show fully depleted (0/5 energy) even while plugged in, which
looks wrong — a charging device should never appear dead. Pass _onUsb to
statsEnergyTier() and use it to clamp the minimum to 1 when on USB power.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant