2021-09-24 16:28:02 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2022-07-20 10:56:33 +00:00
|
|
|
#include <core/pubsub.h>
|
2021-11-24 16:21:12 +00:00
|
|
|
#include <stdbool.h>
|
2021-09-24 16:28:02 +00:00
|
|
|
|
2022-09-14 16:11:38 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2022-07-26 12:21:51 +00:00
|
|
|
#define RECORD_POWER "power"
|
|
|
|
|
2021-09-24 16:28:02 +00:00
|
|
|
typedef struct Power Power;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
PowerBootModeNormal,
|
|
|
|
PowerBootModeDfu,
|
2022-04-15 16:47:57 +00:00
|
|
|
PowerBootModeUpdateStart,
|
2021-09-24 16:28:02 +00: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-18 23:09:11 +00:00
|
|
|
bool gauge_is_ok;
|
2022-09-15 14:13:48 +00:00
|
|
|
bool is_charging;
|
2022-04-18 23:09:11 +00:00
|
|
|
|
2021-09-24 16:28:02 +00:00
|
|
|
float current_charger;
|
|
|
|
float current_gauge;
|
|
|
|
|
2022-12-08 06:57:49 +00:00
|
|
|
float voltage_battery_charging;
|
2021-09-24 16:28:02 +00: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 00:12:30 +00:00
|
|
|
void power_off(Power* power);
|
2021-09-24 16:28:02 +00:00
|
|
|
|
|
|
|
/** Reboot device
|
2022-01-02 22:52:45 +00:00
|
|
|
*
|
|
|
|
* @param mode PowerBootMode
|
2021-09-24 16:28:02 +00:00
|
|
|
*/
|
|
|
|
void power_reboot(PowerBootMode mode);
|
|
|
|
|
|
|
|
/** Get power info
|
2022-01-02 22:52:45 +00:00
|
|
|
*
|
|
|
|
* @param power Power instance
|
|
|
|
* @param info PowerInfo instance
|
2021-09-24 16:28:02 +00:00
|
|
|
*/
|
|
|
|
void power_get_info(Power* power, PowerInfo* info);
|
|
|
|
|
|
|
|
/** Get power event pubsub handler
|
2022-01-02 22:52:45 +00:00
|
|
|
*
|
|
|
|
* @param power Power instance
|
|
|
|
*
|
|
|
|
* @return FuriPubSub instance
|
2021-09-24 16:28:02 +00:00
|
|
|
*/
|
2021-11-01 20:35:54 +00:00
|
|
|
FuriPubSub* power_get_pubsub(Power* power);
|
2021-11-24 16:21:12 +00:00
|
|
|
|
2022-01-02 22:52:45 +00:00
|
|
|
/** Check battery health
|
|
|
|
*
|
|
|
|
* @return true if battery is healthy
|
|
|
|
*/
|
|
|
|
bool power_is_battery_healthy(Power* power);
|
|
|
|
|
2022-11-28 16:51:51 +00:00
|
|
|
/** Enable or disable battery low level notification message
|
2022-01-02 22:52:45 +00: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 16:11:38 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|