1
- # The MIT License (MIT)
1
+ # SPDX-FileCopyrightText: 2017 Scott Shawcroft for Adafruit Industries
2
2
#
3
- # Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
3
+ # SPDX-License-Identifier: MIT
4
+
22
5
"""
23
6
`adafruit_irremote`
24
7
====================================================
@@ -92,8 +75,8 @@ class GenericDecode:
92
75
def bin_data (self , pulses ):
93
76
"""Compute bins of pulse lengths where pulses are +-25% of the average.
94
77
95
- :param list pulses: Input pulse lengths
96
- """
78
+ :param list pulses: Input pulse lengths
79
+ """
97
80
bins = [[pulses [0 ], 0 ]]
98
81
99
82
for _ , pulse in enumerate (pulses ):
@@ -192,12 +175,12 @@ def _read_pulses_non_blocking(
192
175
self , input_pulses , max_pulse = 10000 , pulse_window = 0.10
193
176
):
194
177
"""Read out a burst of pulses without blocking until pulses stop for a specified
195
- period (pulse_window), pruning pulses after a pulse longer than ``max_pulse``.
178
+ period (pulse_window), pruning pulses after a pulse longer than ``max_pulse``.
196
179
197
- :param ~pulseio.PulseIn input_pulses: Object to read pulses from
198
- :param int max_pulse: Pulse duration to end a burst
199
- :param float pulse_window: pulses are collected for this period of time
200
- """
180
+ :param ~pulseio.PulseIn input_pulses: Object to read pulses from
181
+ :param int max_pulse: Pulse duration to end a burst
182
+ :param float pulse_window: pulses are collected for this period of time
183
+ """
201
184
received = None
202
185
recent_count = 0
203
186
pruning = False
@@ -229,16 +212,16 @@ def read_pulses(
229
212
blocking_delay = 0.10
230
213
):
231
214
"""Read out a burst of pulses until pulses stop for a specified
232
- period (pulse_window), pruning pulses after a pulse longer than ``max_pulse``.
233
-
234
- :param ~pulseio.PulseIn input_pulses: Object to read pulses from
235
- :param int max_pulse: Pulse duration to end a burst
236
- :param bool blocking: If True, will block until pulses found.
237
- If False, will return None if no pulses.
238
- Defaults to True for backwards compatibility
239
- :param float pulse_window: pulses are collected for this period of time
240
- :param float blocking_delay: delay between pulse checks when blocking
241
- """
215
+ period (pulse_window), pruning pulses after a pulse longer than ``max_pulse``.
216
+
217
+ :param ~pulseio.PulseIn input_pulses: Object to read pulses from
218
+ :param int max_pulse: Pulse duration to end a burst
219
+ :param bool blocking: If True, will block until pulses found.
220
+ If False, will return None if no pulses.
221
+ Defaults to True for backwards compatibility
222
+ :param float pulse_window: pulses are collected for this period of time
223
+ :param float blocking_delay: delay between pulse checks when blocking
224
+ """
242
225
while True :
243
226
pulses = self ._read_pulses_non_blocking (
244
227
input_pulses , max_pulse , pulse_window
@@ -261,9 +244,9 @@ def __init__(self, header, one, zero, trail):
261
244
def transmit (self , pulseout , data ):
262
245
"""Transmit the ``data`` using the ``pulseout``.
263
246
264
- :param pulseio.PulseOut pulseout: PulseOut to transmit on
265
- :param bytearray data: Data to transmit
266
- """
247
+ :param pulseio.PulseOut pulseout: PulseOut to transmit on
248
+ :param bytearray data: Data to transmit
249
+ """
267
250
durations = array .array ("H" , [0 ] * (2 + len (data ) * 8 * 2 + 1 ))
268
251
durations [0 ] = self .header [0 ]
269
252
durations [1 ] = self .header [1 ]
0 commit comments