Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1702 - 1
/* EOS event visualizer. Connect camera and start pressing some buttons - the events would be printed on the screen */
2
/* doesn't work very well with XSI */
3
#include <inttypes.h>
4
#include <avr/pgmspace.h>
5
 
6
//#include <Spi.h>
7
#include <Max3421e.h>
8
#include <Max3421e_constants.h>
9
#include <Max_LCD.h>
10
#include <Usb.h>
11
 
12
#include <ptp.h>
13
#include <canoneos.h>
14
#include <simpletimer.h>
15
 
16
#define DEV_ADDR        1
17
 
18
// Canon EOS 400D
19
#define DATA_IN_EP      1
20
#define DATA_OUT_EP     2
21
#define INTERRUPT_EP    3
22
#define CONFIG_NUM      1
23
 
24
class CamStateHandlers : public EOSStateHandlers
25
{
26
      enum CamStates { stInitial, stDisconnected, stConnected };
27
      CamStates   stateConnected;
28
 
29
public:
30
      CamStateHandlers() : stateConnected(stInitial) {};
31
 
32
      virtual void OnDeviceDisconnectedState(PTP *ptp);
33
      virtual void OnDeviceInitializedState(PTP *ptp);
34
};
35
 
36
CamStateHandlers    CamStates;
37
SimpleTimer         PTPPollTimer;
38
CanonEOS            Eos(DEV_ADDR, DATA_IN_EP, DATA_OUT_EP, INTERRUPT_EP, CONFIG_NUM, &CamStates);
39
 
40
 
41
void CamStateHandlers::OnDeviceDisconnectedState(PTP *ptp)
42
{
43
    if (stateConnected == stConnected || stateConnected == stInitial)
44
    {
45
        stateConnected = stDisconnected;
46
        PTPPollTimer.Disable();
47
        Notify(PSTR("\r\nDevice disconnected.\r\n"));
48
    }
49
}
50
 
51
void CamStateHandlers::OnDeviceInitializedState(PTP *ptp)
52
{
53
    if (stateConnected == stDisconnected)
54
    {
55
        stateConnected = stConnected;
56
        PTPPollTimer.Enable();
57
    }
58
}
59
 
60
void OnPTPPollTimer()
61
{
62
    EOSEventDump  hex;
63
    Eos.EventCheck(&hex);
64
}
65
 
66
void setup()
67
{
68
    Serial.begin( 115200 );
69
    Serial.println("Start");
70
    Eos.Setup();
71
    delay( 200 );
72
    PTPPollTimer.Set(OnPTPPollTimer, 500);
73
}
74
 
75
void loop()
76
{
77
    Eos.Task();
78
    PTPPollTimer.Run();
79
}
80