mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2025-02-17 05:48:33 +00:00
* Abstract primitive type from main logic in FuriEventLoop * Remove message_queue_i.h * Add stream buffer support for event loop * Add semaphore support for event loop * Add temporary unit test workaround * Make the linter happy * Add mutex support for event loop * Implement event subscription and unsubscription while the event loop is running * Implement edge events * Fix leftover logical errors * Add event loop timer example application * Implement flag-based edge trigger and one-shot mode * Add event loop mutex example application * Only notify the event loop if stream buffer is at or above its trigger level * Reformat comments * Add event loop stream buffer example application * Add event loop multiple elements example application * Improve event loop flag names * Remove redundant signal handler as it is already handled by the event loop * Refactor Power service, improve ViewHolder * Use ViewHolder instead of ViewDispatcher in About app * Enable ViewDispatcher queue on construction, deprecate view_dispatcher_enable_queue() * Remove all invocations of view_dispatcher_enable_queue() * Remove app-scened-template * Remove missing library from target.json * Port Accessor app to ViewHolder * Make the linter happy * Add example_view_holder application, update ViewHolder docs * Add example_view_dispatcher application, update ViewDispatcher docs * Replace FuriSemaphore with FuriApiLock, remove workaround delay * Fix logical error * Fix another logical error * Use the sources directive to speed up compilation * Use constant define macro * Improve FuriEventLoop documentation * Improve FuriEventLoop documentation once more * Bump API Version * Gui: remove redundant checks from ViewDispatcher * Gui: remove dead ifs from ViewDispatcher Co-authored-by: Silent <CookiePLMonster@users.noreply.github.com> Co-authored-by: hedger <hedger@users.noreply.github.com> Co-authored-by: あく <alleteam@gmail.com>
62 lines
1.2 KiB
C
62 lines
1.2 KiB
C
#pragma once
|
|
|
|
#include "power.h"
|
|
|
|
#include <gui/gui.h>
|
|
#include <gui/view_holder.h>
|
|
|
|
#include <toolbox/api_lock.h>
|
|
#include <assets_icons.h>
|
|
|
|
#include "views/power_off.h"
|
|
#include "views/power_unplug_usb.h"
|
|
|
|
typedef enum {
|
|
PowerStateNotCharging,
|
|
PowerStateCharging,
|
|
PowerStateCharged,
|
|
} PowerState;
|
|
|
|
struct Power {
|
|
ViewHolder* view_holder;
|
|
FuriPubSub* event_pubsub;
|
|
FuriEventLoop* event_loop;
|
|
FuriMessageQueue* message_queue;
|
|
|
|
ViewPort* battery_view_port;
|
|
PowerOff* view_power_off;
|
|
PowerUnplugUsb* view_power_unplug_usb;
|
|
|
|
PowerEvent event;
|
|
PowerState state;
|
|
PowerInfo info;
|
|
|
|
bool battery_low;
|
|
bool show_battery_low_warning;
|
|
uint8_t displayBatteryPercentage;
|
|
uint8_t battery_level;
|
|
uint8_t power_off_timeout;
|
|
};
|
|
|
|
typedef enum {
|
|
PowerViewOff,
|
|
PowerViewUnplugUsb,
|
|
} PowerView;
|
|
|
|
typedef enum {
|
|
PowerMessageTypeShutdown,
|
|
PowerMessageTypeReboot,
|
|
PowerMessageTypeGetInfo,
|
|
PowerMessageTypeIsBatteryHealthy,
|
|
PowerMessageTypeShowBatteryLowWarning,
|
|
} PowerMessageType;
|
|
|
|
typedef struct {
|
|
PowerMessageType type;
|
|
union {
|
|
PowerBootMode boot_mode;
|
|
PowerInfo* power_info;
|
|
bool* bool_param;
|
|
};
|
|
FuriApiLock lock;
|
|
} PowerMessage;
|