xremote_scene_ir_timer.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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, xremote_scene_ir_timer_callback, context, item->time, min_value, max_value);
  21. view_dispatcher_switch_to_view(app->view_dispatcher, XRemoteViewIdNumberInput);
  22. }
  23. bool xremote_scene_ir_timer_on_event(void* context, SceneManagerEvent event) {
  24. XRemote* app = context;
  25. bool consumed = false;
  26. if(event.type == SceneManagerEventTypeCustom) {
  27. scene_manager_previous_scene(app->scene_manager);
  28. return true;
  29. }
  30. return consumed;
  31. }
  32. void xremote_scene_ir_timer_on_exit(void* context) {
  33. XRemote* app = context;
  34. UNUSED(app);
  35. }