]> git.gag.com Git - fw/quantimotor/commitdiff
successfully sensing armed input bit and including in status display
authorBdale Garbee <bdale@gag.com>
Wed, 7 May 2025 21:28:15 +0000 (15:28 -0600)
committerBdale Garbee <bdale@gag.com>
Wed, 7 May 2025 21:28:15 +0000 (15:28 -0600)
application/app.py
application/index.html

index 3676fb29a137a96fe344c839bbcc62dae9978719..1a2b6afb9b46ba123c01166d2e39b6a6713904ed 100755 (executable)
@@ -14,7 +14,7 @@ import sys
 
 n=0
 
-# set gpio lines
+# set gpio output lines
 def set_line_values(chip_path, line_values):
   value_str = {Value.ACTIVE: "Active", Value.INACTIVE: "Inactive"}
 
@@ -43,7 +43,19 @@ def handler(signum, frame):
 
 # having systemd use SIGINT to avoid CherryPy consuming the kill signal
 signal.signal(signal.SIGINT, handler)
+
+def sense_armed():
+    with gpiod.request_lines(
+        "/dev/gpiochip0",
+        consumer="get-line-value",
+        config={12: gpiod.LineSettings(direction=Direction.INPUT)},
+    ) as request:
+        value = request.get_value(12)
+        if value == Value.ACTIVE:
+          return 'armed'
+        else:
+          return 'safe'
+
 path   = os.path.abspath(os.path.dirname(__file__))
 config = {
   'global' : {
@@ -75,11 +87,14 @@ class App:
     t = str(n) + b
     pyro_v = str(n) + ' volts'
     batt_v = str(n) + ' volts'
+    armed = sense_armed()
+
     return {
       'pressure' : p,
       'thrust' : t,
       'pyro' : pyro_v,
-      'battery' : batt_v
+      'battery' : batt_v,
+      'armed' : armed
     }
 
 
index 3baaa97f08882518beda30d99a647c47a01171fd..2fdf1b6a66bb54307a2db2085f26c9f862114192 100644 (file)
@@ -16,6 +16,7 @@
         $('#thrust').text(response.thrust);
         $('#pyro').text(response.pyro);
         $('#battery').text(response.battery);
+        $('#armed').text(response.armed);
       });
       request.fail(function(jqXHR, textStatus) 
       {
@@ -36,5 +37,7 @@
   <div id='pyro'></div>
   <h2>Battery</h2>
   <div id='battery'></div>
+  <h2>Armed</h2>
+  <div id='armed'></div>
 </body>
 </html>