[FL-1783] Power service refactoring (#718)
* settings power: introduce power settings app * power: move power API to separate file * settings power: implement reboot scene * settings power: add power off scene * assets: add crying dolphin, fix Subghz assets names * settings power: fix power off scene GUI * settings power: add battery info scene * power: add cli to application on start hook * power: remove power from main menu * power: move to power service folder * power service: rework power off logic * power: add pubsub events * bt: subscribe to battery level change, update characteristic * application: change order of Settings applications * gui: add bubble element * power: gui improvements * application: rename Notification -> LCD and notifications * Applications: menu order according to documentation and add missing power cli init * settings power: add disconnect USB scene * power cli: notify user to disconnect USB after poweroff * Power: update poweroff message in cli Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -26,6 +26,17 @@ static void bt_pin_code_show_event_handler(Bt* bt, uint32_t pin) {
|
||||
string_clear(pin_str);
|
||||
}
|
||||
|
||||
static void bt_battery_level_changed_callback(const void* _event, void* context) {
|
||||
furi_assert(_event);
|
||||
furi_assert(context);
|
||||
|
||||
Bt* bt = context;
|
||||
const PowerEvent* event = _event;
|
||||
if(event->type == PowerEventTypeBatteryLevelChanged) {
|
||||
bt_update_battery_level(bt, event->data.battery_level);
|
||||
}
|
||||
}
|
||||
|
||||
Bt* bt_alloc() {
|
||||
Bt* bt = furi_alloc(sizeof(Bt));
|
||||
// Load settings
|
||||
@@ -45,6 +56,11 @@ Bt* bt_alloc() {
|
||||
bt->dialogs = furi_record_open("dialogs");
|
||||
bt->dialog_message = dialog_message_alloc();
|
||||
|
||||
// Power
|
||||
bt->power = furi_record_open("power");
|
||||
PubSub* power_pubsub = power_get_pubsub(bt->power);
|
||||
subscribe_pubsub(power_pubsub, bt_battery_level_changed_callback, bt);
|
||||
|
||||
return bt;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user