Python RPi.GPIO.cleanup() Examples

The following are 30 code examples of RPi.GPIO.cleanup(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module RPi.GPIO , or try the search function .
Example #1
Source File: charlieplexing-6-on-3.py    From 52-Weeks-of-Pi with MIT License 7 votes vote down vote up
def main():
    try:
        while True:
            for led in LEDS:
                for idx, pin in enumerate(led):
                    if pin == O:
                        GPIO.setup(PINS[idx], GPIO.IN)
                    else:
                        GPIO.setup(PINS[idx], GPIO.OUT)
                        GPIO.output(PINS[idx], pin)
                time.sleep(.1)
            
    except KeyboardInterrupt:
        pass

    finally:
        GPIO.cleanup() 
Example #2
Source File: sakshat.py    From SAKS-tutorials with GNU General Public License v2.0 6 votes vote down vote up
def saks_gpio_init(self):
        #print 'saks_gpio_init'
        GPIO.setwarnings(False)
        GPIO.cleanup()
        GPIO.setmode(GPIO.BCM)

        GPIO.setup(PINS.BUZZER, GPIO.OUT)
        GPIO.output(PINS.BUZZER, GPIO.HIGH)

        for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.LOW)

        for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.HIGH)

        for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) 
Example #3
Source File: controller_rpi.py    From SX127x_driver_for_MicroPython_on_ESP8266 with GNU General Public License v3.0 6 votes vote down vote up
def get_spi(self):             
        spi = None
        
        try: 
            spi = spidev.SpiDev()
            bus = 0
            device = 0
            spi.open(bus, device)            
            spi.max_speed_hz = 10000000
            spi.mode = 0b00
            spi.lsbfirst = False
                
        except Exception as e:
            print(e)
            GPIO.cleanup()
            if spi:
                spi.close()
                spi = None
        
        return spi
        
            
    # https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md
    # https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489 
Example #4
Source File: controller_rpi.py    From SX127x_driver_for_MicroPython_on_ESP8266 with GNU General Public License v3.0 6 votes vote down vote up
def get_spi(self):
        spi = None

        try:
            spi = spidev.SpiDev()
            bus = 0
            device = 0
            spi.open(bus, device)
            spi.max_speed_hz = 10000000
            spi.mode = 0b00
            spi.lsbfirst = False

        except Exception as e:
            print(e)
            GPIO.cleanup()
            if spi:
                spi.close()
                spi = None

        return spi


    # https://www.raspberrypi.org/documentation/hardware/raspberrypi/spi/README.md
    # https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=19489 
Example #5
Source File: gpio_sensor.py    From SecPi with GNU General Public License v3.0 6 votes vote down vote up
def cleanup_sensor(self):
		try:
			GPIO.remove_event_detect(self.gpio)
			GPIO.cleanup(self.gpio)
		except ValueError as ve: # GPIO pin number is not in valid range
			logging.error("GPIOSensor: The given pin number is not in a valid range: %s" % ve)
		logging.debug("GPIOSensor: Removed sensor at pin %s!" % self.gpio)
	
	# callback for alarm 
Example #6
Source File: sakshat.py    From SAKS-SDK with GNU General Public License v2.0 6 votes vote down vote up
def saks_gpio_init(self):
        #print 'saks_gpio_init'
        GPIO.setwarnings(False)
        GPIO.cleanup()
        GPIO.setmode(GPIO.BCM)

        GPIO.setup(PINS.BUZZER, GPIO.OUT)
        GPIO.output(PINS.BUZZER, GPIO.HIGH)

        for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.LOW)

        for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.HIGH)

        for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) 
Example #7
Source File: co2_t110.py    From BerePi with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def init_process():
	print " "
	print "MSG - [S100, T110 CO2 Sensor Driver on RASPI2, Please check log file : ", LOG_PATH
	print "MSG - now starting to read SERIAL PORT"
	print " "
	# HW setup, GPIO
	GPIO.setwarnings(False)
	GPIO.cleanup()
	GPIO.setmode(GPIO.BCM)
	GPIO.setup(18, GPIO.OUT)
	GPIO.setup(23, GPIO.OUT)
	GPIO.setup(24, GPIO.OUT)
	GPIO.setup(25, GPIO.OUT)
	logger.info(' *start* GPIO all set, trying to open serial port, SW starting ')
	rledAllOn()

