-
Notifications
You must be signed in to change notification settings - Fork 2
/
camera.ino
56 lines (48 loc) · 1.44 KB
/
camera.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
//deprecated since revision 2 board
//no longer using canon cameras via the CHDK
bool focusing = false;
#ifdef CANON_PIN
uint8_t photoInterval = 10; //in seconds
static const unsigned int focus_time = 1000; //milliseconds
unsigned long last_photo = 0;
void SetupCamera(){
pinMode(CANON_PIN,OUTPUT);
digitalWrite(CANON_PIN,LOW);
}
void CheckCamera(){
if(GPS.Satellites>=3 || focusing){
if(millis() - last_photo >= (photoInterval*1000) && !focusing){
digitalWrite(CANON_PIN,HIGH);
focusing = true;
last_photo = millis();
}
if(focusing && ((millis() - last_photo) >= focus_time)){
digitalWrite(CANON_PIN,LOW);
focusing = false;
last_photo = millis();
if(GPS.AltitudeF<900){
photoInterval = 30;
}else if(GPS.AltitudeF>=900 && GPS.AltitudeF<5000){
photoInterval = 10;
}else if(GPS.AltitudeF>=5000 && GPS.AltitudeF<17000){
photoInterval = 15;
}else if(GPS.AltitudeF>=17000&&GPS.AltitudeF<34000){
photoInterval = 20;
}else if(GPS.AltitudeF>=34000&&GPS.AltitudeF<51000){
photoInterval = 25;
}else if(GPS.AltitudeF>=51000&&GPS.AltitudeF<68000){
photoInterval = 20;
}else if(GPS.AltitudeF>=68000&&GPS.AltitudeF<90000){
photoInterval = 15;
}else if(GPS.AltitudeF>=90000){
photoInterval = 10;
}else{
photoInterval = 15;
}
}
}
}
#endif
bool isFocusing(){
return focusing;
}