Please forgive the beginner question. I only heard the word Python 2 weeks ago.
I am trying to write a python 2.7 script that has two jobs which run in the AM and PM. This is a reminder program that reminds me every day at 9am and 9pm. It also reminds me hourly after that. I want to try and figure out a way that a GPIO button press will stop the current job, but allow the next scheduled job to occur. The idea is that these two jobs run every day, but a button press says, "Stop this job and wait for the next scheduled job". Once I do what the reminder has "reminded me", a button press stops the nagging.
Here is the basic code I've started writing:
#!/usr/bin/python
import schedule
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
# GPIO 23 set up as input. It is pulled up to stop false signals
GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)
def am_job():
print 'This is the AM job'
def pm_job():
print 'This is the 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)
# I need to figure out a way that this button press cancels the current job
# but allows the next job to continue.
# Over and over each am and pm
GPIO.add_event_detect(23, GPIO.FALLING, callback="some job name here", bouncetime=400)
try:
while True: # This currently just cycles through all the jobs
schedule.run_pending()
time.sleep(1)
except KeyboardInterrupt:
GPIO.cleanup()
Thank you for any and all help!