Пример #1
0
    #     Use Board pin numbering - etc. (12) in pinout command
    GPIO.setmode(GPIO.BCM)
    #Setup GPIOs as inputs with PULL-UP
    for gpi, id in cf.gpi2stream.items():
        GPIO.setup(int(gpi), GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
        # GPIO.setup( int(gpi), GPIO.IN)
        main_log.info('GPIO: {} set up as input'.format(gpi))

    # Tie callbacks to events

    for gpi, id in cf.gpi2stream.items():
        GPIO.add_event_detect( int(gpi), GPIO.BOTH, callback = gpi_event_dict[gpi].\
            start_stop_avail , bouncetime = 20)

    # check_elemental_connection()
except Exception as e:
    main_log.exception('Error:{}'.format(e))
    stater.save_last_exit(last_exit_state='Exit')
    GPIO.cleanup()

if __name__ == '__main__':
    try:
        while (True):
            main_log.info("Running")
            time.sleep(10)
            pass
    except KeyboardInterrupt:
        main_log.info('Exiting on keyboard interrupt\n')
        stater.save_last_exit(last_exit_state='Exit')
        GPIO.cleanup()
        pass