fixed buzzer thread
fixed logging fixed postinstall.sh
This commit is contained in:
parent
efd03d71a1
commit
af3f832758
5 changed files with 25 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import threading
|
||||
import time
|
||||
|
||||
import systemd.daemon
|
||||
|
@ -15,7 +16,11 @@ __run = """raspivid -t 0 -b 5000000 -w 1280 -h 720 -fps 30 -n -o - | gst-launch-
|
|||
def check_battery():
|
||||
while True:
|
||||
time.sleep(2)
|
||||
battery = Battery.percent()
|
||||
battery = 0
|
||||
try:
|
||||
battery = Battery.percent()
|
||||
except Exception as e:
|
||||
logstash_logger.error(f"could not check battery -> {str(e)}")
|
||||
if battery <= 15:
|
||||
logstash_logger.warning(f"LOW BATTERY DETECTED: '{battery}'")
|
||||
Buzzer.set(True)
|
||||
|
@ -30,6 +35,14 @@ if __name__ == '__main__':
|
|||
logstash_logger.warning("Warning, old systemd version detected")
|
||||
systemd.daemon.notify('READY=1')
|
||||
|
||||
logstash_logger.info("starting battery checker")
|
||||
try:
|
||||
battery_checker = threading.Thread(target=check_battery)
|
||||
battery_checker.start()
|
||||
logstash_logger.info("starting battery checker - DONE")
|
||||
except Exception as e:
|
||||
logstash_logger.error(f"could not start battery checker -> {str(e)}")
|
||||
|
||||
logstash_logger.info("starting gstreamer background process")
|
||||
os.system(__run)
|
||||
logstash_logger.error("gstreamer stopped...")
|
||||
|
|
Reference in a new issue