python - Trying to cycle through jobs with a button press -
please forgive beginner question. heard word python 2 weeks ago.
i trying write python 2.7 script has 2 jobs run in , pm. reminder program reminds me every day @ 9am , 9pm. reminds me hourly after that. want try , figure out way gpio button press stop current job, allow next scheduled job occur. idea these 2 jobs run every day, button press says, "stop job , wait next scheduled job". once reminder has "reminded me", button press stops nagging.
here basic code i've started writing:
#!/usr/bin/python import schedule import time import rpi.gpio gpio gpio.setmode(gpio.bcm) # gpio 23 set input. pulled stop false signals gpio.setup(23, gpio.in, pull_up_down=gpio.pud_up) def am_job(): print 'this job' def pm_job(): print 'this pm job' schedule.every().day.at("9:00").do(am_job) schedule.every().day.at("10:00").do(am_job) schedule.every().day.at("11:00").do(am_job) schedule.every().day.at("12:00").do(am_job) schedule.every().day.at("13:00").do(am_job) schedule.every().day.at("21:00").do(pm_job) schedule.every().day.at("22:00").do(pm_job) schedule.every().day.at("23:00").do(pm_job) # need figure out way button press cancels current job # allows next job continue. # on , on each , pm gpio.add_event_detect(23, gpio.falling, callback="some job name here", bouncetime=400) try: while true: # cycles through jobs schedule.run_pending() time.sleep(1) except keyboardinterrupt: gpio.cleanup()
thank , help!
i decided above question not going work. instead, made 2 different python scripts (am , pm). scheduled each cron. in each script, programmed button press interrupt exited script. works great
Comments
Post a Comment