######################################################################
# START Here. Main
######################################################################

# set logger file 
Example #8
Source File: sakshat.py    From SAKS-tutorials with GNU General Public License v2.0 6 votes vote down vote up
def saks_gpio_init(self):
        #print 'saks_gpio_init'
        GPIO.setwarnings(False)
        GPIO.cleanup()
        GPIO.setmode(GPIO.BCM)

        GPIO.setup(PINS.BUZZER, GPIO.OUT)
        GPIO.output(PINS.BUZZER, GPIO.HIGH)

        for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.LOW)

        for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.HIGH)

        for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) 
Example #9
Source File: sakshat.py    From SAKS-tutorials with GNU General Public License v2.0 6 votes vote down vote up
def saks_gpio_init(self):
        #print 'saks_gpio_init'
        GPIO.setwarnings(False)
        GPIO.cleanup()
        GPIO.setmode(GPIO.BCM)

        GPIO.setup(PINS.BUZZER, GPIO.OUT)
        GPIO.output(PINS.BUZZER, GPIO.HIGH)

        for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.LOW)

        for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.HIGH)

        for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) 
Example #10
Source File: sakshat.py    From SAKS-tutorials with GNU General Public License v2.0 6 votes vote down vote up
def saks_gpio_init(self):
        #print 'saks_gpio_init'
        GPIO.setwarnings(False)
        GPIO.cleanup()
        GPIO.setmode(GPIO.BCM)

        GPIO.setup(PINS.BUZZER, GPIO.OUT)
        GPIO.output(PINS.BUZZER, GPIO.HIGH)

        for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.LOW)

        for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.HIGH)

        for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) 
Example #11
Source File: sakshat.py    From SAKS-tutorials with GNU General Public License v2.0 6 votes vote down vote up
def saks_gpio_init(self):
        #print 'saks_gpio_init'
        GPIO.setwarnings(False)
        GPIO.cleanup()
        GPIO.setmode(GPIO.BCM)

        GPIO.setup(PINS.BUZZER, GPIO.OUT)
        GPIO.output(PINS.BUZZER, GPIO.HIGH)

        for p in [PINS.IC_TM1637_DI, PINS.IC_TM1637_CLK, PINS.IC_74HC595_DS, PINS.IC_74HC595_SHCP, PINS.IC_74HC595_STCP]:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.LOW)

        for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.HIGH)

        for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP) 
Example #12
Source File: acceptor_test.py    From LightningATM with MIT License 6 votes vote down vote up
def main():
    global pulses

    ## We're using BCM Mode
    GPIO.setmode(GPIO.BCM)

    ## Setup coin interrupt channel
    GPIO.setup(6, GPIO.IN, pull_up_down=GPIO.PUD_UP)
    # GPIO.setup(PIN_COIN_INTERRUPT,GPIO.IN)
    GPIO.add_event_detect(6, GPIO.FALLING, callback=coinEventHandler)

    while True:
        time.sleep(0.5)
        if (time.time() - lastImpulse > 0.5) and (pulses > 0):
            if pulses == 1:
                print("Coin 1")
            pulses = 0

    GPIO.cleanup()


# handle the coin event 
Example #13
Source File: pi_power.py    From pi_power with MIT License 6 votes vote down vote up
def user_shutdown(channel):
    global safe_mode
        
    shutdown_delay = 10 # seconds

    # in Safe Mode, wait 2 mins before actually shutting down
    if(safe_mode):
        cmd = "sudo wall 'System shutting down in 2 minutes - SAFE MODE'"
        os.system(cmd)
        time.sleep(120)

    cmd = "sudo wall 'System shutting down in %d seconds'" % shutdown_delay
    os.system(cmd)
    time.sleep(shutdown_delay)

    # Log message is added to /var/log/messages
    os.system("sudo logger -t 'pi_power' '** User initiated shut down **'")
    GPIO.cleanup()
    os.system("sudo shutdown now")


