Sync
This commit is contained in:
@@ -15,6 +15,13 @@ typedef enum {
|
||||
BATT_STATE_UNKNOWN,
|
||||
} batt_mgmt_state_t;
|
||||
|
||||
typedef struct {
|
||||
batt_mgmt_state_t state;
|
||||
uint8_t level;
|
||||
uint8_t percent;
|
||||
int32_t voltage_mv;
|
||||
} batt_mgmt_info_t;
|
||||
|
||||
/**
|
||||
* @brief Measure battery VDDH voltage.
|
||||
*
|
||||
@@ -24,13 +31,53 @@ typedef enum {
|
||||
*/
|
||||
int batt_mgmt_measure_vddh_mv(uint8_t oversampling, int32_t *vddh_mv);
|
||||
|
||||
/**
|
||||
* @brief Get display voltage in millivolts.
|
||||
*
|
||||
* Returns the voltage value intended for UI/protocol display. Currently this is
|
||||
* the latest measured VDDH value cached by batt_mgmt.
|
||||
*
|
||||
* @param vddh_mv Pointer receiving display voltage in mV.
|
||||
* @return 0 on success, negative errno on failure.
|
||||
*/
|
||||
int batt_mgmt_get_display_voltage_mv(int32_t *vddh_mv);
|
||||
|
||||
/**
|
||||
* @brief Get battery level bucket (0..4) from configured thresholds.
|
||||
*
|
||||
* Level mapping:
|
||||
* - 0: below 20% threshold
|
||||
* - 1: 20%..49%
|
||||
* - 2: 50%..79%
|
||||
* - 3: 80%..99%
|
||||
* - 4: full and above
|
||||
*
|
||||
* @param level Pointer receiving level in range 0..4.
|
||||
* @return 0 on success, negative errno on failure.
|
||||
*/
|
||||
int batt_mgmt_get_battery_level(uint8_t *level);
|
||||
|
||||
/**
|
||||
* @brief Get battery percentage (0-100) from configured voltage thresholds.
|
||||
*
|
||||
* Uses piecewise linear interpolation over:
|
||||
* - EMPTY..20%
|
||||
* - 20%..50%
|
||||
* - 50%..80%
|
||||
* - 80%..FULL
|
||||
*
|
||||
* @param percent Pointer receiving percentage in range 0..100.
|
||||
* @return 0 on success, negative errno on failure.
|
||||
*/
|
||||
int batt_mgmt_get_battery_percent(uint8_t *percent);
|
||||
|
||||
/**
|
||||
* @brief Get raw charger status (GPIO level).
|
||||
*
|
||||
* Returns the current logic level of the charger status pin (typically from ETA6003).
|
||||
* This is the **raw GPIO status**, not a processed state machine result.
|
||||
*
|
||||
* @return true if charger pin is high (e.g., battery is "full"), false if low.
|
||||
* @return true if charger pin is high (e.g., battery is "charging"), false if low.
|
||||
*/
|
||||
bool batt_mgmt_get_charger_status(void);
|
||||
|
||||
@@ -48,5 +95,13 @@ bool batt_mgmt_get_charger_status(void);
|
||||
*/
|
||||
batt_mgmt_state_t batt_mgmt_get_battery_state(void);
|
||||
|
||||
/**
|
||||
* @brief Get all battery information in one call.
|
||||
*
|
||||
* @param info Pointer receiving state, level (0..4), percent (0..100), and voltage in mV.
|
||||
* @return 0 on success, negative errno on failure.
|
||||
*/
|
||||
int batt_mgmt_get_info(batt_mgmt_info_t *info);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user