-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_03_Helpers.ino
62 lines (52 loc) · 1.06 KB
/
_03_Helpers.ino
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* Helper functions
*
* 20/05/2016
* Flanker
*/
//debug
void debug(String message) {
/*tft.setCursor(10, 100);
tft.setTextColor(WHITE,BLACK); tft.setTextSize(2);
tft.println(message);*/
Serial.println(message);
}
//
//Check if serial connection with PC is active
void HeartBeat() {
if (millis() - lastStatus > 1000) {
cStatus = false;
}
else {
cStatus = true;
}
}
//Convert speed from Kbps to Mbps
String SpeedConvert(int inc) {
if (inc > 999)
{
return String(inc / 1000) + "M";
}
else return String (inc) + "K";
}
//Benchmarking
//Acceps a bool flag.
//If true switches to microseconds
//Else it's milliseconds
String Benchmark (bool micro)
{
if (micro == true)
{
unsigned long currentMicros = micros();
String temp = String(currentMicros - previousMicros);
previousMicros = currentMicros;
return (temp + " micros");
}
else
{
unsigned long currentMicros = millis();
String temp = String(currentMicros - previousMicros);
previousMicros = currentMicros;
return (temp + " milis");
}
}