avr_isp_scene_writer.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include "../avr_isp_app_i.h"
  2. void avr_isp_scene_writer_callback(AvrIspCustomEvent event, void* context) {
  3. furi_assert(context);
  4. AvrIspApp* app = context;
  5. view_dispatcher_send_custom_event(app->view_dispatcher, event);
  6. }
  7. void avr_isp_scene_writer_on_enter(void* context) {
  8. furi_assert(context);
  9. AvrIspApp* app = context;
  10. avr_isp_writer_set_file_path(
  11. app->avr_isp_writer_view, furi_string_get_cstr(app->file_path), app->file_name_tmp);
  12. avr_isp_writer_view_set_callback(app->avr_isp_writer_view, avr_isp_scene_writer_callback, app);
  13. view_dispatcher_switch_to_view(app->view_dispatcher, AvrIspViewWriter);
  14. }
  15. bool avr_isp_scene_writer_on_event(void* context, SceneManagerEvent event) {
  16. furi_assert(context);
  17. AvrIspApp* app = context;
  18. bool consumed = false;
  19. if(event.type == SceneManagerEventTypeBack) {
  20. //do not handle exit on "Back"
  21. consumed = true;
  22. } else if(event.type == SceneManagerEventTypeCustom) {
  23. switch(event.event) {
  24. case AvrIspCustomEventSceneExitStartMenu:
  25. scene_manager_search_and_switch_to_previous_scene(
  26. app->scene_manager, AvrIspSceneStart);
  27. consumed = true;
  28. break;
  29. case AvrIspCustomEventSceneExit:
  30. scene_manager_search_and_switch_to_previous_scene(
  31. app->scene_manager, AvrIspSceneChipDetect);
  32. consumed = true;
  33. break;
  34. case AvrIspCustomEventSceneErrorVerification:
  35. app->error = AvrIspErrorVerification;
  36. scene_manager_search_and_switch_to_previous_scene(
  37. app->scene_manager, AvrIspSceneChipDetect);
  38. consumed = true;
  39. break;
  40. case AvrIspCustomEventSceneErrorWriting:
  41. app->error = AvrIspErrorWriting;
  42. scene_manager_search_and_switch_to_previous_scene(
  43. app->scene_manager, AvrIspSceneChipDetect);
  44. consumed = true;
  45. break;
  46. case AvrIspCustomEventSceneErrorWritingFuse:
  47. app->error = AvrIspErrorWritingFuse;
  48. scene_manager_search_and_switch_to_previous_scene(
  49. app->scene_manager, AvrIspSceneChipDetect);
  50. consumed = true;
  51. break;
  52. default:
  53. break;
  54. }
  55. } else if(event.type == SceneManagerEventTypeTick) {
  56. avr_isp_writer_update_progress(app->avr_isp_writer_view);
  57. }
  58. return consumed;
  59. }
  60. void avr_isp_scene_writer_on_exit(void* context) {
  61. UNUSED(context);
  62. }