spi_mem_scene_verify_error.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "../spi_mem_app_i.h"
  2. static void spi_mem_scene_verify_error_widget_callback(
  3. GuiButtonType result,
  4. InputType type,
  5. void* context) {
  6. SPIMemApp* app = context;
  7. if(type == InputTypeShort) {
  8. view_dispatcher_send_custom_event(app->view_dispatcher, result);
  9. }
  10. }
  11. void spi_mem_scene_verify_error_on_enter(void* context) {
  12. SPIMemApp* app = context;
  13. widget_add_button_element(
  14. app->widget, GuiButtonTypeLeft, "Back", spi_mem_scene_verify_error_widget_callback, app);
  15. widget_add_string_element(
  16. app->widget, 64, 9, AlignCenter, AlignBottom, FontPrimary, "Verification error");
  17. widget_add_string_element(
  18. app->widget, 64, 21, AlignCenter, AlignBottom, FontSecondary, "Data mismatch");
  19. view_dispatcher_switch_to_view(app->view_dispatcher, SPIMemViewWidget);
  20. }
  21. bool spi_mem_scene_verify_error_on_event(void* context, SceneManagerEvent event) {
  22. SPIMemApp* app = context;
  23. bool success = false;
  24. if(event.type == SceneManagerEventTypeBack) {
  25. success = true;
  26. scene_manager_search_and_switch_to_previous_scene(
  27. app->scene_manager, SPIMemSceneChipDetect);
  28. } else if(event.type == SceneManagerEventTypeCustom) {
  29. success = true;
  30. if(event.event == GuiButtonTypeLeft) {
  31. scene_manager_search_and_switch_to_previous_scene(
  32. app->scene_manager, SPIMemSceneChipDetect);
  33. }
  34. }
  35. return success;
  36. }
  37. void spi_mem_scene_verify_error_on_exit(void* context) {
  38. SPIMemApp* app = context;
  39. widget_reset(app->widget);
  40. }