xremote_scene_ir_timer.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. }
  28. bool xremote_scene_ir_timer_on_event(void* context, SceneManagerEvent event) {
  29. XRemote* app = context;
  30. bool consumed = false;
  31. if(event.type == SceneManagerEventTypeCustom) {
  32. scene_manager_previous_scene(app->scene_manager);
  33. return true;
  34. }
  35. return consumed;
  36. }
  37. void xremote_scene_ir_timer_on_exit(void* context) {
  38. XRemote* app = context;
  39. UNUSED(app);
  40. }