Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1702 - 1
/* Bulb mode demo */
2
/* Works with cameras which have bulb mode in shutter speed list (in other words, ones that don't have a letter 'B' on mode dial */
3
/* Tested with EOS Rebel XSI (450D) */
4
/* Camera has to be switched to manual mode */
5
 
6
#include <inttypes.h>
7
#include <avr/pgmspace.h>
8
 
9
//#include <Spi.h>
10
#include <Max3421e.h>
11
#include <Max3421e_constants.h>
12
#include <Max_LCD.h>
13
#include <Usb.h>
14
 
15
#include <ptp.h>
16
#include <canoneos.h>
17
 
18
#define DEV_ADDR        1
19
 
20
// Canon EOS 450D
21
#define DATA_IN_EP      1
22
#define DATA_OUT_EP     2
23
#define INTERRUPT_EP    3
24
#define CONFIG_NUM      1
25
 
26
#define SHUTTER_SPEED_BULB       0x0c
27
 
28
class CamStateHandlers : public EOSStateHandlers
29
{
30
      enum CamStates { stInitial, stDisconnected, stConnected };
31
      CamStates stateConnected;
32
 
33
public:
34
      CamStateHandlers() : stateConnected(stInitial)
35
      {
36
      };
37
 
38
      virtual void OnDeviceDisconnectedState(PTP *ptp);
39
      virtual void OnDeviceInitializedState(PTP *ptp);
40
} CamStates;
41
 
42
CanonEOS  Eos(DEV_ADDR, DATA_IN_EP, DATA_OUT_EP, INTERRUPT_EP, CONFIG_NUM, &CamStates);
43
 
44
void CamStateHandlers::OnDeviceDisconnectedState(PTP *ptp)
45
{
46
    if (stateConnected == stConnected || stateConnected == stInitial)
47
    {
48
        stateConnected = stDisconnected;
49
        Notify(PSTR("Camera disconnected\r\n"));
50
    }
51
}
52
 
53
void CamStateHandlers::OnDeviceInitializedState(PTP *ptp)
54
{
55
    if (stateConnected == stDisconnected)
56
    {
57
        stateConnected = stConnected;
58
 
59
         uint16_t rc = Eos.SetProperty(EOS_DPC_ShutterSpeed,SHUTTER_SPEED_BULB);
60
 
61
        if (rc != PTP_RC_OK)
62
            Message(PSTR("Error: "), rc);
63
    }
64
 
65
    Eos.StartBulb();
66
    delay(6000);
67
    Eos.StopBulb();
68
}
69
 
70
void setup()
71
{
72
  Serial.begin( 115200 );
73
  Serial.println("Start");
74
  Eos.Setup();
75
  delay( 200 );
76
}
77
 
78
void loop() {
79
    Eos.Task();
80
}