scene_start.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #include "app_i.h"
  2. #include <furi.h>
  3. typedef enum {
  4. SceneStartIndexInstallDefault,
  5. SceneStartIndexInstallRGB,
  6. SceneStartIndexInstallCustom,
  7. } SceneStartIndex;
  8. void scene_start_on_enter(void* context) {
  9. App* app = context;
  10. if(!furi_string_empty(app->file_path)) {
  11. // File path is set, go directly to firmware install
  12. scene_manager_next_scene(app->scene_manager, SceneInstall);
  13. return;
  14. }
  15. submenu_add_item(
  16. app->submenu,
  17. "Install Official Firmware",
  18. SceneStartIndexInstallDefault,
  19. submenu_item_common_callback,
  20. app);
  21. submenu_add_item(
  22. app->submenu,
  23. "Install RGB Firmware",
  24. SceneStartIndexInstallRGB,
  25. submenu_item_common_callback,
  26. app);
  27. submenu_add_item(
  28. app->submenu,
  29. "Install Firmware from File",
  30. SceneStartIndexInstallCustom,
  31. submenu_item_common_callback,
  32. app);
  33. view_dispatcher_switch_to_view(app->view_dispatcher, ViewIdSubmenu);
  34. }
  35. bool scene_start_on_event(void* context, SceneManagerEvent event) {
  36. furi_assert(context);
  37. App* app = context;
  38. if(event.type == SceneManagerEventTypeCustom) {
  39. if(event.event == SceneStartIndexInstallDefault) {
  40. furi_string_set(app->file_path, VGM_DEFAULT_FW_FILE);
  41. scene_manager_next_scene(app->scene_manager, SceneConfirm);
  42. } else if(event.event == SceneStartIndexInstallRGB) {
  43. furi_string_set(app->file_path, APP_ASSETS_PATH("vgm-fw-rgb-0.1.0.uf2"));
  44. scene_manager_next_scene(app->scene_manager, SceneConfirm);
  45. } else if(event.event == SceneStartIndexInstallCustom) {
  46. scene_manager_next_scene(app->scene_manager, SceneFileSelect);
  47. }
  48. return true;
  49. } else if(event.type == SceneManagerEventTypeBack) {
  50. view_dispatcher_stop(app->view_dispatcher);
  51. return true;
  52. }
  53. return false;
  54. }
  55. void scene_start_on_exit(void* context) {
  56. App* app = context;
  57. submenu_reset(app->submenu);
  58. }