scene_install.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "app_i.h"
  2. #include <furi.h>
  3. #include "flasher/flasher.h"
  4. static void scene_install_flasher_callback(FlasherEvent event, void* context) {
  5. furi_assert(context);
  6. App* app = context;
  7. if(event.type == FlasherEventTypeProgress) {
  8. progress_set_value(app->progress, event.progress);
  9. } else if(event.type == FlasherEventTypeSuccess) {
  10. scene_manager_next_scene(app->scene_manager, SceneSuccess);
  11. } else if(event.type == FlasherEventTypeError) {
  12. app->flasher_error = event.error;
  13. scene_manager_next_scene(app->scene_manager, SceneError);
  14. }
  15. }
  16. void scene_install_on_enter(void* context) {
  17. App* app = context;
  18. view_dispatcher_switch_to_view(app->view_dispatcher, ViewIdProgress);
  19. flasher_set_callback(scene_install_flasher_callback, app);
  20. flasher_start(furi_string_get_cstr(app->file_path));
  21. }
  22. bool scene_install_on_event(void* context, SceneManagerEvent event) {
  23. UNUSED(context);
  24. UNUSED(event);
  25. return true;
  26. }
  27. void scene_install_on_exit(void* context) {
  28. App* app = context;
  29. progress_reset(app->progress);
  30. }