A lightweight .NET library that implements a consumption-based timer. The timer advances based on a dynamic input percentage.
If the scale remains at 100%, it behaves like a regular timer. When the scale fluctuates, this is taken into account. This is useful for tracking the consumption of a resource in terms of time β for example, battery usage time in an electric vehicle or RC plane.
var timer = new ScaledTimer.ScaledTimer(intervalMs: 3000, startScale: 50);
timer.Start();
timer.SetScale(73);
...
timer.SetScale(49)
...
[Scale changed β 73%]
β Time: 00:00:00.00
β Time: 00:00:00.37
[Scale changed β 49%]
β Time: 00:00:00.73
β Time: 00:00:00.98
[Scale changed β 89%]
β Time: 00:00:01.23
β Time: 00:00:01.68
[Scale changed β 65%]
β Time: 00:00:02.12
β Time: 00:00:02.45
[Scale changed β 39%]
β Time: 00:00:02.77
β Time: 00:00:02.97
[β° Elapsed] Scaled Time: 3.00s | Scale: 39% | Timestamp: 09:34:07.361