diff --git a/include/sta/devices/arduino/time.hpp b/include/sta/devices/arduino/time.hpp new file mode 100644 index 0000000..8d811e3 --- /dev/null +++ b/include/sta/devices/arduino/time.hpp @@ -0,0 +1,28 @@ +#ifndef STA_DEVICES_ARDUINO_TIME_HPP +#define STA_DEVICES_ARDUINO_TIME_HPP + +#include +#ifdef STA_PLATFORM_ARDUINO + +#include + +namespace sta +{ + /** + * @brief The current time in milliseconds. + * + * @return uint32_t Returns current time in milliseconds. + */ + uint32_t now(); + + /** + * @brief The current time in microseconds. + * + * @return uint32_t Returns the current time in microseconds. + */ + uint32_t nowUs(); +} // namespace sta + +#endif // STA_PLATFORM_ARDUINO + +#endif // STA_DEVICES_ARDUINO_TIME_HPP \ No newline at end of file diff --git a/src/devices/arduino/time.cpp b/src/devices/arduino/time.cpp new file mode 100644 index 0000000..8597c6c --- /dev/null +++ b/src/devices/arduino/time.cpp @@ -0,0 +1,19 @@ +#include + +#ifdef STA_PLATFORM_ARDUINO +#include + +namespace sta +{ + uint32_t now() + { + return millis(); + } + + uint32_t nowUs() + { + return micros(); + } +} // namespace sta + +#endif // STA_PLATFORM_ARDUINO