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). Now when this happens it also resets all the relays turning everything 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). Using a file to hold states when closing will not work because it will not stop the resetting of the gpios on restart of the program. The gpios are left in their current state when closing the app. But restarting the program clears all gpios. I'm using the quick2wire module. Now this program does leave the gpios in the state set in order to keep devices running when closing the app.
How do I go about checking 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
Could some one explain what the above line is doing exactly? And is there another way to initialize the gpios then as in the above statement?
I've tried this package RPi.GPIO-0.5.2a but it requires root to use it, and that is a no no since this software will be accessed over the net.
So how do I detect this?
Is there a different way to set the gpios in python(other then quick2wire)?
Is there a better package to use besides 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.