xremote_scene_ir_timer.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #include "../xremote.h"
  2. #include "../models/cross/xremote_cross_remote.h"
  3. void xremote_scene_ir_timer_callback(void* context, int32_t number) {
  4. XRemote* app = context;
  5. CrossRemoteItem* item = xremote_cross_remote_get_item(app->cross_remote, app->edit_item);
  6. item->time = number;
  7. view_dispatcher_send_custom_event(app->view_dispatcher, 0);
  8. }
  9. void xremote_scene_ir_timer_on_enter(void* context) {
  10. furi_assert(context);
  11. XRemote* app = context;
  12. NumberInput* number_input = app->number_input;
  13. char str[50];
  14. int32_t min_value = 0;
  15. int32_t max_value = 9999;
  16. snprintf(str, sizeof(str), "Transmit in ms (%ld - %ld)", min_value, max_value);
  17. CrossRemoteItem* item = xremote_cross_remote_get_item(app->cross_remote, app->edit_item);
  18. number_input_set_header_text(number_input, str);
  19. number_input_set_result_callback(
  20. number_input,
  21. xremote_scene_ir_timer_callback,
  22. context,
  23. item->time,
  24. min_value,
  25. max_value);
  26. view_dispatcher_switch_to_view(app->view_dispatcher, XRemoteViewIdNumberInput);
  27. /* CrossRemoteItem* item = xremote_cross_remote_get_item(app->cross_remote, app->edit_item);
  28. int_input_set_header_text(int_input, constStr);
  29. snprintf(app->text_store[1], 5, "%lu", item->time);
  30. int_input_set_result_callback(
  31. int_input,
  32. xremote_scene_ir_timer_callback,
  33. context,
  34. app->text_store[1],
  35. enter_name_length,
  36. false);
  37. view_dispatcher_switch_to_view(app->view_dispatcher, XRemoteViewIdIntInput);*/
  38. }
  39. bool xremote_scene_ir_timer_on_event(void* context, SceneManagerEvent event) {
  40. XRemote* app = context;
  41. bool consumed = false;
  42. //if(event.type == SceneManagerEventTypeBack) {
  43. if(event.type == SceneManagerEventTypeCustom) {
  44. scene_manager_previous_scene(app->scene_manager);
  45. return true;
  46. /*} else if(event.type == SceneManagerEventTypeCustom) {
  47. CrossRemoteItem* item = xremote_cross_remote_get_item(app->cross_remote, app->edit_item);
  48. xremote_cross_remote_item_set_time(item, (app->text_store[1]));
  49. if(item->time > 9999) {
  50. item->time = 9999;
  51. }
  52. scene_manager_previous_scene(app->scene_manager);
  53. return true;*/
  54. }
  55. return consumed;
  56. }
  57. void xremote_scene_ir_timer_on_exit(void* context) {
  58. XRemote* app = context;
  59. UNUSED(app);
  60. }