Skip to content

Latest commit

 

History

History
32 lines (27 loc) · 986 Bytes

File metadata and controls

32 lines (27 loc) · 986 Bytes

ScaledTimer

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.

🚀 Example

var timer = new ScaledTimer.ScaledTimer(intervalMs: 3000, startScale: 50);
timer.Start();
timer.SetScale(73);
...
timer.SetScale(49)
...

[Scale changed73%]Time: 00:00:00.00Time: 00:00:00.37
[Scale changed49%]Time: 00:00:00.73Time: 00:00:00.98
[Scale changed89%]Time: 00:00:01.23Time: 00:00:01.68
[Scale changed65%]Time: 00:00:02.12Time: 00:00:02.45
[Scale changed39%]Time: 00:00:02.77Time: 00:00:02.97
[Elapsed] Scaled Time: 3.00s | Scale: 39% | Timestamp: 09:34:07.361