-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathGoProControl.ino
180 lines (145 loc) · 3.09 KB
/
GoProControl.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#include <GoProControl.h>
#include "Secrets.h"
/*
Control your GoPro with the Serial Monitor
edit the file Secrets.h with your camera netword name and password
CAMERA could be: HERO3, HERO4, HERO5, HERO6, HERO7, FUSION, HERO8, MAX
*/
#define CAMERA HERO3 // Change here for your camera
GoProControl gp(GOPRO_SSID, GOPRO_PASS, CAMERA);
void setup()
{
gp.enableDebug(&Serial);
}
void loop()
{
char in = 0;
if (Serial.available() > 0)
{
in = Serial.read();
}
switch (in)
{
default:
break;
// Connect
case 'b':
gp.begin();
break;
case 'c':
Serial.print("Connected: ");
Serial.println(gp.isConnected() == true ? "Yes" : "No");
break;
case 'p':
gp.confirmPairing();
break;
case 's':
if (CAMERA == HERO3)
{
char * statusChar;
statusChar = gp.getStatus();
Serial.println("Status :");
for(int i = 0; i < 56; i++)
{
Serial.print(statusChar[i], HEX);Serial.print(" ");
}
Serial.println("");
Serial.println("End Status.");
if (statusChar[0] == 0x00){Serial.println("camera ON");}
else{Serial.println("camera OFF");}
free(statusChar); // Don't forget to free memory
}
else
{
char * statusChar;
statusChar = gp.getStatus();
Serial.println("Status :");
Serial.println(statusChar);
free(statusChar); // Don't forget to free memory
}
break;
case 'm': // DO NOT USE WHEN CAMERA IS OFF, IT FREEZE ESP
char* medialist;
medialist = gp.getMediaList();
Serial.println("Media List:");
Serial.println(medialist);
free(medialist); // Don't forget to free memory
break;
// Turn on and off
case 'T':
gp.turnOn();
break;
case 't':
gp.turnOff();
break;
// Take a picture of start a video
case 'A':
gp.shoot();
break;
// Stop the video
case 'S':
gp.stopShoot();
break;
// Check if it is recording
case 'r':
Serial.print("Recording: ");
Serial.println(gp.isRecording() == true ? "Yes" : "No");
break;
// Set modes
case 'V':
gp.setMode(VIDEO_MODE);
break;
case 'P':
gp.setMode(PHOTO_MODE);
break;
case 'M':
gp.setMode(MULTISHOT_MODE);
break;
// Change the orientation
case 'U':
gp.setOrientation(ORIENTATION_UP);
break;
case 'D':
gp.setOrientation(ORIENTATION_DOWN);
break;
// Change other parameters
case 'f':
gp.setVideoFov(MEDIUM_FOV);
break;
case 'F':
gp.setFrameRate(FR_120);
break;
case 'R':
gp.setVideoResolution(VR_1080p);
break;
case 'h':
gp.setPhotoResolution(PR_12MP_WIDE);
break;
case 'L':
gp.setTimeLapseInterval(60);
break;
// Localize the camera
case 'O':
gp.localizationOn();
break;
case 'o':
gp.localizationOff();
break;
// Delete some files, be carefull!
case 'l':
gp.deleteLast();
break;
case 'g':
gp.deleteAll();
break;
// Print useful data
case 'd':
gp.printStatus();
break;
// Close the connection
case 'X':
gp.end();
break;
}
gp.keepAlive(); // not needed on HERO3
}