subghz_scene_save_success.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include "../subghz_i.h"
  2. #include "../helpers/subghz_custom_event.h"
  3. void subghz_scene_save_success_popup_callback(void* context) {
  4. SubGhz* subghz = context;
  5. view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventSceneSaveSuccess);
  6. }
  7. void subghz_scene_save_success_on_enter(void* context) {
  8. SubGhz* subghz = context;
  9. // Setup view
  10. Popup* popup = subghz->popup;
  11. popup_set_icon(popup, 32, 5, &I_DolphinNice_96x59);
  12. popup_set_header(popup, "Saved!", 13, 22, AlignLeft, AlignBottom);
  13. popup_set_timeout(popup, 1500);
  14. popup_set_context(popup, subghz);
  15. popup_set_callback(popup, subghz_scene_save_success_popup_callback);
  16. popup_enable_timeout(popup);
  17. view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdPopup);
  18. }
  19. bool subghz_scene_save_success_on_event(void* context, SceneManagerEvent event) {
  20. SubGhz* subghz = context;
  21. if(event.type == SceneManagerEventTypeCustom) {
  22. if(event.event == SubGhzCustomEventSceneSaveSuccess) {
  23. if(!scene_manager_search_and_switch_to_previous_scene(
  24. subghz->scene_manager, SubGhzSceneReceiver)) {
  25. subghz->txrx->rx_key_state = SubGhzRxKeyStateRAWSave;
  26. if(!scene_manager_search_and_switch_to_previous_scene(
  27. subghz->scene_manager, SubGhzSceneReadRAW)) {
  28. subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
  29. if(!scene_manager_search_and_switch_to_previous_scene(
  30. subghz->scene_manager, SubGhzSceneSaved)) {
  31. scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaved);
  32. }
  33. }
  34. }
  35. return true;
  36. }
  37. }
  38. return false;
  39. }
  40. void subghz_scene_save_success_on_exit(void* context) {
  41. SubGhz* subghz = context;
  42. Popup* popup = subghz->popup;
  43. popup_reset(popup);
  44. }