Repository navigation
Power: keep per-board capabilities in one table per kind - #423
Merged
Merged
Conversation
The charge state, charge control and power output capabilities were spread across the getters and the switch statements of seven setters, some keyed by PMIC first and others by board first. Each kind now has one static table function (_charge_state_caps, _charge_control_caps, _power_output_caps) that the getter returns directly, and every setter rejects a request whose capability bit is clear right after the identity check. The board conditions that the setters used to repeat are gone. On ESP32 Core2, the vibration bit is now cleared when the PMIC is not AXP192 or AXP2101, matching the only motor rails (AXP192 LDO3, AXP2101 DLDO1). begin() never produces such a pair, so the results for an initialized board are unchanged. The two PMIC identity flags become a three-state enum (not_probed, settled, unconfirmed); the transitions are the same as before. Also correct comments that named IP2316 instead of IP2315, and a comment that described the capability table as the source of getChargeState().
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 charge state, charge control and power output capabilities were spread across the three capability getters and the switch statements of seven setters, some keyed by PMIC first and others by board first. Each kind now has one table function that the getter returns, and each setter refuses a request whose capability bit is clear, right after the PMIC identity check. The board conditions the setters repeated are removed.
Capability results and setter results do not change for any board that
begin()initializes. One table entry is narrowed: on ESP32 Core2 the vibration bit is cleared when the PMIC is neither AXP192 nor AXP2101 (the motor rail is AXP192 LDO3 or AXP2101 DLDO1).begin()never produces that pair.Also:
not_probed,settled,unconfirmed) with the same transitionsgetChargeState()is fixed (the table is only used for the debug cross check)Testing
begin()produces was checked against the seven setters (setBatteryCharge,setChargeCurrent,setChargeVoltage,setExtOutput,setUsbOutput,setVibration,setExtPortBusConfig) in both directions: no setter path without its capability bit, and no capability bit without a setter pathgetChargeStateCaps()/getChargeControlCaps()/getPowerOutputCaps()and charge state asdevelop; external output control checked on Core2 (AXP192 and AXP2101), Tough and ToughC5, vibration on both Core2