libxr 1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
webasm_timebase.hpp
1#pragma once
2
3#include <chrono>
4#include <cstdint>
5
6#include "timebase.hpp"
7
8namespace LibXR
9{
10
15{
16 public:
18 {
19 // 初始化基准时间点
20 start_time_ = std::chrono::system_clock::now();
21 }
22
28 {
29 auto now = std::chrono::system_clock::now();
30 auto us =
31 std::chrono::duration_cast<std::chrono::microseconds>(now - start_time_).count();
32 return static_cast<TimestampUS>(us % UINT32_MAX);
33 }
34
40 {
41 auto now = std::chrono::system_clock::now();
42 auto ms =
43 std::chrono::duration_cast<std::chrono::milliseconds>(now - start_time_).count();
44 return static_cast<TimestampMS>(ms % UINT32_MAX);
45 }
46
47 private:
48 std::chrono::system_clock::time_point start_time_;
49};
50
51} // namespace LibXR
时间基类,用于提供高精度时间戳。 Timebase class for providing high-precision timestamps.
Definition timebase.hpp:18
表示毫秒级时间戳的类。Class representing a timestamp in milliseconds.
表示微秒级时间戳的类。Class representing a timestamp in microseconds.
WebAsmTimebase 类,用于获取 WebAssembly 系统的时间基准。
TimestampUS _get_microseconds() override
获取当前时间戳(微秒级)
TimestampMS _get_milliseconds() override
获取当前时间戳(毫秒级)
LibXR Color Control Library / LibXR终端颜色控制库
Definition esp_gpio.hpp:8
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值