encoder.h 1.4 KB

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