+++ /dev/null
-# samsung.py Decoder for IR remote control using synchronous code\r
-# Supports Samsung TV remote protocols.\r
-\r
-# Author: J.E. Tannenbaum\r
-# Copyright J.E.Tannenbaum 2021 Released under the MIT license\r
-\r
-from utime import ticks_us, ticks_diff\r
-from ir_rx import IR_RX\r
-\r
-class SAMSUNG(IR_RX):\r
- def __init__(self, pin, callback, *args):\r
- super().__init__(pin, 68, 80, callback, *args)\r
-\r
- def decode(self, _):\r
- def near(v, target):\r
- return target * 0.8 < v < target * 1.2\r
-\r
- lb = self.edge - 1 # Possible length of burst\r
- burst = []\r
- for x in range(lb):\r
- dt = ticks_diff(self._times[x + 1], self._times[x])\r
- if x > 0 and dt > 10000: # Reached gap between repeats\r
- break\r
- burst.append(dt)\r
-\r
- lb = len(burst) # Actual length\r
- cmd = 0\r
- if near(burst[0], 4500) and near(burst[1], 4500) and lb == 67:\r
- # Skip the starting bits and the checksum at the end of the sequence\r
- for x in range(2, lb - 1, 2):\r
- cmd *= 2\r
- # Test for logical 1 (One byte low, next byte high)\r
- if burst[x] < 1000 and burst[x + 1] > 1000:\r
- cmd += 1\r
-\r
- # Set up for new data burst and run user callback\r
- self.do_callback(cmd, 0, 0)\r