decoder_analyzer.cpp 954 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "decoder_analyzer.h"
  2. #include <furi.h>
  3. #include <furi_hal.h>
  4. bool DecoderAnalyzer::read(uint8_t* _data, uint8_t _data_size) {
  5. bool result = false;
  6. if(ready) {
  7. result = true;
  8. for(size_t i = 0; i < data_size; i++) {
  9. printf("%lu ", data[i]);
  10. if((i + 1) % 8 == 0) printf("\r\n");
  11. }
  12. printf("\r\n--------\r\n");
  13. ready = false;
  14. }
  15. return result;
  16. }
  17. void DecoderAnalyzer::process_front(bool polarity, uint32_t time) {
  18. if(ready) return;
  19. data[data_index] = time;
  20. if(data_index < data_size) {
  21. data_index++;
  22. } else {
  23. data_index = 0;
  24. ready = true;
  25. }
  26. }
  27. DecoderAnalyzer::DecoderAnalyzer() {
  28. data = reinterpret_cast<uint32_t*>(calloc(data_size, sizeof(uint32_t)));
  29. furi_check(data);
  30. data_index = 0;
  31. ready = false;
  32. }
  33. DecoderAnalyzer::~DecoderAnalyzer() {
  34. free(data);
  35. }
  36. void DecoderAnalyzer::reset_state() {
  37. }