mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-14 06:52:38 +00:00
a8acfcabb4
* Add skeleton for infrared C port, rename old app * Add scene stubs * Add more views * Misc changes * Add remote and signal class stubs * Complete infrared signal class * Add remote button class stub * Check if button contains a signal during destruction * Complete infrared signal class more * Implement remote storing * Implement remote loading * Fix error handling * Implement remote transmitting * Rename scene * Canonise event consumption * Implement remote learning (stub) * Implement learn success screen (stub) * Implement AskBack scene * Improve remote saving&loading * Fix remote file name * Add LearnDone scene * Switch from Remote scene correctly * Add SceneButtonSelect * Remove unneeded assert * Add new SceneManager method * Use new SceneManager method in Infrared * Implement renaming of buttons and remotes * Implement deleting of buttons and remotes * Add universal remotes list * Add brute force code * Brute force code improvements * Partially implement Universal Remote GUI * Fix wrong singnal handling * Fully implement Universal Remote * Use standard custom events everywhere * Return infrared CLI * Remove old Infrared app * Change container name * Fix scene order * Put ButtonPanel into stack only when needed * Show loading animation during slow operations * Do not hardcode Loading widget coordinates * Switch Loading widget orientation as needed * Save Start scene state * Save Remote scene state * Save Edit scene state * Save EditButtonSelect scene state * Do not use scene state * Use string_t instead of const char* for brevity * Fix memory leak * Fix saving raw remotes * Add Infrared debug menu * Add debug view * Move Infrared monitor into Infrared application * Remove old Infrared monitor app * Use common signal received callback everywhere
95 lines
2.8 KiB
C
95 lines
2.8 KiB
C
#include <stdint.h>
|
|
#include <furi.h>
|
|
#include <assets_icons.h>
|
|
#include <gui/icon_animation.h>
|
|
#include <gui/elements.h>
|
|
#include <gui/canvas.h>
|
|
#include <gui/view.h>
|
|
#include <input/input.h>
|
|
|
|
#include "loading.h"
|
|
|
|
struct Loading {
|
|
View* view;
|
|
};
|
|
|
|
typedef struct {
|
|
IconAnimation* icon;
|
|
} LoadingModel;
|
|
|
|
static void loading_draw_callback(Canvas* canvas, void* _model) {
|
|
LoadingModel* model = (LoadingModel*)_model;
|
|
|
|
uint8_t width = 49;
|
|
uint8_t height = 47;
|
|
uint8_t x = (canvas_width(canvas) - width) / 2;
|
|
uint8_t y = (canvas_height(canvas) - height) / 2;
|
|
|
|
elements_bold_rounded_frame(canvas, x, y, width, height);
|
|
|
|
canvas_set_font(canvas, FontSecondary);
|
|
elements_multiline_text(canvas, x + 7, y + 13, "Loading...");
|
|
|
|
canvas_draw_icon_animation(canvas, x + 13, y + 19, model->icon);
|
|
}
|
|
|
|
static bool loading_input_callback(InputEvent* event, void* context) {
|
|
UNUSED(event);
|
|
furi_assert(context);
|
|
return true;
|
|
}
|
|
|
|
static void loading_enter_callback(void* context) {
|
|
furi_assert(context);
|
|
Loading* instance = context;
|
|
LoadingModel* model = view_get_model(instance->view);
|
|
/* using Loading View in conjunction with several
|
|
* Stack View obligates to reassign
|
|
* Update callback, as it can be rewritten
|
|
*/
|
|
view_tie_icon_animation(instance->view, model->icon);
|
|
icon_animation_start(model->icon);
|
|
view_commit_model(instance->view, false);
|
|
}
|
|
|
|
static void loading_exit_callback(void* context) {
|
|
furi_assert(context);
|
|
Loading* instance = context;
|
|
LoadingModel* model = view_get_model(instance->view);
|
|
icon_animation_stop(model->icon);
|
|
view_commit_model(instance->view, false);
|
|
}
|
|
|
|
Loading* loading_alloc(void) {
|
|
Loading* instance = malloc(sizeof(Loading));
|
|
instance->view = view_alloc();
|
|
view_allocate_model(instance->view, ViewModelTypeLocking, sizeof(LoadingModel));
|
|
LoadingModel* model = view_get_model(instance->view);
|
|
model->icon = icon_animation_alloc(&A_Loading_24);
|
|
view_tie_icon_animation(instance->view, model->icon);
|
|
view_commit_model(instance->view, false);
|
|
|
|
view_set_context(instance->view, instance);
|
|
view_set_draw_callback(instance->view, loading_draw_callback);
|
|
view_set_input_callback(instance->view, loading_input_callback);
|
|
view_set_enter_callback(instance->view, loading_enter_callback);
|
|
view_set_exit_callback(instance->view, loading_exit_callback);
|
|
|
|
return instance;
|
|
}
|
|
|
|
void loading_free(Loading* instance) {
|
|
LoadingModel* model = view_get_model(instance->view);
|
|
icon_animation_free(model->icon);
|
|
view_commit_model(instance->view, false);
|
|
|
|
furi_assert(instance);
|
|
view_free(instance->view);
|
|
free(instance);
|
|
}
|
|
|
|
View* loading_get_view(Loading* instance) {
|
|
furi_assert(instance);
|
|
furi_assert(instance->view);
|
|
return instance->view;
|
|
}
|