* @brief Update the timer state based on current time * * Checks if the timer is still running based on the current time. * If the specified duration has elapsed, the timer will stop. * * @param now Current time in milliseconds (typically from millis()) * @return true if the timer is still running, false if stopped or elapsed */
| 40 | * @return true if the timer is still running, false if stopped or elapsed |
| 41 | */ |
| 42 | bool update(uint32_t now) { |
| 43 | if (!running) { |
| 44 | return false; |
| 45 | } |
| 46 | uint32_t elapsed = now - start_time; |
| 47 | if (elapsed > duration) { |
| 48 | running = false; |
| 49 | return false; |
| 50 | } |
| 51 | return true; |
| 52 | } |
| 53 | |
| 54 | private: |
| 55 | uint32_t start_time; // When the timer was started (in milliseconds) |