Reading timer progress

I have some code on a device I call “The Monitor” (a PHOTON), that uses 3 timers (“Flood”, “Hot”, “Sump”) that will causes an alarm (Beep) when/if the timer completes. There are three PHOTONs (I call “Sensors”) sends an event via the cloud to reset the associated timer on the Monitor. This allows me to get an alarm if one or more “Sensors” don’t check-in with the Monitor after 2 minutes.

The question,
Can I display the progress of the timers (“Flood”, “Hot”, “Sump”) on the Monitor?
Like Serial.print(Flood); (don’t work)

I found one topic of someone asking about “unsigned long count = TIM_GetCounter(TIM3);”
but when I try it, using “Flood” in place of “TIM3”, I get the following error message…
cannot convert ‘Timer’ to ‘TIM_TypeDef*’ for argument ‘1’ to ‘uint32_t TIM_GetCounter(TIM_TypeDef*)’

Albert

@albertk836, can you please post some code or share your application if you are using the Web IDE? I am not sure what “timers” you are using - hardware timers or Software timers.

Do you really need the precision of hardware timers?
When we are talking minutes or even seconds I’d suppose Software Timers or even millis() should do just fine and are way easier to manage.

What kind of precision are you aiming for?
How often would you want to read the elapsed time?

OS I am using is 1.4.4 (PHOTON)

Software Timers (sorry)

Code is a little long so here are the timer sections…

lines 54 - 56 Def
lines 76 - 78 Init
lines 197 - 199 (This is where i would like to display the current timer values)
lines 255 - 257 updating after data received
lines 263 - 267 Stopping

https://go.particle.io/shared_apps/5e221a52c89e50002183e4bd

What kind of precision are you aiming for?
Precision is not critical +/- 2 seconds

How often would you want to read the elapsed time?
On request, a push of a physical button. Maybe at first 10-15 times a day. After bug tested 1-2 week.

I thought of millis() but if timer(s) are keeping tracking of it, use that.

Albert

Software Timers as such don’t provide access to their “internal counter” but when you have it running at your desired resolution (e.g. 1Hz) you can have it counting up/down a global variable or have the timer call a custom class method that encapsulates your timing object(s).

1 Like

OK, Thanks!