From efd03d71a1700c2b8344edfa3907fb9bb93c7af3 Mon Sep 17 00:00:00 2001 From: Joel Date: Thu, 28 Jan 2021 23:15:21 +0100 Subject: [PATCH] buzzer is now starting to issue a warning if battery is under 15% --- build_deb.sh | 2 +- compLib/VisionDaemon.py | 17 ++++++++++++++++- compLib/__init__.py | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/build_deb.sh b/build_deb.sh index f1b9aa8..4d49971 100644 --- a/build_deb.sh +++ b/build_deb.sh @@ -32,7 +32,7 @@ fpm -s python --python-bin python3 --python-pip pip3 --python-package-name-prefi -d "python-pigpio" \ -d "python3-pigpio" \ -d "python3-numpy" \ - -v 0.0.3-8 -t deb setup.py + -v 0.0.4-2 -t deb setup.py # --deb-changelog changelog \ # --deb-upstream-changelog changelog \ diff --git a/compLib/VisionDaemon.py b/compLib/VisionDaemon.py index e000127..36a2cde 100644 --- a/compLib/VisionDaemon.py +++ b/compLib/VisionDaemon.py @@ -1,13 +1,28 @@ import os +import time import systemd.daemon import LogstashLogging from LogstashLogging import logstash_logger +from threading import Thread import logging +from Battery import Battery +from Buzzer import Buzzer __run = """raspivid -t 0 -b 5000000 -w 1280 -h 720 -fps 30 -n -o - | gst-launch-1.0 fdsrc ! video/x-h264,width=1280,height=720,framerate=30/1,noise-reduction=1,profile=high,stream-format=byte-stream ! h264parse ! queue ! flvmux streamable=true ! rtmpsink location=\"rtmp://localhost/live/stream\"""" +def check_battery(): + while True: + time.sleep(2) + battery = Battery.percent() + if battery <= 15: + logstash_logger.warning(f"LOW BATTERY DETECTED: '{battery}'") + Buzzer.set(True) + time.sleep(1) + Buzzer.set(False) + + if __name__ == '__main__': try: systemd.daemon.notify(systemd.daemon.Notification.READY) @@ -15,6 +30,6 @@ if __name__ == '__main__': logstash_logger.warning("Warning, old systemd version detected") systemd.daemon.notify('READY=1') - logging.info("starting gstreamer background process") + logstash_logger.info("starting gstreamer background process") os.system(__run) logstash_logger.error("gstreamer stopped...") diff --git a/compLib/__init__.py b/compLib/__init__.py index 29c6d95..a5afb15 100644 --- a/compLib/__init__.py +++ b/compLib/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.0.3" +__version__ = "0.0.4" import compLib.LogstashLogging import logging