Remove whitespace, update email addresses and URLs.
[kodak.git] / dc210camera.h
1 //+----------------------------------------------------------------------------
2 //
3 // File:     kodak.h
4 //
5 // Module:   
6 //
7 // Synopsis: 
8 //
9 // Copyright (C) 1999 Microsoft Corporation.  All rights reserved.
10 //
11 // Author:       sgasch
12 //
13 // Created    5 Jun 1999
14 //
15 //+----------------------------------------------------------------------------
16
17 #ifndef _KODAK
18 #define _KODAK
19
20 #include "camera.h"
21 #include "global.h"
22 #include "serial.h"
23
24 //
25 // Status codes
26 //
27 #define DC210_COMMAND_COMPLETE       0x00
28 #define DC210_COMMAND_ACK            0xD1
29 #define DC210_CORRECT_PACKET         0xD2
30 #define DC210_COMMAND_NAK            0xE1
31 #define DC210_ILLEGAL_PACKET         0xE3
32 #define DC210_BUSY                   0xF0
33 #define DC210_ABORT                  0xE4
34
35 //
36 // Packet codes
37 //
38 #define DC210_NORMAL_PACKET          0x01
39 #define DC210_FINAL_PACKET           0x80
40 #define DC210_ABORT_PACKET           0xFF
41 #define DC210_NORMAL_RECEIVE_PACKET  0x01
42
43 //
44 // Commands
45 //
46 #define DC210_SET_RESOLUTION         0x36
47 #define DC210_SET_FORMAT             0x37
48 #define DC210_SET_SPEED              0x41
49 #define DC210_PICTURE_DOWNLOAD       0x64
50 #define DC210_PICTURE_INFO           0x65
51 #define DC210_PICTURE_THUMBNAIL      0x66
52 #define DC210_SET_FLASH              0x72
53 #define DC210_SET_COMPRESSION        0x71
54 #define DC210_SET_SHUTTER_DELAY      0x74
55 #define DC210_SET_ZOOM               0x78
56 #define DC210_TAKE_PICTURE           0x7C
57 #define DC210_ERASE                  0x7B
58 #define DC210_INITIALIZE             0x7E
59 #define DC210_STATUS                 0x7F
60 #define DC210_RESET                  0x8A
61 #define DC210_FORMAT_MEMORY_CARD     0x95
62
63 typedef enum
64 {
65         battery_unknown,
66         battery_full,
67         battery_low,
68         battery_empty
69
70 } DC210_BATTERY_STATE;
71
72 typedef enum
73 {
74         zoom_unknown,
75         zoom_fully_zoomed,
76         zoom_3,
77         zoom_2,
78         zoom_1,
79         zoom_wideangle,
80         zoom_closeup
81
82 } DC210_ZOOM_STATE;
83
84 typedef enum
85 {
86         compression_unknown,
87         compression_none,
88         compression_low,
89         compression_medium,
90         compression_high
91
92 } DC210_COMPRESSION_STATE;
93
94 typedef enum
95 {
96         flash_unknown,
97         flash_auto,
98         flash_fill,
99         flash_off,
100         flash_auto_redeye,
101         flash_fill_redeye
102
103 } DC210_FLASH_STATE;
104
105 typedef enum
106 {
107         format_unknown,
108         format_raw,
109         format_jpeg,
110         format_flashpix
111
112 } DC210_FILE_FORMAT;
113
114 #define DC210_MEMORY_CARD_INSERTED             0x40
115 #define DC210_MEMORY_CARD_WRITE_PROTECTED      0x20
116 #define DC210_MEMORY_CARD_ILLEGAL              0x10
117 #define DC210_MEMORY_CARD_FORMATTED            0x08
118 #define DC210_MEMORY_CARD_OPENED               0x04
119
120 class CKodakDC210 : public CCamera
121 {
122         friend class CKodakDC210Photo;
123
124 public:
125         CKodakDC210(char *szDevice, int iSpeed);
126         ~CKodakDC210(void);
127
128         bool Initialize(void);
129         bool SetSpeed(int iBps);
130         bool TakePicture(void);
131
132         bool GetRawStatusData(BYTE *pData);
133         bool GetFirmwareVersion(int *piMajor, int *piMinor);
134         bool GetRomVersion(int *piMajor, int *piMinor);
135         bool GetBatteryStatus(DC210_BATTERY_STATE *pState);
136         bool IsAdapterAttached(bool *pfAttached);
137         bool GetClock(int *piCameraClock);
138         bool GetZoomState(DC210_ZOOM_STATE *pZoom);
139         bool SetZoomState(DC210_ZOOM_STATE eZoom);
140         bool GetResolution(int *piWidth, int *piHeight);
141         bool IsFlashCharged(bool *pfCharged);
142         bool GetFlashState(DC210_FLASH_STATE *pState);
143         bool SetFlashState(bool fState);
144         bool SetFlashState(DC210_FLASH_STATE eState);
145         bool GetCompressionState(DC210_COMPRESSION_STATE *pState);
146         bool SetCompressionState(DC210_COMPRESSION_STATE eCompression);
147         bool IsUsingJpeg(bool *pfJPEG);
148         bool IsUsingFlashPix(bool *pfFlashPix);
149         bool GetPictureFormat(DC210_FILE_FORMAT *eFormat);
150         bool SetPictureFormat(DC210_FILE_FORMAT eFormat);
151         bool GetLifetimePictureCount(int *piPictures);
152         bool GetLifetimeFlashCount(int *piFlashes);
153         bool IsTimerOn(bool *pfTimer);
154         bool IsMemoryCardInserted(bool *pfInserted);
155         bool IsMemoryCardWriteProtected(bool *pfInserted);
156         bool IsMemoryCardIllegal(bool *pfInserted);
157         bool IsMemoryCardFormatted(bool *pfInserted);
158         bool IsMemoryCardOpened(bool *pfInserted);
159         bool GetMemoryCardBitvector(BYTE *pbBitv);
160         bool IsUsingNTSC(bool *pfNTSC);
161         bool IsUsingPAL(bool *pfPAL);
162         bool GetNumberPictures(int *piNum);
163         bool GetRemainingPicturesLowCompression(int *piNum);
164         bool GetRemainingPicturesMedCompression(int *piNum);
165         bool GetRemainingPicturesHighCompression(int *piNum);
166         bool GetMemoryCardVolumeLabel(char *szLabel);
167         bool GetIdString(char *szId);
168         bool GetTimeValue(int *piClock);
169         bool GetTimeString(char *pszTime);
170         bool GetTimeMinutes(int *piMin);
171         bool GetTimeHours(int *piHrs);
172         bool GetTimeSeconds(int *piSec);
173         bool GetTimeMonth(int *piMon);
174         bool GetTimeDay(int *piDay);
175         bool GetTimeYear(int *piYear);
176         bool EraseAllPictures(void);
177         bool SetResolution(int iWidth, int iHeight);
178         bool Reset(void);
179         bool ToggleShutterDelay(BOOL fEnable);
180         bool SetExposureCompensationValue(float floatValue);
181         bool FormatMemoryCard(void);
182         bool SetIdString(char *szId);
183
184 private:
185         bool CommandComplete(void);
186         bool GetAck(void);
187         bool SendCommand(int bCommand, BYTE arg1, BYTE arg2, BYTE arg3, BYTE arg4);
188         bool ReadPacket(BYTE *buf, int iPacketSize);
189         bool SendPacket(BYTE bControl, BYTE *buf, int iLength);
190         bool ComputeChecksum(BYTE *pbChecksum, BYTE *buf, int iSize);
191
192         bool RefreshProperties(void);
193         
194         CSerialPort *_pSerialPort;
195         bool _fInitialized;
196         int _iMaxAttempts;
197         BYTE _bRawStatusData[256];
198
199 };
200
201 #endif // _KODAK
202