2021-09-24 19:28:02 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2022-07-20 13:56:33 +03:00
|
|
|
#include <core/pubsub.h>
|
2021-11-24 19:21:12 +03:00
|
|
|
#include <stdbool.h>
|
2021-09-24 19:28:02 +03:00
|
|
|
|
2022-09-14 19:11:38 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2022-07-26 15:21:51 +03:00
|
|
|
#define RECORD_POWER "power"
|
|
|
|
|
2021-09-24 19:28:02 +03:00
|
|
|
typedef struct Power Power;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
PowerBootModeNormal,
|
|
|
|
PowerBootModeDfu,
|
2022-04-15 19:47:57 +03:00
|
|
|
PowerBootModeUpdateStart,
|
2021-09-24 19:28:02 +03:00
|
|
|
} PowerBootMode;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
PowerEventTypeStopCharging,
|
|
|
|
PowerEventTypeStartCharging,
|
|
|
|
PowerEventTypeFullyCharged,
|
|
|
|
PowerEventTypeBatteryLevelChanged,
|
|
|
|
} PowerEventType;
|
|
|
|
|
|
|
|
typedef union {
|
|
|
|
uint8_t battery_level;
|
|
|
|
} PowerEventData;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
PowerEventType type;
|
|
|
|
PowerEventData data;
|
|
|
|
} PowerEvent;
|
|
|
|
|
|
|
|
typedef struct {
|
2022-04-19 02:09:11 +03:00
|
|
|
bool gauge_is_ok;
|
2022-09-15 17:13:48 +03:00
|
|
|
bool is_charging;
|
2022-04-19 02:09:11 +03:00
|
|
|
|
2021-09-24 19:28:02 +03:00
|
|
|
float current_charger;
|
|
|
|
float current_gauge;
|
|
|
|
|
2023-02-26 20:23:39 +03:00
|
|
|
float voltage_battery_charge_limit;
|
2021-09-24 19:28:02 +03:00
|
|
|
float voltage_charger;
|
|
|
|
float voltage_gauge;
|
|
|
|
float voltage_vbus;
|
|
|
|
|
|
|
|
uint32_t capacity_remaining;
|
|
|
|
uint32_t capacity_full;
|
|
|
|
|
|
|
|
float temperature_charger;
|
|
|
|
float temperature_gauge;
|
|
|
|
|
|
|
|
uint8_t charge;
|
|
|
|
uint8_t health;
|
|
|
|
} PowerInfo;
|
|
|
|
|
|
|
|
/** Power off device
|
|
|
|
*/
|
2021-11-16 03:12:30 +03:00
|
|
|
void power_off(Power* power);
|
2021-09-24 19:28:02 +03:00
|
|
|
|
|
|
|
/** Reboot device
|
2022-01-03 01:52:45 +03:00
|
|
|
*
|
|
|
|
* @param mode PowerBootMode
|
2021-09-24 19:28:02 +03:00
|
|
|
*/
|
|
|
|
void power_reboot(PowerBootMode mode);
|
|
|
|
|
|
|
|
/** Get power info
|
2022-01-03 01:52:45 +03:00
|
|
|
*
|
|
|
|
* @param power Power instance
|
|
|
|
* @param info PowerInfo instance
|
2021-09-24 19:28:02 +03:00
|
|
|
*/
|
|
|
|
void power_get_info(Power* power, PowerInfo* info);
|
|
|
|
|
|
|
|
/** Get power event pubsub handler
|
2022-01-03 01:52:45 +03:00
|
|
|
*
|
|
|
|
* @param power Power instance
|
|
|
|
*
|
|
|
|
* @return FuriPubSub instance
|
2021-09-24 19:28:02 +03:00
|
|
|
*/
|
2021-11-01 23:35:54 +03:00
|
|
|
FuriPubSub* power_get_pubsub(Power* power);
|
2021-11-24 19:21:12 +03:00
|
|
|
|
2022-01-03 01:52:45 +03:00
|
|
|
/** Check battery health
|
|
|
|
*
|
|
|
|
* @return true if battery is healthy
|
|
|
|
*/
|
|
|
|
bool power_is_battery_healthy(Power* power);
|
|
|
|
|
2022-11-28 19:51:51 +03:00
|
|
|
/** Enable or disable battery low level notification message
|
2022-01-03 01:52:45 +03:00
|
|
|
*
|
|
|
|
* @param power Power instance
|
|
|
|
* @param enable true - enable, false - disable
|
|
|
|
*/
|
|
|
|
void power_enable_low_battery_level_notification(Power* power, bool enable);
|
2022-09-14 19:11:38 +03:00
|
|
|
|
2023-04-21 15:55:06 +03:00
|
|
|
/** Trigger UI update for changing battery layout
|
|
|
|
*
|
|
|
|
* @param power Power instance
|
|
|
|
*/
|
|
|
|
void power_trigger_ui_update(Power* power);
|
|
|
|
|
2022-09-14 19:11:38 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|