Detect GPIO states at program start
Posted: Wed May 15, 2013 10:04 pm
OK here's the question:
I've built a system to control lights and environmental controls for my cabin. All works fine as currently programmed except for the fact that when I close the app and restart it the app resets all gpios to out with a state value of 0(off). I want the program to detect current setting and pin values(if light 1 is on it needs to stay on, if the air is on it needs to stay on). But restarting the program clears all gpios. I'm using the quick2wire module.
How do I go about checks the states before it resets every thing?
I think this is the line that is resetting the gpios:
pin1 = Pin(int(sys.argv[1]) if len(sys.argv) > 1 else 12, Pin.Out) # = gpio 18
So how do I detect this?
Is there a different way to set the gpios?
Is there a better package to use then the quick2wire module for python? Keep in mind that a normal user needs to be able to execute the program, NOT root!
Any help would be greatly appreciated.
I've built a system to control lights and environmental controls for my cabin. All works fine as currently programmed except for the fact that when I close the app and restart it the app resets all gpios to out with a state value of 0(off). I want the program to detect current setting and pin values(if light 1 is on it needs to stay on, if the air is on it needs to stay on). But restarting the program clears all gpios. I'm using the quick2wire module.
How do I go about checks the states before it resets every thing?
I think this is the line that is resetting the gpios:
pin1 = Pin(int(sys.argv[1]) if len(sys.argv) > 1 else 12, Pin.Out) # = gpio 18
So how do I detect this?
Is there a different way to set the gpios?
Is there a better package to use then the quick2wire module for python? Keep in mind that a normal user needs to be able to execute the program, NOT root!
Any help would be greatly appreciated.