# Shutdown system because of low battery 
Example #14
Source File: pi_power.py    From pi_power with MIT License 6 votes vote down vote up
def low_battery_shutdown():
    global safe_mode

    shutdown_delay = 30 # seconds
    
    # in Safe Mode, wait 2 mins before actually shutting down
    if(safe_mode):
        cmd = "sudo wall 'System shutting down in 2 minutes - SAFE MODE'"
        os.system(cmd)
        time.sleep(120)
    
    cmd = "sudo wall 'System shutting down in %d seconds'" % shutdown_delay
    os.system(cmd)
    time.sleep(shutdown_delay)
    # Log message is added to /var/log/messages
    os.system("sudo logger -t 'pi_power' '** Low Battery - shutting down now **'")
    GPIO.cleanup()
    os.system("sudo shutdown now")
                

    

# MAIN ----------------------- 
Example #15
Source File: pi_fan_tuner.py    From PIFanTuner with MIT License 6 votes vote down vote up
def simple_on_of(debug, port, on_t):
    if debug:
        set_debug()

    fan_on = turn_port_in(port)

    try:
        while True:
            temperature = get_cpu_temp()
            if temperature >= on_t:
                if not fan_on:
                    logging.debug("Temperature {0} CPU fan on.".format(temperature))
                    fan_on = turn_port_out(port)
            else:
                if fan_on:
                    logging.debug("Temperature {0} CPU fan off.".format(temperature))
                    fan_on = turn_port_in(port)
            sleep(10)
    except Exception:
        logging.exception("Error occurs while tune fan status:")
        GPIO.cleanup() 
Example #16
Source File: test_MAX31856.py    From Adafruit_Python_MAX31856 with MIT License 6 votes vote down vote up
def tearDown(self):
        GPIO.cleanup()

    #def test_software_spi_initialize(self):
        #"""Checks to see if the sensor can initialize on the software SPI interface.

        #Will fail if it cannot find the MAX31856 library or any dependencies.
        #Test only checks to see that the sensor can be initialized in Software, does not check the
        #hardware connection.
        #"""
        #_logger.debug('test_software_SPI_initialize()')
        ## Raspberry Pi software SPI configuration.
        #software_spi = {"clk": 25, "cs": 8, "do": 9, "di": 10}
        #sensor = MAX31856(software_spi=software_spi)

        #if sensor:
            #self.assertTrue(True)
        #else:
            #self.assertTrue(False) 
Example #17
Source File: serialMenu.py    From Raspberry-Pi-3-Cookbook-for-Python-Programmers-Third-Edition with MIT License 6 votes vote down vote up
def main():
  try:
    gpioSetup()
    with SC.serPort(serName=SERNAME) as mySerialPort:
      mySerialPort.send("\r\n")
      mySerialPort.send("  GPIO Serial Control\r\n")
      mySerialPort.send("  -------------------\r\n")
      mySerialPort.send("  CMD PIN STATE "+
                        "[GPIO Pin# ON]\r\n")
      while running==True:
        print ("Waiting for command...")
        mySerialPort.send(">>")
        cmd = mySerialPort.receive(terminate="\r\n")
        response=handleCmd(cmd)
        mySerialPort.send(response)
      mySerialPort.send("  Finished!\r\n")
  except OSError:
    print ("Check selected port is valid: %s" %serName)
  except KeyboardInterrupt:
    print ("Finished")
  finally:
    GPIO.cleanup() 
Example #18
Source File: controller_rpi.py    From SX127x_driver_for_MicroPython_on_ESP8266 with GNU General Public License v3.0 5 votes vote down vote up
def __exit__(self):
        GPIO.cleanup()
        self.spi.close() 
Example #19
Source File: control.py    From rpi-film-capture with MIT License 5 votes vote down vote up
def cleanup(self):
        logging.info("Cleaning up GPIO")
        self.light.off()
        self.redled.off()
        self.yellowled.off()
        self.motor.stop()
        GPIO.cleanup() 
