Page 1 of 1

gpio.cleanup()

Posted: Mon Mar 31, 2014 1:17 pm
by mrfloppy88
i need a GPIO pin to be HIGH after my script finishes...
at the moment GPIO.cleanup() turns it into INPUT, and this is no good for me...

can i setup the one pin and make it high after gpio.cleanup() has done its thing?
or can i prevent gpio.cleanup() to cleanup all pins, and just leave one active (i will set warnings off if this is the case)

thanks
Mrfloppy88

Re: gpio.cleanup()

Posted: Mon Mar 31, 2014 3:08 pm
by croston
I will be changing GPIO.cleanup() in the next release to be able specify certain pins to clean up. So in your case, you would need to do something like:

Code: Select all

# set up a list of the channels your program has used
channels_used = [2,4,6,7,8,9]

# clean up everything except channel 6
channels_used.remove(6)   # remove channel 6 from the list
for channel in channels_used:
    GPIO.cleanup(channel)
The code fix is this one:
http://sourceforge.net/p/raspberry-gpio ... ickets/52/

Re: gpio.cleanup()

Posted: Tue Apr 01, 2014 6:49 pm
by alexeames
Ben, can you set it up so that it gives people a rather terse/rude/abusive message if they use

GPIO.cleanup()

before they've set up or used any ports? It seems very common indeed that people put it at the top of scripts thinking it gives them a fresh start.