encoder-indala.cpp 735 B

123456789101112131415161718192021222324252627
  1. #include "encoder-indala.h"
  2. #include <furi.h>
  3. void EncoderIndala::init(const uint8_t* data, const uint8_t data_size) {
  4. card_data = 0b1010000000000000000000000000000010011101111110011001001001010010;
  5. last_polarity = card_data & 1;
  6. card_data_index = 0;
  7. }
  8. void EncoderIndala::get_next(bool* polarity, uint16_t* period, uint16_t* pulse) {
  9. bool new_bit = (card_data >> (63 - card_data_index)) & 1;
  10. *period = 2;
  11. *pulse = 1;
  12. *polarity = (new_bit != last_polarity);
  13. bit_clock_index++;
  14. if(bit_clock_index >= clock_per_bit) {
  15. bit_clock_index = 0;
  16. last_polarity = *polarity;
  17. card_data_index++;
  18. if(card_data_index >= 64) {
  19. card_data_index = 0;
  20. }
  21. }
  22. }