Example #20
Source File: sakshat.py    From SAKS-tutorials with GNU General Public License v2.0 5 votes vote down vote up
def saks_gpio_init(self):
        #print 'saks_gpio_init'
        GPIO.setwarnings(False)
        GPIO.cleanup()
        GPIO.setmode(GPIO.BCM)

        GPIO.setup(PINS.BUZZER, GPIO.OUT)
        GPIO.output(PINS.BUZZER, GPIO.HIGH)

        for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.HIGH)

        for p in PINS.LEDS + PINS.DIGITAL_DISPLAY + PINS.DIGITAL_DISPLAY_SELECT:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.HIGH)

        for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP)
            #GPIO.setup(p, GPIO.IN)

        #由于SAKS的蓝色LED和数码管共享引脚,此处将数码管位选关闭,只让信号作用于LED
        #GPIO.setup(17, GPIO.OUT, initial = GPIO.HIGH)
        #GPIO.setup(27, GPIO.OUT, initial = GPIO.HIGH)
        #GPIO.setup(22, GPIO.OUT, initial = GPIO.HIGH)
        #GPIO.setup(10, GPIO.OUT, initial = GPIO.HIGH) 
Example #21
Source File: sakshat.py    From SAKS-tutorials with GNU General Public License v2.0 5 votes vote down vote up
def saks_gpio_init(self):
        #print 'saks_gpio_init'
        GPIO.setwarnings(False)
        GPIO.cleanup()
        GPIO.setmode(GPIO.BCM)

        GPIO.setup(PINS.BUZZER, GPIO.OUT)
        GPIO.output(PINS.BUZZER, GPIO.HIGH)

        for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.HIGH)

        for p in PINS.LEDS + PINS.DIGITAL_DISPLAY + PINS.DIGITAL_DISPLAY_SELECT:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.HIGH)

        for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP)
            #GPIO.setup(p, GPIO.IN)

        #由于SAKS的蓝色LED和数码管共享引脚,此处将数码管位选关闭,只让信号作用于LED
        #GPIO.setup(17, GPIO.OUT, initial = GPIO.HIGH)
        #GPIO.setup(27, GPIO.OUT, initial = GPIO.HIGH)
        #GPIO.setup(22, GPIO.OUT, initial = GPIO.HIGH)
        #GPIO.setup(10, GPIO.OUT, initial = GPIO.HIGH) 
Example #22
Source File: sakshat.py    From SAKS-tutorials with GNU General Public License v2.0 5 votes vote down vote up
def saks_gpio_init(self):
        #print 'saks_gpio_init'
        GPIO.setwarnings(False)
        GPIO.cleanup()
        GPIO.setmode(GPIO.BCM)

        GPIO.setup(PINS.BUZZER, GPIO.OUT)
        GPIO.output(PINS.BUZZER, GPIO.HIGH)

        for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.HIGH)

        for p in PINS.LEDS + PINS.DIGITAL_DISPLAY + PINS.DIGITAL_DISPLAY_SELECT:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.HIGH)

        for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP)
            #GPIO.setup(p, GPIO.IN)

        #由于SAKS的蓝色LED和数码管共享引脚,此处将数码管位选关闭,只让信号作用于LED
        #GPIO.setup(17, GPIO.OUT, initial = GPIO.HIGH)
        #GPIO.setup(27, GPIO.OUT, initial = GPIO.HIGH)
        #GPIO.setup(22, GPIO.OUT, initial = GPIO.HIGH)
        #GPIO.setup(10, GPIO.OUT, initial = GPIO.HIGH) 
