summaryrefslogtreecommitdiff
path: root/include/samsung_decoder.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/samsung_decoder.h')
-rw-r--r--include/samsung_decoder.h93
1 files changed, 0 insertions, 93 deletions
diff --git a/include/samsung_decoder.h b/include/samsung_decoder.h
deleted file mode 100644
index 3e55a94..0000000
--- a/include/samsung_decoder.h
+++ /dev/null
@@ -1,93 +0,0 @@
-#pragma
-
-#include <cstdint>
-#include <cstdio>
-#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;
- }
-
- template<uint16_t PeriodTime, uint16_t PulseTime>
- bool check_pulse(sample s)
- {
-// printf("between(%d, %d, %d) && between(%d, %d, %d)\n",
-// int(PeriodTime * 0.8), int(PeriodTime * 1.2), s.period_us,
-// int(PulseTime * 0.8), int(PulseTime * 1.2), s.pulse_us);
-
- return between(uint16_t(PeriodTime * 0.8), uint16_t(PeriodTime * 1.2), s.period_us) &&
- between(uint16_t(PulseTime * 0.8), uint16_t(PulseTime * 1.2), s.pulse_us);
- }
-
- inline
- bool start_bit(sample s)
- {
- return check_pulse<9000, 4500>(s);
- }
-
- inline
- bool one_bit(sample s)
- {
- return check_pulse<2250, 560>(s);
- }
-
- inline
- bool zero_bit(sample s)
- {
- return check_pulse<1125, 560>(s);
- }
-
- void dump_values(sample_iterator *it)
- {
- while (it->next()) {
- auto s = it->value();
- auto pct = int(s.pulse_us / double(s.period_us) * 100);
- auto type = start_bit(s) ? "start" : one_bit(s) ? "1" : zero_bit(s) ? "0" : "?";
- printf("% 5d us % 5d us, %s\n", s.period_us, s.pulse_us, type);
- }
- }
-
-public:
-
- decoding_result decode(sample_iterator *it) override
- {
- return decoding_result{decoding_state::FAIL};
-// printf("Samsung, size=%d\n", it->size());
-//
-// dump_values(it);
-// it->reset();
-//
-// sample s{};
-// bit_string data;
-//
-// if (!it->next()) {
-// return {decoding_state::TOO_SHORT};
-// }
-// s = it->value();
-// if (!start_bit(s)) {
-// return {decoding_state::BAD_START};
-// }
-//
-// for (int i = 0; i < 32 && it->next(); i++) {
-// s = it->value();
-//
-// if (one_bit(s)) {
-// data.append(true);
-// } else if (zero_bit(s)) {
-// data.append(false);
-// } else {
-// return {decoding_state::SHORT_BODY};
-// }
-// }
-//
-// return {decoding_state::OK, data};
- }
-};
-
-} // namespace radio_controller