|
TinyRobotics
|
Represents a time duration with a specific unit (seconds, milliseconds, microseconds, minutes, or hours). More...
#include <Time.h>
Public Member Functions | |
| Time (float time, TimeUnit unit) | |
| void | setValue (float newTime, TimeUnit newUnit) |
| float | getValue (TimeUnit desiredUnit) const |
| Time | operator+ (const Time &other) const |
| Time | operator- (const Time &other) const |
| Time | operator* (float scalar) const |
| Time | operator/ (float scalar) const |
| bool | operator== (const Time &other) const |
| bool | operator!= (const Time &other) const |
| bool | operator< (const Time &other) const |
| bool | operator<= (const Time &other) const |
| bool | operator> (const Time &other) const |
| bool | operator>= (const Time &other) const |
| Time & | operator+= (const Time &other) |
| Time & | operator-= (const Time &other) |
| Time & | operator*= (float scalar) |
| Time & | operator/= (float scalar) |
Protected Attributes | |
| float | time = 0.0f |
| TimeUnit | unit = TimeUnit::MS |
Represents a time duration with a specific unit (seconds, milliseconds, microseconds, minutes, or hours).
Provides methods to set and get the time in different units, as well as handle unit conversion when retrieving the time in a desired unit. The internal representation of the time is stored in the unit specified at construction, and all operations ensure that the time can be accurately converted between supported units.
This class can be used for various applications such as navigation, robotics, or any scenario that requires time representation and manipulation. The getValue method allows for easy retrieval of the time in the desired unit, while the setValue method allows for updating the time measurement with a new value and unit. The class is designed to be simple and efficient for use in embedded systems, with basic unit conversion logic that covers common time units.