arduino-audio-tools
All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Modules Pages
Time.h
1#pragma once
3#include <iostream>
4#include <thread>
5
6// #ifndef DESKTOP_MILLIS_DEFINED
7// #define DESKTOP_MILLIS_DEFINED
8
9namespace audio_tools {
10
13 using namespace std::chrono;
14 // Get current time with precision of milliseconds
15 auto now = time_point_cast<milliseconds>(system_clock::now());
16 // sys_milliseconds is type time_point<system_clock, milliseconds>
17 using sys_milliseconds = decltype(now);
18 // Convert time_point to signed integral type
19 return now.time_since_epoch().count();
20}
21
22// sleep ms milliseconds
23void delay(unsigned long ms){
24 std::this_thread::sleep_for(std::chrono::milliseconds(ms));
25}
26
27// sleep us milliseconds
28void delayMicroseconds(unsigned int us){
29 std::this_thread::sleep_for(std::chrono::microseconds(us));
30}
31
32// Returns the micros of milliseconds passed since epich
33inline unsigned long micros(void){
34 using namespace std::chrono;
35 // Get current time with precision of milliseconds
36 auto now = time_point_cast<microseconds>(system_clock::now());
37 // sys_milliseconds is type time_point<system_clock, milliseconds>
38 using sys_milliseconds = decltype(now);
39 // Convert time_point to signed integral type
40 return now.time_since_epoch().count();
41}
42
43}
44
45// #endif
If you want to use the framework w/o Arduino you need to provide the implementation of a couple of cl...
Vector implementation which provides the most important methods as defined by std::vector....
Definition Vector.h:21
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition AudioConfig.h:885
uint32_t millis()
Returns the milliseconds since the start.
Definition Time.h:12