uart_terminal_scene_hex_input.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. UART_TextInput* text_input = app->hex_input;
  10. // Add help message to header
  11. uart_hex_input_set_header_text(text_input, "Send HEX packet to UART");
  12. uart_hex_input_set_result_callback(
  13. text_input,
  14. uart_terminal_scene_hex_input_callback,
  15. app,
  16. app->text_input_store,
  17. UART_TERMINAL_TEXT_INPUT_STORE_SIZE,
  18. false);
  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. uart_hex_input_reset(app->hex_input);
  37. }