mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-23 04:53:08 +00:00
f4122a924a
* 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>
88 lines
2.7 KiB
C
88 lines
2.7 KiB
C
#include "expansion_settings_app.h"
|
|
|
|
static const char* const expansion_uart_text[] = {
|
|
"USART",
|
|
"LPUART",
|
|
"None",
|
|
};
|
|
|
|
static void expansion_settings_app_uart_changed(VariableItem* item) {
|
|
ExpansionSettingsApp* app = variable_item_get_context(item);
|
|
const uint8_t index = variable_item_get_current_value_index(item);
|
|
variable_item_set_current_value_text(item, expansion_uart_text[index]);
|
|
app->settings.uart_index = index;
|
|
|
|
if(index < FuriHalSerialIdMax) {
|
|
expansion_set_listen_serial(app->expansion, index);
|
|
} else {
|
|
expansion_disable(app->expansion);
|
|
}
|
|
}
|
|
|
|
static uint32_t expansion_settings_app_exit(void* context) {
|
|
UNUSED(context);
|
|
return VIEW_NONE;
|
|
}
|
|
|
|
static ExpansionSettingsApp* expansion_settings_app_alloc(void) {
|
|
ExpansionSettingsApp* app = malloc(sizeof(ExpansionSettingsApp));
|
|
|
|
expansion_settings_load(&app->settings);
|
|
|
|
app->gui = furi_record_open(RECORD_GUI);
|
|
app->expansion = furi_record_open(RECORD_EXPANSION);
|
|
|
|
app->view_dispatcher = view_dispatcher_alloc();
|
|
view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
|
|
|
|
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
|
|
|
app->var_item_list = variable_item_list_alloc();
|
|
|
|
VariableItem* item;
|
|
uint8_t value_index;
|
|
|
|
item = variable_item_list_add(
|
|
app->var_item_list,
|
|
"Listen UART",
|
|
COUNT_OF(expansion_uart_text),
|
|
expansion_settings_app_uart_changed,
|
|
app);
|
|
value_index = app->settings.uart_index;
|
|
variable_item_set_current_value_index(item, value_index);
|
|
variable_item_set_current_value_text(item, expansion_uart_text[value_index]);
|
|
|
|
view_set_previous_callback(
|
|
variable_item_list_get_view(app->var_item_list), expansion_settings_app_exit);
|
|
view_dispatcher_add_view(
|
|
app->view_dispatcher,
|
|
ExpansionSettingsViewVarItemList,
|
|
variable_item_list_get_view(app->var_item_list));
|
|
|
|
view_dispatcher_switch_to_view(app->view_dispatcher, ExpansionSettingsViewVarItemList);
|
|
|
|
return app;
|
|
}
|
|
|
|
static void expansion_settings_app_free(ExpansionSettingsApp* app) {
|
|
furi_assert(app);
|
|
|
|
expansion_settings_save(&app->settings);
|
|
|
|
view_dispatcher_remove_view(app->view_dispatcher, ExpansionSettingsViewVarItemList);
|
|
variable_item_list_free(app->var_item_list);
|
|
view_dispatcher_free(app->view_dispatcher);
|
|
|
|
furi_record_close(RECORD_EXPANSION);
|
|
furi_record_close(RECORD_GUI);
|
|
|
|
free(app);
|
|
}
|
|
|
|
int32_t expansion_settings_app(void* p) {
|
|
UNUSED(p);
|
|
ExpansionSettingsApp* app = expansion_settings_app_alloc();
|
|
view_dispatcher_run(app->view_dispatcher);
|
|
expansion_settings_app_free(app);
|
|
return 0;
|
|
}
|