-
Notifications
You must be signed in to change notification settings - Fork 2
/
GoProCam.cpp
75 lines (61 loc) · 1.93 KB
/
GoProCam.cpp
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "GoProCam.h"
GoProCam::GoProCam(uint8_t* mac) {
memcpy(_mac, mac, 6);
}
void GoProCam::setIp(uint32_t ip) {
_ip = ip;
}
void GoProCam::resetIp() {
_ip = 0;
}
void GoProCam::setMac(uint8_t* mac) {
memcpy(_mac, mac, 6);
}
uint32_t GoProCam::getIp() {
return _ip;
}
uint8_t* GoProCam::getMac() {
return _mac;
}
void GoProCam::setCamTimeGotMillis(unsigned long cMillis) {
_camTimeGotMillis = cMillis;
}
void GoProCam::setCamTime(uint8_t* camTime) {
memcpy(_camTime, camTime, 7);
}
const char *GoProCam::getTimeString() {
if (_camTimeGotMillis > 0) {
char *dt = new char[21];
char buf[21];
unsigned long camTimeSeconds = ((unsigned long)(_camTime[3] * 86400000) +
(unsigned long)(_camTime[4] * 3600000) +
(unsigned long)(_camTime[5] * 60000) +
(unsigned long)(_camTime[6] * 1000) +
(unsigned long)(millis() - _camTimeGotMillis))
/ 1000;
uint8_t days = (float)camTimeSeconds / 60.0f / 60.0f / 24.0f;
uint8_t hours = (float)(camTimeSeconds - (days * 86400)) / 60.0f / 60.0f;
uint8_t minutes = (float)(camTimeSeconds - (days * 86400) - (hours * 3600)) / 60.0f;
uint8_t seconds = camTimeSeconds - (days * 86400) - (hours * 3600) - (minutes * 60);
snprintf(buf,
sizeof(buf),
"%d-%02d-%02d, %02d:%02d:%02d",
(int)_camTime[0] * 256 + (int)_camTime[1], //Y
(int)_camTime[2], //M
(int)days, //D
(int)hours, //h
(int)minutes, //m
(int)seconds //s
);
strcpy(dt, buf);
return dt;
} else {
return "n/a";
}
}
void GoProCam::setBattLevel(uint8_t percent){
_battLevel = percent;
}
uint8_t GoProCam::getBattLevel(){
return _battLevel;
}