]> git.gag.com Git - fw/quantimotor/commitdiff
add rudimentary management of LED and alarm outputs
authorBdale Garbee <bdale@gag.com>
Mon, 26 May 2025 21:15:12 +0000 (15:15 -0600)
committerBdale Garbee <bdale@gag.com>
Mon, 26 May 2025 21:15:12 +0000 (15:15 -0600)
ui/app.py

index c71ccf446ef58a94d6425de83696e54a71db0d77..08bbccd19ecee0e975e662db01536541e61fac67 100755 (executable)
--- a/ui/app.py
+++ b/ui/app.py
@@ -80,6 +80,35 @@ def sense_armed():
         else:
           return 'safe'
 
+# LED (and alarms) management function we'll arrange to run periodically
+def manageLEDs():
+  # cherrypy.log("manageLEDs")
+  armed = sense_armed()
+
+  # set siren (alarm_a) output
+  if armed == "armed":
+    set_line_values("/dev/gpiochip0", {27: Value.ACTIVE})
+  else:
+    set_line_values("/dev/gpiochip0", {27: Value.INACTIVE})
+
+  # set strobe (alarm_b) output
+  if armed == "armed":
+    set_line_values("/dev/gpiochip0", {17: Value.ACTIVE})
+  else:
+    set_line_values("/dev/gpiochip0", {17: Value.INACTIVE})
+
+  # set continuity LED based on pyro voltage
+  if pyro == "good":
+    set_line_values("/dev/gpiochip0", {20: Value.ACTIVE})
+  else:
+    set_line_values("/dev/gpiochip0", {20: Value.INACTIVE})
+
+  # set armed LED based on safe/arm switch setting
+  if armed == "safe":
+    set_line_values("/dev/gpiochip0", {21: Value.INACTIVE})
+  else:
+    set_line_values("/dev/gpiochip0", {21: Value.ACTIVE})
+
 path   = os.path.abspath(os.path.dirname(__file__))
 config = {
   'global' : {
@@ -209,6 +238,9 @@ if __name__ == '__main__':
     chan.attrs['scale'].value = SCALE
     chan.attrs['offset'].value = OFFSET
 
+  # subscribe our LED management function to the main loop
+  cherrypy.engine.subscribe('main', manageLEDs)
+
   # launch web user interface
   cherrypy.quickstart(App(), '/', config)