-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconversion.cpp
More file actions
34 lines (27 loc) · 1015 Bytes
/
conversion.cpp
File metadata and controls
34 lines (27 loc) · 1015 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
#include "conversion.hpp"
unsigned long bufferToLong(byte* buffer, int start) {
unsigned long result = (unsigned long) buffer[start]
| (unsigned long) buffer[start + 1] << 8
| (unsigned long) buffer[start + 2] << 16
| (unsigned long) buffer[start + 3] << 24;
return result;
}
void longToBuffer(byte* buffer, unsigned long value, int start) {
buffer[start] = value;
buffer[start + 1] = value >> 8;
buffer[start + 2] = value >> 16;
buffer[start + 3] = value >> 24;
}
String longToTime(unsigned long convertTime) {
convertTime /= 60;
unsigned long hours = convertTime / 60;
unsigned long minutes = convertTime % 60;
String hoursS = String(hours);
String minutesS = String(minutes);
if (hoursS.length() == 1)
hoursS = "0" + hoursS;
if (minutesS.length() == 1)
minutesS = "0" + minutesS;
String result = hoursS + ":" + minutesS;
return result;
}