8 This class forms a hash over the IR pulses generated by an
11 The remote key press is not converted into a code in the manner of
12 the lirc module. No attempt is made to decode the type of protocol
13 used by the remote. The hash is likely to be unique for different
14 keys and different remotes but this is not guaranteed.
16 This hashing process works for some remotes/protocols but not for
17 others. The only way to find out if it works for one or more of
18 your remotes is to try it and see.
29 print("hash={}".format(hash));
33 ir = ir_hasher.hasher(pi, 7, callback, 5)
35 print("ctrl c to exit");
42 def __init__(self, pi, gpio, callback, timeout=5):
45 Initialises an IR remote hasher on a pi's gpio. A gap of timeout
46 milliseconds indicates the end of the remote key press.
56 pi.set_mode(gpio, pigpio.INPUT)
58 self.
cb = pi.callback(gpio, pigpio.EITHER_EDGE, self.
_cb)
60 def _hash(self, old_val, new_val):
62 if new_val < (old_val * 0.60):
64 elif old_val < (new_val * 0.60):
73 def _cb(self, gpio, level, tick):
75 if level != pigpio.TIMEOUT:
101 if self.
t1 is not None:
120 if __name__ ==
"__main__":
127 142650387:
'2', 244341844:
'menu', 262513468:
'vol-',
128 272048826:
'5', 345069212:
'6', 363685443:
'prev.ch',
129 434191356:
'1', 492745084:
'OK', 549497027:
'mute',
130 603729091:
'text', 646476378:
'chan-', 832916949:
'home',
131 923778138:
'power', 938165610:
'power', 953243510:
'forward',
132 1009731980:
'1', 1018231875:
'TV', 1142888517:
'c-up',
133 1151589683:
'chan+', 1344018636:
'OK', 1348032067:
'chan+',
134 1367109971:
'prev.ch', 1370712102:
'c-left', 1438405361:
'rewind',
135 1452589043:
'pause', 1518578730:
'chan-', 1554432645:
'8',
136 1583569525:
'0', 1629745313:
'rewind', 1666513749:
'record',
137 1677653754:
'c-down', 1825951717:
'c-right', 1852412236:
'6',
138 1894279468:
'9', 1904895749:
'vol+', 1941947509:
'ff',
139 2076573637:
'0', 2104823531:
'back', 2141641957:
'home',
140 2160787557:
'record', 2398525299:
'7', 2468117013:
'8',
141 2476712746:
'play', 2574308838:
'forward', 2577952149:
'4',
142 2706654902:
'stop', 2829002741:
'c-up', 2956097083:
'back',
143 3112717386:
'5', 3263244773:
'ff', 3286088195:
'pause',
144 3363767978:
'c-down', 3468076364:
'vol-', 3491068358:
'stop',
145 3593710134:
'c-left', 3708232515:
'3', 3734134565:
'back',
146 3766109107:
'TV', 3798010010:
'play', 3869937700:
'menu',
147 3872715523:
'7', 3885097091:
'2', 3895301587:
'text',
148 3931058739:
'mute', 3983900853:
'c-right', 4032250885:
'4',
149 4041913909:
'vol+', 4207017660:
'9', 4227138677:
'back',
154 print(
"key={} hash={}".format(hashes[hash], hash));
160 print(
"ctrl c to exit");