mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-10 05:59:08 -07: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>
73 lines
1.7 KiB
C
73 lines
1.7 KiB
C
#include "power_i.h"
|
|
|
|
void power_off(Power* power) {
|
|
furi_check(power);
|
|
|
|
PowerMessage msg = {
|
|
.type = PowerMessageTypeShutdown,
|
|
};
|
|
|
|
furi_check(
|
|
furi_message_queue_put(power->message_queue, &msg, FuriWaitForever) == FuriStatusOk);
|
|
}
|
|
|
|
void power_reboot(Power* power, PowerBootMode mode) {
|
|
PowerMessage msg = {
|
|
.type = PowerMessageTypeReboot,
|
|
.boot_mode = mode,
|
|
};
|
|
|
|
furi_check(
|
|
furi_message_queue_put(power->message_queue, &msg, FuriWaitForever) == FuriStatusOk);
|
|
}
|
|
|
|
void power_get_info(Power* power, PowerInfo* info) {
|
|
furi_check(power);
|
|
furi_check(info);
|
|
|
|
PowerMessage msg = {
|
|
.type = PowerMessageTypeGetInfo,
|
|
.power_info = info,
|
|
.lock = api_lock_alloc_locked(),
|
|
};
|
|
|
|
furi_check(
|
|
furi_message_queue_put(power->message_queue, &msg, FuriWaitForever) == FuriStatusOk);
|
|
api_lock_wait_unlock_and_free(msg.lock);
|
|
}
|
|
|
|
FuriPubSub* power_get_pubsub(Power* power) {
|
|
furi_check(power);
|
|
return power->event_pubsub;
|
|
}
|
|
|
|
bool power_is_battery_healthy(Power* power) {
|
|
furi_check(power);
|
|
|
|
bool ret = false;
|
|
|
|
PowerMessage msg = {
|
|
.type = PowerMessageTypeIsBatteryHealthy,
|
|
.lock = api_lock_alloc_locked(),
|
|
.bool_param = &ret,
|
|
};
|
|
|
|
furi_check(
|
|
furi_message_queue_put(power->message_queue, &msg, FuriWaitForever) == FuriStatusOk);
|
|
api_lock_wait_unlock_and_free(msg.lock);
|
|
|
|
return ret;
|
|
}
|
|
|
|
void power_enable_low_battery_level_notification(Power* power, bool enable) {
|
|
furi_check(power);
|
|
|
|
PowerMessage msg = {
|
|
.type = PowerMessageTypeShowBatteryLowWarning,
|
|
.bool_param = &enable,
|
|
};
|
|
|
|
furi_check(
|
|
furi_message_queue_put(power->message_queue, &msg, FuriWaitForever) == FuriStatusOk);
|
|
}
|