From: Bdale Garbee Date: Mon, 21 Apr 2025 08:38:18 +0000 (+0000) Subject: initialize gpio lines X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=77a09402b769b53a5d297a27e0b09113003fb2ce;p=fw%2Fquantimotor initialize gpio lines --- diff --git a/application/app.py b/application/app.py index c48af50..1ae093d 100755 --- a/application/app.py +++ b/application/app.py @@ -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)