[FL-1237] Notifications app (#476)
* Notification app: init * Notification app: separate message sequences * Notification app: rename notifications to notification * Notification app: rework api * Notification app: new sequences for charger * Power app: add state for better led handling * Power app: NotificationSequence type, notification led process * Blink app: use notifications * Notification app: sound and vibro notifications * Notification app: note messages * Notification app: more messages * Notification app: update note message generator * Blink app: fix state counter * Notification app: fix delay event * App sd-filesystem: notifications * App notifications: headers c++ compatibility * App notifications: Cmaj success chord sequence * App iButton: use notifications * App notification: display backlight notifications * App notification: add "display on" message to success and error sequences * App accessor: use notifications * App ibutton: guard onewire key read * Lib-RFAL: remove api_hal_light usage * App notification: add blocking mode, rework display api * Cli led command: use internal notification instead of direc access to leds. * App unit test: use notifications * App lfrfid: use notifications * Apps: close notification record * App subghz: rough use of notifications * App notificaton: ignore reset flag * App strobe: removed * Lib irda decoder: fix nec decoding * App irda: fix assert, use notifications * Apps: use notifications * Fix IRDA tests * Cli: better var naming * App notification: readable sources Co-authored-by: Albert Kharisov <albert@flipperdevices.com> Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -16,8 +16,16 @@
|
||||
#include <assets_icons.h>
|
||||
#include <stm32wbxx.h>
|
||||
|
||||
#include <notification/notification-messages.h>
|
||||
|
||||
#define POWER_OFF_TIMEOUT 30
|
||||
|
||||
typedef enum {
|
||||
PowerStateNotCharging,
|
||||
PowerStateCharging,
|
||||
PowerStateCharged,
|
||||
} PowerState;
|
||||
|
||||
struct Power {
|
||||
ViewDispatcher* view_dispatcher;
|
||||
View* info_view;
|
||||
@@ -32,6 +40,8 @@ struct Power {
|
||||
ValueMutex* menu_vm;
|
||||
Cli* cli;
|
||||
MenuItem* menu;
|
||||
|
||||
PowerState state;
|
||||
};
|
||||
|
||||
void power_draw_battery_callback(Canvas* canvas, void* context) {
|
||||
@@ -91,6 +101,8 @@ void power_menu_info_callback(void* context) {
|
||||
Power* power_alloc() {
|
||||
Power* power = furi_alloc(sizeof(Power));
|
||||
|
||||
power->state = PowerStateNotCharging;
|
||||
|
||||
power->menu_vm = furi_record_open("menu");
|
||||
|
||||
power->cli = furi_record_open("cli");
|
||||
@@ -159,20 +171,26 @@ void power_reset(Power* power, PowerBootMode mode) {
|
||||
api_hal_power_reset();
|
||||
}
|
||||
|
||||
static void power_charging_indication_handler() {
|
||||
static void power_charging_indication_handler(Power* power, NotificationApp* notifications) {
|
||||
if(api_hal_power_is_charging()) {
|
||||
if(api_hal_power_get_pct() == 100) {
|
||||
api_hal_light_set(LightRed, 0x00);
|
||||
api_hal_light_set(LightGreen, 0xFF);
|
||||
if(power->state != PowerStateCharged) {
|
||||
notification_internal_message(notifications, &sequence_charged);
|
||||
power->state = PowerStateCharged;
|
||||
}
|
||||
} else {
|
||||
api_hal_light_set(LightGreen, 0x00);
|
||||
api_hal_light_set(LightRed, 0xFF);
|
||||
if(power->state != PowerStateCharging) {
|
||||
notification_internal_message(notifications, &sequence_charging);
|
||||
power->state = PowerStateCharging;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!api_hal_power_is_charging()) {
|
||||
api_hal_light_set(LightRed, 0x00);
|
||||
api_hal_light_set(LightGreen, 0x00);
|
||||
if(power->state != PowerStateNotCharging) {
|
||||
notification_internal_message(notifications, &sequence_not_charging);
|
||||
power->state = PowerStateNotCharging;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,6 +198,7 @@ int32_t power_task(void* p) {
|
||||
(void)p;
|
||||
Power* power = power_alloc();
|
||||
|
||||
NotificationApp* notifications = furi_record_open("notification");
|
||||
Gui* gui = furi_record_open("gui");
|
||||
gui_add_view_port(gui, power->battery_view_port, GuiLayerStatusBarRight);
|
||||
view_dispatcher_attach_to_gui(power->view_dispatcher, gui, ViewDispatcherTypeFullscreen);
|
||||
@@ -238,7 +257,7 @@ int32_t power_task(void* p) {
|
||||
return true;
|
||||
});
|
||||
|
||||
power_charging_indication_handler();
|
||||
power_charging_indication_handler(power, notifications);
|
||||
|
||||
view_port_update(power->battery_view_port);
|
||||
|
||||
|
Reference in New Issue
Block a user