From: Bdale Garbee Date: Mon, 26 May 2025 21:15:12 +0000 (-0600) Subject: add rudimentary management of LED and alarm outputs X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=d7c8bb6bc4d86decf77597fad9bfd15b97425022;p=fw%2Fquantimotor add rudimentary management of LED and alarm outputs --- diff --git a/ui/app.py b/ui/app.py index c71ccf4..08bbccd 100755 --- 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)