summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/IR Formats 1.PDFbin0 -> 157922 bytes
-rw-r--r--doc/IR Formats 2.PDFbin0 -> 431088 bytes
-rw-r--r--include/decoder.h13
-rw-r--r--src/radio-controller.cpp7
4 files changed, 19 insertions, 1 deletions
diff --git a/doc/IR Formats 1.PDF b/doc/IR Formats 1.PDF
new file mode 100644
index 0000000..db5f78c
--- /dev/null
+++ b/doc/IR Formats 1.PDF
Binary files differ
diff --git a/doc/IR Formats 2.PDF b/doc/IR Formats 2.PDF
new file mode 100644
index 0000000..285dfdb
--- /dev/null
+++ b/doc/IR Formats 2.PDF
Binary files 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 <cstdint>
+#include <mcu/init.h>
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();