Example #1
0
def clean_up():
	GPIO.clean_up()
    ap.add_argument("-p", "--pin", required=True, help="signal input pin")
    ap.add_argument("-e", "--exec", required=True, help="command to exec")
    ap.add_argument("-d", "--debounce", default=2, help="debounce time")
    ap.add_argument("-i",
                    "--init",
                    choices=["down", "up"],
                    default="down",
                    help="down or up")
    args = vars(ap.parse_args())

    last = time.time()

    pin = int(args['pin'])
    wait = int(args['debounce'])
    exec_id = args['exec']
    GPIO.setmode(GPIO.BOARD)
    pull_type = GPIO.PUD_DOWN if (args['init'] == "down") else GPIO.PUD_UP
    GPIO.setup(pin, GPIO.IN, pull_up_down=pull_type)
    GPIO.add_event_detect(pin,
                          GPIO.BOTH,
                          callback=lambda ch: detect(ch, wait, exec_id),
                          bouncetime=500)

    #app = make_app()
    #app.listen(5000)
    #tornado.ioloop.IOLoop.current().start()
    while True:
        sleep(1)

GPIO.clean_up()
Example #3
0
    kl.train(train_gen,
             val_gen,
             saved_model_path=model_path,
             steps=steps_per_epoch,
             train_split=cfg.TRAIN_TEST_SPLIT)





if __name__ == '__main__':
    args = docopt(__doc__)
    cfg = dk.load_config()
    try:
        if args['drive']:
            drive(cfg, model_path = args['--model'], use_joystick=args['--js'])
    
        elif args['train']:
            tub = args['--tub']
            model = args['--model']
            cache = not args['--no_cache']
            train(cfg, tub, model)
    except (KeyboardInterrupt,SystemExit):
        GPIO.clean_up()
        raise