Repository navigation
Fix Display Out enable bit, charge-state caps, IP5306 voltage steps and PowerHub power-off - #403
Merged
Merged
Conversation
The Display Out enable was split into two bitfields (the new unit_poep4_display_out at bit 9 and the deprecated unit_poep4_hdmi at bit 10) and required both to be set. Clearing external_display_value and then setting only the new name therefore left the output disabled, and a raw mask with only bit 9 set (the 0.2.26 meaning) no longer enabled it either. Bit 9 is now the only enable bit, which restores the 0.2.26 raw-mask layout. The legacy bitfield external_display.unit_poep4_hdmi is removed, so code that still writes it fails to compile instead of silently losing its effect. Replace it with external_display.unit_poep4_display_out. The config structure member cfg.unit_poep4_hdmi is unchanged.
…-off retry getChargeStateCaps() now returns the set by value, like getChargeControlCaps() and getPowerOutputCaps(). The set is empty before M5.begin() completes, on unsupported models, and while the PMIC identity is unconfirmed; getChargeState() reports not_initialized, unsupported or io_error respectively. IP5306 setChargeVoltage() selects and reports the nominal steps 4200 / 4300 / 4350 / 4400 mV, like the AXP192 / AXP2101 paths. Comparing the requests with the boosted values selected one step lower than requested (4300 gave the 4.2 V step). 0.2.26 clamped requests at the equivalent of 4360 mV, so the 4.4 V step was unreachable; requests of 4400 mV or more now select it. The register values and the datasheet boost are unchanged. On PowerHub an accepted power-off request cannot be withdrawn and may still complete after timerSleep() has returned. The flag that records it now stays set for the rest of the boot, and timerSleep() refuses before touching the RTC, the ESP wake sources or the display, so a retry can no longer clear the alarm that a delayed power-off needs. PowerHub power-off cleared registers 0x01-0x05 (outputs and the voltage / current measurement) and did not restore them when the device kept running, so battery and charge readings stayed broken afterwards. The values are saved before the request and written back when it fails or times out; if they could not be read, only the measurement enable is restored.
Merged
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.
Use a single enable bit for the Unit PoE-P4 display output
unit_poep4_display_out(bit 9) and the deprecatedunit_poep4_hdmi(bit 10). Aftercfg.external_display_value = 0, setting only the new name left the output disabled, and a raw mask with only bit 9 (the 0.2.26 meaning) no longer enabled it.external_display.unit_poep4_hdmiis removed, so code that writes it fails to compile; useexternal_display.unit_poep4_display_out.cfg.unit_poep4_hdmi(the config structure) is unchanged.Power
getChargeStateCaps()returnscharge_state_set_tby value, like the other two capability getters. Empty beforeM5.begin(), on unsupported models, and while the PMIC identity is unconfirmed.setChargeVoltage()selects and reports the nominal steps 4200 / 4300 / 4350 / 4400 mV (the AXP192 / AXP2101 convention). The previous comparison with boosted values selected one step lower (4300 → 4.2 V step). Requests of 4400 mV or more now reach the 4.4 V step, which the 0.2.26 clamp never selected.timerSleep()refuses before touching the RTC, wake sources or display. A retry can no longer clear the alarm that a delayed power-off needs.Testing
setChargeVoltage()with 4100 / 4200 / 4299 / 4300 / 4350 / 4400 / 4500 mV gave the expected nominal step and CHG_CTL2 value (0x02 / 0x02 / 0x02 / 0x05 / 0x09 / 0x0D / 0x0D).timerSleep(time)powered off and woke at the alarm. The path where the device keeps running (failed or timed-out request) could not be produced on hardware and was checked by review.