-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathArduinoSystem.cpp
More file actions
38 lines (30 loc) · 790 Bytes
/
ArduinoSystem.cpp
File metadata and controls
38 lines (30 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "ArduinoSystem.h"
void ArduinoSystem::set_heartbeat(uint32_t period) {
this->heartbeat_period = period;
}
uint32_t ArduinoSystem::get_heartbeat() {
return this->heartbeat_period;
}
bool ArduinoSystem::has_beaten() {
uint32_t current = millis();
if (current - heartbeat_current > heartbeat_period) {
this->heartbeat_current = current;
return true;
}
return false;
}
uint32_t ArduinoSystem::get_elapsed_time() {
uint32_t current = millis();
uint32_t elapsed_time = current - elapsed_current;
elapsed_current = current;
return elapsed_time;
}
void ArduinoSystem::sleep(uint32_t duration) {
delay(duration);
}
void ArduinoSystem::exit() {
/* throw std::exception();
#if defined(ESP8266)
ESP.reset();
#endif*/
}