SofaPirate / Plaquette

Object-oriented Arduino library for creative physical computing
https://sofapirate.github.io/Plaquette/
GNU General Public License v3.0
15 stars 4 forks source link

Remove Timer in favor of Alarm #98

Open sofian opened 9 months ago

sofian commented 9 months ago

It is confusing to have both -- and Timer functionality is better handled by Ramp.

sofian commented 8 months ago

In fact I am wondering if we should not have a single unit that would integrate Alarm, Timer and Chronometer.

Essentially, it would be an Alarm with an option for a NO_ALARM mode (which sounds a bit counter-intuitive). But the idea is that a single class could cover everything, because you could access the information of Timer through the progress() function; and the info of time through an elapsed() function (which I believe we should rename seconds() and also add millis() and micros() to echo the existing functions).

The drawback is that when you do not use it as an actual alarm you get rid of the actual functionality of the get() function, which I do not particularly love. An alternative would be to "promote" the Chronometer class (which I would rename Chrono to stay short and in continuity with Metro) to be a Node, and whose get() function would return the time in seconds (possibly with options for millis(), micros(), minutes or hours).