Instead of code, I am looking for a methodology.
My original approach was if current_datetime == scheduled_datetime then trigger. The problem with this approach is that sometimes the board skips a few beats/seconds (could be because of WiFi, etc - I don't really know). I believe I can't avoid this so I need to go a route where if current_datetime is past scheduled_datetime then trigger (this will catch up if the board got stuck for a few seconds here or there).
Requirement: The trigger happens one or more days of the week at the same exact time. This is the input to the program. The user has the ability to change the schedule at any time.
Example 3:00pm Tuesday and Thursday OR 5:00am Saturday and Sunday.
Crude Approach: Without a library, with the input I have (3:00pm Tuesday and Thursday), if I can build a list/queue of exact DateTimes for future events I can then easily do the comparison (of if current_datetime is past scheduled_datetime then trigger). After triggering, I will re-build the list/queue.
My challenge here is that if today is 11/1/2018 5:00pm, how do I get the DateTime (date part) for the next few 3:00pm Tuesday and Thursday to keep in my list/queue.
Library Approach: It looks like there is an TimeAlarm library available. Specifically the function in there Alarm.alarmRepeat(dowTuesday, 15,00,0, TuesdayTrigger). It seems like this will trigger on Tuesdays at 3:00pm. I am hoping this will catch up missed alarms if the board got stuck for a few seconds. My challenge here is that I don't see a way to cancel the existing ones if the end user decided to change the input/schedule.
I would appreciate any help!