2021-09-24 19:28:02 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <furi/pubsub.h>
|
2021-11-24 19:21:12 +03:00
|
|
|
#include <stdbool.h>
|
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;
|
|
|
|
|
2021-09-24 19:28:02 +03:00
|
|
|
float current_charger;
|
|
|
|
float current_gauge;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
/** Enable or disable battery low level notification mesage
|
|
|
|
*
|
|
|
|
* @param power Power instance
|
|
|
|
* @param enable true - enable, false - disable
|
|
|
|
*/
|
|
|
|
void power_enable_low_battery_level_notification(Power* power, bool enable);
|