uart_terminal_scene_hex_input.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "../uart_terminal_app_i.h"
  2. void uart_terminal_scene_hex_input_callback(void* context) {
  3. UART_TerminalApp* app = context;
  4. view_dispatcher_send_custom_event(app->view_dispatcher, UART_TerminalEventStartConsole);
  5. }
  6. void uart_terminal_scene_hex_input_on_enter(void* context) {
  7. UART_TerminalApp* app = context;
  8. // Setup view
  9. ByteInput* hex_input = app->hex_input;
  10. // Add help message to header
  11. byte_input_set_header_text(hex_input, "Send HEX packet to UART");
  12. byte_input_set_result_callback(
  13. hex_input,
  14. uart_terminal_scene_hex_input_callback,
  15. NULL,
  16. app,
  17. app->text_input_store,
  18. UART_TERMINAL_TEXT_INPUT_STORE_SIZE);
  19. view_dispatcher_switch_to_view(app->view_dispatcher, UART_TerminalAppViewHexInput);
  20. }
  21. bool uart_terminal_scene_hex_input_on_event(void* context, SceneManagerEvent event) {
  22. UART_TerminalApp* app = context;
  23. bool consumed = false;
  24. if(event.type == SceneManagerEventTypeCustom) {
  25. if(event.event == UART_TerminalEventStartConsole) {
  26. // Point to custom string to send
  27. app->selected_tx_string = app->text_input_store;
  28. scene_manager_next_scene(app->scene_manager, UART_TerminalSceneConsoleOutput);
  29. consumed = true;
  30. }
  31. }
  32. return consumed;
  33. }
  34. void uart_terminal_scene_hex_input_on_exit(void* context) {
  35. UART_TerminalApp* app = context;
  36. byte_input_set_result_callback(app->hex_input, NULL, NULL, NULL, NULL, 0);
  37. byte_input_set_header_text(app->hex_input, "");
  38. }