byte_input.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma once
  2. #include <gui/view.h>
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /**
  7. * @brief Byte input anonymous structure
  8. *
  9. */
  10. typedef struct ByteInput ByteInput;
  11. /**
  12. * @brief callback that is executed on save button press
  13. *
  14. */
  15. typedef void (*ByteInputCallback)(void* context);
  16. /**
  17. * @brief callback that is executed when byte buffer is changed
  18. *
  19. */
  20. typedef void (*ByteChangedCallback)(void* context);
  21. /**
  22. * @brief Allocate and initialize byte input. This byte input is used to enter bytes.
  23. *
  24. * @return ByteInput instance pointer
  25. */
  26. ByteInput* byte_input_alloc();
  27. /**
  28. * @brief Deinitialize and free byte input
  29. *
  30. * @param byte_input Byte input instance
  31. */
  32. void byte_input_free(ByteInput* byte_input);
  33. /**
  34. * @brief Get byte input view
  35. *
  36. * @param byte_input byte input instance
  37. * @return View instance that can be used for embedding
  38. */
  39. View* byte_input_get_view(ByteInput* byte_input);
  40. /**
  41. * @brief Set byte input result callback
  42. *
  43. * @param byte_input byte input instance
  44. * @param input_callback input callback fn
  45. * @param changed_callback changed callback fn
  46. * @param callback_context callback context
  47. * @param bytes buffer to use
  48. * @param bytes_count buffer length
  49. */
  50. void byte_input_set_result_callback(
  51. ByteInput* byte_input,
  52. ByteInputCallback input_callback,
  53. ByteChangedCallback changed_callback,
  54. void* callback_context,
  55. uint8_t* bytes,
  56. uint8_t bytes_count);
  57. /**
  58. * @brief Set byte input header text
  59. *
  60. * @param byte_input byte input instance
  61. * @param text text to be shown
  62. */
  63. void byte_input_set_header_text(ByteInput* byte_input, const char* text);
  64. #ifdef __cplusplus
  65. }
  66. #endif