Repository navigation
The battery's charge and charging show in the status bar - #43
Merged
Merged
Conversation
The launcher's status bar always read "--%" and the pause menu 0%. The BSP reads the INA226 only in read_battery_status(); Tab5Emu::battery_status() returns its cache, which nothing refreshed after initialize_battery_monitoring() zeroed it. The launcher waits for battery_topic, but nothing published it. - Tab5Emu::initialize_battery() starts a battery task (4 KB stack in PSRAM, priority 1). Every 2 s it reads the battery and publishes battery_topic when what the UI shows changes: the percent, charging, or whether a pack is in the bay. It logs each change. - Gui::on_battery only marks the reading new; Gui::update() applies it on the GUI's own task, so LVGL isn't touched from the event task while the pause menu runs LVGL on its own. The flag starts set, so the launcher shows the battery from its first update, even if the first publish came before the Gui subscribed. - With no pack in the bay (is_present false: running from USB), the launcher and the pause menu show "--%", not an empty battery. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The launcher's status bar always read "--%", and the pause menu 0%: nothing ever read the battery.
read_battery_status().Tab5Emu::battery_status()returns the BSP's cache (get_battery_status()), whichinitialize_battery_monitoring()zeroes and nothing refreshed afterwards.Gui::on_battery) waits forbattery_topic, but nothing published it.Changes
Tab5Emu::initialize_battery()starts it, with a 4 KB stack in PSRAM at priority 1.read_battery_status(), which also refreshes the cache thatbattery_status()returns.battery_topiconly when what the UI shows changes: the percent, charging, or whether a pack is in the bay. It logs each change, e.g.battery: 99%, charging (8.38 V, -502 mA).Gui::on_batterynow only marks the reading new, andGui::update()applies it. The pause menu runs LVGL on its own task, so touching the launcher from the event task could race it.Guisubscribes. (initialize_battery()runs before theGuiis constructed inmain.cpp.)is_presentis false (running from USB), the launcher and the pause menu show "--%" instead of an empty battery.Testing (Tab5, audio muted)
battery_status()cache. It couldn't be screenshot, because emulink refuses screenshots while the menu is open.Notes
update_battery_status, which calls itself a rough placeholder), and the voltage rises under charge. The BSP also pauses charging while audio plays (update_charging_for_audio), even with audio muted. A steadier figure needs the BSP to allow for the charge current; that's not in this PR.Gui::on_volumehas the same LVGL-from-the-event-task pattern this avoids for the battery. It's untouched here.🤖 Generated with Claude Code
https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY