Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1702 - 1
#if !defined(__HDRCAPTURE_H__)
2
#define __HDRCAPTURE_H__
3
 
4
#include <inttypes.h>
5
#include <avr/pgmspace.h>
6
#include <qep_port.h>
7
#include <ptp.h>
8
#include <canoneos.h>
9
#include <simplefifo.h>
10
#include <valuelist.h>
11
 
12
#define PTP_TIMEOUT    250
13
 
14
#define TA_PTP_TIMEOUT   0x00
15
#define TA_SELF_TIMER    0x03
16
#define TA_INTR_TIMER    0x05
17
#define TA_BULB_TIMER    0x07
18
 
19
enum HDRCaptureSignals
20
{
21
    TICK_MILLIS_SIG = Q_USER_SIG,
22
    SET_FRAMES_SIG,
23
    SET_SELF_TIMEOUT_SIG,
24
    SET_FRAME_TIMEOUT_SIG,
25
    SET_BRACKETING_SIG,
26
    RUN_SIG,
27
    ABORT_SIG,
28
    TIMEOUT_SIG,
29
    SET_TIMEOUT_SIG,
30
    PTP_RC_SIG,
31
    PTP_RC_OK_SIG
32
};
33
 
34
struct SetTimeoutEvt : public QEvent
35
{
36
    uint32_t   timeout;
37
    uint8_t    attribs;
38
};
39
 
40
struct SetEvt : public QEvent
41
{
42
    uint32_t    value;
43
};
44
 
45
struct SetBktEvt : public QEvent
46
{
47
    uint8_t  step;
48
    uint8_t  negative;
49
    uint8_t  positive;
50
};
51
 
52
struct PTP_RC_Evt : public QEvent
53
{
54
    uint16_t  rc;
55
};
56
 
57
class HDRCapture : public QHsm
58
{
59
    uint16_t    frmCntdn;
60
    uint16_t    frmCount;
61
    uint32_t    selfTimeout;
62
    uint32_t    frameTimeout;
63
    uint8_t     bktStep;
64
    uint8_t     bktNegative;
65
    uint8_t     bktPositive;
66
    uint8_t     bktCntdn;
67
    uint8_t     bktPos;
68
    uint8_t     bktOldVal;
69
 
70
    CanonEOS    &Eos;
71
 
72
    SetTimeoutEvt  toEvt;
73
    PTP_RC_Evt     rcEvt;
74
    QEvent         qpEvt;
75
 
76
    QStateHandler  activeHistory;
77
 
78
    SimpleFIFO<QEvent*, 4>  theQueue;
79
 
80
public:
81
    HDRCapture(CanonEOS &eos) :
82
        QHsm((QStateHandler)&HDRCapture::Initial),
83
        frmCount(0),
84
        frmCntdn(0),
85
        selfTimeout(0),
86
        frameTimeout(0),
87
        bktStep(0),
88
        bktNegative(0),
89
        bktPositive(0),
90
        bktCntdn(0),
91
        bktPos(0),
92
        bktOldVal(0),
93
        Eos(eos),
94
        activeHistory(NULL)
95
    {
96
        toEvt.sig = SET_TIMEOUT_SIG;
97
        rcEvt.sig = PTP_RC_SIG;
98
    };
99
    void PostEvent(QEvent *e)
100
    {
101
        theQueue.Push(e);
102
    };
103
    void Run()
104
    {
105
        QEvent *e = NULL;
106
 
107
        while ( (e = theQueue.Pop()) )
108
            dispatch(e);
109
    };
110
 
111
protected:
112
    static QState Initial(HDRCapture *me, QEvent const *e);
113
    static QState Inactive(HDRCapture *me, QEvent const *e);
114
    static QState Active(HDRCapture *me, QEvent const *e);
115
    static QState SelfTimer(HDRCapture *me, QEvent const *e);
116
    static QState PreCapture(HDRCapture *me, QEvent const *e);
117
    static QState Capture(HDRCapture *me, QEvent const *e);
118
    static QState PostCapture(HDRCapture *me, QEvent const *e);
119
    static QState ExpCompSet(HDRCapture *me, QEvent const *e);
120
    static QState SaveSettings(HDRCapture *me, QEvent const *e);
121
    static QState RestoreSettings(HDRCapture *me, QEvent const *e);
122
    static QState Timeout(HDRCapture *me, QEvent const *e);
123
 
124
    virtual void OnFrameCaptured(uint16_t left) {};
125
    virtual void OnBktFrameCaptured(uint16_t left) {};
126
    virtual void OnSelfTimerProgress(uint32_t left) {};
127
    virtual void OnIntrTimerProgress(uint32_t left) {};
128
};
129
 
130
#endif // __HDRCAPTURE_H__