Timer/Scheduling with Photon

Right now, I’m trying to write a program that can change the time of an alarm/timer, using this TimeAlarms library based on a certain condition.

For example, if I have a flag that can be either ON or OFF, if it’s ON, I want to call a function every one minute but if the flag is OFF, I want to call it every 20 minutes instead. I looked at the example and I’m not sure if there’s a possible method that’ll allow me to do so. Does anyone know if it’s possible or if there’s a different library that may allow me to do so?

Is this periodicity the only reason for using TimeAlarms?
What is the application doing in between triggers?
If you only want to do things periodically but nothing in between then System.sleep() might be an option.
If you need to do things “parallel” to the periodic task I’d just go for software timers.

But have you even tried just calling timeRepeat() with different arguments to change the periode?
If that didn’t work and you actually need to use TimeAlarms you could just use your flag inside the callback function to either act on each visit to the function or only every 20th call or just return without action all the other 19 times.
Or you have two alarms set but depending on your flag only enable the one needed and disable the other on change of flag.
Or you use a one-shot alarm and rearm according to flag.
Or …