uart_hex_input.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #pragma once
  2. #include <gui/view.h>
  3. #include "uart_validators.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /** Text input anonymous structure */
  8. typedef struct UART_TextInput UART_TextInput;
  9. typedef void (*UART_TextInputCallback)(void* context);
  10. typedef bool (*UART_TextInputValidatorCallback)(const char* text, FuriString* error, void* context);
  11. /** Allocate and initialize text input
  12. *
  13. * This text input is used to enter string
  14. *
  15. * @return UART_TextInput instance
  16. */
  17. UART_TextInput* uart_hex_input_alloc();
  18. /** Deinitialize and free text input
  19. *
  20. * @param uart_text_input UART_TextInput instance
  21. */
  22. void uart_hex_input_free(UART_TextInput* uart_text_input);
  23. /** Clean text input view Note: this function does not free memory
  24. *
  25. * @param uart_text_input Text input instance
  26. */
  27. void uart_hex_input_reset(UART_TextInput* uart_text_input);
  28. /** Get text input view
  29. *
  30. * @param uart_text_input UART_TextInput instance
  31. *
  32. * @return View instance that can be used for embedding
  33. */
  34. View* uart_hex_input_get_view(UART_TextInput* uart_text_input);
  35. /** Set text input result callback
  36. *
  37. * @param uart_text_input UART_TextInput instance
  38. * @param callback callback fn
  39. * @param callback_context callback context
  40. * @param text_buffer pointer to YOUR text buffer, that we going
  41. * to modify
  42. * @param text_buffer_size YOUR text buffer size in bytes. Max string
  43. * length will be text_buffer_size-1.
  44. * @param clear_default_text clear text from text_buffer on first OK
  45. * event
  46. */
  47. void uart_hex_input_set_result_callback(
  48. UART_TextInput* uart_text_input,
  49. UART_TextInputCallback callback,
  50. void* callback_context,
  51. char* text_buffer,
  52. size_t text_buffer_size,
  53. bool clear_default_text);
  54. void uart_hex_input_set_validator(
  55. UART_TextInput* uart_text_input,
  56. UART_TextInputValidatorCallback callback,
  57. void* callback_context);
  58. UART_TextInputValidatorCallback
  59. uart_hex_input_get_validator_callback(UART_TextInput* uart_text_input);
  60. void* uart_hex_input_get_validator_callback_context(UART_TextInput* uart_text_input);
  61. /** Set text input header text
  62. *
  63. * @param uart_text_input UART_TextInput instance
  64. * @param text text to be shown
  65. */
  66. void uart_hex_input_set_header_text(UART_TextInput* uart_text_input, const char* text);
  67. #ifdef __cplusplus
  68. }
  69. #endif