Skip to content

Commit 2be8031

Browse files
committed
New Micros API
1 parent 83a2b2f commit 2be8031

7 files changed

Lines changed: 18 additions & 5 deletions

File tree

Devices/Device.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ namespace Device
2525
void Bootloader();
2626
void ErrorHandler();
2727

28+
uint64_t Micros();
29+
2830
void DeviceSettings();
2931

3032
void Log(string &format, va_list &valst);

Devices/MatrixESP32/Family.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ namespace Device
160160
}
161161

162162
void ErrorHandler() {}
163+
164+
uint64_t Micros() {
165+
struct timeval tv_now;
166+
gettimeofday(&tv_now, NULL);
167+
return (int64_t)tv_now.tv_sec * 1000000L + (int64_t)tv_now.tv_usec;
168+
}
163169
}
164170

165171
namespace MatrixOS::SYS

OS/Framework/Color/ColorEffects.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace MatrixOS::SYS
77
{
8-
uint32_t Millis();
8+
uint64_t Millis();
99
}
1010

1111
namespace ColorEffects

OS/Framework/KeyEvent/KeyEvent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// Avoid recursive include
1515
namespace MatrixOS::SYS
1616
{
17-
uint32_t Millis(void);
17+
uint64_t Millis(void);
1818
}
1919

2020
namespace MatrixOS::Logging

OS/Framework/Timer/Timer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Avoid recursive include
66
namespace MatrixOS::SYS
77
{
8-
uint32_t Millis(void);
8+
uint64_t Millis(void);
99
}
1010

1111
class Timer {

OS/MatrixOS.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ namespace MatrixOS
3232
void Begin(void);
3333
void InitSysModules(void);
3434

35-
uint32_t Millis(void);
35+
uint64_t Millis(void);
36+
uint64_t Micros(void);
3637
void DelayMs(uint32_t intervalMs);
3738

3839
void Reboot(void);

OS/System/System.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,14 @@ namespace MatrixOS::SYS
103103
HID::Init();
104104
}
105105

106-
uint32_t Millis() {
106+
uint64_t Millis() {
107107
return ((((uint64_t)xTaskGetTickCount()) * 1000) / configTICK_RATE_HZ);
108108
}
109109

110+
uint64_t Micros() {
111+
return Device::Micros();
112+
}
113+
110114
void DelayMs(uint32_t intervalMs) {
111115
vTaskDelay(pdMS_TO_TICKS(intervalMs));
112116
}

0 commit comments

Comments
 (0)