encoder.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #include <stdbool.h>
  3. #include <stdint.h>
  4. #include <stddef.h>
  5. #include <lib/toolbox/level_duration.h>
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. typedef struct {
  10. bool is_running;
  11. size_t repeat;
  12. size_t front;
  13. size_t size_upload;
  14. LevelDuration* upload;
  15. } SubGhzProtocolBlockEncoder;
  16. /**
  17. * Set data bit when encoding HEX array.
  18. * @param bit_value The value of the bit to be set
  19. * @param data_array Pointer to a HEX array
  20. * @param set_index_bit Number set a bit in the array starting from the left
  21. * @param max_size_array array size, check not to overflow
  22. */
  23. void subghz_protocol_blocks_set_bit_array(
  24. bool bit_value,
  25. uint8_t data_array[],
  26. size_t set_index_bit,
  27. size_t max_size_array);
  28. /**
  29. * Get data bit when encoding HEX array.
  30. * @param data_array Pointer to a HEX array
  31. * @param read_index_bit Number get a bit in the array starting from the left
  32. * @return bool value bit
  33. */
  34. bool subghz_protocol_blocks_get_bit_array(uint8_t data_array[], size_t read_index_bit);
  35. /**
  36. * Generating an upload from data.
  37. * @param data_array Pointer to a HEX array
  38. * @param count_bit_data_array How many bits in the array are processed
  39. * @param upload Pointer to a LevelDuration
  40. * @param max_size_upload upload size, check not to overflow
  41. * @param duration_bit duration 1 bit
  42. */
  43. size_t subghz_protocol_blocks_get_upload(
  44. uint8_t data_array[],
  45. size_t count_bit_data_array,
  46. LevelDuration* upload,
  47. size_t max_size_upload,
  48. uint32_t duration_bit);
  49. #ifdef __cplusplus
  50. }
  51. #endif