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,
|
|
|
|
} PowerBootMode;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
PowerEventTypeStopCharging,
|
|
|
|
PowerEventTypeStartCharging,
|
|
|
|
PowerEventTypeFullyCharged,
|
|
|
|
PowerEventTypeBatteryLevelChanged,
|
|
|
|
} PowerEventType;
|
|
|
|
|
|
|
|
typedef union {
|
|
|
|
uint8_t battery_level;
|
|
|
|
} PowerEventData;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
PowerEventType type;
|
|
|
|
PowerEventData data;
|
|
|
|
} PowerEvent;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
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
|
|
|
|
* @param mode - PowerBootMode
|
|
|
|
*/
|
|
|
|
void power_reboot(PowerBootMode mode);
|
|
|
|
|
|
|
|
/** Get power info
|
|
|
|
* @param power - Power instance
|
|
|
|
* @param info - PowerInfo instance
|
|
|
|
*/
|
|
|
|
void power_get_info(Power* power, PowerInfo* info);
|
|
|
|
|
|
|
|
/** Get power event pubsub handler
|
|
|
|
* @param power - Power instance
|
|
|
|
*/
|
2021-11-01 23:35:54 +03:00
|
|
|
FuriPubSub* power_get_pubsub(Power* power);
|
2021-11-24 19:21:12 +03:00
|
|
|
|
|
|
|
bool power_is_battery_well(PowerInfo* info);
|