* amplitude * ^ * 255 ─────────────────────── * / \ * / \ * / \ * / \ * 0 ────────────┴ ┴──────────────────> time (ms) * t0 t1 t2 t4 * * * */
| 61 | * |
| 62 | */ |
| 63 | class TimeRamp : public TimeAlpha { |
| 64 | public: |
| 65 | /// @param latchMs total active time (ms) |
| 66 | /// @param risingTime time to ramp from 0→255 (ms) |
| 67 | /// @param fallingTime time to ramp from 255→0 (ms) |
| 68 | TimeRamp(u32 risingTime, u32 latchMs, u32 fallingTime) FL_NOEXCEPT; |
| 69 | |
| 70 | /// Call this when you want to (re)start the ramp cycle. |
| 71 | /// Smart re-trigger that preserves state when already active: |
| 72 | /// - If in plateau: extends the plateau time |
| 73 | /// - If falling: reverses back to plateau |
| 74 | /// - If rising: continues rising |
| 75 | /// - If inactive: starts new cycle |
| 76 | void trigger(u32 now) FL_NOEXCEPT override; |
| 77 | |
| 78 | /// @return true iff we're still within the latch period. |
| 79 | bool isActive(u32 now) const FL_NOEXCEPT override; |
| 80 | |
| 81 | /// Get the current phase of the ramp |
| 82 | RampPhase getCurrentPhase(u32 now) const FL_NOEXCEPT; |
| 83 | |
| 84 | /// Compute current 0–255 output based on how much time has elapsed since |
| 85 | /// trigger(). |
| 86 | u8 update8(u32 now) FL_NOEXCEPT override; |
| 87 | |
| 88 | private: |
| 89 | u32 mLatchMs; |
| 90 | u32 mRisingTime; |
| 91 | u32 mFallingTime; |
| 92 | |
| 93 | u32 mFinishedRisingTime = 0; |
| 94 | u32 mFinishedPlateauTime = 0; |
| 95 | u32 mFinishedFallingTime = 0; |
| 96 | |
| 97 | u32 mStart = 0; |
| 98 | u8 mLastValue = 0; |
| 99 | }; |
| 100 | |
| 101 | /* |
| 102 | * amplitude |
no outgoing calls
no test coverage detected