15 u32 elapsed = now - start;
16 u32 total =
end - start;
17 u32 out = (elapsed * 255) / total;
21 return static_cast<u8>(out);
31 u32 elapsed = now - start;
32 u32 total =
end - start;
33 u32 out = (elapsed * 65535) / total;
37 return static_cast<u16
>(out);
TimeRamp(u32 risingTime, u32 latchMs, u32 fallingTime)
void trigger(u32 now) override
Call this when you want to (re)start the ramp cycle.
u8 update8(u32 now) override
Compute current 0–255 output based on how much time has elapsed since trigger().
bool isActive(u32 now) const override
u16 time_alpha16(u32 now, u32 start, u32 end)
constexpr T * end(T(&array)[N]) noexcept
u8 time_alpha8(u32 now, u32 start, u32 end)