meal_pager_scene_set_first_pager.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include "../meal_pager_i.h"
  2. #include "../helpers/meal_pager_custom_event.h"
  3. #include "../helpers/meal_pager_led.h"
  4. #include <dolphin/dolphin.h>
  5. void meal_pager_set_first_pager_callback(void* context) {
  6. furi_assert(context);
  7. Meal_Pager* app = context;
  8. view_dispatcher_send_custom_event(app->view_dispatcher, Meal_PagerCustomerEventIntInput);
  9. }
  10. void meal_pager_scene_set_first_pager_on_enter(void* context) {
  11. furi_assert(context);
  12. Meal_Pager* app = context;
  13. IntInput* int_input = app->int_input;
  14. size_t enter_name_length = 5;
  15. meal_pager_set_max_values(app);
  16. char* str = "Set First Pager (0 - 999)";
  17. const char* constStr = str;
  18. snprintf(str, 36, "Set First Pager (0 - %lu)", app->max_pager);
  19. int_input_set_header_text(int_input, constStr);
  20. int_input_set_result_callback(
  21. int_input,
  22. meal_pager_set_first_pager_callback,
  23. context,
  24. app->text_store[2],
  25. enter_name_length,
  26. false);
  27. view_dispatcher_switch_to_view(app->view_dispatcher, Meal_PagerViewIdIntInput);
  28. }
  29. bool meal_pager_scene_set_first_pager_on_event(void* context, SceneManagerEvent event) {
  30. Meal_Pager* app = context;
  31. bool consumed = false;
  32. if(event.type == SceneManagerEventTypeBack) {
  33. scene_manager_previous_scene(app->scene_manager);
  34. return true;
  35. } else if(event.type == SceneManagerEventTypeCustom) {
  36. app->first_pager = atoi(app->text_store[2]);
  37. if(app->first_pager > app->max_pager) {
  38. app->first_pager = app->max_pager;
  39. snprintf(app->text_store[2], sizeof(app->text_store[2]), "%lu", app->first_pager);
  40. }
  41. app->first_pager_char = app->text_store[2];
  42. scene_manager_previous_scene(app->scene_manager);
  43. return true;
  44. } else if(event.type == SceneManagerEventTypeTick) {
  45. if(app->state_notifications == SubGhzNotificationStateTx) {
  46. app->state_notifications = SubGhzNotificationStateIDLE;
  47. subghz_txrx_stop(app->subghz->txrx);
  48. meal_pager_blink_stop(app);
  49. meal_pager_transmit_model_set_sending(app->meal_pager_transmit, 0);
  50. }
  51. return true;
  52. }
  53. return consumed;
  54. }
  55. void meal_pager_scene_set_first_pager_on_exit(void* context) {
  56. Meal_Pager* app = context;
  57. UNUSED(app);
  58. }