From 0939cdedf8e0aeb19a98517360c2887055d68e7e Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 26 Jun 2018 00:16:04 +0200 Subject: [PATCH] Added utility to scan for messages on the ZeroBorg infrared sensor --- .../ir/{zeroborg.py => zeroborg/__init__.py} | 0 platypush/backend/sensor/ir/zeroborg/scan.py | 23 +++++++++++++++++++ 2 files changed, 23 insertions(+) rename platypush/backend/sensor/ir/{zeroborg.py => zeroborg/__init__.py} (100%) create mode 100644 platypush/backend/sensor/ir/zeroborg/scan.py diff --git a/platypush/backend/sensor/ir/zeroborg.py b/platypush/backend/sensor/ir/zeroborg/__init__.py similarity index 100% rename from platypush/backend/sensor/ir/zeroborg.py rename to platypush/backend/sensor/ir/zeroborg/__init__.py diff --git a/platypush/backend/sensor/ir/zeroborg/scan.py b/platypush/backend/sensor/ir/zeroborg/scan.py new file mode 100644 index 000000000..d168584ea --- /dev/null +++ b/platypush/backend/sensor/ir/zeroborg/scan.py @@ -0,0 +1,23 @@ +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: +