buzzer is now starting to issue a warning if battery is under 15%
This commit is contained in:
parent
7ec6854ac6
commit
efd03d71a1
3 changed files with 18 additions and 3 deletions
|
@ -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...")
|
||||
|
|
Reference in a new issue