summaryrefslogtreecommitdiff
path: root/include/samsung_decoder.h
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2017-06-04 10:00:57 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2017-06-04 10:00:57 +0200
commita484b095fb03313f5f192b23c90d04972ca3b957 (patch)
tree3f965869157a7901bc9c92e0dc0727e9ef8d5552 /include/samsung_decoder.h
parent0bc2a81c0aab3c89b534415d6f07d07e392260ce (diff)
downloadradio-controller-a484b095fb03313f5f192b23c90d04972ca3b957.tar.gz
radio-controller-a484b095fb03313f5f192b23c90d04972ca3b957.tar.bz2
radio-controller-a484b095fb03313f5f192b23c90d04972ca3b957.tar.xz
radio-controller-a484b095fb03313f5f192b23c90d04972ca3b957.zip
o Getting closer to a working decoder.
Diffstat (limited to 'include/samsung_decoder.h')
-rw-r--r--include/samsung_decoder.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/include/samsung_decoder.h b/include/samsung_decoder.h
new file mode 100644
index 0000000..5d2b555
--- /dev/null
+++ b/include/samsung_decoder.h
@@ -0,0 +1,38 @@
+#pragma
+
+#include "decoder.h"
+
+namespace radio_controller {
+
+class samsung_decoder : public decoder {
+
+ inline
+ bool between(uint16_t smallest, uint16_t biggest, uint16_t value)
+ {
+ return smallest <= value && value <= biggest;
+ }
+
+ inline
+ bool start_bit(uint16_t time)
+ {
+ return between(4200, 4700, time);
+ }
+
+ inline
+ bool one_bit(uint16_t time)
+ {
+ return between(4200, 4700, time);
+ }
+
+public:
+ void decode(iterator<sample> *it) override
+ {
+ printf("Samsung\n");
+ while (it->next()) {
+ auto s = it->value();
+ printf("% 5d us % 5d us, %.02d%%\n", s.period_us, s.pulse_us, int(s.pulse_us / double(s.period_us) * 100));
+ }
+ }
+};
+
+} // namespace radio_controller