PIDUINO
Loading...
Searching...
No Matches
clock.h
1/* Copyright © 2018-2025 Pascal JEAN, All rights reserved.
2 * This file is part of the Piduino Library.
3 *
4 * The Piduino Library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 3 of the License, or (at your option) any later version.
8 *
9 * The Piduino Library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with the Piduino Library; if not, see <http://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include <cstdint>
20
26namespace Piduino {
27
39 class Clock {
40
41 public:
49
53 virtual ~Clock();
54
64#ifdef __DOXYGEN__
65 static inline void sleep (unsigned long s);
66#else
67 static inline void sleep (unsigned long s) {
68 delay (s * 1000UL);
69 }
70#endif
71
81 static void delay (unsigned long ms);
82
95 static void delayMicroseconds (unsigned long us);
96
103 unsigned long millis();
104
111 unsigned long micros();
112
113 private:
114 uint64_t _us;
115 uint64_t _ms;
116 };
117 // ---------------------------------------------------------------------------
118 //
119 // Piduino Clock Global Object
120 //
121 // ---------------------------------------------------------------------------
122 extern Clock clk;
126}
127
128/* ========================================================================== */
Horloge.
Definition clock.h:39
unsigned long millis()
Number of milliseconds.
static void sleep(unsigned long s)
Pauses for the amount of seconds.
Definition clock.h:67
Clock()
Constructor.
uint64_t _ms
Definition clock.h:115
static void delay(unsigned long ms)
Pauses for the amount of milliseconds.
static void delayMicroseconds(unsigned long us)
Pauses for the amount of microseconds.
uint64_t _us
Definition clock.h:114
unsigned long micros()
Number of microseconds.
virtual ~Clock()
Destructor.
Clock clk
Piduino Clock Global Object.
Global namespace for Piduino.
Definition board.h:28