decoder_analyzer.cpp 1011 B

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