From e758988579c3bf058214bf6e4ae56cf27b52bcfb Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 4 Jun 2017 19:25:41 +0200 Subject: o Decoding manufacturer and command too. --- doc/IR Formats 1.PDF | Bin 0 -> 157922 bytes doc/IR Formats 2.PDF | Bin 0 -> 431088 bytes include/decoder.h | 13 +++++++++++++ src/radio-controller.cpp | 7 ++++++- 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 doc/IR Formats 1.PDF create mode 100644 doc/IR Formats 2.PDF diff --git a/doc/IR Formats 1.PDF b/doc/IR Formats 1.PDF new file mode 100644 index 0000000..db5f78c Binary files /dev/null and b/doc/IR Formats 1.PDF differ diff --git a/doc/IR Formats 2.PDF b/doc/IR Formats 2.PDF new file mode 100644 index 0000000..285dfdb Binary files /dev/null and b/doc/IR Formats 2.PDF differ diff --git a/include/decoder.h b/include/decoder.h index 56ea647..9aee34d 100644 --- a/include/decoder.h +++ b/include/decoder.h @@ -1,6 +1,7 @@ #pragma once #include +#include namespace radio_controller { @@ -33,6 +34,18 @@ public: return size_; } + __attribute__((noinline)) + uint32_t extract_bits(int start, int count) + { + if (start + count > 32) { + halt(); + } + + uint32_t value = a_ >> start; + auto mask = uint32_t((1 << count + 1) - 1); + return value & mask; + } + uint32_t u32(int i) { switch (i) { diff --git a/src/radio-controller.cpp b/src/radio-controller.cpp index 2c038ed..e4218cc 100644 --- a/src/radio-controller.cpp +++ b/src/radio-controller.cpp @@ -245,7 +245,12 @@ void main_loop() } else if (result.state == decoding_state::BAD_START) { printf("Bad start\n"); } else if (result.state == decoding_state::OK) { - printf("OK: size=%d, value: 0x%08" PRIx32 "%08" PRIx32 "\n", result.data.size(), result.data.u32(1), result.data.u32(0)); + printf("OK: size=%d, value: 0x%08" PRIx32 "%08" PRIx32 "\n", result.data.size(), + result.data.u32(1), result.data.u32(0)); + uint32_t manufacturer = result.data.extract_bits(0, 12); + uint32_t command = result.data.extract_bits(12, 8); + printf("Samsung: Manufacturer=%" PRIu32 ", 0x%" PRIx32 ", command=%" PRIu32 ", 0x%" PRIx32 "\n", + manufacturer, manufacturer, command, command); } ir_buffer.reset(); -- cgit v1.2.3