Declares tiny helpers for elapsed-time arithmetic that must never wrap. More...
#include <stdint.h>

Go to the source code of this file.
Functions | |
| constexpr auto | timeUtils::addElapsedTimeSaturated (uint16_t currentAge_ms, uint16_t elapsed_ms) -> uint16_t |
| Add one elapsed-time delta to a 16-bit age without wrapping. | |
Declares tiny helpers for elapsed-time arithmetic that must never wrap.
Copyright 2026 Jacopo Labardi
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
inlineconstexpr |
Add one elapsed-time delta to a 16-bit age without wrapping.
The firmware uses 16-bit "age" counters in several hot paths. Saturating the addition keeps those counters monotonic even after very long loop stalls, debugger pauses or temporary scheduling hiccups, while staying cheaper than carrying 32-bit timestamps through every object.
| currentAge_ms | Age already accumulated before the current loop pass. |
| elapsed_ms | Additional milliseconds measured since the previous pass. |
UINT16_MAX. 
