xremote_scene_ir_timer.c 2.0 KB

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