summaryrefslogtreecommitdiff
path: root/external/plyer/facades/irblaster.py
diff options
context:
space:
mode:
authorLivio Recchia <recchialivio@libero.it>2020-02-10 23:06:34 +0100
committerLivio Recchia <recchialivio@libero.it>2020-02-10 23:06:34 +0100
commit9a13903a2f7d3a65fdf15a65fb59cccd622e2066 (patch)
tree9403b7dff39eb5e5d7fa0f79efb69b496add4c4b /external/plyer/facades/irblaster.py
parent11cc316b74d5f3f283413a33e7693b314741aa4a (diff)
downloadmanachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.tar.gz
manachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.tar.bz2
manachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.tar.xz
manachat-9a13903a2f7d3a65fdf15a65fb59cccd622e2066.zip
Initial commit
Diffstat (limited to 'external/plyer/facades/irblaster.py')
-rw-r--r--external/plyer/facades/irblaster.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/external/plyer/facades/irblaster.py b/external/plyer/facades/irblaster.py
new file mode 100644
index 0000000..0e15a07
--- /dev/null
+++ b/external/plyer/facades/irblaster.py
@@ -0,0 +1,59 @@
+class IrBlaster(object):
+ '''Infrared blaster facade.'''
+
+ @staticmethod
+ def periods_to_microseconds(frequency, pattern):
+ '''Convert a pattern from period counts to microseconds.
+ '''
+ period = 1000000. / frequency
+ return [period * x for x in pattern]
+
+ @staticmethod
+ def microseconds_to_periods(frequency, pattern):
+ '''Convert a pattern from microseconds to period counts.
+ '''
+ period = 1000000. / frequency
+ return [x / period for x in pattern]
+
+ @property
+ def frequencies(self):
+ '''Property which contains a list of frequency ranges
+ supported by the device in the form:
+
+ [(from1, to1),
+ (from2, to2),
+ ...
+ (fromN, toN)]
+ '''
+ return self.get_frequencies()
+
+ def get_frequencies(self):
+ return self._get_frequencies()
+
+ def _get_frequencies(self):
+ raise NotImplementedError()
+
+ def transmit(self, frequency, pattern, mode='period'):
+ '''Transmit an IR sequence.
+
+ :parameters:
+ `frequency`: int
+ Carrier frequency for the IR transmission.
+ `pattern`: list[int]
+ Burst pair pattern to transmit.
+ `mode`: str, defaults to 'period'
+ Specifies the format of the pattern values.
+ Can be 'period' or 'microseconds'.
+ '''
+ return self._transmit(frequency, pattern, mode)
+
+ def _transmit(self, frequency, pattern, mode):
+ raise NotImplementedError()
+
+ def exists(self):
+ '''Check if the device has an infrared emitter.
+ '''
+ return self._exists()
+
+ def _exists(self):
+ raise NotImplementedError()