Example #23
Source File: sakshat.py    From SAKS-tutorials with GNU General Public License v2.0 5 votes vote down vote up
def saks_gpio_init(self):
        #print 'saks_gpio_init'
        GPIO.setwarnings(False)
        GPIO.cleanup()
        GPIO.setmode(GPIO.BCM)

        GPIO.setup(PINS.BUZZER, GPIO.OUT)
        GPIO.output(PINS.BUZZER, GPIO.HIGH)

        for p in [PINS.BUZZER, PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.HIGH)

        for p in PINS.LEDS + PINS.DIGITAL_DISPLAY + PINS.DIGITAL_DISPLAY_SELECT:
            GPIO.setup(p, GPIO.OUT)
            GPIO.output(p, GPIO.HIGH)

        for p in [PINS.TACT_RIGHT, PINS.TACT_LEFT, PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2]:
            GPIO.setup(p, GPIO.IN, pull_up_down = GPIO.PUD_UP)
            #GPIO.setup(p, GPIO.IN)

        #由于SAKS的蓝色LED和数码管共享引脚,此处将数码管位选关闭,只让信号作用于LED
        #GPIO.setup(17, GPIO.OUT, initial = GPIO.HIGH)
        #GPIO.setup(27, GPIO.OUT, initial = GPIO.HIGH)
        #GPIO.setup(22, GPIO.OUT, initial = GPIO.HIGH)
        #GPIO.setup(10, GPIO.OUT, initial = GPIO.HIGH) 
Example #24
Source File: app.py    From GaragePi with MIT License 5 votes vote down vote up
def finalize():
    global finalized
    logger.info('Entering finalizer.')
    if finalized:
        logger.info('Finalizer already called. Skipping...')
        return
    logger.info('Calling cleanup on GPIO')
    GPIO.cleanup()
    finalized = True
    return 
Example #25
Source File: radiodbp.py    From piradio with GNU General Public License v3.0 5 votes vote down vote up
def signalHandler(signal,frame):
	global lcd
	global log
	radio.execCommand("umount /media > /dev/null 2>&1")
	radio.execCommand("umount /share > /dev/null 2>&1")
	pid = os.getpid()
	log.message("Radio stopped, PID " + str(pid), log.INFO)
	lcd.line1("Radio stopped")
	lcd.line2("")
	lcd.line3("")
	lcd.line4("")
	GPIO.cleanup()
	sys.exit(0)

# Signal SIGTERM handler 
Example #26
Source File: radio4x40.py    From piradio with GNU General Public License v3.0 5 votes vote down vote up
def signalHandler(signal,frame):
	global lcd
	global log
	radio.execCommand("umount /media > /dev/null 2>&1")
	radio.execCommand("umount /share > /dev/null 2>&1")
	pid = os.getpid()
	log.message("Radio stopped, PID " + str(pid), log.INFO)
	lcd.line1("Radio stopped")
	lcd.line2("2")
	lcd.line3("1")
	lcd.line4("0")
	GPIO.cleanup()
	sys.exit(0)

# Daemon class 
Example #27
Source File: radio4x40.py    From piradio with GNU General Public License v3.0 5 votes vote down vote up
def signalHandler(signal,frame):
	global lcd
	global log
	radio.execCommand("umount /media > /dev/null 2>&1")
	radio.execCommand("umount /share > /dev/null 2>&1")
	pid = os.getpid()
	log.message("Radio stopped, PID " + str(pid), log.INFO)
	lcd.line1("Radio stopped")
	lcd.line2("2")
	lcd.line3("1")
	lcd.line4("0")
	GPIO.cleanup()
	sys.exit(0)

# Daemon class 
Example #28
Source File: st7565.py    From Pi-ST7565 with MIT License 5 votes vote down vote up
def cleanup(self):
        """Clean up SPI and GPIO"""
        self.clear_display()
        self.sleep()
        self.__spi.close()
        import RPi.GPIO as GPIO
        GPIO.cleanup() 
Example #29
Source File: example.py    From hx711py with Apache License 2.0 5 votes vote down vote up
def cleanAndExit():
    print("Cleaning...")

    if not EMULATE_HX711:
        GPIO.cleanup()
        
    print("Bye!")
    sys.exit() 
Example #30
Source File: gpio.py    From thingflow-python with Apache License 2.0 5 votes vote down vote up
def _cleanup(self):
        if not self.closed:
            gpio.output(self.port, gpio.LOW)
            gpio.cleanup()
        self.closed = True