├── test_protocols ├── __init__.py ├── test_universal.py ├── test_proton40.py ├── test_rca38.py ├── test_rcaold.py ├── test_rc57f57.py ├── test_nrc1632.py ├── test_directv3.py ├── test_arctech38.py ├── test_directv4.py ├── test_directv5.py ├── test_archer.py ├── test_grundig1630.py ├── test_gwts.py ├── test_lutron.py ├── test_jerrold.py ├── test_pctv.py ├── test_akai.py ├── test_pid0004.py ├── test_pid0001.py ├── test_rcmm12.py ├── test_sony8.py ├── test_viewstar.py ├── test_nokia12.py ├── test_ad_notham.py ├── test_motorola.py ├── test_somfy.py ├── test_x10_8.py └── test_matsui.py ├── pyIRDecoder ├── air_conditioner │ ├── lg.py │ ├── coolix.py │ ├── daikin.py │ ├── electra.py │ ├── fujitsu.py │ ├── gree.py │ ├── haier.py │ ├── hitachi.py │ ├── midea.py │ ├── samsung.py │ ├── tcl.py │ ├── teco.py │ ├── toshiba.py │ ├── trotec.py │ ├── vestel.py │ ├── __init__.py │ ├── goodweather.py │ ├── kelvinator.py │ ├── mitsubishi.py │ ├── neoclima.py │ ├── panasonic.py │ └── whirlpool.py └── protocols │ ├── inax.py │ ├── lego.py │ ├── nikai.py │ ├── sanyo.py │ ├── magiquest.py │ ├── rc57f57.py │ ├── rca38.py │ ├── streamzap57.py │ ├── proton40.py │ ├── rcaold.py │ ├── arctech38.py │ ├── amino56.py │ ├── grundig1630.py │ ├── nrc1632.py │ ├── tdc56.py │ ├── zaptor56.py │ ├── directv1.py │ ├── directv3.py │ ├── recs800090.py │ ├── directv2.py │ ├── directv4.py │ ├── directv5.py │ ├── recs800068.py │ ├── dyson2.py │ ├── archer.py │ ├── jerrold.py │ ├── pid0004.py │ ├── sony8.py │ ├── matsui.py │ ├── bryston.py │ ├── rcmm24.py │ ├── mitsubishi.py │ ├── sony12.py │ ├── sony15.py │ ├── pctv.py │ ├── sim2.py │ ├── konka.py │ ├── barco.py │ ├── rcmmoem.py │ ├── nokia.py │ ├── tdc38.py │ ├── sony20.py │ ├── girg.py │ ├── akai.py │ ├── samsung20.py │ ├── lutron.py │ ├── audiovox.py │ ├── proton.py │ ├── f32.py │ ├── jvc.py │ ├── elunevision.py │ ├── viewstar.py │ └── sharp1.py └── .gitignore /test_protocols/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/lg.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/inax.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/lego.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/nikai.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/sanyo.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/coolix.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/daikin.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/electra.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/fujitsu.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/gree.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/haier.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/hitachi.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/midea.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/samsung.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/tcl.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/teco.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/toshiba.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/trotec.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/vestel.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/magiquest.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/goodweather.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/kelvinator.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/mitsubishi.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/neoclima.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/panasonic.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/air_conditioner/whirlpool.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/rc57f57.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import rc57f 30 | 31 | 32 | # noinspection PyProtectedMember 33 | class RC57F57(rc57f.RC57F): 34 | """ 35 | IR decoder for the RC57F57 protocol. 36 | """ 37 | irp = '{57k,889,msb}<1,-1|-1,1>(1,~D:1:5,T:1,D:5,F:7,^114m)*' 38 | frequency = 57000 39 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/rca38.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import rca 30 | 31 | TIMING = 460 32 | 33 | 34 | # noinspection PyProtectedMember 35 | class RCA38(rca.RCA): 36 | """ 37 | IR decoder for the RCA38 protocol. 38 | """ 39 | irp = '{38.7k,460,msb}<1,-2|1,-4>(8,-8,D:4,F:8,~D:4,~F:8,1,-16)*' 40 | frequency = 38700 41 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/streamzap57.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import streamzap 30 | 31 | 32 | # noinspection PyProtectedMember 33 | class StreamZap57(streamzap.StreamZap): 34 | """ 35 | IR decoder for the StreamZap57 protocol. 36 | """ 37 | irp = '{57k,889,msb}<1,-1|-1,1>(1,~F:1:6,T:1,D:6,F:6,^114m)*' 38 | frequency = 57000 39 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/proton40.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import proton 30 | 31 | 32 | TIMING = 500 33 | 34 | 35 | # noinspection PyProtectedMember 36 | class Proton40(proton.Proton): 37 | """ 38 | IR decoder for the Proton40 protocol. 39 | """ 40 | irp = '{40.5k,500,lsb}<1,-1|1,-3>(16,-8,D:8,1,-8,F:8,1,^63m)*' 41 | frequency = 40500 42 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/rcaold.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import rca38old 30 | 31 | TIMING = 460 32 | 33 | 34 | # noinspection PyProtectedMember 35 | class RCAOld(rca38old.RCA38Old): 36 | """ 37 | IR decoder for the RCAOld protocol. 38 | """ 39 | irp = '{58k,460,msb}<1,-2|1,-4>([40][8],-8,D:4,F:8,~D:4,~F:8,2,-16)' 40 | frequency = 58000 41 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/arctech38.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import arctech 30 | 31 | 32 | # noinspection PyProtectedMember 33 | class Arctech38(arctech.Arctech): 34 | """ 35 | IR decoder for the Arctech38 protocol. 36 | """ 37 | irp = ( 38 | '{38k,388,lsb}<1,-3|3,-1>(<0:2|2:2>((D-1):4,(S-1):4),40:7,' 39 | 'F:1,0:1,-10.2m)*' 40 | ) 41 | frequency = 38000 42 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/amino56.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import amino 30 | 31 | 32 | # noinspection PyProtectedMember 33 | class Amino56(amino.Amino): 34 | """ 35 | IR decoder for the Amino56 protocol. 36 | """ 37 | irp = ( 38 | '{56.0k,268,msb}<-1,1|1,-1>([T=1][T=0],7,-6,3,D:4,1:1,T:1,1:2,' 39 | '0:8,F:8,15:4,C:4,-79m)+{C=(D:4+4*T+9+F:4+F:4:4+15)&15}' 40 | ) 41 | frequency = 56000 42 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/grundig1630.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import grundig16 30 | 31 | 32 | # noinspection PyProtectedMember 33 | class Grundig1630(grundig16.Grundig16): 34 | """ 35 | IR decoder for the Grundig1630 protocol. 36 | """ 37 | irp = ( 38 | '{30.3k,578,msb}<-4,2|-3,1,-1,1|-2,1,-2,1|-1,1,-3,1>' 39 | '(806u,-2960u,1346u,T:1,F:8,D:7,-100)*' 40 | ) 41 | frequency = 30300 42 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/nrc1632.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import nrc16 30 | 31 | 32 | # noinspection PyProtectedMember 33 | class NRC1632(nrc16.NRC16): 34 | """ 35 | IR decoder for the NRC1632 protocol. 36 | """ 37 | irp = ( 38 | '{32k,500,lsb}<-1,1|1,-1>' 39 | '(1,-5,1:1,254:8,127:7,-15m,' 40 | '(1,-5,1:1,F:8,D:7,-110m)+,' 41 | '1,-5,1:1,254:8,127:7,-15m)' 42 | ) 43 | frequency = 32000 44 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/tdc56.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import tdc38 30 | 31 | 32 | TIMING = 213 33 | 34 | 35 | # noinspection PyProtectedMember 36 | class TDC56(tdc38.TDC38): 37 | """ 38 | IR decoder for the TDC56 protocol. 39 | """ 40 | irp = '{56.3k,213,msb}<-1,1|1,-1>(1,-1,D:5,S:5,F:7,-89m)*' 41 | frequency = 56300 42 | 43 | _lead_in = [TIMING, -TIMING] 44 | _bursts = [[-TIMING, TIMING], [TIMING, -TIMING]] 45 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/zaptor56.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import zaptor36 30 | 31 | 32 | # noinspection PyProtectedMember 33 | class Zaptor56(zaptor36.Zaptor36): 34 | """ 35 | IR decoder for the Zaptor56 protocol. 36 | """ 37 | irp = ( 38 | '{56k,330,msb}<-1,1|1,-1>(8,-6,2,D:8,T:1,S:7,F:8,E:4,C:4,-74m)' 39 | '{C=(((D:4)+(D:4:4)+(S:4)+(S:3:4)+(8*T)+(F:4)+(F:4:4)+E)&15)}' 40 | ) 41 | 42 | frequency = 56000 43 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/directv1.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import directv0 30 | 31 | TIMING = 600 32 | 33 | 34 | # noinspection PyProtectedMember 35 | class DirecTV1(directv0.DirecTV0): 36 | """ 37 | IR decoder for the DirecTV1 protocol. 38 | """ 39 | irp = ( 40 | '{40k,600,msb}<1,-1|1,-2|2,-1|2,-2>' 41 | '([10][5],-2,D:4,F:8,C:4,1,-50)' 42 | '{C=7*(F:2:6)+5*(F:2:4)+3*(F:2:2)+(F:2)}' 43 | ) 44 | frequency = 40000 45 | _lead_out = [TIMING, -TIMING * 50] 46 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/directv3.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import directv1 30 | 31 | TIMING = 600 32 | 33 | 34 | # noinspection PyProtectedMember 35 | class DirecTV3(directv1.DirecTV1): 36 | """ 37 | IR decoder for the DirecTV3 protocol. 38 | """ 39 | irp = ( 40 | '{38k,600,msb}<1,-1|1,-2|2,-1|2,-2>' 41 | '([10][5],-2,D:4,F:8,C:4,1,-50)' 42 | '{C=7*(F:2:6)+5*(F:2:4)+3*(F:2:2)+(F:2)}' 43 | ) 44 | frequency = 38000 45 | _lead_out = [TIMING, -TIMING * 50] 46 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/recs800090.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import recs800045 30 | from . import protocol_base 31 | 32 | TIMING = 158 33 | 34 | 35 | # noinspection PyProtectedMember 36 | class RECS800090(recs800045.RECS800045): 37 | """ 38 | IR decoder for the RECS800068 protocol. 39 | """ 40 | irp = '{0k,158,msb}<1,-31|1,-47>(1:1,T:1,D:3,F:6,1,^138m)*' 41 | frequency = 0 42 | 43 | _lead_out = [TIMING, 138000] 44 | _bursts = [[TIMING, -TIMING * 31], [TIMING, -TIMING * 47]] 45 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/directv2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import directv0 30 | 31 | TIMING = 600 32 | 33 | 34 | # noinspection PyProtectedMember 35 | class DirecTV2(directv0.DirecTV0): 36 | """ 37 | IR decoder for the DirecTV2 protocol. 38 | """ 39 | irp = ( 40 | '{38k,600,msb}<1,-1|1,-2|2,-1|2,-2>' 41 | '([10][5],-2,D:4,F:8,C:4,1,-15)' 42 | '{C=7*(F:2:6)+5*(F:2:4)+3*(F:2:2)+(F:2)}' 43 | ) 44 | frequency = 38000 45 | _lead_out = [TIMING, -TIMING * 15] 46 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/directv4.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import directv0 30 | 31 | TIMING = 600 32 | 33 | 34 | # noinspection PyProtectedMember 35 | class DirecTV4(directv0.DirecTV0): 36 | """ 37 | IR decoder for the DirecTV4 protocol. 38 | """ 39 | irp = ( 40 | '{57k,600,msb}<1,-1|1,-2|2,-1|2,-2>' 41 | '([10][5],-2,D:4,F:8,C:4,1,-15)' 42 | '{C=7*(F:2:6)+5*(F:2:4)+3*(F:2:2)+(F:2)}' 43 | ) 44 | frequency = 57000 45 | _lead_out = [TIMING, -TIMING * 15] 46 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/directv5.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import directv1 30 | 31 | TIMING = 600 32 | 33 | 34 | # noinspection PyProtectedMember 35 | class DirecTV5(directv1.DirecTV1): 36 | """ 37 | IR decoder for the DirecTV5 protocol. 38 | """ 39 | irp = ( 40 | '{57k,600,msb}<1,-1|1,-2|2,-1|2,-2>' 41 | '([10][5],-2,D:4,F:8,C:4,1,-50)' 42 | '{C=7*(F:2:6)+5*(F:2:4)+3*(F:2:2)+(F:2)}' 43 | ) 44 | frequency = 57000 45 | _lead_out = [TIMING, -TIMING * 50] 46 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/recs800068.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | from . import recs800045 31 | 32 | 33 | TIMING = 180 34 | 35 | 36 | # noinspection PyProtectedMember 37 | class RECS800068(recs800045.RECS800045): 38 | """ 39 | IR decoder for the RECS800068 protocol. 40 | """ 41 | irp = '{33.3k,180,msb}<1,-31|1,-47>(1:1,T:1,D:3,F:6,1,^138m)*' 42 | frequency = 33300 43 | 44 | _lead_out = [TIMING, 138000] 45 | _bursts = [[TIMING, -TIMING * 31], [TIMING, -TIMING * 47]] 46 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/dyson2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import dyson 30 | 31 | TIMING = 780 32 | 33 | 34 | # noinspection PyProtectedMember 35 | class Dyson2(dyson.Dyson): 36 | """ 37 | IR decoder for the Dyson2 protocol. 38 | """ 39 | irp = ( 40 | '{38k,780,lsb}<1,-1|1,-2>' 41 | '(3,-1,D:7,F:6,T:-2,1,-400m,3,-1,D:7,F:6,T:-2,1,-60m,' 42 | '(3,-1,1:1,1,-60m)*)' 43 | ) 44 | 45 | _middle_timings = [(TIMING, -400000), (TIMING * 3, -TIMING)] 46 | _backup_middle_timings = _middle_timings[:] 47 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | .idea 7 | 8 | # C extensions 9 | *.so 10 | 11 | # Distribution / packaging 12 | .Python 13 | build/ 14 | develop-eggs/ 15 | dist/ 16 | downloads/ 17 | eggs/ 18 | .eggs/ 19 | lib/ 20 | lib64/ 21 | parts/ 22 | sdist/ 23 | var/ 24 | wheels/ 25 | pip-wheel-metadata/ 26 | share/python-wheels/ 27 | *.egg-info/ 28 | .installed.cfg 29 | *.egg 30 | MANIFEST 31 | 32 | # PyInstaller 33 | # Usually these files are written by a python script from a template 34 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 35 | *.manifest 36 | *.spec 37 | 38 | # Installer logs 39 | pip-log.txt 40 | pip-delete-this-directory.txt 41 | 42 | # Unit test / coverage reports 43 | htmlcov/ 44 | .tox/ 45 | .nox/ 46 | .coverage 47 | .coverage.* 48 | .cache 49 | nosetests.xml 50 | coverage.xml 51 | *.cover 52 | *.py,cover 53 | .hypothesis/ 54 | .pytest_cache/ 55 | 56 | # Translations 57 | *.mo 58 | *.pot 59 | 60 | # Django stuff: 61 | *.log 62 | local_settings.py 63 | db.sqlite3 64 | db.sqlite3-journal 65 | 66 | # Flask stuff: 67 | instance/ 68 | .webassets-cache 69 | 70 | # Scrapy stuff: 71 | .scrapy 72 | 73 | # Sphinx documentation 74 | docs/_build/ 75 | 76 | # PyBuilder 77 | target/ 78 | 79 | # Jupyter Notebook 80 | .ipynb_checkpoints 81 | 82 | # IPython 83 | profile_default/ 84 | ipython_config.py 85 | 86 | # pyenv 87 | .python-version 88 | 89 | # pipenv 90 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 91 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 92 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 93 | # install all needed dependencies. 94 | #Pipfile.lock 95 | 96 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 97 | __pypackages__/ 98 | 99 | # Celery stuff 100 | celerybeat-schedule 101 | celerybeat.pid 102 | 103 | # SageMath parsed files 104 | *.sage.py 105 | 106 | # Environments 107 | .env 108 | .venv 109 | env/ 110 | venv/ 111 | ENV/ 112 | env.bak/ 113 | venv.bak/ 114 | 115 | # Spyder project settings 116 | .spyderproject 117 | .spyproject 118 | 119 | # Rope project settings 120 | .ropeproject 121 | 122 | # mkdocs documentation 123 | /site 124 | 125 | # mypy 126 | .mypy_cache/ 127 | .dmypy.json 128 | dmypy.json 129 | 130 | # Pyre type checker 131 | .pyre/ 132 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/archer.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 12 33 | 34 | 35 | class Archer(protocol_base.IrProtocolBase): 36 | """ 37 | IR decoder for the Archer protocol. 38 | """ 39 | irp = '{0k,12,lsb}<1,-3.3m|1,-4.7m>(F:5,1,-9.7m)*' 40 | frequency = 0 41 | bit_count = 5 42 | encoding = 'lsb' 43 | 44 | _lead_out = [TIMING, -9700] 45 | _bursts = [[TIMING, -3300], [TIMING, -4700]] 46 | 47 | _code_order = [ 48 | ['F', 5] 49 | ] 50 | 51 | _parameters = [ 52 | ['F', 0, 4], 53 | ] 54 | # [F:0..31] 55 | encode_parameters = [ 56 | ['function', 0, 31], 57 | ] 58 | 59 | def encode( 60 | self, 61 | function: int, 62 | repeat_count: int = 0 63 | ) -> protocol_base.IRCode: 64 | packet = self._build_packet( 65 | F=function 66 | ) 67 | 68 | params = dict( 69 | frequency=self.frequency, 70 | F=function, 71 | ) 72 | 73 | code = protocol_base.IRCode( 74 | self, 75 | packet[:] * (repeat_count + 1), 76 | [packet[:]] * (repeat_count + 1), 77 | params, 78 | repeat_count 79 | ) 80 | return code 81 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/jerrold.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 44 33 | 34 | 35 | class Jerrold(protocol_base.IrProtocolBase): 36 | """ 37 | IR decoder for the Jerrold protocol. 38 | """ 39 | irp = '{0k,44,lsb}<1,-7.5m|1,-11.5m>(F:5,1,-23.5m)*' 40 | frequency = 0 41 | bit_count = 5 42 | encoding = 'lsb' 43 | 44 | _lead_in = [] 45 | _lead_out = [TIMING, -23500] 46 | _middle_timings = [] 47 | _bursts = [[TIMING, -7500], [TIMING, -11500]] 48 | 49 | _code_order = [ 50 | ['F', 5], 51 | ] 52 | 53 | _parameters = [ 54 | ['F', 0, 4], 55 | ] 56 | # [F:0..31] 57 | encode_parameters = [ 58 | ['function', 0, 31], 59 | ] 60 | 61 | def encode( 62 | self, 63 | function: int, 64 | repeat_count: int = 0 65 | ) -> protocol_base.IRCode: 66 | params = dict(F=function) 67 | packet = self._build_packet(**params) 68 | params['frequency'] = self.frequency 69 | 70 | code = protocol_base.IRCode( 71 | self, 72 | packet[:] * (repeat_count + 1), 73 | [packet[:]] * (repeat_count + 1), 74 | params, 75 | repeat_count 76 | ) 77 | 78 | return code 79 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/pid0004.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 1 33 | 34 | 35 | class PID0004(protocol_base.IrProtocolBase): 36 | """ 37 | IR decoder for the pid0004 protocol. 38 | """ 39 | irp = '{0k,1,msb}<12,-130|12,-372>(F:6,12,-27m)*' 40 | frequency = 0 41 | bit_count = 6 42 | encoding = 'msb' 43 | 44 | _lead_in = [] 45 | _lead_out = [12, -27000] 46 | _middle_timings = [] 47 | _bursts = [[12, -130], [12, -372]] 48 | 49 | _code_order = [ 50 | ['F', 6], 51 | ] 52 | 53 | _parameters = [ 54 | ['F', 0, 5], 55 | ] 56 | # [F:0..63] 57 | encode_parameters = [ 58 | ['function', 0, 63], 59 | ] 60 | 61 | def encode( 62 | self, 63 | function: int, 64 | repeat_count: int = 0 65 | ) -> protocol_base.IRCode: 66 | params = dict( 67 | F=function, 68 | ) 69 | 70 | packet = self._build_packet(**params) 71 | 72 | params['frequency'] = self.frequency 73 | 74 | code = protocol_base.IRCode( 75 | self, 76 | packet[:] * (repeat_count + 1), 77 | [packet[:]] * (repeat_count + 1), 78 | params, 79 | repeat_count 80 | ) 81 | 82 | return code 83 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/sony8.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 600 33 | 34 | 35 | class Sony8(protocol_base.IrProtocolBase): 36 | """ 37 | IR decoder for the Sony8 protocol. 38 | """ 39 | irp = '{40k,600,lsb}<1,-1|2,-1>(4,-1,F:8,^45m)' 40 | frequency = 40000 41 | bit_count = 8 42 | encoding = 'lsb' 43 | 44 | _lead_in = [TIMING * 4, -TIMING] 45 | _lead_out = [45000] 46 | _middle_timings = [] 47 | _bursts = [[TIMING, -TIMING], [TIMING * 2, -TIMING]] 48 | 49 | _code_order = [ 50 | ['F', 8], 51 | ] 52 | 53 | _parameters = [ 54 | ['F', 0, 7], 55 | ] 56 | # [F:0..255] 57 | encode_parameters = [ 58 | ['function', 0, 255], 59 | ] 60 | 61 | def encode( 62 | self, 63 | function: int, 64 | repeat_count: int = 0 65 | ) -> protocol_base.IRCode: 66 | params = dict( 67 | F=function, 68 | ) 69 | 70 | packet = self._build_packet(**params) 71 | 72 | params['frequency'] = self.frequency 73 | 74 | code = protocol_base.IRCode( 75 | self, 76 | packet[:] * (repeat_count + 1), 77 | [packet[:]] * (repeat_count + 1), 78 | params, 79 | repeat_count 80 | ) 81 | 82 | return code 83 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/matsui.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 525 33 | 34 | 35 | class Matsui(protocol_base.IrProtocolBase): 36 | """ 37 | IR decoder for the Matsui protocol. 38 | """ 39 | irp = '{38k,525,lsb}<1,-1|1,-3>(D:3,F:7,1,^30.5m)*' 40 | frequency = 38000 41 | bit_count = 10 42 | encoding = 'lsb' 43 | 44 | _lead_in = [] 45 | _lead_out = [TIMING, 30500] 46 | _middle_timings = [] 47 | _bursts = [[TIMING, -TIMING], [TIMING, -TIMING * 3]] 48 | 49 | _code_order = [ 50 | ['D', 3], 51 | ['F', 7], 52 | ] 53 | 54 | _parameters = [ 55 | ['D', 0, 2], 56 | ['F', 3, 9], 57 | ] 58 | # [D:0..7,F:0..127] 59 | encode_parameters = [ 60 | ['device', 0, 7], 61 | ['function', 0, 127], 62 | ] 63 | 64 | def encode( 65 | self, 66 | device: int, 67 | function: int, 68 | repeat_count: int = 0 69 | ) -> protocol_base.IRCode: 70 | params = dict( 71 | D=device, 72 | F=function, 73 | ) 74 | 75 | packet = self._build_packet(**params) 76 | params['frequency'] = self.frequency 77 | 78 | code = protocol_base.IRCode( 79 | self, 80 | [packet[:]], 81 | [packet[:]] * (repeat_count + 1), 82 | params, 83 | repeat_count 84 | ) 85 | 86 | return code 87 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/bryston.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 315 33 | 34 | 35 | class Bryston(protocol_base.IrProtocolBase): 36 | """ 37 | IR decoder for the Bryston protocol. 38 | """ 39 | irp = '{38.0k,315,lsb}<1,-6|6,-1>(D:10,F:8,-18m)*' 40 | frequency = 38000 41 | bit_count = 18 42 | encoding = 'lsb' 43 | 44 | _lead_out = [-18000] 45 | _bursts = [[TIMING, -TIMING * 6], [TIMING * 6, -TIMING]] 46 | 47 | _code_order = [ 48 | ['D', 10], 49 | ['F', 8] 50 | ] 51 | 52 | _parameters = [ 53 | ['D', 0, 9], 54 | ['F', 10, 17] 55 | ] 56 | # [D:0..1023,F:0..255] 57 | encode_parameters = [ 58 | ['device', 0, 1023], 59 | ['function', 0, 255], 60 | ] 61 | 62 | def encode( 63 | self, 64 | device: int, 65 | function: int, 66 | repeat_count: int = 0 67 | ) -> protocol_base.IRCode: 68 | packet = self._build_packet( 69 | D=device, 70 | F=function, 71 | ) 72 | 73 | params = dict( 74 | frequency=self.frequency, 75 | D=device, 76 | F=function, 77 | ) 78 | 79 | code = protocol_base.IRCode( 80 | self, 81 | packet[:] * (repeat_count + 1), 82 | [packet[:]] * (repeat_count + 1), 83 | params, 84 | repeat_count 85 | ) 86 | return code 87 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/rcmm24.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | from . import rcmm12 31 | 32 | 33 | # noinspection PyAbstractClass 34 | class RCMM24(rcmm12.RCMM12): 35 | irp = '{36k,1p,msb}<6, -10|6,-16|6,-22|6,-28>(15,-10,M:4,F:20)*' 36 | bit_count = 24 37 | 38 | _code_order = [ 39 | ['M', 4], 40 | ['F', 20] 41 | ] 42 | 43 | _parameters = [ 44 | ['M', 0, 3], 45 | ['F', 4, 23] 46 | ] 47 | # [M:0..15,F:0..1048575] 48 | encode_parameters = [ 49 | ['mode', 0, 15], 50 | ['function', 0, 1048575] 51 | ] 52 | 53 | MODE_MAPPING = { 54 | 0: 'OEM', 55 | 1: 'Mouse', 56 | 2: 'Keyboard', 57 | 3: 'Gamepad' 58 | } 59 | 60 | # noinspection PyMethodOverriding 61 | def encode( 62 | self, 63 | mode: int, 64 | function: int, 65 | repeat_count: int = 0 66 | ) -> protocol_base.IRCode: 67 | 68 | params = dict( 69 | M=mode, 70 | F=function 71 | ) 72 | 73 | # noinspection PyUnresolvedReferences 74 | packet = self._build_packet(**params) 75 | # noinspection PyUnresolvedReferences 76 | params['frequency'] = self.frequency 77 | 78 | code = protocol_base.IRCode( 79 | self, 80 | packet[:] * (repeat_count + 1), 81 | [packet[:]] * (repeat_count + 1), 82 | params 83 | ) 84 | return code 85 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/mitsubishi.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 300 33 | 34 | 35 | class Mitsubishi(protocol_base.IrProtocolBase): 36 | """ 37 | IR decoder for the Mitsubishi protocol. 38 | """ 39 | irp = '{32.6k,300,lsb}<1,-3|1,-7>(D:8,F:8,1,-80)*' 40 | frequency = 32600 41 | bit_count = 16 42 | encoding = 'lsb' 43 | 44 | _lead_in = [] 45 | _lead_out = [TIMING, -TIMING * 80] 46 | _middle_timings = [] 47 | _bursts = [[TIMING, -TIMING * 3], [TIMING, -TIMING * 7]] 48 | 49 | _code_order = [ 50 | ['D', 8], 51 | ['F', 8], 52 | ] 53 | 54 | _parameters = [ 55 | ['D', 0, 7], 56 | ['F', 8, 15], 57 | ] 58 | # [D:0..127,F:0..255] 59 | encode_parameters = [ 60 | ['device', 0, 127], 61 | ['function', 0, 255], 62 | ] 63 | 64 | def encode( 65 | self, 66 | device: int, 67 | function: int, 68 | repeat_count: int = 0 69 | ) -> protocol_base.IRCode: 70 | params = dict( 71 | D=device, 72 | F=function, 73 | ) 74 | 75 | packet = self._build_packet(**params) 76 | params['frequency'] = self.frequency 77 | 78 | code = protocol_base.IRCode( 79 | self, 80 | packet[:] * (repeat_count + 1), 81 | [packet[:]] * (repeat_count + 1), 82 | params, 83 | repeat_count 84 | ) 85 | 86 | return code 87 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/sony12.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 600 33 | 34 | 35 | class Sony12(protocol_base.IrProtocolBase): 36 | """ 37 | IR decoder for the Sony12 protocol. 38 | """ 39 | irp = '{40k,600,lsb}<1,-1|2,-1>(4,-1,F:7,D:5,^45m)*' 40 | frequency = 40000 41 | bit_count = 12 42 | encoding = 'lsb' 43 | 44 | _lead_in = [TIMING * 4, -TIMING] 45 | _lead_out = [45000] 46 | _middle_timings = [] 47 | _bursts = [[TIMING, -TIMING], [TIMING * 2, -TIMING]] 48 | 49 | _code_order = [ 50 | ['F', 7], 51 | ['D', 5], 52 | ] 53 | 54 | _parameters = [ 55 | ['F', 0, 6], 56 | ['D', 7, 11], 57 | ] 58 | # [D:0..31,F:0..127] 59 | encode_parameters = [ 60 | ['device', 0, 31], 61 | ['function', 0, 127], 62 | ] 63 | 64 | def encode( 65 | self, 66 | device: int, 67 | function: int, 68 | repeat_count: int = 0 69 | ) -> protocol_base.IRCode: 70 | params = dict( 71 | D=device, 72 | F=function, 73 | ) 74 | 75 | packet = self._build_packet(**params) 76 | 77 | params['frequency'] = self.frequency 78 | 79 | code = protocol_base.IRCode( 80 | self, 81 | packet[:] * (repeat_count + 1), 82 | [packet[:]] * (repeat_count + 1), 83 | params, 84 | repeat_count 85 | ) 86 | 87 | return code 88 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/sony15.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 600 33 | 34 | 35 | class Sony15(protocol_base.IrProtocolBase): 36 | """ 37 | IR decoder for the Sony15 protocol. 38 | """ 39 | irp = '{40k,600,lsb}<1,-1|2,-1>(4,-1,F:7,D:8,^45m)*' 40 | frequency = 40000 41 | bit_count = 15 42 | encoding = 'lsb' 43 | 44 | _lead_in = [TIMING * 4, -TIMING] 45 | _lead_out = [45000] 46 | _middle_timings = [] 47 | _bursts = [[TIMING, -TIMING], [TIMING * 2, -TIMING]] 48 | 49 | _code_order = [ 50 | ['F', 7], 51 | ['D', 8] 52 | ] 53 | 54 | _parameters = [ 55 | ['F', 0, 6], 56 | ['D', 7, 14], 57 | ] 58 | 59 | # [D:0..255,F:0..127] 60 | encode_parameters = [ 61 | ['device', 0, 255], 62 | ['function', 0, 127], 63 | ] 64 | 65 | def encode( 66 | self, 67 | device: int, 68 | function: int, 69 | repeat_count: int = 0 70 | ) -> protocol_base.IRCode: 71 | params = dict( 72 | D=device, 73 | F=function, 74 | ) 75 | 76 | packet = self._build_packet(**params) 77 | 78 | params['frequency'] = self.frequency 79 | 80 | code = protocol_base.IRCode( 81 | self, 82 | packet[:] * (repeat_count + 1), 83 | [packet[:]] * (repeat_count + 1), 84 | params, 85 | repeat_count 86 | ) 87 | 88 | return code 89 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/pctv.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 832 33 | 34 | 35 | # TODO: finish 36 | class PCTV(protocol_base.IrProtocolBase): 37 | """ 38 | IR decoder for the PCTV protocol. 39 | """ 40 | irp = '{38.4k,832,lsb}<-1|1>(2,-8,1,D:8,F:8,2,-100m)' 41 | frequency = 38400 42 | bit_count = 16 43 | encoding = 'lsb' 44 | 45 | _lead_in = [TIMING * 2, -TIMING * 8, TIMING] 46 | _lead_out = [TIMING * 2, -100000] 47 | _middle_timings = [] 48 | _bursts = [-TIMING, TIMING] 49 | 50 | _code_order = [ 51 | ['D', 8], 52 | ['F', 8], 53 | ] 54 | 55 | _parameters = [ 56 | ['D', 0, 7], 57 | ['F', 8, 15] 58 | ] 59 | # [D:0..255,F:0..255] 60 | encode_parameters = [ 61 | ['device', 0, 255], 62 | ['function', 0, 255], 63 | ] 64 | 65 | def encode( 66 | self, 67 | device: int, 68 | function: int, 69 | repeat_count: int = 0 70 | ) -> protocol_base.IRCode: 71 | params = dict( 72 | D=device, 73 | F=function, 74 | ) 75 | packet = self._build_packet(**params) 76 | 77 | params['frequency'] = self.frequency 78 | 79 | code = protocol_base.IRCode( 80 | self, 81 | packet[:] * (repeat_count + 1), 82 | [packet[:]] * (repeat_count + 1), 83 | params, 84 | repeat_count 85 | ) 86 | 87 | return code 88 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/sim2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 400 33 | 34 | 35 | class SIM2(protocol_base.IrProtocolBase): 36 | """ 37 | IR decoder for the SIM2 protocol. 38 | """ 39 | irp = '{38.8k,400,lsb}<3,-3|3,-7>(6,-7,D:8,F:8,3,^115m)' 40 | frequency = 38800 41 | bit_count = 16 42 | encoding = 'lsb' 43 | 44 | _lead_in = [TIMING * 6, -TIMING * 7] 45 | _lead_out = [TIMING * 3, 115000] 46 | _middle_timings = [] 47 | _bursts = [[TIMING * 3, -TIMING * 3], [TIMING * 3, -TIMING * 7]] 48 | 49 | _code_order = [ 50 | ['D', 8], 51 | ['F', 8], 52 | ] 53 | 54 | _parameters = [ 55 | ['D', 0, 7], 56 | ['F', 8, 15] 57 | ] 58 | # [D:0..255=236,F:0..255] 59 | encode_parameters = [ 60 | ['device', 0, 255], 61 | ['function', 0, 255], 62 | ] 63 | 64 | def encode( 65 | self, 66 | device: int, 67 | function: int, 68 | repeat_count: int = 0 69 | ) -> protocol_base.IRCode: 70 | params = dict( 71 | D=device, 72 | F=function, 73 | ) 74 | packet = self._build_packet(**params) 75 | params['frequency'] = self.frequency 76 | 77 | code = protocol_base.IRCode( 78 | self, 79 | packet[:] * (repeat_count + 1), 80 | [packet[:]] * (repeat_count + 1), 81 | params, 82 | repeat_count 83 | ) 84 | 85 | return code 86 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/konka.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 500 33 | 34 | 35 | class Konka(protocol_base.IrProtocolBase): 36 | """ 37 | IR decoder for the Konka protocol. 38 | """ 39 | irp = '{38k,500,msb}<1,-3|1,-5>(6,-6,D:8,F:8,1,-8,1,-46)*' 40 | frequency = 38000 41 | bit_count = 16 42 | encoding = 'msb' 43 | 44 | _lead_in = [TIMING * 6, -TIMING * 6] 45 | _lead_out = [TIMING, -TIMING * 8, TIMING, -TIMING * 46] 46 | _middle_timings = [] 47 | _bursts = [[TIMING, -TIMING * 3], [TIMING, -TIMING * 5]] 48 | 49 | _code_order = [ 50 | ['D', 8], 51 | ['F', 8], 52 | ] 53 | 54 | _parameters = [ 55 | ['D', 0, 7], 56 | ['F', 8, 15], 57 | ] 58 | # [D:0..255,F:0..255] 59 | encode_parameters = [ 60 | ['device', 0, 255], 61 | ['function', 0, 255], 62 | ] 63 | 64 | def encode( 65 | self, 66 | device: int, 67 | function: int, 68 | repeat_count: int = 0 69 | ) -> protocol_base.IRCode: 70 | params = dict( 71 | D=device, 72 | F=function, 73 | ) 74 | packet = self._build_packet(**params) 75 | params['frequency'] = self.frequency 76 | 77 | code = protocol_base.IRCode( 78 | self, 79 | packet[:] * (repeat_count + 1), 80 | [packet[:]] * (repeat_count + 1), 81 | params, 82 | repeat_count 83 | ) 84 | 85 | return code 86 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/barco.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 10 33 | 34 | 35 | class Barco(protocol_base.IrProtocolBase): 36 | """ 37 | IR decoder for the Barco protocol. 38 | """ 39 | irp = '{0k,10,lsb}<1,-5|1,-15>(1,-25,D:5,F:6,1,-25,1,120m)+ ' 40 | frequency = 0 41 | bit_count = 11 42 | encoding = 'lsb' 43 | 44 | _lead_in = [TIMING, -TIMING * 25] 45 | _lead_out = [TIMING, -TIMING * 25, TIMING, -120000] 46 | _bursts = [[TIMING, -TIMING * 5], [TIMING, -TIMING * 15]] 47 | 48 | _code_order = [ 49 | ['D', 5], 50 | ['F', 6] 51 | ] 52 | 53 | _parameters = [ 54 | ['D', 0, 4], 55 | ['F', 5, 10], 56 | ] 57 | # [D:0..31,F:0..63] 58 | encode_parameters = [ 59 | ['device', 0, 31], 60 | ['function', 0, 63], 61 | ] 62 | 63 | def encode( 64 | self, 65 | device: int, 66 | function: int, 67 | repeat_count: int = 0 68 | ) -> protocol_base.IRCode: 69 | 70 | packet = self._build_packet( 71 | D=device, 72 | F=function, 73 | ) 74 | 75 | params = dict( 76 | frequency=self.frequency, 77 | D=device, 78 | F=function, 79 | ) 80 | 81 | code = protocol_base.IRCode( 82 | self, 83 | packet[:] * (repeat_count + 1), 84 | [packet[:]] * (repeat_count + 1), 85 | params, 86 | repeat_count 87 | ) 88 | return code 89 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/rcmmoem.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | from . import rcmm12 31 | 32 | TIMING = 28.777777777777 33 | 34 | 35 | # noinspection PyAbstractClass, PyProtectedMember 36 | class RCMMOEM(rcmm12.RCMM12): 37 | irp = '{36k,1p,msb}<6, -10|6,-16|6,-22|6,-28>(15,-10,M:6,ID:6,F:12)*' 38 | bit_count = 24 39 | encoding = 'msb' 40 | 41 | _code_order = [ 42 | ['ID', 6], 43 | ['F', 12] 44 | ] 45 | 46 | _parameters = [ 47 | ['M', 0, 5], 48 | ['ID', 6, 11], 49 | ['F', 12, 23] 50 | ] 51 | # [id:0..63,F:0..4095] 52 | encode_parameters = [ 53 | ['id', 0, 63], 54 | ['function', 0, 4095] 55 | ] 56 | 57 | MODE_MAPPING = { 58 | 3: 'OEM' 59 | } 60 | 61 | # noinspection PyShadowingBuiltins, PyMethodOverriding 62 | def encode( 63 | self, 64 | id: int, 65 | function: int, 66 | repeat_count: int = 0 67 | ) -> protocol_base.IRCode: 68 | 69 | params = dict( 70 | M=3, 71 | ID=id, 72 | F=function 73 | ) 74 | 75 | # noinspection PyUnresolvedReferences 76 | packet = self._build_packet(**params) 77 | # noinspection PyUnresolvedReferences 78 | params['frequency'] = self.frequency 79 | 80 | code = protocol_base.IRCode( 81 | self, 82 | packet[:] * (repeat_count + 1), 83 | [packet[:]] * (repeat_count + 1), 84 | params 85 | ) 86 | return code 87 | -------------------------------------------------------------------------------- /test_protocols/test_universal.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | 27 | from pyIRDecoder import ( 28 | RepeatLeadInError, 29 | RepeatLeadOutError, 30 | IRException 31 | ) 32 | from pyIRDecoder import protocols 33 | 34 | protocol = protocols.Universal 35 | 36 | 37 | class Universal(object): 38 | rlc = [[ 39 | 25000, -500, 500, -1000, 500, -500, 1000, -500, 500, -1000, 500, -500, 40 | 1000, -1000, 500, -500, 1000, -500, 500, -1000, 1000, -500, 500, -1000, 41 | 1000, -500, 500, -500, 500, -1000, 500, -500, 1000, -1000, 1000, -500, 42 | 500, -1000, 1000, -1000, 1000, -500, 500, -500, 500, -1000, 1000, 43 | -1000, 1000, -500, 500, -500, 500, -500, 500, -1000, 1000, -1000, 1000, 44 | -500, 500, -500, 500, -1000, 1000, -1000, 1000, -1000, 500, -500, 500, 45 | -500, 500, -500, 1000, -500, 500, -500, 500, -500, 500, -1000, 500, 46 | -500, 1000, -500, 500, -1000, 1000, -500, 500, -500, 500, -25500 47 | ]] 48 | params = [dict(code=0x1E6C91A51428AF0C8)] 49 | 50 | 51 | def test_decode(): 52 | for rlc, params in zip(Universal.rlc, Universal.params): 53 | try: 54 | ir_code = protocol.decode(rlc, protocol.frequency) 55 | except (RepeatLeadInError, RepeatLeadOutError): 56 | if params is not None: 57 | raise 58 | continue 59 | 60 | for key, value in params.items(): 61 | assert getattr(ir_code, key) == value, ( 62 | key, 63 | getattr(ir_code, key), 64 | value 65 | ) 66 | print() 67 | print(ir_code, repr(ir_code)) 68 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/nokia.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | from . import nokia12 31 | 32 | 33 | TIMING = 27.77777777777778 34 | 35 | 36 | # noinspection PyUnresolvedReferences, PyProtectedMember 37 | class Nokia(nokia12.Nokia12): 38 | """ 39 | IR decoder for the Nokia protocol. 40 | """ 41 | irp = ( 42 | '{36k,1p,msb}<6,-10|6,-16|6,-22|6,-28>' 43 | '(15,-10,D:8,S:8,F:8,6,^100m)*' 44 | ) 45 | bit_count = 24 46 | 47 | _code_order = [ 48 | ['D', 8], 49 | ['S', 8], 50 | ['F', 8], 51 | ] 52 | 53 | _parameters = [ 54 | ['D', 0, 7], 55 | ['S', 8, 15], 56 | ['F', 16, 23], 57 | ] 58 | # [D:0..255,S:0..255,F:0..255] 59 | encode_parameters = [ 60 | ['device', 0, 255], 61 | ['sub_device', 0, 255], 62 | ['function', 0, 255], 63 | ] 64 | 65 | # noinspection PyMethodOverriding 66 | def encode( 67 | self, 68 | device: int, 69 | sub_device: int, 70 | function: int, 71 | repeat_count: int = 0 72 | ) -> protocol_base.IRCode: 73 | params = dict( 74 | D=device, 75 | S=sub_device, 76 | F=function, 77 | ) 78 | 79 | packet = self._build_packet(**params) 80 | params['frequency'] = self.frequency 81 | 82 | code = protocol_base.IRCode( 83 | self, 84 | packet[:] * (repeat_count + 1), 85 | [packet[:]] * (repeat_count + 1), 86 | params, 87 | repeat_count 88 | ) 89 | 90 | return code 91 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/tdc38.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 315 33 | 34 | 35 | class TDC38(protocol_base.IrProtocolBase): 36 | """ 37 | IR decoder for the TDC38 protocol. 38 | """ 39 | irp = '{38k,315,msb}<-1,1|1,-1>(1,-1,D:5,S:5,F:7,-89m)*' 40 | frequency = 38000 41 | bit_count = 17 42 | encoding = 'msb' 43 | 44 | _lead_in = [TIMING, -TIMING] 45 | _lead_out = [-89000] 46 | _middle_timings = [] 47 | _bursts = [[-TIMING, TIMING], [TIMING, -TIMING]] 48 | 49 | _code_order = [ 50 | ['D', 5], 51 | ['S', 5], 52 | ['F', 7] 53 | ] 54 | 55 | _parameters = [ 56 | ['D', 0, 4], 57 | ['S', 5, 9], 58 | ['F', 10, 16], 59 | ] 60 | # [D:0..31,S:0..31,F:0..127] 61 | encode_parameters = [ 62 | ['device', 0, 31], 63 | ['sub_device', 0, 31], 64 | ['function', 0, 127], 65 | ] 66 | 67 | def encode( 68 | self, 69 | device: int, 70 | sub_device: int, 71 | function: int, 72 | repeat_count: int = 0 73 | ) -> protocol_base.IRCode: 74 | params = dict( 75 | D=device, 76 | S=sub_device, 77 | F=function, 78 | ) 79 | 80 | packet = self._build_packet(**params) 81 | 82 | params['frequency'] = self.frequency 83 | 84 | code = protocol_base.IRCode( 85 | self, 86 | packet[:] * (repeat_count + 1), 87 | [packet[:]] * (repeat_count + 1), 88 | params, 89 | repeat_count 90 | ) 91 | 92 | return code 93 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/sony20.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 600 33 | 34 | 35 | class Sony20(protocol_base.IrProtocolBase): 36 | """ 37 | IR decoder for the Sony20 protocol. 38 | """ 39 | irp = '{40k,600,lsb}<1,-1|2,-1>(4,-1,F:7,D:5,S:8,^45m)*' 40 | frequency = 40000 41 | bit_count = 20 42 | encoding = 'lsb' 43 | 44 | _lead_in = [TIMING * 4, -TIMING] 45 | _lead_out = [45000] 46 | _middle_timings = [] 47 | _bursts = [[TIMING, -TIMING], [TIMING * 2, -TIMING]] 48 | 49 | _code_order = [ 50 | ['F', 7], 51 | ['D', 5], 52 | ['S', 8], 53 | ] 54 | 55 | _parameters = [ 56 | ['F', 0, 6], 57 | ['D', 7, 11], 58 | ['S', 12, 19] 59 | ] 60 | 61 | # [D:0..31,S:0..255,F:0..127] 62 | encode_parameters = [ 63 | ['device', 0, 31], 64 | ['sub_device', 0, 255], 65 | ['function', 0, 127], 66 | ] 67 | 68 | def encode( 69 | self, 70 | device: int, 71 | sub_device: int, 72 | function: int, 73 | repeat_count: int = 0 74 | ) -> protocol_base.IRCode: 75 | params = dict( 76 | D=device, 77 | S=sub_device, 78 | F=function, 79 | ) 80 | 81 | packet = self._build_packet(**params) 82 | 83 | params['frequency'] = self.frequency 84 | 85 | code = protocol_base.IRCode( 86 | self, 87 | packet[:] * (repeat_count + 1), 88 | [packet[:]] * (repeat_count + 1), 89 | params, 90 | repeat_count 91 | ) 92 | 93 | return code 94 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/girg.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 1000 33 | 34 | 35 | class GIRG(protocol_base.IrProtocolBase): 36 | """ 37 | IR decoder for the GIRG protocol. 38 | """ 39 | irp = '{37.3k,1000,msb}<1,-1|1,-3>(5,-3,F:6,S:2,D:8,1,-60)*' 40 | frequency = 37300 41 | bit_count = 16 42 | encoding = 'msb' 43 | 44 | _lead_in = [TIMING * 5, -TIMING * 3] 45 | _lead_out = [TIMING, -TIMING * 60] 46 | _middle_timings = [] 47 | _bursts = [[TIMING, -TIMING], [TIMING, -TIMING * 3]] 48 | 49 | _code_order = [ 50 | ['F', 6], 51 | ['S', 2], 52 | ['D', 8], 53 | ] 54 | 55 | _parameters = [ 56 | ['F', 0, 5], 57 | ['S', 6, 7], 58 | ['D', 8, 15] 59 | ] 60 | # [D:0..255, S:0..3, F:0..63] 61 | encode_parameters = [ 62 | ['device', 0, 255], 63 | ['sub_device', 0, 3], 64 | ['function', 0, 63], 65 | ] 66 | 67 | def encode( 68 | self, 69 | device: int, 70 | sub_device: int, 71 | function: int, 72 | repeat_count: int = 0 73 | ) -> protocol_base.IRCode: 74 | params = dict( 75 | D=device, 76 | S=sub_device, 77 | F=function, 78 | ) 79 | 80 | packet = self._build_packet(**params) 81 | params['frequency'] = self.frequency 82 | 83 | code = protocol_base.IRCode( 84 | self, 85 | packet[:] * (repeat_count + 1), 86 | [packet[:]] * (repeat_count + 1), 87 | params, 88 | repeat_count 89 | ) 90 | 91 | return code 92 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/akai.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 289 33 | 34 | 35 | class Akai(protocol_base.IrProtocolBase): 36 | """ 37 | IR decoder for the Akai protocol. 38 | """ 39 | irp = '{38k,289,lsb}<1,-2.6|1,-6.3>(D:3,F:7,1,^25.3m)*' 40 | blah = [289, -751, 289, -1821, 289, -751, 289, -1821, 289, -751, 289, -1821, 289, -1821, 289, -1821, 289, -751, 289, -1821, 289, -8191] 41 | 42 | frequency = 38000 43 | bit_count = 10 44 | encoding = 'lsb' 45 | 46 | _lead_out = [TIMING, 25300] 47 | _bursts = [ 48 | [TIMING, -int(round(TIMING * 2.6))], 49 | [TIMING, -int(round(TIMING * 6.3))] 50 | ] 51 | 52 | _code_order = [ 53 | ['D', 3], 54 | ['F', 7] 55 | ] 56 | 57 | _parameters = [ 58 | ['D', 0, 2], 59 | ['F', 3, 9], 60 | ] 61 | # [D:0..7,F:0..127] 62 | encode_parameters = [ 63 | ['device', 0, 7], 64 | ['function', 0, 127], 65 | ] 66 | 67 | def encode( 68 | self, 69 | device: int, 70 | function: int, 71 | repeat_count: int = 0 72 | ) -> protocol_base.IRCode: 73 | packet = self._build_packet( 74 | D=device, 75 | F=function 76 | ) 77 | 78 | params = dict( 79 | frequency=self.frequency, 80 | D=device, 81 | F=function 82 | ) 83 | 84 | code = protocol_base.IRCode( 85 | self, 86 | packet[:] * (repeat_count + 1), 87 | [packet[:]] * (repeat_count + 1), 88 | params, 89 | repeat_count 90 | ) 91 | return code 92 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/samsung20.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 564 33 | 34 | 35 | class Samsung20(protocol_base.IrProtocolBase): 36 | """ 37 | IR decoder for the Samsung20 protocol. 38 | """ 39 | irp = '{38.4k,564,lsb}<1,-1|1,-3>(8,-8,D:6,S:6,F:8,1,^100m)*' 40 | frequency = 38400 41 | bit_count = 20 42 | encoding = 'lsb' 43 | 44 | _lead_in = [TIMING * 8, -TIMING * 8] 45 | _lead_out = [TIMING, 100000] 46 | _middle_timings = [] 47 | _bursts = [[TIMING, -TIMING], [TIMING, -TIMING * 3]] 48 | 49 | _code_order = [ 50 | ['D', 6], 51 | ['S', 6], 52 | ['F', 8], 53 | ] 54 | 55 | _parameters = [ 56 | ['D', 0, 5], 57 | ['S', 6, 11], 58 | ['F', 12, 19], 59 | ] 60 | # [D:0..63,S:0..63,F:0..255] 61 | encode_parameters = [ 62 | ['device', 0, 63], 63 | ['sub_device', 0, 63], 64 | ['function', 0, 255], 65 | ] 66 | 67 | def encode( 68 | self, 69 | device: int, 70 | sub_device: int, 71 | function: int, 72 | repeat_count: int = 0 73 | ) -> protocol_base.IRCode: 74 | params = dict( 75 | D=device, 76 | S=sub_device, 77 | F=function, 78 | ) 79 | packet = self._build_packet(**params) 80 | 81 | params['frequency'] = self.frequency 82 | 83 | code = protocol_base.IRCode( 84 | self, 85 | packet[:] * (repeat_count + 1), 86 | [packet[:]] * (repeat_count + 1), 87 | params, 88 | repeat_count 89 | ) 90 | 91 | return code 92 | -------------------------------------------------------------------------------- /test_protocols/test_proton40.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | 27 | from pyIRDecoder import ( 28 | RepeatLeadInError, 29 | RepeatLeadOutError, 30 | IRException 31 | ) 32 | from pyIRDecoder import protocols 33 | 34 | from . import test_proton 35 | 36 | protocol = protocols.Proton40 37 | 38 | 39 | class Proton40(test_proton.Proton): 40 | pass 41 | 42 | 43 | def test_decode(): 44 | for rlc, params in zip(Proton40.rlc, Proton40.params): 45 | try: 46 | ir_code = protocol.decode(rlc, protocol.frequency) 47 | except (RepeatLeadInError, RepeatLeadOutError): 48 | if params is not None: 49 | raise 50 | continue 51 | 52 | for key, value in params.items(): 53 | assert getattr(ir_code, key) == value, ( 54 | key, 55 | getattr(ir_code, key), 56 | value 57 | ) 58 | print() 59 | print(ir_code, repr(ir_code)) 60 | 61 | 62 | def test_encode(): 63 | for params in Proton40.params: 64 | if params is None: 65 | continue 66 | 67 | ir_code = protocol.encode(**params) 68 | for key, value in params.items(): 69 | assert getattr(ir_code, key) == value, ( 70 | key, 71 | getattr(ir_code, key), 72 | value 73 | ) 74 | 75 | new_ir_code = None 76 | for rlc in ir_code.normalized_rlc: 77 | try: 78 | new_ir_code = protocol.decode(rlc, protocol.frequency) 79 | except (RepeatLeadInError, RepeatLeadOutError): 80 | continue 81 | except IRException: 82 | new_ir_code = protocol.decode( 83 | ir_code.original_rlc, 84 | protocol.frequency 85 | ) 86 | break 87 | 88 | print() 89 | print(ir_code, repr(ir_code)) 90 | print(new_ir_code) 91 | 92 | assert new_ir_code == ir_code 93 | 94 | break 95 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/lutron.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | from . import DecodeError 31 | 32 | 33 | TIMING = 2300 34 | 35 | 36 | # TODO: Finish 37 | class Lutron(protocol_base.IrProtocolBase): 38 | """ 39 | IR decoder for the Lutron protocol. 40 | """ 41 | irp = '{40k,2300,msb}<-1|1>(255:8,X:24,0:4)*' 42 | frequency = 40000 43 | bit_count = 36 44 | encoding = 'msb' 45 | 46 | _bursts = [-TIMING, TIMING] 47 | 48 | _code_order = [ 49 | ['X', 24], 50 | ] 51 | 52 | _parameters = [ 53 | ['C0', 0, 7], 54 | ['X', 8, 31], 55 | ['C1', 32, 35], 56 | ] 57 | # [X:0..16777215] 58 | encode_parameters = [ 59 | ['x', 0, 16777215] 60 | ] 61 | 62 | def decode(self, data: list, frequency: int = 0) -> protocol_base.IRCode: 63 | code = protocol_base.IrProtocolBase.decode(self, data, frequency) 64 | if code.c0 != 255 or code.c1 != 0: 65 | raise DecodeError('Checksum failed') 66 | 67 | if self._last_code is not None: 68 | if self._last_code == code: 69 | return self._last_code 70 | 71 | self._last_code.repeat_timer.stop() 72 | self._last_code = None 73 | 74 | self._last_code = code 75 | return code 76 | 77 | def encode( 78 | self, 79 | x: int, 80 | repeat_count: int = 0 81 | ) -> protocol_base.IRCode: 82 | params = dict( 83 | X=x, 84 | C0=255, 85 | C1=0 86 | ) 87 | 88 | packet = self._build_packet(**params) 89 | 90 | params['frequency'] = self.frequency 91 | 92 | code = protocol_base.IRCode( 93 | self, 94 | packet[:] * (repeat_count + 1), 95 | [packet[:]] * (repeat_count + 1), 96 | params, 97 | repeat_count 98 | ) 99 | 100 | return code 101 | -------------------------------------------------------------------------------- /test_protocols/test_rca38.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | # Local imports 27 | from pyIRDecoder import ( 28 | RepeatLeadInError, 29 | RepeatLeadOutError, 30 | IRException 31 | ) 32 | from pyIRDecoder import protocols 33 | 34 | # Local imports 35 | from . import test_rca 36 | 37 | protocol = protocols.RCA38 38 | 39 | 40 | class RCA38(test_rca.RCA): 41 | pass 42 | 43 | 44 | def test_decode(): 45 | for rlc, params in zip(RCA38.rlc, RCA38.params): 46 | try: 47 | ir_code = protocol.decode(rlc, protocol.frequency) 48 | except (RepeatLeadInError, RepeatLeadOutError): 49 | if params is not None: 50 | raise 51 | continue 52 | 53 | for key, value in params.items(): 54 | assert getattr(ir_code, key) == value, ( 55 | key, 56 | getattr(ir_code, key), 57 | value 58 | ) 59 | print() 60 | print(ir_code, repr(ir_code)) 61 | 62 | 63 | def test_encode(): 64 | for params in RCA38.params: 65 | if params is None: 66 | continue 67 | 68 | ir_code = protocol.encode(**params) 69 | for key, value in params.items(): 70 | assert getattr(ir_code, key) == value, ( 71 | key, 72 | getattr(ir_code, key), 73 | value 74 | ) 75 | 76 | new_ir_code = None 77 | for rlc in ir_code.normalized_rlc: 78 | try: 79 | new_ir_code = protocol.decode(rlc, protocol.frequency) 80 | except (RepeatLeadInError, RepeatLeadOutError): 81 | continue 82 | except IRException: 83 | new_ir_code = protocol.decode( 84 | ir_code.original_rlc, 85 | protocol.frequency 86 | ) 87 | break 88 | 89 | print() 90 | print(ir_code, repr(ir_code)) 91 | print(new_ir_code) 92 | 93 | assert new_ir_code == ir_code 94 | 95 | break 96 | -------------------------------------------------------------------------------- /test_protocols/test_rcaold.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | # Local imports 27 | from pyIRDecoder import ( 28 | RepeatLeadInError, 29 | RepeatLeadOutError, 30 | IRException 31 | ) 32 | from pyIRDecoder import protocols 33 | 34 | from . import test_rca38old 35 | 36 | protocol = protocols.RCAOld 37 | 38 | 39 | class RCAOld(test_rca38old.RCA38Old): 40 | pass 41 | 42 | 43 | def test_decode(): 44 | for rlc, params in zip(RCAOld.rlc, RCAOld.params): 45 | try: 46 | ir_code = protocol.decode(rlc, protocol.frequency) 47 | except (RepeatLeadInError, RepeatLeadOutError): 48 | if params is not None: 49 | raise 50 | continue 51 | 52 | for key, value in params.items(): 53 | assert getattr(ir_code, key) == value, ( 54 | key, 55 | getattr(ir_code, key), 56 | value 57 | ) 58 | print() 59 | print(ir_code, repr(ir_code)) 60 | 61 | 62 | def test_encode(): 63 | for params in RCAOld.params: 64 | if params is None: 65 | continue 66 | 67 | ir_code = protocol.encode(**params) 68 | for key, value in params.items(): 69 | assert getattr(ir_code, key) == value, ( 70 | key, 71 | getattr(ir_code, key), 72 | value 73 | ) 74 | 75 | new_ir_code = None 76 | for rlc in ir_code.normalized_rlc: 77 | try: 78 | new_ir_code = protocol.decode(rlc, protocol.frequency) 79 | except (RepeatLeadInError, RepeatLeadOutError): 80 | continue 81 | except IRException: 82 | new_ir_code = protocol.decode( 83 | ir_code.original_rlc, 84 | protocol.frequency 85 | ) 86 | break 87 | 88 | print() 89 | print(ir_code, repr(ir_code)) 90 | print(new_ir_code) 91 | 92 | assert new_ir_code == ir_code 93 | 94 | break 95 | -------------------------------------------------------------------------------- /test_protocols/test_rc57f57.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | # Local imports 27 | 28 | from pyIRDecoder import ( 29 | RepeatLeadInError, 30 | RepeatLeadOutError, 31 | IRException 32 | ) 33 | from pyIRDecoder import protocols 34 | 35 | # Local imports 36 | from . import test_rc57f 37 | 38 | protocol = protocols.RC57F57 39 | 40 | 41 | class RC57F57(test_rc57f.RC57F): 42 | pass 43 | 44 | 45 | def test_decode(): 46 | for rlc, params in zip(RC57F57.rlc, RC57F57.params): 47 | try: 48 | ir_code = protocol.decode(rlc, protocol.frequency) 49 | except (RepeatLeadInError, RepeatLeadOutError): 50 | if params is not None: 51 | raise 52 | continue 53 | 54 | for key, value in params.items(): 55 | assert getattr(ir_code, key) == value, ( 56 | key, 57 | getattr(ir_code, key), 58 | value 59 | ) 60 | print() 61 | print(ir_code, repr(ir_code)) 62 | 63 | 64 | def test_encode(): 65 | for params in RC57F57.params: 66 | if params is None: 67 | continue 68 | 69 | ir_code = protocol.encode(**params) 70 | for key, value in params.items(): 71 | assert getattr(ir_code, key) == value, ( 72 | key, 73 | getattr(ir_code, key), 74 | value 75 | ) 76 | 77 | new_ir_code = None 78 | for rlc in ir_code.normalized_rlc: 79 | try: 80 | new_ir_code = protocol.decode(rlc, protocol.frequency) 81 | except (RepeatLeadInError, RepeatLeadOutError): 82 | continue 83 | except IRException: 84 | new_ir_code = protocol.decode( 85 | ir_code.original_rlc, 86 | protocol.frequency 87 | ) 88 | break 89 | 90 | print() 91 | print(ir_code, repr(ir_code)) 92 | print(new_ir_code) 93 | 94 | assert new_ir_code == ir_code 95 | 96 | break 97 | -------------------------------------------------------------------------------- /test_protocols/test_nrc1632.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | # Local imports 27 | 28 | from pyIRDecoder import ( 29 | RepeatLeadInError, 30 | RepeatLeadOutError, 31 | IRException 32 | ) 33 | from pyIRDecoder import protocols 34 | 35 | # Local imports 36 | from . import test_nrc16 37 | 38 | protocol = protocols.NRC1632 39 | 40 | 41 | class NRC1632(test_nrc16.NRC16): 42 | pass 43 | 44 | 45 | def test_decode(): 46 | for rlc, params in zip(NRC1632.rlc, NRC1632.params): 47 | try: 48 | ir_code = protocol.decode(rlc, protocol.frequency) 49 | except (RepeatLeadInError, RepeatLeadOutError): 50 | if params is not None: 51 | raise 52 | continue 53 | 54 | for key, value in params.items(): 55 | assert getattr(ir_code, key) == value, ( 56 | key, 57 | getattr(ir_code, key), 58 | value 59 | ) 60 | print() 61 | print(ir_code, repr(ir_code)) 62 | 63 | 64 | def test_encode(): 65 | for params in NRC1632.params: 66 | if params is None: 67 | continue 68 | 69 | ir_code = protocol.encode(**params) 70 | for key, value in params.items(): 71 | assert getattr(ir_code, key) == value, ( 72 | key, 73 | getattr(ir_code, key), 74 | value 75 | ) 76 | 77 | new_ir_code = None 78 | for rlc in ir_code.normalized_rlc: 79 | try: 80 | new_ir_code = protocol.decode(rlc, protocol.frequency) 81 | except (RepeatLeadInError, RepeatLeadOutError): 82 | continue 83 | except IRException: 84 | new_ir_code = protocol.decode( 85 | ir_code.original_rlc, 86 | protocol.frequency 87 | ) 88 | break 89 | 90 | print() 91 | print(ir_code, repr(ir_code)) 92 | print(new_ir_code) 93 | 94 | assert new_ir_code == ir_code 95 | 96 | break 97 | -------------------------------------------------------------------------------- /test_protocols/test_directv3.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | # Local imports 27 | 28 | from pyIRDecoder import ( 29 | RepeatLeadInError, 30 | RepeatLeadOutError, 31 | IRException 32 | ) 33 | from pyIRDecoder import protocols 34 | 35 | # Local imports 36 | from . import test_directv1 37 | 38 | protocol = protocols.DirecTV3 39 | 40 | 41 | class DirecTV3(test_directv1.DirecTV1): 42 | pass 43 | 44 | 45 | def test_decode(): 46 | for rlc, params in zip(DirecTV3.rlc, DirecTV3.params): 47 | try: 48 | ir_code = protocol.decode(rlc, protocol.frequency) 49 | except (RepeatLeadInError, RepeatLeadOutError): 50 | if params is not None: 51 | raise 52 | continue 53 | 54 | for key, value in params.items(): 55 | assert getattr(ir_code, key) == value, ( 56 | key, 57 | getattr(ir_code, key), 58 | value 59 | ) 60 | print() 61 | print(ir_code, repr(ir_code)) 62 | 63 | 64 | def test_encode(): 65 | for params in DirecTV3.params: 66 | if params is None: 67 | continue 68 | 69 | ir_code = protocol.encode(**params) 70 | for key, value in params.items(): 71 | assert getattr(ir_code, key) == value, ( 72 | key, 73 | getattr(ir_code, key), 74 | value 75 | ) 76 | 77 | new_ir_code = None 78 | for rlc in ir_code.normalized_rlc: 79 | try: 80 | new_ir_code = protocol.decode(rlc, protocol.frequency) 81 | except (RepeatLeadInError, RepeatLeadOutError): 82 | continue 83 | except IRException: 84 | new_ir_code = protocol.decode( 85 | ir_code.original_rlc, 86 | protocol.frequency 87 | ) 88 | break 89 | 90 | print() 91 | print(ir_code, repr(ir_code)) 92 | print(new_ir_code) 93 | 94 | assert new_ir_code == ir_code 95 | 96 | break 97 | -------------------------------------------------------------------------------- /test_protocols/test_arctech38.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | # Local imports 27 | 28 | from pyIRDecoder import ( 29 | RepeatLeadInError, 30 | RepeatLeadOutError, 31 | IRException 32 | ) 33 | from pyIRDecoder import protocols 34 | 35 | # Local imports 36 | from . import test_arctech 37 | 38 | protocol = protocols.Arctech38 39 | 40 | 41 | class Arctech38(test_arctech.Arctech): 42 | pass 43 | 44 | 45 | def test_decode(): 46 | for rlc, params in zip(Arctech38.rlc, Arctech38.params): 47 | try: 48 | ir_code = protocol.decode(rlc, protocol.frequency) 49 | except (RepeatLeadInError, RepeatLeadOutError): 50 | if params is not None: 51 | raise 52 | continue 53 | 54 | for key, value in params.items(): 55 | assert getattr(ir_code, key) == value, ( 56 | key, 57 | getattr(ir_code, key), 58 | value 59 | ) 60 | print() 61 | print(ir_code, repr(ir_code)) 62 | 63 | 64 | def test_encode(): 65 | for params in Arctech38.params: 66 | if params is None: 67 | continue 68 | 69 | ir_code = protocol.encode(**params) 70 | for key, value in params.items(): 71 | assert getattr(ir_code, key) == value, ( 72 | key, 73 | getattr(ir_code, key), 74 | value 75 | ) 76 | 77 | new_ir_code = None 78 | for rlc in ir_code.normalized_rlc: 79 | try: 80 | new_ir_code = protocol.decode(rlc, protocol.frequency) 81 | except (RepeatLeadInError, RepeatLeadOutError): 82 | continue 83 | except IRException: 84 | new_ir_code = protocol.decode( 85 | ir_code.original_rlc, 86 | protocol.frequency 87 | ) 88 | break 89 | 90 | print() 91 | print(ir_code, repr(ir_code)) 92 | print(new_ir_code) 93 | 94 | assert new_ir_code == ir_code 95 | 96 | break 97 | -------------------------------------------------------------------------------- /test_protocols/test_directv4.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | # Local imports 27 | 28 | from pyIRDecoder import ( 29 | RepeatLeadInError, 30 | RepeatLeadOutError, 31 | IRException 32 | ) 33 | from pyIRDecoder import protocols 34 | 35 | # Local imports 36 | from . import test_directv0 37 | 38 | protocol = protocols.DirecTV4 39 | 40 | 41 | class DirecTV4(test_directv0.DirecTV0): 42 | pass 43 | 44 | 45 | def test_decode(): 46 | for rlc, params in zip(DirecTV4.rlc, DirecTV4.params): 47 | try: 48 | ir_code = protocol.decode(rlc, protocol.frequency) 49 | except (RepeatLeadInError, RepeatLeadOutError): 50 | if params is not None: 51 | raise 52 | continue 53 | 54 | for key, value in params.items(): 55 | assert getattr(ir_code, key) == value, ( 56 | key, 57 | getattr(ir_code, key), 58 | value 59 | ) 60 | print() 61 | print(ir_code, repr(ir_code)) 62 | 63 | 64 | def test_encode(): 65 | for params in DirecTV4.params: 66 | if params is None: 67 | continue 68 | 69 | ir_code = protocol.encode(**params) 70 | for key, value in params.items(): 71 | assert getattr(ir_code, key) == value, ( 72 | key, 73 | getattr(ir_code, key), 74 | value 75 | ) 76 | 77 | new_ir_code = None 78 | for rlc in ir_code.normalized_rlc: 79 | try: 80 | new_ir_code = protocol.decode(rlc, protocol.frequency) 81 | except (RepeatLeadInError, RepeatLeadOutError): 82 | continue 83 | except IRException: 84 | new_ir_code = protocol.decode( 85 | ir_code.original_rlc, 86 | protocol.frequency 87 | ) 88 | break 89 | 90 | print() 91 | print(ir_code, repr(ir_code)) 92 | print(new_ir_code) 93 | 94 | assert new_ir_code == ir_code 95 | 96 | break 97 | -------------------------------------------------------------------------------- /test_protocols/test_directv5.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | # Local imports 27 | 28 | from pyIRDecoder import ( 29 | RepeatLeadInError, 30 | RepeatLeadOutError, 31 | IRException 32 | ) 33 | from pyIRDecoder import protocols 34 | 35 | # Local imports 36 | from . import test_directv1 37 | 38 | protocol = protocols.DirecTV5 39 | 40 | 41 | class DirecTV5(test_directv1.DirecTV1): 42 | pass 43 | 44 | 45 | def test_decode(): 46 | for rlc, params in zip(DirecTV5.rlc, DirecTV5.params): 47 | try: 48 | ir_code = protocol.decode(rlc, protocol.frequency) 49 | except (RepeatLeadInError, RepeatLeadOutError): 50 | if params is not None: 51 | raise 52 | continue 53 | 54 | for key, value in params.items(): 55 | assert getattr(ir_code, key) == value, ( 56 | key, 57 | getattr(ir_code, key), 58 | value 59 | ) 60 | print() 61 | print(ir_code, repr(ir_code)) 62 | 63 | 64 | def test_encode(): 65 | for params in DirecTV5.params: 66 | if params is None: 67 | continue 68 | 69 | ir_code = protocol.encode(**params) 70 | for key, value in params.items(): 71 | assert getattr(ir_code, key) == value, ( 72 | key, 73 | getattr(ir_code, key), 74 | value 75 | ) 76 | 77 | new_ir_code = None 78 | for rlc in ir_code.normalized_rlc: 79 | try: 80 | new_ir_code = protocol.decode(rlc, protocol.frequency) 81 | except (RepeatLeadInError, RepeatLeadOutError): 82 | continue 83 | except IRException: 84 | new_ir_code = protocol.decode( 85 | ir_code.original_rlc, 86 | protocol.frequency 87 | ) 88 | break 89 | 90 | print() 91 | print(ir_code, repr(ir_code)) 92 | print(new_ir_code) 93 | 94 | assert new_ir_code == ir_code 95 | 96 | break 97 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/audiovox.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 500 33 | 34 | 35 | class Audiovox(protocol_base.IrProtocolBase): 36 | """ 37 | IR decoder for the Audiovox protocol. 38 | """ 39 | irp = '{40k,500,lsb}<1,-1|1,-3>(16,-8,D:8,1,-8,F:8,1,-40)*' 40 | frequency = 40000 41 | bit_count = 16 42 | encoding = 'lsb' 43 | 44 | _lead_in = [TIMING * 16, -TIMING * 8] 45 | _lead_out = [TIMING, -TIMING * 40] 46 | _middle_timings = [(TIMING, -TIMING * 8)] 47 | _bursts = [[TIMING, -TIMING], [TIMING, -TIMING * 3]] 48 | 49 | _code_order = [ 50 | ['D', 8], 51 | ['F', 8] 52 | ] 53 | 54 | _parameters = [ 55 | ['D', 0, 7], 56 | ['F', 8, 15], 57 | ] 58 | # [D:0..255,F:0..255] 59 | encode_parameters = [ 60 | ['device', 0, 255], 61 | ['function', 0, 255], 62 | ] 63 | 64 | def encode( 65 | self, 66 | device: int, 67 | function: int, 68 | repeat_count: int = 0 69 | ) -> protocol_base.IRCode: 70 | device = protocol_base.IntegerWrapper( 71 | device, 72 | 8, 73 | self._bursts, 74 | self.encoding 75 | ) 76 | function = protocol_base.IntegerWrapper( 77 | function, 78 | 8, 79 | self._bursts, 80 | self.encoding 81 | ) 82 | packet = self._build_packet( 83 | device.timings, 84 | self._middle_timings[:], 85 | function.timings, 86 | ) 87 | 88 | params = dict( 89 | frequency=self.frequency, 90 | D=device, 91 | F=function, 92 | ) 93 | 94 | code = protocol_base.IRCode( 95 | self, 96 | packet[:] * (repeat_count + 1), 97 | [packet[:]] * (repeat_count + 1), 98 | params, 99 | repeat_count 100 | ) 101 | return code 102 | -------------------------------------------------------------------------------- /test_protocols/test_archer.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | 27 | from pyIRDecoder import ( 28 | RepeatLeadInError, 29 | RepeatLeadOutError, 30 | IRException 31 | ) 32 | from pyIRDecoder import protocols 33 | 34 | protocol = protocols.Archer 35 | 36 | 37 | class Archer(object): 38 | rlc = [[ 39 | 12, -3300, 12, -3300, 12, -4700, 12, -4700, 12, -4700, 12, -9700 40 | ]] 41 | 42 | params = [dict(function=28)] 43 | 44 | 45 | def test_decode(): 46 | for rlc, params in zip(Archer.rlc, Archer.params): 47 | try: 48 | ir_code = protocol.decode(rlc, protocol.frequency) 49 | except (RepeatLeadInError, RepeatLeadOutError): 50 | if params is not None: 51 | raise 52 | continue 53 | 54 | for key, value in params.items(): 55 | assert getattr(ir_code, key) == value, ( 56 | key, 57 | getattr(ir_code, key), 58 | value 59 | ) 60 | print() 61 | print(ir_code, repr(ir_code)) 62 | 63 | 64 | def test_encode(): 65 | for params in Archer.params: 66 | if params is None: 67 | continue 68 | 69 | ir_code = protocol.encode(**params) 70 | for key, value in params.items(): 71 | assert getattr(ir_code, key) == value, ( 72 | key, 73 | getattr(ir_code, key), 74 | value 75 | ) 76 | 77 | new_ir_code = None 78 | for rlc in ir_code.normalized_rlc: 79 | try: 80 | new_ir_code = protocol.decode(rlc, protocol.frequency) 81 | except (RepeatLeadInError, RepeatLeadOutError): 82 | continue 83 | except IRException: 84 | new_ir_code = protocol.decode( 85 | ir_code.original_rlc, 86 | protocol.frequency 87 | ) 88 | break 89 | 90 | print() 91 | print(ir_code, repr(ir_code)) 92 | print(new_ir_code) 93 | 94 | assert new_ir_code == ir_code 95 | 96 | break 97 | -------------------------------------------------------------------------------- /test_protocols/test_grundig1630.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | # Local imports 27 | 28 | from pyIRDecoder import ( 29 | RepeatLeadInError, 30 | RepeatLeadOutError, 31 | IRException 32 | ) 33 | from pyIRDecoder import protocols 34 | 35 | # Local imports 36 | from . import test_grundig16 37 | 38 | protocol = protocols.Grundig1630 39 | 40 | 41 | class Grundig1630(test_grundig16.Grundig16): 42 | pass 43 | 44 | 45 | def test_decode(): 46 | for rlc, params in zip(Grundig1630.rlc, Grundig1630.params): 47 | try: 48 | ir_code = protocol.decode(rlc, protocol.frequency) 49 | except (RepeatLeadInError, RepeatLeadOutError): 50 | if params is not None: 51 | raise 52 | continue 53 | 54 | for key, value in params.items(): 55 | assert getattr(ir_code, key) == value, ( 56 | key, 57 | getattr(ir_code, key), 58 | value 59 | ) 60 | print() 61 | print(ir_code, repr(ir_code)) 62 | 63 | 64 | def test_encode(): 65 | for params in Grundig1630.params: 66 | if params is None: 67 | continue 68 | 69 | ir_code = protocol.encode(**params) 70 | for key, value in params.items(): 71 | assert getattr(ir_code, key) == value, ( 72 | key, 73 | getattr(ir_code, key), 74 | value 75 | ) 76 | 77 | new_ir_code = None 78 | for rlc in ir_code.normalized_rlc: 79 | try: 80 | new_ir_code = protocol.decode(rlc, protocol.frequency) 81 | except (RepeatLeadInError, RepeatLeadOutError): 82 | continue 83 | except IRException: 84 | new_ir_code = protocol.decode( 85 | ir_code.original_rlc, 86 | protocol.frequency 87 | ) 88 | break 89 | 90 | print() 91 | print(ir_code, repr(ir_code)) 92 | print(new_ir_code) 93 | 94 | assert new_ir_code == ir_code 95 | 96 | break 97 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/proton.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 500 33 | 34 | 35 | class Proton(protocol_base.IrProtocolBase): 36 | """ 37 | IR decoder for the Proton protocol. 38 | """ 39 | irp = '{38.5k,500,lsb}<1,-1|1,-3>(16,-8,D:8,1,-8,F:8,1,^63m)*' 40 | frequency = 38500 41 | bit_count = 16 42 | encoding = 'lsb' 43 | 44 | _lead_in = [TIMING * 16, -TIMING * 8] 45 | _lead_out = [TIMING, 63000] 46 | _middle_timings = [(TIMING, -TIMING * 8)] 47 | _bursts = [[TIMING, -TIMING], [TIMING, -TIMING * 3]] 48 | 49 | _code_order = [ 50 | ['D', 8], 51 | ['F', 8], 52 | ] 53 | 54 | _parameters = [ 55 | ['D', 0, 7], 56 | ['F', 8, 15], 57 | ] 58 | # [D:0..255,F:0..255] 59 | encode_parameters = [ 60 | ['device', 0, 255], 61 | ['function', 0, 255], 62 | ] 63 | 64 | def encode( 65 | self, 66 | device: int, 67 | function: int, 68 | repeat_count: int = 0 69 | ) -> protocol_base.IRCode: 70 | 71 | device = protocol_base.IntegerWrapper( 72 | device, 73 | 8, 74 | self._bursts, 75 | self.encoding 76 | ) 77 | function = protocol_base.IntegerWrapper( 78 | function, 79 | 8, 80 | self._bursts, 81 | self.encoding 82 | ) 83 | packet = self._build_packet( 84 | device.timings, 85 | self._middle_timings[0], 86 | function.timings 87 | ) 88 | 89 | params = dict( 90 | frequency=self.frequency, 91 | D=device, 92 | F=function, 93 | ) 94 | 95 | code = protocol_base.IRCode( 96 | self, 97 | packet[:] * (repeat_count + 1), 98 | [packet[:]] * (repeat_count + 1), 99 | params, 100 | repeat_count 101 | ) 102 | 103 | return code 104 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/f32.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # ***************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | TIMING = 422 32 | 33 | 34 | class F32(protocol_base.IrProtocolBase): 35 | """ 36 | IR decoder for the F32 protocol. 37 | """ 38 | irp = '{37.9k,422,msb}<1,-3|3,-1>(D:8,S:8,F:8,E:8,-100m)*' 39 | frequency = 37900 40 | bit_count = 32 41 | encoding = 'msb' 42 | 43 | _lead_in = [] 44 | _lead_out = [-100000] 45 | _middle_timings = [] 46 | _bursts = [[TIMING, -TIMING * 3], [TIMING * 3, -TIMING]] 47 | 48 | _repeat_lead_in = [] 49 | _repeat_lead_out = [] 50 | _repeat_bursts = [] 51 | 52 | _code_order = [ 53 | ['D', 8], 54 | ['S', 8], 55 | ['F', 8], 56 | ['E', 8] 57 | ] 58 | _parameters = [ 59 | ['D', 0, 7], 60 | ['S', 8, 15], 61 | ['F', 16, 23], 62 | ['E', 24, 31] 63 | ] 64 | # [D:0..255,S:0..255,F:0..255,E:0..255] 65 | encode_parameters = [ 66 | ['device', 0, 255], 67 | ['sub_device', 0, 255], 68 | ['function', 0, 255], 69 | ['extended_function', 0, 255] 70 | ] 71 | 72 | def encode( 73 | self, 74 | device: int, 75 | sub_device: int, 76 | function: int, 77 | extended_function: int, 78 | repeat_count: int = 0 79 | ) -> protocol_base.IRCode: 80 | packet = self._build_packet( 81 | D=device, 82 | S=sub_device, 83 | F=function, 84 | E=extended_function, 85 | ) 86 | 87 | params = dict( 88 | frequency=self.frequency, 89 | D=device, 90 | S=sub_device, 91 | F=function, 92 | E=extended_function 93 | ) 94 | 95 | code = protocol_base.IRCode( 96 | self, 97 | packet[:] * (repeat_count + 1), 98 | [packet[:]] * (repeat_count + 1), 99 | params, 100 | repeat_count 101 | ) 102 | 103 | return code 104 | -------------------------------------------------------------------------------- /test_protocols/test_gwts.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | 27 | from pyIRDecoder import ( 28 | RepeatLeadInError, 29 | RepeatLeadOutError, 30 | IRException 31 | ) 32 | from pyIRDecoder import protocols 33 | 34 | protocol = protocols.GwtS 35 | 36 | 37 | class GwtS(object): 38 | rlc = [[ 39 | 417, -2085, 834, -834, 1251, -417, 2085, -417, 417, -417, 2085, 40 | -1251 41 | ]] 42 | 43 | params = [dict(device=159, function=4, crc=193)] 44 | 45 | 46 | def test_decode(): 47 | for rlc, params in zip(GwtS.rlc, GwtS.params): 48 | try: 49 | ir_code = protocol.decode(rlc, protocol.frequency) 50 | except (RepeatLeadInError, RepeatLeadOutError): 51 | if params is not None: 52 | raise 53 | continue 54 | 55 | for key, value in params.items(): 56 | assert getattr(ir_code, key) == value, ( 57 | key, 58 | getattr(ir_code, key), 59 | value 60 | ) 61 | print() 62 | print(ir_code, repr(ir_code)) 63 | 64 | 65 | def test_encode(): 66 | for params in GwtS.params: 67 | if params is None: 68 | continue 69 | 70 | ir_code = protocol.encode(**params) 71 | for key, value in params.items(): 72 | assert getattr(ir_code, key) == value, ( 73 | key, 74 | getattr(ir_code, key), 75 | value 76 | ) 77 | 78 | new_ir_code = None 79 | for rlc in ir_code.normalized_rlc: 80 | try: 81 | new_ir_code = protocol.decode(rlc, protocol.frequency) 82 | except (RepeatLeadInError, RepeatLeadOutError): 83 | continue 84 | except IRException: 85 | new_ir_code = protocol.decode( 86 | ir_code.original_rlc, 87 | protocol.frequency 88 | ) 89 | break 90 | 91 | print() 92 | print(ir_code, repr(ir_code)) 93 | print(new_ir_code) 94 | 95 | assert new_ir_code == ir_code 96 | 97 | break 98 | -------------------------------------------------------------------------------- /test_protocols/test_lutron.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | 27 | from pyIRDecoder import ( 28 | RepeatLeadInError, 29 | RepeatLeadOutError, 30 | IRException 31 | ) 32 | from pyIRDecoder import protocols 33 | 34 | protocol = protocols.Lutron 35 | 36 | 37 | class Lutron(object): 38 | rlc = [[ 39 | 23000, -6900, 2300, -9200, 4600, -4600, 2300, -2300, 4600, -4600, 40 | 2300, -16100, 41 | ]] 42 | 43 | params = [dict(x=12858056)] 44 | 45 | 46 | def test_decode(): 47 | for rlc, params in zip(Lutron.rlc, Lutron.params): 48 | try: 49 | ir_code = protocol.decode(rlc, protocol.frequency) 50 | except (RepeatLeadInError, RepeatLeadOutError): 51 | if params is not None: 52 | raise 53 | continue 54 | 55 | for key, value in params.items(): 56 | assert getattr(ir_code, key) == value, ( 57 | key, 58 | getattr(ir_code, key), 59 | value 60 | ) 61 | print() 62 | print(ir_code, repr(ir_code)) 63 | 64 | 65 | def test_encode(): 66 | for params in Lutron.params: 67 | if params is None: 68 | continue 69 | 70 | ir_code = protocol.encode(**params) 71 | for key, value in params.items(): 72 | assert getattr(ir_code, key) == value, ( 73 | key, 74 | getattr(ir_code, key), 75 | value 76 | ) 77 | 78 | new_ir_code = None 79 | for rlc in ir_code.normalized_rlc: 80 | try: 81 | new_ir_code = protocol.decode(rlc, protocol.frequency) 82 | except (RepeatLeadInError, RepeatLeadOutError): 83 | continue 84 | except IRException: 85 | new_ir_code = protocol.decode( 86 | ir_code.original_rlc, 87 | protocol.frequency 88 | ) 89 | break 90 | 91 | print() 92 | print(ir_code, repr(ir_code)) 93 | print(new_ir_code) 94 | 95 | assert new_ir_code == ir_code 96 | 97 | break 98 | -------------------------------------------------------------------------------- /test_protocols/test_jerrold.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | 27 | from pyIRDecoder import ( 28 | RepeatLeadInError, 29 | RepeatLeadOutError, 30 | IRException 31 | ) 32 | from pyIRDecoder import protocols 33 | 34 | protocol = protocols.Jerrold 35 | 36 | 37 | class Jerrold(object): 38 | rlc = [[ 39 | 44, -11500, 44, -7500, 44, -7500, 44, -11500, 44, -11500, 44, 40 | -23500 41 | ]] 42 | 43 | params = [dict(function=25)] 44 | 45 | 46 | def test_decode(): 47 | for rlc, params in zip(Jerrold.rlc, Jerrold.params): 48 | try: 49 | ir_code = protocol.decode(rlc, protocol.frequency) 50 | except (RepeatLeadInError, RepeatLeadOutError): 51 | if params is not None: 52 | raise 53 | continue 54 | 55 | for key, value in params.items(): 56 | assert getattr(ir_code, key) == value, ( 57 | key, 58 | getattr(ir_code, key), 59 | value 60 | ) 61 | print() 62 | print(ir_code, repr(ir_code)) 63 | 64 | 65 | def test_encode(): 66 | for params in Jerrold.params: 67 | if params is None: 68 | continue 69 | 70 | ir_code = protocol.encode(**params) 71 | for key, value in params.items(): 72 | assert getattr(ir_code, key) == value, ( 73 | key, 74 | getattr(ir_code, key), 75 | value 76 | ) 77 | 78 | new_ir_code = None 79 | for rlc in ir_code.normalized_rlc: 80 | try: 81 | new_ir_code = protocol.decode(rlc, protocol.frequency) 82 | except (RepeatLeadInError, RepeatLeadOutError): 83 | continue 84 | except IRException: 85 | new_ir_code = protocol.decode( 86 | ir_code.original_rlc, 87 | protocol.frequency 88 | ) 89 | break 90 | 91 | print() 92 | print(ir_code, repr(ir_code)) 93 | print(new_ir_code) 94 | 95 | assert new_ir_code == ir_code 96 | 97 | break 98 | -------------------------------------------------------------------------------- /test_protocols/test_pctv.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | 27 | from pyIRDecoder import ( 28 | RepeatLeadInError, 29 | RepeatLeadOutError, 30 | IRException 31 | ) 32 | from pyIRDecoder import protocols 33 | 34 | protocol = protocols.PCTV 35 | 36 | 37 | class PCTV(object): 38 | rlc = [[ 39 | 1664, -6656, 832, -832, 2496, -832, 3328, -1664, 3328, -832, 1664, 40 | -100000, 41 | ]] 42 | 43 | params = [dict(device=238, function=121)] 44 | 45 | 46 | def test_decode(): 47 | for rlc, params in zip(PCTV.rlc, PCTV.params): 48 | try: 49 | ir_code = protocol.decode(rlc, protocol.frequency) 50 | except (RepeatLeadInError, RepeatLeadOutError): 51 | if params is not None: 52 | raise 53 | continue 54 | 55 | for key, value in params.items(): 56 | assert getattr(ir_code, key) == value, ( 57 | key, 58 | getattr(ir_code, key), 59 | value 60 | ) 61 | print() 62 | print(ir_code, repr(ir_code)) 63 | 64 | 65 | def test_encode(): 66 | for params in PCTV.params: 67 | if params is None: 68 | continue 69 | 70 | ir_code = protocol.encode(**params) 71 | for key, value in params.items(): 72 | assert getattr(ir_code, key) == value, ( 73 | key, 74 | getattr(ir_code, key), 75 | value 76 | ) 77 | 78 | new_ir_code = None 79 | for rlc in ir_code.normalized_rlc: 80 | try: 81 | new_ir_code = protocol.decode(rlc, protocol.frequency) 82 | except (RepeatLeadInError, RepeatLeadOutError): 83 | continue 84 | except IRException: 85 | new_ir_code = protocol.decode( 86 | ir_code.original_rlc, 87 | protocol.frequency 88 | ) 89 | break 90 | 91 | print() 92 | print(ir_code, repr(ir_code)) 93 | print(new_ir_code) 94 | 95 | assert new_ir_code == ir_code 96 | 97 | break 98 | -------------------------------------------------------------------------------- /test_protocols/test_akai.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | 27 | from pyIRDecoder import RepeatLeadInError, RepeatLeadOutError, IRException 28 | from pyIRDecoder import protocols 29 | 30 | protocol = protocols.Akai 31 | 32 | 33 | class Akai(object): 34 | rlc = [[ 35 | 289, -1821, 289, -751, 289, -751, 289, -751, 289, -1821, 289, 36 | -751, 289, -751, 289, -751, 289, -751, 289, -1821, 289, -11399 37 | ]] 38 | 39 | params = [dict(device=1, function=66)] 40 | 41 | 42 | def test_decode(): 43 | for rlc, params in zip(Akai.rlc, Akai.params): 44 | try: 45 | ir_code = protocol.decode(rlc, protocol.frequency) 46 | except (RepeatLeadInError, RepeatLeadOutError): 47 | if params is not None: 48 | raise 49 | continue 50 | 51 | for key, value in params.items(): 52 | assert getattr(ir_code, key) == value, ( 53 | key, 54 | getattr(ir_code, key), 55 | value 56 | ) 57 | print() 58 | print(ir_code, repr(ir_code)) 59 | 60 | 61 | def test_encode(): 62 | for params in Akai.params: 63 | if params is None: 64 | continue 65 | 66 | ir_code = protocol.encode(**params) 67 | for key, value in params.items(): 68 | assert getattr(ir_code, key) == value, ( 69 | key, 70 | getattr(ir_code, key), 71 | value 72 | ) 73 | 74 | new_ir_code = None 75 | for rlc in ir_code.normalized_rlc: 76 | try: 77 | new_ir_code = protocol.decode(rlc, protocol.frequency) 78 | except (RepeatLeadInError, RepeatLeadOutError): 79 | continue 80 | except IRException: 81 | new_ir_code = protocol.decode( 82 | ir_code.original_rlc, 83 | protocol.frequency 84 | ) 85 | break 86 | 87 | print() 88 | print(ir_code, repr(ir_code)) 89 | print(new_ir_code) 90 | 91 | assert new_ir_code == ir_code 92 | 93 | break 94 | -------------------------------------------------------------------------------- /test_protocols/test_pid0004.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | 27 | from pyIRDecoder import ( 28 | RepeatLeadInError, 29 | RepeatLeadOutError, 30 | IRException 31 | ) 32 | from pyIRDecoder import protocols 33 | 34 | protocol = protocols.PID0004 35 | 36 | 37 | class PID0004(object): 38 | rlc = [[ 39 | 12, -130, 12, -372, 12, -130, 12, -372, 12, -372, 12, -130, 12, 40 | -27000, 41 | ]] 42 | 43 | params = [dict(function=22)] 44 | 45 | 46 | def test_decode(): 47 | for rlc, params in zip(PID0004.rlc, PID0004.params): 48 | try: 49 | ir_code = protocol.decode(rlc, protocol.frequency) 50 | except (RepeatLeadInError, RepeatLeadOutError): 51 | if params is not None: 52 | raise 53 | continue 54 | 55 | for key, value in params.items(): 56 | assert getattr(ir_code, key) == value, ( 57 | key, 58 | getattr(ir_code, key), 59 | value 60 | ) 61 | print() 62 | print(ir_code, repr(ir_code)) 63 | 64 | 65 | def test_encode(): 66 | for params in PID0004.params: 67 | if params is None: 68 | continue 69 | 70 | ir_code = protocol.encode(**params) 71 | for key, value in params.items(): 72 | assert getattr(ir_code, key) == value, ( 73 | key, 74 | getattr(ir_code, key), 75 | value 76 | ) 77 | 78 | new_ir_code = None 79 | for rlc in ir_code.normalized_rlc: 80 | try: 81 | new_ir_code = protocol.decode(rlc, protocol.frequency) 82 | except (RepeatLeadInError, RepeatLeadOutError): 83 | continue 84 | except IRException: 85 | new_ir_code = protocol.decode( 86 | ir_code.original_rlc, 87 | protocol.frequency 88 | ) 89 | break 90 | 91 | print() 92 | print(ir_code, repr(ir_code)) 93 | print(new_ir_code) 94 | 95 | assert new_ir_code == ir_code 96 | 97 | break 98 | -------------------------------------------------------------------------------- /test_protocols/test_pid0001.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | 27 | from pyIRDecoder import ( 28 | RepeatLeadInError, 29 | RepeatLeadOutError, 30 | IRException 31 | ) 32 | from pyIRDecoder import protocols 33 | 34 | protocol = protocols.PID0001 35 | 36 | 37 | class PID0001(object): 38 | rlc = [[ 39 | 24, -21148, 24, -13486, 24, -9314, 24, -13486, 24, -13486, 24, 40 | -9314, 1, -28000, 41 | ]] 42 | 43 | params = [dict(function=22)] 44 | 45 | 46 | def test_decode(): 47 | for rlc, params in zip(PID0001.rlc, PID0001.params): 48 | try: 49 | ir_code = protocol.decode(rlc, protocol.frequency) 50 | except (RepeatLeadInError, RepeatLeadOutError): 51 | if params is not None: 52 | raise 53 | continue 54 | 55 | for key, value in params.items(): 56 | assert getattr(ir_code, key) == value, ( 57 | key, 58 | getattr(ir_code, key), 59 | value 60 | ) 61 | print() 62 | print(ir_code, repr(ir_code)) 63 | 64 | 65 | def test_encode(): 66 | for params in PID0001.params: 67 | if params is None: 68 | continue 69 | 70 | ir_code = protocol.encode(**params) 71 | for key, value in params.items(): 72 | assert getattr(ir_code, key) == value, ( 73 | key, 74 | getattr(ir_code, key), 75 | value 76 | ) 77 | 78 | new_ir_code = None 79 | for rlc in ir_code.normalized_rlc: 80 | try: 81 | new_ir_code = protocol.decode(rlc, protocol.frequency) 82 | except (RepeatLeadInError, RepeatLeadOutError): 83 | continue 84 | except IRException: 85 | new_ir_code = protocol.decode( 86 | ir_code.original_rlc, 87 | protocol.frequency 88 | ) 89 | break 90 | 91 | print() 92 | print(ir_code, repr(ir_code)) 93 | print(new_ir_code) 94 | 95 | assert new_ir_code == ir_code 96 | 97 | break 98 | -------------------------------------------------------------------------------- /test_protocols/test_rcmm12.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | 27 | from pyIRDecoder import ( 28 | RepeatLeadInError, 29 | RepeatLeadOutError, 30 | IRException 31 | ) 32 | from pyIRDecoder import protocols 33 | 34 | protocol = protocols.RCMM12 35 | 36 | 37 | class RCMM12(object): 38 | rlc = [[ 39 | 431, -287, 172, -460, 172, -460, 172, -460, 172, -460, 172, -460, 40 | 172, -460 41 | ]] 42 | 43 | params = [dict(mode=1, address=1, function=85)] 44 | 45 | 46 | def test_decode(): 47 | for rlc, params in zip(RCMM12.rlc, RCMM12.params): 48 | try: 49 | ir_code = protocol.decode(rlc, protocol.frequency) 50 | except (RepeatLeadInError, RepeatLeadOutError): 51 | if params is not None: 52 | raise 53 | continue 54 | 55 | for key, value in params.items(): 56 | assert getattr(ir_code, key) == value, ( 57 | key, 58 | getattr(ir_code, key), 59 | value 60 | ) 61 | print() 62 | print(ir_code, repr(ir_code)) 63 | 64 | 65 | def test_encode(): 66 | for params in RCMM12.params: 67 | if params is None: 68 | continue 69 | 70 | ir_code = protocol.encode(**params) 71 | for key, value in params.items(): 72 | assert getattr(ir_code, key) == value, ( 73 | key, 74 | getattr(ir_code, key), 75 | value 76 | ) 77 | 78 | new_ir_code = None 79 | for rlc in ir_code.normalized_rlc: 80 | try: 81 | new_ir_code = protocol.decode(rlc, protocol.frequency) 82 | except (RepeatLeadInError, RepeatLeadOutError): 83 | continue 84 | except IRException: 85 | new_ir_code = protocol.decode( 86 | ir_code.original_rlc, 87 | protocol.frequency 88 | ) 89 | break 90 | 91 | print() 92 | print(ir_code, repr(ir_code)) 93 | print(new_ir_code) 94 | 95 | assert new_ir_code == ir_code 96 | 97 | break 98 | -------------------------------------------------------------------------------- /test_protocols/test_sony8.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | 27 | from pyIRDecoder import ( 28 | RepeatLeadInError, 29 | RepeatLeadOutError, 30 | IRException 31 | ) 32 | from pyIRDecoder import protocols 33 | 34 | protocol = protocols.Sony8 35 | 36 | 37 | class Sony8(object): 38 | rlc = [[ 39 | 2400, -600, 1200, -600, 600, -600, 600, -600, 1200, -600, 600, 40 | -600, 600, -600, 1200, -600, 600, -31200, 41 | ]] 42 | 43 | params = [dict(function=73)] 44 | 45 | 46 | def test_decode(): 47 | for rlc, params in zip(Sony8.rlc, Sony8.params): 48 | try: 49 | ir_code = protocol.decode(rlc, protocol.frequency) 50 | except (RepeatLeadInError, RepeatLeadOutError): 51 | if params is not None: 52 | raise 53 | continue 54 | 55 | for key, value in params.items(): 56 | assert getattr(ir_code, key) == value, ( 57 | key, 58 | getattr(ir_code, key), 59 | value 60 | ) 61 | print() 62 | print(ir_code, repr(ir_code)) 63 | 64 | 65 | def test_encode(): 66 | for params in Sony8.params: 67 | if params is None: 68 | continue 69 | 70 | ir_code = protocol.encode(**params) 71 | for key, value in params.items(): 72 | assert getattr(ir_code, key) == value, ( 73 | key, 74 | getattr(ir_code, key), 75 | value 76 | ) 77 | 78 | new_ir_code = None 79 | for rlc in ir_code.normalized_rlc: 80 | try: 81 | new_ir_code = protocol.decode(rlc, protocol.frequency) 82 | except (RepeatLeadInError, RepeatLeadOutError): 83 | continue 84 | except IRException: 85 | new_ir_code = protocol.decode( 86 | ir_code.original_rlc, 87 | protocol.frequency 88 | ) 89 | break 90 | 91 | print() 92 | print(ir_code, repr(ir_code)) 93 | print(new_ir_code) 94 | 95 | assert new_ir_code == ir_code 96 | 97 | break 98 | -------------------------------------------------------------------------------- /test_protocols/test_viewstar.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | 27 | from pyIRDecoder import ( 28 | RepeatLeadInError, 29 | RepeatLeadOutError, 30 | IRException 31 | ) 32 | from pyIRDecoder import protocols 33 | 34 | protocol = protocols.Viewstar 35 | 36 | 37 | class Viewstar(object): 38 | rlc = [[ 39 | +337, -2696, +337, -2696, +337, -2696, +337, -1685, +337, -2696, +337, 40 | -5729 41 | ]] 42 | 43 | params = [dict(function=23)] 44 | 45 | 46 | def test_decode(): 47 | for rlc, params in zip(Viewstar.rlc, Viewstar.params): 48 | try: 49 | ir_code = protocol.decode(rlc, protocol.frequency) 50 | except (RepeatLeadInError, RepeatLeadOutError): 51 | if params is not None: 52 | raise 53 | continue 54 | 55 | for key, value in params.items(): 56 | assert getattr(ir_code, key) == value, ( 57 | key, 58 | getattr(ir_code, key), 59 | value 60 | ) 61 | print() 62 | print(ir_code, repr(ir_code)) 63 | 64 | 65 | def test_encode(): 66 | for params in Viewstar.params: 67 | if params is None: 68 | continue 69 | 70 | ir_code = protocol.encode(**params) 71 | for key, value in params.items(): 72 | assert getattr(ir_code, key) == value, ( 73 | key, 74 | getattr(ir_code, key), 75 | value 76 | ) 77 | 78 | new_ir_code = None 79 | for rlc in ir_code.normalized_rlc: 80 | try: 81 | new_ir_code = protocol.decode(rlc, protocol.frequency) 82 | except (RepeatLeadInError, RepeatLeadOutError): 83 | continue 84 | except IRException: 85 | new_ir_code = protocol.decode( 86 | ir_code.original_rlc, 87 | protocol.frequency 88 | ) 89 | break 90 | 91 | print() 92 | print(ir_code, repr(ir_code)) 93 | print(new_ir_code) 94 | 95 | assert new_ir_code == ir_code 96 | 97 | break 98 | -------------------------------------------------------------------------------- /test_protocols/test_nokia12.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | 27 | from pyIRDecoder import ( 28 | RepeatLeadInError, 29 | RepeatLeadOutError, 30 | IRException 31 | ) 32 | from pyIRDecoder import protocols 33 | 34 | protocol = protocols.Nokia12 35 | 36 | 37 | class Nokia12(object): 38 | rlc = [[ 39 | 417, -278, 167, -611, 167, -778, 167, -444, 167, -778, 167, -611, 40 | 167, -611, 167, -94306 41 | ]] 42 | params = [dict(device=11, function=122)] 43 | 44 | 45 | def test_decode(): 46 | for rlc, params in zip(Nokia12.rlc, Nokia12.params): 47 | try: 48 | ir_code = protocol.decode(rlc, protocol.frequency) 49 | except (RepeatLeadInError, RepeatLeadOutError): 50 | if params is not None: 51 | raise 52 | continue 53 | 54 | for key, value in params.items(): 55 | assert getattr(ir_code, key) == value, ( 56 | key, 57 | getattr(ir_code, key), 58 | value 59 | ) 60 | print() 61 | print(ir_code, repr(ir_code)) 62 | 63 | 64 | def test_encode(): 65 | for params in Nokia12.params: 66 | if params is None: 67 | continue 68 | 69 | ir_code = protocol.encode(**params) 70 | for key, value in params.items(): 71 | assert getattr(ir_code, key) == value, ( 72 | key, 73 | getattr(ir_code, key), 74 | value 75 | ) 76 | 77 | new_ir_code = None 78 | for rlc in ir_code.normalized_rlc: 79 | try: 80 | new_ir_code = protocol.decode(rlc, protocol.frequency) 81 | except (RepeatLeadInError, RepeatLeadOutError): 82 | continue 83 | except IRException: 84 | new_ir_code = protocol.decode( 85 | ir_code.original_rlc, 86 | protocol.frequency 87 | ) 88 | break 89 | 90 | print() 91 | print(ir_code, repr(ir_code)) 92 | print(new_ir_code) 93 | 94 | assert new_ir_code == ir_code 95 | 96 | break 97 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/jvc.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # ***************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 527 33 | 34 | 35 | class JVC(protocol_base.IrProtocolBase): 36 | """ 37 | IR decoder for the JVC protocol. 38 | """ 39 | irp = ( 40 | '{37.9k,527,lsb}<1,-1|1,-3>' 41 | '(16,-8,D:8,F:8,1,^59.08m,(D:8,F:8,1,^46.42m)*)' 42 | ) 43 | frequency = 37900 44 | bit_count = 16 45 | encoding = 'lsb' 46 | 47 | _lead_in = [TIMING * 16, -TIMING * 8] 48 | _lead_out = [TIMING, 59080] 49 | _middle_timings = [] 50 | _bursts = [[TIMING, -TIMING], [TIMING, -TIMING * 3]] 51 | 52 | _repeat_lead_in = [] 53 | _repeat_lead_out = [TIMING, 46420] 54 | _repeat_bursts = [[TIMING, -TIMING], [TIMING, -TIMING * 3]] 55 | 56 | _code_order = [ 57 | ['D', 8], 58 | ['F', 8], 59 | ] 60 | 61 | _parameters = [ 62 | ['D', 0, 7], 63 | ['F', 8, 15], 64 | ] 65 | # [D:0..255,F:0..255] 66 | encode_parameters = [ 67 | ['device', 0, 255], 68 | ['function', 0, 255] 69 | ] 70 | 71 | def encode( 72 | self, 73 | device: int, 74 | function: int, 75 | repeat_count: int = 0 76 | ) -> protocol_base.IRCode: 77 | lead_in = self._lead_in[:] 78 | lead_out = self._lead_out[:] 79 | params = dict( 80 | D=device, 81 | F=function, 82 | ) 83 | 84 | packet = self._build_packet(**params) 85 | 86 | del self._lead_in[:] 87 | self._lead_out = self._repeat_lead_out[:] 88 | 89 | repeat = self._build_packet(**params) 90 | 91 | self._lead_in = lead_in[:] 92 | self._lead_out = lead_out[:] 93 | 94 | params['frequency'] = self.frequency 95 | 96 | code = protocol_base.IRCode( 97 | self, 98 | packet[:] + (repeat[:] * repeat_count), 99 | [packet[:]] + ([repeat[:]] * repeat_count), 100 | params, 101 | repeat_count 102 | ) 103 | 104 | return code 105 | -------------------------------------------------------------------------------- /test_protocols/test_ad_notham.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | 27 | from pyIRDecoder import RepeatLeadInError, RepeatLeadOutError, IRException 28 | from pyIRDecoder import protocols 29 | 30 | protocol = protocols.AdNotham 31 | 32 | 33 | class AdNotham(object): 34 | rlc = [[ 35 | 895, -1790, 1790, -895, 895, -895, 895, -1790, 895, -895, 895, 36 | -895, 1790, -1790, 895, -895, 1790, -1790, 1790, -89835 37 | ]] 38 | 39 | params = [dict(device=7, function=26)] 40 | 41 | 42 | def test_decode(): 43 | for rlc, params in zip(AdNotham.rlc, AdNotham.params): 44 | try: 45 | ir_code = protocol.decode(rlc, protocol.frequency) 46 | except (RepeatLeadInError, RepeatLeadOutError): 47 | if params is not None: 48 | raise 49 | continue 50 | 51 | for key, value in params.items(): 52 | assert getattr(ir_code, key) == value, ( 53 | key, 54 | getattr(ir_code, key), 55 | value 56 | ) 57 | print() 58 | print(ir_code, repr(ir_code)) 59 | 60 | 61 | def test_encode(): 62 | for params in AdNotham.params: 63 | if params is None: 64 | continue 65 | 66 | ir_code = protocol.encode(**params) 67 | for key, value in params.items(): 68 | assert getattr(ir_code, key) == value, ( 69 | key, 70 | getattr(ir_code, key), 71 | value 72 | ) 73 | 74 | new_ir_code = None 75 | for rlc in ir_code.normalized_rlc: 76 | try: 77 | new_ir_code = protocol.decode(rlc, protocol.frequency) 78 | except (RepeatLeadInError, RepeatLeadOutError): 79 | continue 80 | except IRException: 81 | new_ir_code = protocol.decode( 82 | ir_code.original_rlc, 83 | protocol.frequency 84 | ) 85 | break 86 | 87 | print() 88 | print(ir_code, repr(ir_code)) 89 | print(new_ir_code) 90 | 91 | assert new_ir_code == ir_code 92 | 93 | break 94 | -------------------------------------------------------------------------------- /test_protocols/test_motorola.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | 27 | from pyIRDecoder import ( 28 | RepeatLeadInError, 29 | RepeatLeadOutError, 30 | IRException 31 | ) 32 | from pyIRDecoder import protocols 33 | 34 | protocol = protocols.Motorola 35 | 36 | 37 | class Motorola(object): 38 | rlc = [[ 39 | 512, -2560, 512, -512, 512, -1024, 1024, -512, 512, -1024, 1024, 40 | -1024, 512, -512, 1024, -1000 41 | ]] 42 | params = [dict(function=45, device=2)] 43 | 44 | 45 | def test_decode(): 46 | for rlc, params in zip(Motorola.rlc, Motorola.params): 47 | try: 48 | ir_code = protocol.decode(rlc, protocol.frequency) 49 | except (RepeatLeadInError, RepeatLeadOutError): 50 | if params is not None: 51 | raise 52 | continue 53 | 54 | for key, value in params.items(): 55 | assert getattr(ir_code, key) == value, ( 56 | key, 57 | getattr(ir_code, key), 58 | value 59 | ) 60 | print() 61 | print(ir_code, repr(ir_code)) 62 | 63 | 64 | def test_encode(): 65 | for params in Motorola.params: 66 | if params is None: 67 | continue 68 | 69 | ir_code = protocol.encode(**params) 70 | for key, value in params.items(): 71 | assert getattr(ir_code, key) == value, ( 72 | key, 73 | getattr(ir_code, key), 74 | value 75 | ) 76 | 77 | new_ir_code = None 78 | for rlc in ir_code.normalized_rlc: 79 | try: 80 | new_ir_code = protocol.decode(rlc, protocol.frequency) 81 | except (RepeatLeadInError, RepeatLeadOutError): 82 | continue 83 | except IRException: 84 | new_ir_code = protocol.decode( 85 | ir_code.original_rlc, 86 | protocol.frequency 87 | ) 88 | break 89 | 90 | print() 91 | print(ir_code, repr(ir_code)) 92 | print(new_ir_code) 93 | 94 | assert new_ir_code == ir_code 95 | 96 | break 97 | -------------------------------------------------------------------------------- /test_protocols/test_somfy.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | 27 | from pyIRDecoder import ( 28 | RepeatLeadInError, 29 | RepeatLeadOutError, 30 | IRException 31 | ) 32 | from pyIRDecoder import protocols 33 | 34 | protocol = protocols.Somfy 35 | 36 | 37 | class Somfy(object): 38 | rlc = [[ 39 | 2072, -484, 669, -520, 669, -520, 308, -881, 669, -520, 308, -881, 40 | 669, -520, 308, -881, 308, -881, 308, -3181, 41 | ]] 42 | 43 | params = [dict(device=2, function=3)] 44 | 45 | 46 | def test_decode(): 47 | for rlc, params in zip(Somfy.rlc, Somfy.params): 48 | try: 49 | ir_code = protocol.decode(rlc, protocol.frequency) 50 | except (RepeatLeadInError, RepeatLeadOutError): 51 | if params is not None: 52 | raise 53 | continue 54 | 55 | for key, value in params.items(): 56 | assert getattr(ir_code, key) == value, ( 57 | key, 58 | getattr(ir_code, key), 59 | value 60 | ) 61 | print() 62 | print(ir_code, repr(ir_code)) 63 | 64 | 65 | def test_encode(): 66 | for params in Somfy.params: 67 | if params is None: 68 | continue 69 | 70 | ir_code = protocol.encode(**params) 71 | for key, value in params.items(): 72 | assert getattr(ir_code, key) == value, ( 73 | key, 74 | getattr(ir_code, key), 75 | value 76 | ) 77 | 78 | new_ir_code = None 79 | for rlc in ir_code.normalized_rlc: 80 | try: 81 | new_ir_code = protocol.decode(rlc, protocol.frequency) 82 | except (RepeatLeadInError, RepeatLeadOutError): 83 | continue 84 | except IRException: 85 | new_ir_code = protocol.decode( 86 | ir_code.original_rlc, 87 | protocol.frequency 88 | ) 89 | break 90 | 91 | print() 92 | print(ir_code, repr(ir_code)) 93 | print(new_ir_code) 94 | 95 | assert new_ir_code == ir_code 96 | 97 | break 98 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/elunevision.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | from . import DecodeError 31 | 32 | 33 | TIMING = 358 34 | 35 | 36 | class Elunevision(protocol_base.IrProtocolBase): 37 | """ 38 | IR decoder for the Elunevision protocol. 39 | """ 40 | irp = '{0k,358,msb}<1,-3|3,-1>(10,-3,D:24,F:8,-7)*{D=0xf48080}' 41 | frequency = 0 42 | bit_count = 32 43 | encoding = 'msb' 44 | 45 | _lead_in = [TIMING * 10, -TIMING * 3] 46 | _lead_out = [-TIMING * 7] 47 | _middle_timings = [] 48 | _bursts = [[TIMING, -TIMING * 3], [TIMING * 3, -TIMING]] 49 | 50 | _repeat_lead_in = [] 51 | _repeat_lead_out = [] 52 | _repeat_bursts = [] 53 | 54 | _code_order = [ 55 | ['F', 8] 56 | ] 57 | 58 | _parameters = [ 59 | ['D', 0, 23], 60 | ['F', 24, 31], 61 | ] 62 | # [F:0..255] 63 | encode_parameters = [ 64 | ['function', 0, 255], 65 | ] 66 | 67 | def decode(self, data: list, frequency: int = 0) -> protocol_base.IRCode: 68 | code = protocol_base.IrProtocolBase.decode(self, data, frequency) 69 | 70 | if code.device != 0xF48080: 71 | raise DecodeError('Incorrect device') 72 | 73 | if self._last_code is not None: 74 | if self._last_code == code: 75 | return self._last_code 76 | 77 | self._last_code.repeat_timer.stop() 78 | self._last_code = None 79 | 80 | self._last_code = code 81 | return code 82 | 83 | def encode(self, function, repeat_count=0): 84 | packet = self._build_packet( 85 | D=0xF48080, 86 | F=function, 87 | ) 88 | 89 | params = dict( 90 | frequency=self.frequency, 91 | F=function, 92 | ) 93 | 94 | code = protocol_base.IRCode( 95 | self, 96 | packet[:] * (repeat_count + 1), 97 | [packet[:]] * (repeat_count + 1), 98 | params, 99 | repeat_count 100 | ) 101 | return code 102 | -------------------------------------------------------------------------------- /test_protocols/test_x10_8.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | 27 | from pyIRDecoder import ( 28 | RepeatLeadInError, 29 | RepeatLeadOutError, 30 | IRException 31 | ) 32 | from pyIRDecoder import protocols 33 | 34 | protocol = protocols.X10_8 35 | 36 | 37 | class X10_8(object): 38 | rlc = [[ 39 | +3990, -3990, +1140, -6840, +1140, -6840, +1140, -6840, +3990, -3990, 40 | +3990, -3990, +3990, -3990, +3990, -3990, +1140, -6840, +11970, -3990 41 | ]] 42 | 43 | params = [dict(function=8)] 44 | 45 | 46 | def test_decode(): 47 | for rlc, params in zip(X10_8.rlc, X10_8.params): 48 | try: 49 | ir_code = protocol.decode(rlc, protocol.frequency) 50 | except (RepeatLeadInError, RepeatLeadOutError): 51 | if params is not None: 52 | raise 53 | continue 54 | 55 | for key, value in params.items(): 56 | assert getattr(ir_code, key) == value, ( 57 | key, 58 | getattr(ir_code, key), 59 | value 60 | ) 61 | print() 62 | print(ir_code, repr(ir_code)) 63 | 64 | 65 | def test_encode(): 66 | for params in X10_8.params: 67 | if params is None: 68 | continue 69 | 70 | ir_code = protocol.encode(**params) 71 | for key, value in params.items(): 72 | assert getattr(ir_code, key) == value, ( 73 | key, 74 | getattr(ir_code, key), 75 | value 76 | ) 77 | 78 | new_ir_code = None 79 | for rlc in ir_code.normalized_rlc: 80 | try: 81 | new_ir_code = protocol.decode(rlc, protocol.frequency) 82 | except (RepeatLeadInError, RepeatLeadOutError): 83 | continue 84 | except IRException: 85 | new_ir_code = protocol.decode( 86 | ir_code.original_rlc, 87 | protocol.frequency 88 | ) 89 | break 90 | 91 | print() 92 | print(ir_code, repr(ir_code)) 93 | print(new_ir_code) 94 | 95 | assert new_ir_code == ir_code 96 | 97 | break 98 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/viewstar.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | 31 | 32 | TIMING = 337 33 | 34 | 35 | class Viewstar(protocol_base.IrProtocolBase): 36 | """ 37 | IR decoder for the Viewstar protocol. 38 | """ 39 | irp = '{50.5k,337,lsb}<1,-8|1,-5>(~F:5,1,-17)*' 40 | frequency = 50500 41 | bit_count = 5 42 | encoding = 'lsb' 43 | 44 | _lead_in = [] 45 | _lead_out = [TIMING, -TIMING * 17] 46 | _middle_timings = [] 47 | _bursts = [[TIMING, -TIMING * 8], [TIMING, -TIMING * 5]] 48 | 49 | _code_order = [ 50 | ['F', 5], 51 | ] 52 | 53 | _parameters = [ 54 | ['F', 0, 4] 55 | ] 56 | # [F:0..31] 57 | encode_parameters = [ 58 | ['function', 0, 31], 59 | ] 60 | 61 | def decode(self, data: list, frequency: int = 0) -> protocol_base.IRCode: 62 | code = protocol_base.IrProtocolBase.decode(self, data, frequency) 63 | 64 | # noinspection PyProtectedMember 65 | code._data['F'] = code.function[True:5:0] 66 | 67 | if self._last_code is not None: 68 | if self._last_code == code: 69 | return self._last_code 70 | 71 | self._last_code.repeat_timer.stop() 72 | 73 | self._last_code = code 74 | return code 75 | 76 | def encode( 77 | self, 78 | function: int, 79 | repeat_count: int = 0 80 | ) -> protocol_base.IRCode: 81 | function = protocol_base.IntegerWrapper( 82 | function, 83 | 5, 84 | self._bursts, 85 | self.encoding 86 | ) 87 | 88 | params = dict( 89 | F=function, 90 | ) 91 | 92 | packet = self._build_packet(F=function[True:5:0]) 93 | 94 | params['frequency'] = self.frequency 95 | 96 | code = protocol_base.IRCode( 97 | self, 98 | packet[:] * (repeat_count + 1), 99 | [packet[:]] * (repeat_count + 1), 100 | params, 101 | repeat_count 102 | ) 103 | 104 | return code 105 | -------------------------------------------------------------------------------- /pyIRDecoder/protocols/sharp1.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | 26 | # **************************************************************************** 27 | 28 | # Local imports 29 | from . import protocol_base 30 | from . import DecodeError 31 | 32 | 33 | TIMING = 264 34 | 35 | 36 | class Sharp1(protocol_base.IrProtocolBase): 37 | """ 38 | IR decoder for the Sharp1 protocol. 39 | """ 40 | irp = '{38k,264,lsb}<1,-3|1,-7>(D:5,F:8,1:2,1,-165)*' 41 | frequency = 38000 42 | bit_count = 15 43 | encoding = 'lsb' 44 | 45 | _lead_in = [] 46 | _lead_out = [TIMING, -TIMING * 165] 47 | _middle_timings = [] 48 | _bursts = [[TIMING, -TIMING * 3], [TIMING, -TIMING * 7]] 49 | 50 | _code_order = [ 51 | ['D', 5], 52 | ['F', 8], 53 | ] 54 | 55 | _parameters = [ 56 | ['D', 0, 4], 57 | ['F', 5, 12], 58 | ['C0', 13, 14], 59 | ] 60 | # [D:0..31,F:0..255] 61 | encode_parameters = [ 62 | ['device', 0, 31], 63 | ['function', 0, 255], 64 | ] 65 | 66 | def decode(self, data: list, frequency: int = 0) -> protocol_base.IRCode: 67 | code = protocol_base.IrProtocolBase.decode(self, data, frequency) 68 | 69 | if code.c0 != 1: 70 | raise DecodeError('Checksum failed') 71 | 72 | if self._last_code is not None: 73 | if self._last_code == code: 74 | return self._last_code 75 | 76 | self._last_code.repeat_timer.stop() 77 | 78 | self._last_code = code 79 | return code 80 | 81 | def encode( 82 | self, 83 | device: int, 84 | function: int, 85 | repeat_count: int = 0 86 | ) -> protocol_base.IRCode: 87 | params = dict( 88 | D=device, 89 | F=function, 90 | C0=1 91 | ) 92 | packet = self._build_packet(**params) 93 | 94 | params['frequency'] = self.frequency 95 | 96 | code = protocol_base.IRCode( 97 | self, 98 | packet[:] * (repeat_count + 1), 99 | [packet[:]] * (repeat_count + 1), 100 | params, 101 | repeat_count 102 | ) 103 | 104 | return code 105 | -------------------------------------------------------------------------------- /test_protocols/test_matsui.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # ***************************************************************************** 4 | # MIT License 5 | # 6 | # Copyright (c) 2020 Kevin G. Schlosser 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # **************************************************************************** 26 | 27 | from pyIRDecoder import ( 28 | RepeatLeadInError, 29 | RepeatLeadOutError, 30 | IRException 31 | ) 32 | from pyIRDecoder import protocols 33 | 34 | protocol = protocols.Matsui 35 | 36 | 37 | class Matsui(object): 38 | rlc = [[ 39 | 525, -525, 525, -1575, 525, -525, 525, -1575, 525, -1575, 525, 40 | -525, 525, -525, 525, -1575, 525, -1575, 525, -1575, 525, -13175, 41 | ]] 42 | 43 | params = [dict(device=2, function=115)] 44 | 45 | 46 | def test_decode(): 47 | for rlc, params in zip(Matsui.rlc, Matsui.params): 48 | try: 49 | ir_code = protocol.decode(rlc, protocol.frequency) 50 | except (RepeatLeadInError, RepeatLeadOutError): 51 | if params is not None: 52 | raise 53 | continue 54 | 55 | for key, value in params.items(): 56 | assert getattr(ir_code, key) == value, ( 57 | key, 58 | getattr(ir_code, key), 59 | value 60 | ) 61 | print() 62 | print(ir_code, repr(ir_code)) 63 | 64 | 65 | def test_encode(): 66 | for params in Matsui.params: 67 | if params is None: 68 | continue 69 | 70 | ir_code = protocol.encode(**params) 71 | for key, value in params.items(): 72 | assert getattr(ir_code, key) == value, ( 73 | key, 74 | getattr(ir_code, key), 75 | value 76 | ) 77 | 78 | new_ir_code = None 79 | for rlc in ir_code.normalized_rlc: 80 | try: 81 | new_ir_code = protocol.decode(rlc, protocol.frequency) 82 | except (RepeatLeadInError, RepeatLeadOutError): 83 | continue 84 | except IRException: 85 | new_ir_code = protocol.decode( 86 | ir_code.original_rlc, 87 | protocol.frequency 88 | ) 89 | break 90 | 91 | print() 92 | print(ir_code, repr(ir_code)) 93 | print(new_ir_code) 94 | 95 | assert new_ir_code == ir_code 96 | 97 | break 98 | --------------------------------------------------------------------------------