From d16daa3fdf96cd01e31ec65ce33b5763759c8b0a Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 28 Feb 2024 01:54:38 +0100 Subject: [PATCH] Removed `backend.sensor.ir.zeroborg`. That code is very old and broken, and it covers a very marginal feature (events from the IR sensor of a Zeroborg board) that can be easily covered by any general-purpose IR sensors. --- docs/source/backends.rst | 1 - .../platypush/backend/sensor.ir.zeroborg.rst | 6 -- platypush/backend/sensor/__init__.py | 0 platypush/backend/sensor/ir/__init__.py | 0 .../backend/sensor/ir/zeroborg/__init__.py | 61 ------------------- .../backend/sensor/ir/zeroborg/manifest.yaml | 8 --- platypush/backend/sensor/ir/zeroborg/scan.py | 23 ------- 7 files changed, 99 deletions(-) delete mode 100644 docs/source/platypush/backend/sensor.ir.zeroborg.rst delete mode 100644 platypush/backend/sensor/__init__.py delete mode 100644 platypush/backend/sensor/ir/__init__.py delete mode 100644 platypush/backend/sensor/ir/zeroborg/__init__.py delete mode 100644 platypush/backend/sensor/ir/zeroborg/manifest.yaml delete mode 100644 platypush/backend/sensor/ir/zeroborg/scan.py diff --git a/docs/source/backends.rst b/docs/source/backends.rst index 9601137ed..c8c2facf6 100644 --- a/docs/source/backends.rst +++ b/docs/source/backends.rst @@ -15,7 +15,6 @@ Backends platypush/backend/music.spotify.rst platypush/backend/nodered.rst platypush/backend/redis.rst - platypush/backend/sensor.ir.zeroborg.rst platypush/backend/stt.deepspeech.rst platypush/backend/stt.picovoice.hotword.rst platypush/backend/stt.picovoice.speech.rst diff --git a/docs/source/platypush/backend/sensor.ir.zeroborg.rst b/docs/source/platypush/backend/sensor.ir.zeroborg.rst deleted file mode 100644 index e3333b0bd..000000000 --- a/docs/source/platypush/backend/sensor.ir.zeroborg.rst +++ /dev/null @@ -1,6 +0,0 @@ -``sensor.ir.zeroborg`` -======================================== - -.. automodule:: platypush.backend.sensor.ir.zeroborg - :members: - diff --git a/platypush/backend/sensor/__init__.py b/platypush/backend/sensor/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/platypush/backend/sensor/ir/__init__.py b/platypush/backend/sensor/ir/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/platypush/backend/sensor/ir/zeroborg/__init__.py b/platypush/backend/sensor/ir/zeroborg/__init__.py deleted file mode 100644 index 4b0f69336..000000000 --- a/platypush/backend/sensor/ir/zeroborg/__init__.py +++ /dev/null @@ -1,61 +0,0 @@ -import time - -from platypush.backend import Backend -from platypush.message.event.sensor.ir import IrKeyUpEvent, IrKeyDownEvent - - -class SensorIrZeroborgBackend(Backend): - """ - This backend will read for events on the infrared sensor of a ZeroBorg - (https://www.piborg.org/motor-control-1135/zeroborg) circuitry for - Raspberry Pi. You can see the codes associated to an IR event from any - remote by running the scan utility:: - - python -m platypush.backend.sensor.ir.zeroborg.scan - """ - - last_message = None - last_message_timestamp = None - - def __init__(self, no_message_timeout=0.37, **kwargs): - import platypush.plugins.gpio.zeroborg.lib as ZeroBorg - - super().__init__(**kwargs) - self.no_message_timeout = no_message_timeout - self.zb = ZeroBorg.ZeroBorg() - self.zb.Init() - self.logger.info('Initialized Zeroborg infrared sensor backend') - - def run(self): - super().run() - - while not self.should_stop(): - try: - self.zb.GetIrMessage() - if self.zb.HasNewIrMessage(): - message = self.zb.GetIrMessage() - if message != self.last_message: - self.logger.info( - 'Received key down event on the IR sensor: %s', message - ) - self.bus.post(IrKeyDownEvent(message=message)) - - self.last_message = message - self.last_message_timestamp = time.time() - except OSError as e: - self.logger.warning( - 'Failed reading IR sensor status: %s: %s', type(e), e - ) - - if ( - self.last_message_timestamp - and time.time() - self.last_message_timestamp > self.no_message_timeout - ): - self.logger.info('Received key up event on the IR sensor') - self.bus.post(IrKeyUpEvent(message=self.last_message)) - - self.last_message = None - self.last_message_timestamp = None - - -# vim:sw=4:ts=4:et: diff --git a/platypush/backend/sensor/ir/zeroborg/manifest.yaml b/platypush/backend/sensor/ir/zeroborg/manifest.yaml deleted file mode 100644 index 0fc02bdd3..000000000 --- a/platypush/backend/sensor/ir/zeroborg/manifest.yaml +++ /dev/null @@ -1,8 +0,0 @@ -manifest: - events: - platypush.message.event.sensor.ir.IrKeyDownEvent: when a key is pressed - platypush.message.event.sensor.ir.IrKeyUpEvent: when a key is released - install: - pip: [] - package: platypush.backend.sensor.ir.zeroborg - type: backend diff --git a/platypush/backend/sensor/ir/zeroborg/scan.py b/platypush/backend/sensor/ir/zeroborg/scan.py deleted file mode 100644 index d168584ea..000000000 --- a/platypush/backend/sensor/ir/zeroborg/scan.py +++ /dev/null @@ -1,23 +0,0 @@ -import time - -import platypush.plugins.gpio.zeroborg.lib as ZeroBorg - -no_msg_timeout = 0.37 -last_msg = None -last_msg_timestamp = None -auto_mode = False - -ZB = ZeroBorg.ZeroBorg() -ZB.Init() - -while True: - ZB.GetIrMessage() - if ZB.HasNewIrMessage(): - message = ZB.GetIrMessage() - print('Received message: {}'.format(message)) - - last_msg = message - last_msg_timestamp = time.time() - -# vim:sw=4:ts=4:et: -