]> git.gag.com Git - fw/quantimotor/commitdiff
initialize gpio lines
authorBdale Garbee <bdale@gag.com>
Mon, 21 Apr 2025 08:38:18 +0000 (08:38 +0000)
committerBdale Garbee <bdale@gag.com>
Mon, 21 Apr 2025 08:38:18 +0000 (08:38 +0000)
application/app.py

index c48af50bd9eb2559f594cab7dfff7f566f20eca5..1ae093df3dace9b75fa217d54db1bbed11381d21 100755 (executable)
@@ -5,11 +5,23 @@
 #
 
 import os
-
 import cherrypy
 from cherrypy.lib.static import serve_file
+import gpiod
+from gpiod.line import Direction, Value
 
+def set_line_values(chip_path, line_values):
+  value_str = {Value.ACTIVE: "Active", Value.INACTIVE: "Inactive"}
 
+  request = gpiod.request_lines(
+    chip_path,
+    consumer=sys.argv[0],
+    config={
+      tuple(line_values.keys()): gpiod.LineSettings(direction=Direction.OUTPUT)
+    },
+  )
+  request.set_values(line_values)
 path   = os.path.abspath(os.path.dirname(__file__))
 config = {
   'global' : {
@@ -40,5 +52,19 @@ class App:
 
 
 if __name__ == '__main__':
+  # initialize hardware
+  set_line_values(
+      "/dev/gpiochip0", 
+      {25: Value.ACTIVE,               # take ADS8688 out of reset
+        4: Value.ACTIVE,               # indicate 'ready' to LPC
+       16: Value.INACTIVE,             # pyro off
+       17: Value.INACTIVE,             # alarm b off
+       20: Value.INACTIVE,             # continuity LED off
+       21: Value.INACTIVE,             # armed LED off
+       27: Value.INACTIVE              # alarm a off
+      }
+  )
+
+  # launch web user interface
   cherrypy.quickstart(App(), '/', config)