Browse Source

This thing can take pictures now!

master
Peter J. Jones 5 years ago
parent
commit
60b247be91
99 changed files with 122 additions and 19555 deletions
  1. 0
    5
      lib/Arduino_Camera_Control/README
  2. 0
    235
      lib/Arduino_Camera_Control/canoneos.cpp
  3. 0
    151
      lib/Arduino_Camera_Control/canoneos.h
  4. 0
    76
      lib/Arduino_Camera_Control/canonps.cpp
  5. 0
    165
      lib/Arduino_Camera_Control/canonps.h
  6. 0
    15
      lib/Arduino_Camera_Control/copying.txt
  7. 0
    296
      lib/Arduino_Camera_Control/eosvaluetitles.h
  8. 0
    80
      lib/Arduino_Camera_Control/examples/EOSBulb/EOSBulb.pde
  9. 0
    556
      lib/Arduino_Camera_Control/examples/EOSCamController/EOSCamController.pde
  10. 0
    49
      lib/Arduino_Camera_Control/examples/EOSCamController/camcontroller.h
  11. 0
    50
      lib/Arduino_Camera_Control/examples/EOSCamController/controls.cpp
  12. 0
    50
      lib/Arduino_Camera_Control/examples/EOSCamController/controls.h
  13. 0
    51
      lib/Arduino_Camera_Control/examples/EOSCamController/dataitem.cpp
  14. 0
    194
      lib/Arduino_Camera_Control/examples/EOSCamController/dataitem.h
  15. 0
    191
      lib/Arduino_Camera_Control/examples/EOSCamController/eoseventparser.cpp
  16. 0
    75
      lib/Arduino_Camera_Control/examples/EOSCamController/eoseventparser.h
  17. 0
    3
      lib/Arduino_Camera_Control/examples/EOSCamController/expcomp_macro.h
  18. 0
    336
      lib/Arduino_Camera_Control/examples/EOSCamController/hdrcapture.cpp
  19. 0
    130
      lib/Arduino_Camera_Control/examples/EOSCamController/hdrcapture.h
  20. 0
    39
      lib/Arduino_Camera_Control/examples/EOSCamController/menu.cpp
  21. 0
    200
      lib/Arduino_Camera_Control/examples/EOSCamController/menu.h
  22. 0
    43
      lib/Arduino_Camera_Control/examples/EOSCamController/screen.cpp
  23. 0
    32
      lib/Arduino_Camera_Control/examples/EOSCamController/screen.h
  24. 0
    89
      lib/Arduino_Camera_Control/examples/EOSCamController/screenitem.cpp
  25. 0
    36
      lib/Arduino_Camera_Control/examples/EOSCamController/screenitem.h
  26. 0
    71
      lib/Arduino_Camera_Control/examples/EOSCapture/EOSCapture.pde
  27. 0
    80
      lib/Arduino_Camera_Control/examples/EOSEventLab/EOSEventLab.pde
  28. 0
    83
      lib/Arduino_Camera_Control/examples/EOSEventMonitor/EOSEventMonitor.pde
  29. 0
    87
      lib/Arduino_Camera_Control/examples/EOSFocus/EOSFocus.pde
  30. 0
    114
      lib/Arduino_Camera_Control/examples/EOSHDRCapture/EOSHDRCapture.pde
  31. 0
    9
      lib/Arduino_Camera_Control/examples/EOSHDRCapture/expcomp_macro.h
  32. 0
    336
      lib/Arduino_Camera_Control/examples/EOSHDRCapture/hdrcapture.cpp
  33. 0
    130
      lib/Arduino_Camera_Control/examples/EOSHDRCapture/hdrcapture.h
  34. 0
    428
      lib/Arduino_Camera_Control/examples/EOSRemote/EOSConsole.cpp
  35. 0
    51
      lib/Arduino_Camera_Control/examples/EOSRemote/EOSConsole.h
  36. 0
    147
      lib/Arduino_Camera_Control/examples/EOSRemote/EOSRemote.pde
  37. 0
    212
      lib/Arduino_Camera_Control/examples/EOSRemote/eoseventparser.cpp
  38. 0
    74
      lib/Arduino_Camera_Control/examples/EOSRemote/eoseventparser.h
  39. 0
    263
      lib/Arduino_Camera_Control/examples/EOSRemote/valuetitles.h
  40. 0
    106
      lib/Arduino_Camera_Control/examples/PSCapture/PSCapture.pde
  41. 0
    86
      lib/Arduino_Camera_Control/examples/PSCapture/pseventparser.cpp
  42. 0
    29
      lib/Arduino_Camera_Control/examples/PSCapture/pseventparser.h
  43. 0
    298
      lib/Arduino_Camera_Control/examples/PSCapture/ptpobjinfoparser.cpp
  44. 0
    83
      lib/Arduino_Camera_Control/examples/PSCapture/ptpobjinfoparser.h
  45. 0
    96
      lib/Arduino_Camera_Control/examples/PSCapture/sample_output.txt
  46. 0
    105
      lib/Arduino_Camera_Control/examples/PSDevProp/PSDevProp.pde
  47. 0
    368
      lib/Arduino_Camera_Control/examples/PSDevProp/devpropparser.cpp
  48. 0
    167
      lib/Arduino_Camera_Control/examples/PSDevProp/devpropparser.h
  49. 0
    2290
      lib/Arduino_Camera_Control/examples/PSDevProp/sample_output_a640.txt
  50. 0
    110
      lib/Arduino_Camera_Control/examples/PSRemote/PSRemote.pde
  51. 0
    475
      lib/Arduino_Camera_Control/examples/PSRemote/psconsole.cpp
  52. 0
    56
      lib/Arduino_Camera_Control/examples/PSRemote/psconsole.h
  53. 0
    85
      lib/Arduino_Camera_Control/examples/PSRemote/pseventparser.cpp
  54. 0
    29
      lib/Arduino_Camera_Control/examples/PSRemote/pseventparser.h
  55. 0
    298
      lib/Arduino_Camera_Control/examples/PSRemote/ptpobjinfoparser.cpp
  56. 0
    83
      lib/Arduino_Camera_Control/examples/PSRemote/ptpobjinfoparser.h
  57. 0
    71
      lib/Arduino_Camera_Control/examples/PTPCapture/PTPCapture.pde
  58. 0
    78
      lib/Arduino_Camera_Control/examples/PTPDevInfo/PTPDevInfo.pde
  59. 0
    714
      lib/Arduino_Camera_Control/examples/PTPDevInfo/devinfoparser.cpp
  60. 0
    295
      lib/Arduino_Camera_Control/examples/PTPDevInfo/devinfoparser.h
  61. 0
    340
      lib/Arduino_Camera_Control/gpl2.txt
  62. 0
    249
      lib/Arduino_Camera_Control/mtpconst.h
  63. 0
    369
      lib/Arduino_Camera_Control/psvaluetitles.h
  64. 0
    892
      lib/Arduino_Camera_Control/ptp.cpp
  65. 0
    183
      lib/Arduino_Camera_Control/ptp.h
  66. 0
    73
      lib/Arduino_Camera_Control/ptpcallback.cpp
  67. 0
    159
      lib/Arduino_Camera_Control/ptpcallback.h
  68. 0
    310
      lib/Arduino_Camera_Control/ptpconst.h
  69. 0
    133
      lib/Arduino_Camera_Control/ptpdebug.cpp
  70. 0
    86
      lib/Arduino_Camera_Control/ptpdebug.h
  71. 0
    240
      lib/Arduino_Camera_Control/ptpdpparser.h
  72. 0
    95
      lib/Arduino_Camera_Control/ptpmsgstr.h
  73. 0
    88
      lib/Arduino_Camera_Control/scheduler.cpp
  74. 0
    253
      lib/Arduino_Camera_Control/scheduler.h
  75. 0
    86
      lib/Arduino_Camera_Control/simplefifo.h
  76. 0
    88
      lib/Arduino_Camera_Control/simpletimer.cpp
  77. 0
    108
      lib/Arduino_Camera_Control/simpletimer.h
  78. 0
    238
      lib/Arduino_Camera_Control/valuelist.h
  79. 0
    3
      lib/USB_Host_Shield/.gitignore
  80. 0
    271
      lib/USB_Host_Shield/Max3421e.cpp
  81. 0
    56
      lib/USB_Host_Shield/Max3421e.h
  82. 0
    236
      lib/USB_Host_Shield/Max3421e_constants.h
  83. 0
    260
      lib/USB_Host_Shield/Max_LCD.cpp
  84. 0
    92
      lib/USB_Host_Shield/Max_LCD.h
  85. 0
    6
      lib/USB_Host_Shield/README
  86. 0
    422
      lib/USB_Host_Shield/Usb.cpp
  87. 0
    176
      lib/USB_Host_Shield/Usb.h
  88. 0
    168
      lib/USB_Host_Shield/ch9.h
  89. 0
    335
      lib/USB_Host_Shield/examples/LCDkbd.pde
  90. 0
    566
      lib/USB_Host_Shield/examples/PS3LCD.pde
  91. 0
    34
      lib/USB_Host_Shield/examples/adktest.pde
  92. 0
    284
      lib/USB_Host_Shield/examples/arm_mouse.pde
  93. 0
    21
      lib/USB_Host_Shield/examples/board_test/board_test.h
  94. 0
    296
      lib/USB_Host_Shield/examples/board_test/board_test.pde
  95. 0
    181
      lib/USB_Host_Shield/examples/conf_descr_dump.pde
  96. 0
    284
      lib/USB_Host_Shield/examples/descriptor_parser/descriptor_parser.h
  97. 0
    720
      lib/USB_Host_Shield/examples/descriptor_parser/descriptor_parser.pde
  98. 32
    0
      src/GNUmakefile
  99. 90
    0
      src/cameraduino.ino

+ 0
- 5
lib/Arduino_Camera_Control/README View File

@@ -1,5 +0,0 @@
PTP and camera-specific libraries for Arduino USB Host Project.
This library depends on https://github.com/felis/USB_Host_Shield">USB_Host_Shield library written to support http://www.circuitsathome.com/arduino_usb_host_shield_projects.
The project is hosted at http://www.circuitsathome.com

+ 0
- 235
lib/Arduino_Camera_Control/canoneos.cpp View File

@@ -1,235 +0,0 @@
/* Copyright (C) 2010-2011 Circuits At Home, LTD. All rights reserved.
This software may be distributed and modified under the terms of the GNU
General Public License version 2 (GPL2) as published by the Free Software
Foundation and appearing in the file GPL2.TXT included in the packaging of
this file. Please note that GPL2 Section 2[b] requires that all works based
on this software must also be made publicly available under the terms of
the GPL2 ("Copyleft").
Contact information
-------------------
Circuits At Home, LTD
Web : http://www.circuitsathome.com
e-mail : support@circuitsathome.com
*/
#include "canoneos.h"
void EOSStateHandlers::OnSessionOpenedState(PTP *ptp)
{
if (!FAILED(((CanonEOS*)ptp)->SetPCConnectMode(1)) && !FAILED(((CanonEOS*)ptp)->SetExtendedEventInfo(1)))
ptp->SetState(PTP_STATE_DEVICE_INITIALIZED);
}
uint32_t ImgQualitySupplier::GetDataSize()
{
return ((pictFormat & 0xFFFF0000) ? 0x0000002C : 0x0000001C);
}
void ImgQualitySupplier::GetData(const uint16_t len, uint8_t *pbuf)
{
uint8_t num_files = (pictFormat & 0xFFFF0000) ? 2 : 1;
((uint32_t*)pbuf)[0] = (num_files == 2) ? 0x0000002C : 0x0000001C;
((uint32_t*)pbuf)[1] = (uint32_t) EOS_DPC_ImageQuality;
((uint32_t*)pbuf)[2] = (uint32_t) num_files;
uint32_t format = pictFormat;
for (uint8_t i=0, pos=3; i<num_files; i++)
{
((uint32_t*)pbuf)[pos++] = 0x00000010;
for (uint8_t j=0; j<3; j++, format >>= 4)
((uint32_t*)pbuf)[pos++] = (uint32_t)(format & 0xF);
}
}
CanonEOS::CanonEOS(uint8_t addr, uint8_t epin, uint8_t epout, uint8_t epint, uint8_t nconf, PTPStateHandlers *s)
: PTP(addr, epin, epout, epint, nconf, s)
{
}
uint16_t CanonEOS::SetImageQuality(uint32_t format)
{
uint16_t ptp_error = PTP_RC_GeneralError;
OperFlags flags = { 0, 0, 1, 1, 1, 0 };
ImgQualitySupplier sup;
sup.SetPictureFormat(format);
if ( (ptp_error = Transaction(EOS_OC_SetDevicePropValue, &flags, NULL, (void*)&sup)) != PTP_RC_OK)
PTPTRACE2("SetImageQuality error", ptp_error);
return ptp_error;
}
uint16_t CanonEOS::SetPCConnectMode(uint8_t mode)
{
uint32_t params[1];
params[0] = (uint32_t) mode;
return Operation(EOS_OC_SetPCConnectMode, 1, params);
}
uint16_t CanonEOS::SetExtendedEventInfo(uint8_t mode)
{
uint32_t params[1];
params[0] = (uint32_t) mode;
return Operation(EOS_OC_SetExtendedEventInfo, 1, params);
}
uint16_t CanonEOS::StartBulb()
{
uint32_t params[3];
params[0] = 0xfffffff8;
params[1] = 0x00001000;
params[2] = 0x00000000;
Operation(0x911A, 3, params);
Operation(0x911B, 0, NULL);
Operation(0x9125, 0, NULL);
return PTP_RC_OK;
}
uint16_t CanonEOS::StopBulb()
{
uint32_t params[3];
params[0] = 0xffffffff;
params[1] = 0x00001000;
params[2] = 0x00000000;
Operation(0x911A, 3, params);
params[0] = 0xfffffffc;
Operation(0x911A, 3, params);
Operation(0x9126, 0, NULL);
Operation(0x911C, 0, NULL);
return PTP_RC_OK;
}
uint16_t CanonEOS::CancelTransfer(uint32_t object_id)
{
uint32_t params[1];
params[0] = object_id;
return Operation(EOS_OC_CancelTransfer, 1, params);
}
uint16_t CanonEOS::ResetTransfer(uint32_t object_id)
{
uint32_t params[1];
params[0] = object_id;
return Operation(EOS_OC_ResetTransfer, 1, params);
}
uint16_t CanonEOS::SwitchLiveView(bool on)
{
uint16_t ptp_error = PTP_RC_GeneralError;
if ((ptp_error = SetProperty(EOS_DPC_LiveView, (on) ? 2 : 0)) == PTP_RC_OK)
{
if (on)
{
if ((ptp_error = SetProperty(0xD1B3, 0)) != PTP_RC_OK)
{
PTPTRACE2("LiveView start failure:", ptp_error);
SetProperty(EOS_DPC_LiveView, 0);
return PTP_RC_GeneralError;
}
}
}
return ptp_error;
}
uint16_t CanonEOS::MoveFocus(uint16_t step)
{
uint16_t ptp_error = PTP_RC_GeneralError;
OperFlags flags = { 1, 0, 0, 0, 0, 0 };
uint32_t params[1];
params[0] = (uint32_t) step;
if ( (ptp_error = Transaction(EOS_OC_MoveFocus, &flags, params, NULL)) != PTP_RC_OK)
PTPTRACE2("MoveFocus error: ", ptp_error);
return ptp_error;
}
uint16_t CanonEOS::EventCheck(PTPReadParser *parser)
{
uint16_t ptp_error = PTP_RC_GeneralError;
OperFlags flags = { 0, 0, 0, 1, 1, 0 };
if ( (ptp_error = Transaction(0x9116, &flags, NULL, parser)) != PTP_RC_OK)
PTPTRACE2("EOSEventCheck error:", ptp_error);
return ptp_error;
}
uint16_t CanonEOS::Capture()
{
return Operation(EOS_OC_Capture, 0, NULL);
}
uint16_t CanonEOS::SetProperty(uint16_t prop, uint32_t val)
{
uint16_t ptp_error = PTP_RC_GeneralError;
OperFlags flags = { 0, 0, 1, 1, 3, 12 };
uint32_t params[3];
params[0] = 0x0000000C;
params[1] = (uint32_t)prop;
params[2] = val;
if ( (ptp_error = Transaction(EOS_OC_SetDevicePropValue, &flags, NULL, (void*)params)) != PTP_RC_OK)
PTPTRACE2("SetProperty error:", ptp_error);
return ptp_error;
}
uint16_t CanonEOS::GetProperty(uint16_t prop, PTPReadParser *parser)
{
uint16_t ptp_error = PTP_RC_GeneralError;
OperFlags flags = { 1, 0, 0, 1, 1, 0 };
uint32_t params[1];
params[0] = (uint32_t)prop;
if ( (ptp_error = Transaction(EOS_OC_GetDevicePropValue, &flags, params, (void*)parser)) != PTP_RC_OK)
PTPTRACE2("GetProperty error:", ptp_error);
return ptp_error;
}
uint16_t CanonEOS::GetDeviceInfoEx(PTPReadParser *parser)
{
uint16_t ptp_error = PTP_RC_GeneralError;
OperFlags flags = { 0, 0, 0, 1, 1, 0 };
if ( (ptp_error = Transaction(EOS_OC_GetDeviceInfoEx, &flags, NULL, (void*)parser)) != PTP_RC_OK)
PTPTRACE2("GetDeviceInfo error:", ptp_error);
return ptp_error;
}
uint16_t CanonEOS::GetObject(uint32_t object_id, uint32_t parent_id, PTPReadParser *parser)
{
uint16_t ptp_error = PTP_RC_GeneralError;
OperFlags flags = { 2, 0, 0, 1, 1, 0 };
uint32_t params[2];
params[0] = object_id;
params[1] = parent_id;
if ( (ptp_error = Transaction(EOS_OC_GetObject, &flags, params, (void*)parser)) != PTP_RC_OK)
PTPTRACE2("GetObject error:", ptp_error);
return ptp_error;
}

+ 0
- 151
lib/Arduino_Camera_Control/canoneos.h View File

@@ -1,151 +0,0 @@
/* Copyright (C) 2010-2011 Circuits At Home, LTD. All rights reserved.
This software may be distributed and modified under the terms of the GNU
General Public License version 2 (GPL2) as published by the Free Software
Foundation and appearing in the file GPL2.TXT included in the packaging of
this file. Please note that GPL2 Section 2[b] requires that all works based
on this software must also be made publicly available under the terms of
the GPL2 ("Copyleft").
Contact information
-------------------
Circuits At Home, LTD
Web : http://www.circuitsathome.com
e-mail : support@circuitsathome.com
*/
#ifndef __CANONEOS_H__
#define __CANONEOS_H__
#include "WProgram.h"
#include "ptp.h"
// PTP Operation Codes (EOS specific)
#define EOS_OC_GetStorageIDs 0x9101
#define EOS_OC_GetStorageInfo 0x9102
#define EOS_OC_GetObject 0x9107
#define EOS_OC_GetDeviceInfoEx 0x9108
#define EOS_OC_GetObjectIDs 0x9109
#define EOS_OC_Capture 0x910f
#define EOS_OC_SetDevicePropValue 0x9110
#define EOS_OC_SetPCConnectMode 0x9114
#define EOS_OC_SetExtendedEventInfo 0x9115
#define EOS_OC_GetEvent 0x9116
#define EOS_OC_TransferComplete 0x9117
#define EOS_OC_CancelTransfer 0x9118
#define EOS_OC_ResetTransfer 0x9119
#define EOS_OC_GetDevicePropValue 0x9127
#define EOS_OC_GetLiveViewPicture 0x9153
#define EOS_OC_MoveFocus 0x9155
// PTP Device Properties
#define EOS_DPC_CameraDescription 0xD402
// Non-PTP Device properties
#define EOS_DPC_Aperture 0xD101
#define EOS_DPC_ShutterSpeed 0xD102
#define EOS_DPC_Iso 0xD103
#define EOS_DPC_ExposureCompensation 0xD104
#define EOS_DPC_ShootingMode 0xD105
#define EOS_DPC_DriveMode 0xD106
#define EOS_DPC_ExpMeterringMode 0xD107
#define EOS_DPC_AFMode 0xD108
#define EOS_DPC_WhiteBalance 0xD109
#define EOS_DPC_PictureStyle 0xD110
#define EOS_DPC_TransferOption 0xD111
#define EOS_DPC_UnixTime 0xD113
#define EOS_DPC_ImageQuality 0xD120
#define EOS_DPC_LiveView 0xD1B0
#define EOS_DPC_AvailableShots 0xD11B
#define EOS_DPC_CaptureDestination 0xD11C
#define EOS_DPC_BracketMode 0xD11D
// Non-PTP Events
#define EOS_EC_DevPropChanged 0xC189
#define EOS_EC_ObjectCreated 0xC181
#define EOS_EC_DevPropValuesAccepted 0xC18A
#define EOS_EC_Capture 0xC18B
#define EOS_EC_HalfPushReleaseButton 0xC18E
class EOSStateHandlers : public PTPStateHandlers
{
public:
virtual void OnSessionOpenedState(PTP *ptp);
};
class ImgQualitySupplier : PTPDataSupplier
{
uint32_t pictFormat;
public:
ImgQualitySupplier() {};
void SetPictureFormat(uint32_t format) { pictFormat = format; };
virtual uint32_t GetDataSize();
virtual void GetData(const uint16_t len, uint8_t *pbuf);
};
class CanonEOS : public PTP
{
public:
enum { modeADEP=5, modeM=3, modeAv=2, modeTv=1, modeP=0, modeAuto=9, modePortrait=0xC, modeLandscape=0xD,
modeMacro=0xE, modeSport=0xB, modeNight=0xA, modeFlashOff=0xF};
enum { driveSingleShot = 0, driveSelf = 1, driveContinuous = 0x10 };
enum { iso100 = 0x48, iso200 = 0x50, iso400 = 0x58, iso800 = 0x60, iso1600 = 0x68 };
enum { styleStandard = 0x81, stylePortrait, styleLandscape, styleNeutral, styleFaithful, styleMonochrome,
styleUser1 = 0x21, styleUser2, styleUser3 };
enum { afmodeOneShot, afmodeAIServo, afmodeAIFocus };
enum { pictSFine = 0x00000321, pictSNormal = 0x00000221, pictMFine = 0x00000311, pictMNormal = 0x00000211,
pictLFine = 0x00000301, pictLNormal = 0x00000201, pictRaw = 0x00000406, pictRawPlusL = 0x00301406 };
enum { wbAuto, wbDaylight, wbCloudy, wbTungsten, wbFluorescent, wbStrobe, wbWhitePaper, wbShade = 8 };
enum
{
ecPlus2 = 0x10, //"+2"
ecPlus1_2d3 = 0x0d, //"+1 2/3"
ecPlus1_1d3 = 0x0b, //"+1 1/3"
ecPlus1 = 0x08, //"+1"
ecPlus0_2d3 = 0x05, //"+2/3"
ecPlus0_1d3 = 0x03, //"+1/3"
ecZerro = 0x00, //"0"
ecMinus0_1d3= 0xfd, //"-1/3"
ecMinus0_2d3= 0xfb, //"-2/3"
ecMinus1 = 0xf8, //"-1"
ecMinus1_1d3= 0xf5, //"-1 1/3"
ecMinus1_2d3= 0xf3, //"-1 2/3"
ecMinus2 = 0xf0, //"-2"
};
CanonEOS(uint8_t addr, uint8_t epin, uint8_t epout, uint8_t epint, uint8_t nconf, PTPStateHandlers *s);
uint16_t SetPCConnectMode(uint8_t mode);
uint16_t SetExtendedEventInfo(uint8_t mode);
uint16_t Capture();
uint16_t StartBulb();
uint16_t StopBulb();
uint16_t SwitchLiveView(bool on);
uint16_t MoveFocus(uint16_t step);
uint16_t SetProperty(uint16_t prop, uint32_t val);
uint16_t GetProperty(uint16_t prop, PTPReadParser *parser);
uint16_t GetDeviceInfoEx(PTPReadParser *parser);
uint16_t SetImageQuality(uint32_t format);
uint16_t GetObject(uint32_t object_id, uint32_t parent_id, PTPReadParser *parser);
uint16_t ResetTransfer(uint32_t object_id);
uint16_t CancelTransfer(uint32_t object_id);
virtual uint16_t EventCheck(PTPReadParser *parser);
uint16_t DigitalZoom(uint16_t magnify);
};
#endif // __CANONEOS_H__

+ 0
- 76
lib/Arduino_Camera_Control/canonps.cpp View File

@@ -1,76 +0,0 @@
/* Copyright (C) 2010-2011 Circuits At Home, LTD. All rights reserved.
This software may be distributed and modified under the terms of the GNU
General Public License version 2 (GPL2) as published by the Free Software
Foundation and appearing in the file GPL2.TXT included in the packaging of
this file. Please note that GPL2 Section 2[b] requires that all works based
on this software must also be made publicly available under the terms of
the GPL2 ("Copyleft").
Contact information
-------------------
Circuits At Home, LTD
Web : http://www.circuitsathome.com
e-mail : support@circuitsathome.com
*/
#include "canonps.h"
void PSStateHandlers::OnSessionOpenedState(PTP *ptp)
{
if (FAILED(((CanonPS*)ptp)->SetDevicePropValue(PS_DPC_EventEmulateMode, (uint16_t)4)) )
PTPTRACE("EventEmulateMode error\r\n");
if (FAILED(((CanonPS*)ptp)->Initialize(true)) )
PTPTRACE("Initialization error\r\n");
ptp->SetState(PTP_STATE_DEVICE_INITIALIZED);
}
CanonPS::CanonPS(uint8_t addr, uint8_t epin, uint8_t epout, uint8_t epint, uint8_t nconf, PTPStateHandlers *s)
: PTP(addr, epin, epout, epint, nconf, s)
{
}
uint16_t CanonPS::EventCheck(PTPReadParser *parser)
{
uint16_t ptp_error = PTP_RC_GeneralError;
OperFlags flags = { 0, 0, 0, 1, 1, 0 };
if ( (ptp_error = Transaction(PS_OC_CheckEvent, &flags, NULL, parser)) != PTP_RC_OK)
PTPTRACE2("EOSEventCheck error: ", ptp_error);
return ptp_error;
}
uint16_t CanonPS::Initialize(bool binit)
{
uint16_t ptp_error;
if (binit)
{
if ((ptp_error = Operation(PS_OC_StartShootingMode, 0, NULL)) != PTP_RC_OK)
PTPTRACE2("StartShootingMode failed: ", ptp_error);
}
else
{
if ((ptp_error = Operation(PS_OC_EndShootingMode, 0, NULL)) != PTP_RC_OK)
PTPTRACE2("EndShootingMode failed: ", ptp_error);
}
return ptp_error;
}
uint16_t CanonPS::Capture()
{
uint16_t ptp_error;
if ((ptp_error = Operation(PS_OC_FocusLock, 0, NULL)) != PTP_RC_OK)
PTPTRACE2("Focus Lock Error: ", ptp_error);
if ((ptp_error = Operation(PS_OC_InitiateCaptureInMemory, 0, NULL)) != PTP_RC_OK)
PTPTRACE2("Capture Error: ", ptp_error);
return ptp_error;
}

+ 0
- 165
lib/Arduino_Camera_Control/canonps.h View File

@@ -1,165 +0,0 @@
/* Copyright (C) 2010-2011 Circuits At Home, LTD. All rights reserved.
This software may be distributed and modified under the terms of the GNU
General Public License version 2 (GPL2) as published by the Free Software
Foundation and appearing in the file GPL2.TXT included in the packaging of
this file. Please note that GPL2 Section 2[b] requires that all works based
on this software must also be made publicly available under the terms of
the GPL2 ("Copyleft").
Contact information
-------------------
Circuits At Home, LTD
Web : http://www.circuitsathome.com
e-mail : support@circuitsathome.com
*/
#ifndef __CANONPS_H__
#define __CANONPS_H__
#include "ptp.h"
// PTP Operation Codes (PowerShot specific)
#define PS_OC_GetObjectSize 0x9001
#define PS_OC_StartShootingMode 0x9008
#define PS_OC_EndShootingMode 0x9009
#define PS_OC_ViewfinderOn 0x900B
#define PS_OC_ViewfinderOff 0x900C
#define PS_OC_ReflectChanges 0x900D
#define PS_OC_CheckEvent 0x9013
#define PS_OC_FocusLock 0x9014
#define PS_OC_FocusUnlock 0x9015
#define PS_OC_InitiateCaptureInMemory 0x901A
#define PS_OC_GetPartialObject 0x901B
#define PS_OC_GetViewfinderImage 0x901d
#define PS_OC_GetChanges 0x9020
#define PS_OC_GetFolderEntries 0x9021
// PTP PowerShot Extention Events
#define PS_EC_ShutDownCFDoorWasOpened 0xC001 /* The Device has shut down due to the opening of the SD card cover.*/
#define PS_EC_ResetHwError 0xC005 /* The device has generated a hardware error. */
#define PS_EC_AbortPCEvf 0xC006 /* The Viewfinder mode has been cancelled. */
#define PS_EC_EnablePCEvf 0xC007 /* The Viewfinder mode has been enablede. */
#define PS_EC_FullViewReleased 0xC008 /* Transfer timing of main image data */
#define PS_EC_ThumbnailReleased 0xC009 /* Transfer timing of thumbnail image data */
#define PS_EC_ChangeBatteryStatus 0xC00A /* The power condition of the camera has changed. */
#define PS_EC_PushedReleaseSw 0xC00B /* User has pressed the release swtich on camera. */
#define PS_EC_PropertyChanged 0xC00C /* A group of properties relating to release control have been changed. */
#define PS_EC_RotationAngleChanged 0xC00D /* The angle of rotation of the camera has been changed. */
#define PS_EC_ChangedByCamUI 0xC00E /* An operation control on the camera has been operated.*/
#define PS_EC_Shutdown 0xD001 /* Shutdown */
#define PS_EC_StartDirectTransfer 0xC011
#define PS_EC_StopDirectTransfer 0xC013
// PowerShot-specific Device Properties
#define PS_DPC_BeepMode 0xD001
#define PS_DPC_BatteryKind 0xD002
#define PS_DPC_BatteryStatus 0xD003
#define PS_DPC_UILockType 0xD004
#define PS_DPC_CameraMode 0xD005
#define PS_DPC_ImageQuality 0xD006
#define PS_DPC_FullViewFileFormat 0xD007
#define PS_DPC_ImageSize 0xD008
#define PS_DPC_SelfTime 0xD009
#define PS_DPC_FlashMode 0xD00A
#define PS_DPC_Beep 0xD00B
#define PS_DPC_ShootingMode 0xD00C
#define PS_DPC_ImageMode 0xD00D
#define PS_DPC_DriveMode 0xD00E
#define PS_DPC_EZoom 0xD00F
#define PS_DPC_MeteringMode 0xD010
#define PS_DPC_AFDistance 0xD011
#define PS_DPC_FocusingPoint 0xD012
#define PS_DPC_WhiteBalance 0xD013
#define PS_DPC_SlowShutterSetting 0xD014
#define PS_DPC_AFMode 0xD015
#define PS_DPC_ImageStabilization 0xD016
#define PS_DPC_Contrast 0xD017
#define PS_DPC_ColorGain 0xD018
#define PS_DPC_Sharpness 0xD019
#define PS_DPC_Sensitivity 0xD01A
#define PS_DPC_ParameterSet 0xD01B
#define PS_DPC_ISOSpeed 0xD01C
#define PS_DPC_Aperture 0xD01D
#define PS_DPC_ShutterSpeed 0xD01E
#define PS_DPC_ExpCompensation 0xD01F
#define PS_DPC_FlashCompensation 0xD020
#define PS_DPC_AEBExposureCompensation 0xD021
#define PS_DPC_AvOpen 0xD023
#define PS_DPC_AvMax 0xD024
#define PS_DPC_FocalLength 0xD025
#define PS_DPC_FocalLengthTele 0xD026
#define PS_DPC_FocalLengthWide 0xD027
#define PS_DPC_FocalLengthDenominator 0xD028
#define PS_DPC_CaptureTransferMode 0xD029
#define PS_DPC_Zoom 0xD02A
#define PS_DPC_NamePrefix 0xD02B
#define PS_DPC_SizeQualityMode 0xD02C
#define PS_DPC_SupportedThumbSize 0xD02D
#define PS_DPC_SizeOfOutputDataFromCamera 0xD02E
#define PS_DPC_SizeOfInputDataToCamera 0xD02F
#define PS_DPC_RemoteAPIVersion 0xD030
#define PS_DPC_FirmwareVersion 0xD031
#define PS_DPC_CameraModel 0xD032
#define PS_DPC_CameraOwner 0xD033
#define PS_DPC_UnixTime 0xD034
#define PS_DPC_CameraBodyID 0xD035
#define PS_DPC_CameraOutput 0xD036
#define PS_DPC_DispAv 0xD037
#define PS_DPC_AvOpenApex 0xD038
#define PS_DPC_DZoomMagnification 0xD039
#define PS_DPC_MlSpotPos 0xD03A
#define PS_DPC_DispAvMax 0xD03B
#define PS_DPC_AvMaxApex 0xD03C
#define PS_DPC_EZoomStartPosition 0xD03D
#define PS_DPC_FocalLengthOfTele 0xD03E
#define PS_DPC_EZoomSizeOfTele 0xD03F
#define PS_DPC_PhotoEffect 0xD040
#define PS_DPC_AssistLight 0xD041
#define PS_DPC_FlashQuantityCount 0xD042
#define PS_DPC_RotationAngle 0xD043
#define PS_DPC_RotationScene 0xD044
#define PS_DPC_EventEmulateMode 0xD045
#define PS_DPC_DPOFVersion 0xD046
#define PS_DPC_TypeOfSupportedSlideShow 0xD047
#define PS_DPC_AverageFilesizes 0xD048
#define PS_DPC_ModelID 0xD049
class PSStateHandlers : public PTPStateHandlers
{
public:
virtual void OnSessionOpenedState(PTP *ptp);
};
class CanonPS : public PTP
{
public:
// ISO Speed Values
enum { IsoAuto = 0, Iso80 = 0x45, Iso100 = 0x48, Iso200 = 0x50, Iso400 = 0x58, Iso800=0x60 };
// White Balance Values
enum { WbAuto = 0, WbSunny, WbCloudy, WbTungsten, WbFluorescent, WbFlash, WbCustom, WbUnknown };
// Exposure Compensation Values (same values for both exposure compensation and flash compensation)
enum { ExpCompDown2 = 0x08, ExpCompDown1_2d3= 0x0B, ExpCompDown1_1d3= 0x0D, ExpCompDown1 = 0x10, ExpCompDown2d3 = 0x13,
ExpCompDown1d3 = 0x15, ExpComp_0 = 18, ExpCompUp1d3 = 0x1B, ExpCompUp2d3 = 0x1D, ExpCompUp1 = 0x20,
ExpCompUp1_1d3 = 0x23, ExpCompUp1_2d3 = 0x25, ExpCompUp2 = 0x28 };
// Image Quality Values
enum { ImgQualityNormal = 2, ImageQualityFine = 3, ImageQualitySuperb = 5 };
// Image Size Values
enum { ImgSizeLarge, ImgSizeMedium1, ImgSizeSmall, ImgSizeMedium2 };
CanonPS(uint8_t addr, uint8_t epin, uint8_t epout, uint8_t epint, uint8_t nconf, PTPStateHandlers *s);
uint16_t Initialize(bool binit);
uint16_t Capture();
uint16_t EventCheck(PTPReadParser *parser);
};
#endif // __CANONPS_H__

+ 0
- 15
lib/Arduino_Camera_Control/copying.txt View File

@@ -1,15 +0,0 @@
Copyright (C) 2010 Circuits At Home, LTD. All rights reserved.
This software may be distributed and modified under the terms of the GNU
General Public License version 2 (GPL2) as published by the Free Software
Foundation and appearing in the file GPL2.TXT included in the packaging of
this file. Please note that GPL2 Section 2[b] requires that all works based
on this software must also be made publicly available under the terms of
the GPL2 ("Copyleft").
Contact information
-------------------
Circuits At Home, LTD
Web : http://www.circuitsathome.com
e-mail : support@circuitsathome.com

+ 0
- 296
lib/Arduino_Camera_Control/eosvaluetitles.h View File

@@ -1,296 +0,0 @@
/* Copyright (C) 2010-2011 Circuits At Home, LTD. All rights reserved.
This software may be distributed and modified under the terms of the GNU
General Public License version 2 (GPL2) as published by the Free Software
Foundation and appearing in the file GPL2.TXT included in the packaging of
this file. Please note that GPL2 Section 2[b] requires that all works based
on this software must also be made publicly available under the terms of
the GPL2 ("Copyleft").
Contact information
-------------------
Circuits At Home, LTD
Web : http://www.circuitsathome.com
e-mail : support@circuitsathome.com
*/
#if !defined(__EOSVALUETITLES_H__)
#define __EOSVALUETITLES_H__
#include <inttypes.h>
#include <avr/pgmspace.h>
#include <valuelist.h>
typedef uint8_t VT_APERTURE;
typedef uint8_t VT_MODE;
typedef uint8_t VT_WB;
typedef uint8_t VT_SHSPEED;
typedef uint8_t VT_PSTYLE;
typedef uint8_t VT_ISO;
typedef uint8_t VT_EXPCOMP;
#define VT_MODE_TEXT_LEN 4
#define VT_WB_TEXT_LEN 4
#define VT_SHSPEED_TEXT_LEN 5
#define VT_PSTYLE_TEXT_LEN 4
#define VT_ISO_TEXT_LEN 5
#define VT_EXPCOMP_TEXT_LEN 7
#define VT_APT_TEXT_LEN 4
const ValueTitle<VT_APERTURE, VT_APT_TEXT_LEN> ApertureTitles[] PROGMEM =
{
{0x00, {' ', ' ', '0', 0 } },
{0x08, {' ', ' ', '1', 0 } },
{0x0B, {'1', '.', '1', 0 } },
{0x0C, {'1', '.', '2', 0 } },
{0x0D, {'1', '.', '2', 0 } },
{0x10, {'1', '.', '4', 0 } },
{0x13, {'1', '.', '6', 0 } },
{0x14, {'1', '.', '8', 0 } },
{0x15, {'1', '.', '8', 0 } },
{0x18, {'2', '.', '0', 0 } },
{0x1B, {'2', '.', '2', 0 } },
{0x1C, {'2', '.', '5', 0 } },
{0x1D, {'2', '.', '5', 0 } },
{0x20, {'2', '.', '8', 0 } },
{0x23, {'3', '.', '2', 0 } },
{0x24, {'3', '.', '5', 0 } },
{0x25, {'3', '.', '5', 0 } },
{0x28, {'4', '.', '0', 0 } },
{0x2B, {'4', '.', '5', 0 } },
{0x2C, {'4', '.', '5', 0 } },
{0x2D, {'5', '.', '0', 0 } },
{0x30, {'5', '.', '6', 0 } },
{0x33, {'6', '.', '3', 0 } },
{0x34, {'6', '.', '7', 0 } },
{0x35, {'7', '.', '1', 0 } },
{0x38, {'8', '.', '0', 0 } },
{0x3B, {'9', '.', '0', 0 } },
{0x3C, {'9', '.', '5', 0 } },
{0x3D, {' ', '1', '0', 0 } },
{0x40, {' ', '1', '1', 0 } },
{0x43, {' ', '1', '3', 0 } },
{0x44, {' ', '1', '3', 0 } },
{0x45, {' ', '1', '4', 0 } },
{0x48, {' ', '1', '6', 0 } },
{0x4B, {' ', '1', '8', 0 } },
{0x4C, {' ', '1', '9', 0 } },
{0x4D, {' ', '2', '0', 0 } },
{0x50, {' ', '2', '2', 0 } },
{0x53, {' ', '2', '5', 0 } },
{0x54, {' ', '2', '7', 0 } },
{0x55, {' ', '2', '9', 0 } },
{0x58, {' ', '3', '2', 0 } },
{0x5B, {' ', '3', '6', 0 } },
{0x5C, {' ', '3', '8', 0 } },
{0x5D, {' ', '4', '0', 0 } },
{0x60, {' ', '4', '5', 0 } },
{0x63, {' ', '5', '1', 0 } },
{0x64, {' ', '5', '4', 0 } },
{0x65, {' ', '5', '7', 0 } },
{0x68, {' ', '6', '4', 0 } },
{0x6B, {' ', '7', '2', 0 } },
{0x6C, {' ', '7', '6', 0 } },
{0x6D, {' ', '8', '0', 0 } },
{0x70, {' ', '9', '1', 0 } }
};
const ValueTitle<VT_SHSPEED, VT_SHSPEED_TEXT_LEN> ShutterSpeedTitles[] PROGMEM =
{
{0x0c, {'B','u','l','b',0} },
{0x10, {' ','3','0','"',0} },
{0x13, {' ','2','5','"',0} },
{0x14, {' ','2','0','"',0} },
{0x15, {' ','2','0','"',0} },
{0x18, {' ','1','5','"',0} },
{0x1B, {' ','1','3','"',0} },
{0x1C, {' ','1','0','"',0} },
{0x1D, {' ','1','0','"',0} },
{0x20, {' ',' ','8','"',0} },
{0x23, {' ',' ','6','"',0} },
{0x24, {' ',' ','6','"',0} },
{0x25, {' ',' ','5','"',0} },
{0x28, {' ',' ','4','"',0} },
{0x2B, {' ','3','"','2',0} },
{0x2C, {' ',' ','3','"',0} },
{0x2D, {' ','2','"','5',0} },
{0x30, {' ',' ','2','"',0} },
{0x33, {' ','1','"','6',0} },
{0x34, {' ','1','"','5',0} },
{0x35, {' ','1','"','3',0} },
{0x38, {' ',' ','1','"',0} },
{0x3B, {' ','0','"','8',0} },
{0x3C, {' ','0','"','7',0} },
{0x3D, {' ','0','"','6',0} },
{0x40, {' ','0','"','5',0} },
{0x43, {' ','0','"','4',0} },
{0x44, {' ','0','"','3',0} },
{0x45, {' ','0','"','3',0} },
{0x48, {' ',' ',' ','4',0} },
{0x4B, {' ',' ',' ','5',0} },
{0x4C, {' ',' ',' ','6',0} },
{0x4D, {' ',' ',' ','6',0} },
{0x50, {' ',' ',' ','8',0} },
{0x53, {' ',' ','1','0',0} },
{0x54, {' ',' ','1','0',0} },
{0x55, {' ',' ','1','3',0} },
{0x58, {' ',' ','1','5',0} },
{0x5B, {' ',' ','2','0',0} },
{0x5C, {' ',' ','2','0',0} },
{0x5D, {' ',' ','2','5',0} },
{0x60, {' ',' ','3','0',0} },
{0x63, {' ',' ','4','0',0} },
{0x64, {' ',' ','4','5',0} },
{0x65, {' ',' ','5','0',0} },
{0x68, {' ',' ','6','0',0} },
{0x6B, {' ',' ','8','0',0} },
{0x6C, {' ',' ','9','0',0} },
{0x6D, {' ','1','0','0',0} },
{0x70, {' ','1','2','5',0} },
{0x73, {' ','1','6','0',0} },
{0x74, {' ','1','8','0',0} },
{0x75, {' ','2','0','0',0} },
{0x78, {' ','2','5','0',0} },
{0x7B, {' ','3','2','0',0} },
{0x7C, {' ','3','5','0',0} },
{0x7D, {' ','4','0','0',0} },
{0x80, {' ','5','0','0',0} },
{0x83, {' ','6','4','0',0} },
{0x84, {' ','7','5','0',0} },
{0x85, {' ','8','0','0',0} },
{0x88, {'1','0','0','0',0} },
{0x8B, {'1','2','5','0',0} },
{0x8C, {'1','5','0','0',0} },
{0x8D, {'1','6','0','0',0} },
{0x90, {'2','0','0','0',0} },
{0x93, {'2','5','0','0',0} },
{0x94, {'3','0','0','0',0} },
{0x95, {'3','2','0','0',0} },
{0x98, {'4','0','0','0',0} },
{0x9B, {'5','0','0','0',0} },
{0x9C, {'6','0','0','0',0} },
{0x9D, {'6','4','0','0',0} },
{0xA0, {'8','0','0','0',0} }
};
const ValueTitle<VT_ISO, VT_ISO_TEXT_LEN> IsoTitles[] PROGMEM =
{
{0x28, {'6',' ',' ',' ',0} },
{0x30, {'1','2',' ',' ',0} },
{0x38, {'2','5',' ',' ',0} },
{0x40, {'5','0',' ',' ',0} },
{0x48, {'1','0','0',' ',0} },
{0x4b, {'1','2','5',' ',0} },
{0x4d, {'1','6','0',' ',0} },
{0x50, {'2','0','0',' ',0} },
{0x53, {'2','5','0',' ',0} },
{0x55, {'3','2','0',' ',0} },
{0x58, {'4','0','0',' ',0} },
{0x5b, {'5','0','0',' ',0} },
{0x5d, {'6','4','0',' ',0} },
{0x60, {'8','0','0',' ',0} },
{0x63, {'1','0','0','0',0} },
{0x65, {'1','2','5','0',0} },
{0x68, {'1','6','0','0',0} },
{0x70, {'3','2','0','0',0} },
{0x78, {'6','4','0','0',0} }
};
// Exposure Compensation Title Array
const ValueTitle<VT_EXPCOMP, VT_EXPCOMP_TEXT_LEN> ExpCompTitles[] PROGMEM =
{
{0x28, {'+','5',' ',' ',' ',' ',0} },
{0x25, {'+','4',' ','2','/','3',0} },
{0x23, {'+','4',' ','1','/','3',0} },
{0x20, {'+','4',' ',' ',' ',' ',0} },
{0x1d, {'+','3',' ','2','/','3',0} },
{0x1b, {'+','3',' ','1','/','3',0} },
{0x18, {'+','3',' ',' ',' ',' ',0} },
{0x15, {'+','2',' ','2','/','3',0} },
{0x14, {'+','2',' ','1','/','2',0} },
{0x13, {'+','2',' ','1','/','3',0} },
{0x10, {'+','2',' ',' ',' ',' ',0} },
{0x0d, {'+','1',' ','2','/','3',0} },
{0x0c, {'+','1',' ','1','/','2',0} },
{0x0b, {'+','1',' ','1','/','3',0} },
{0x08, {'+','1',' ',' ',' ',' ',0} },
{0x05, {'+','2','/','3',' ',' ',0} },
{0x04, {'+','1','/','2',' ',' ',0} },
{0x03, {'+','1','/','3',' ',' ',0} },
{0x00, {'0',' ',' ',' ',' ',' ',0} },
{0xfd, {'-','1','/','3',' ',' ',0} },
{0xfc, {'-','1','/','2',' ',' ',0} },
{0xfb, {'-','2','/','3',' ',' ',0} },
{0xf8, {'-','1',' ',' ',' ',' ',0} },
{0xf5, {'-','1',' ','1','/','3',0} },
{0xf4, {'-','1',' ','1','/','2',0} },
{0xf3, {'-','1',' ','2','/','3',0} },
{0xf0, {'-','2',' ',' ',' ',' ',0} },
{0xed, {'-','2',' ','1','/','3',0} },
{0xec, {'-','2',' ','1','/','2',0} },
{0xeb, {'-','2',' ','2','/','3',0} },
{0xe8, {'-','3',' ',' ',' ',' ',0} },
{0xe5, {'-','3',' ','1','/','3',0} },
{0xe3, {'-','3',' ','2','/','3',0} },
{0xe0, {'-','4',' ',' ',' ',' ',0} },
{0xdd, {'-','4',' ','1','/','3',0} },
{0xdb, {'-','3',' ','2','/','3',0} },
{0xd8, {'-','5',' ',' ',' ',' ',0} }
};
// Shooting Mode Title Array
const ValueTitle<VT_MODE, VT_MODE_TEXT_LEN> ModeTitles[] PROGMEM =
{
{0, {'P',' ',' ',0} }, // Program
{1, {'T','v',' ',0} }, // Tv
{2, {'A','v',' ',0} }, // Av
{3, {'M',' ',' ',0} }, // Manual
{4, {'B','l','b',0} }, // Bulb
{5, {'A','-','D',0} }, // A-DEP
{6, {'D','E','P',0} }, // DEP
{7, {'C',' ',' ',0} }, // Custom
{8, {'L','c','k',0} }, // Lock
{9, {'G','r','n',0} }, // Green (Fully Automatic Mode)
{10,{'N','g','h',0} }, // Night Portrait
{11,{'S','p','r',0} }, // Sports
{13,{'L','n','d',0} }, // Landscape
{14,{'C','l','s',0} }, // Closeup
{15,{'N','/','F',0} } // No Flash
};
// White Balance Title Array
const ValueTitle<VT_WB, VT_WB_TEXT_LEN> WbTitles[] PROGMEM =
{
{0, {'A','W','B',0} }, // Auto White Balance
{1, {'D','a','y',0} }, // Daylight
{2, {'C','l','d',0} }, // Clouds
{3, {'T','n','g',0} }, // Tungsteen
{4, {'F','l','r',0} }, // Fluoriscent
{5, {'S','t','r',0} }, // Strobe
{6, {'W','/','P',0} }, // White Paper
{8, {'S','h','d',0} } // Shade
};
// Picture Style Title Array
const ValueTitle<VT_PSTYLE, VT_PSTYLE_TEXT_LEN> PStyleTitles[] PROGMEM =
{
{0x21, {'U','s','1',0} }, // User 1
{0x22, {'U','s','2',0} }, // User 2
{0x23, {'U','s','3',0} }, // User 3
{0x81, {'S','t','d',0} }, // Standard
{0x82, {'P','r','t',0} }, // Portrait
{0x83, {'L','n','d',0} }, // Landscape
{0x84, {'N','t','l',0} }, // Neutral
{0x85, {'F','t','h',0} }, // Faithful
{0x86, {'M','o','n',0} } // Monochrome
};
#define VT_APT_COUNT sizeof(ApertureTitles) / (sizeof(VT_APERTURE) + VT_APT_TEXT_LEN)
#define VT_MODE_COUNT sizeof(ModeTitles) / (sizeof(VT_MODE) + VT_MODE_TEXT_LEN)
#define VT_WB_COUNT sizeof(WbTitles) / (sizeof(VT_WB) + VT_WB_TEXT_LEN)
#define VT_SHSPEED_COUNT sizeof(ShutterSpeedTitles) / (sizeof(VT_SHSPEED) + VT_SHSPEED_TEXT_LEN)
#define VT_PSTYLE_COUNT sizeof(PStyleTitles) / (sizeof(VT_PSTYLE) + VT_PSTYLE_TEXT_LEN)
#define VT_ISO_COUNT sizeof(IsoTitles) / (sizeof(VT_ISO) + VT_ISO_TEXT_LEN)
#define VT_EXPCOMP_COUNT sizeof(ExpCompTitles) / (sizeof(VT_EXPCOMP) + VT_EXPCOMP_TEXT_LEN)
#endif // __EOSVALUETITLES_H__

+ 0
- 80
lib/Arduino_Camera_Control/examples/EOSBulb/EOSBulb.pde View File

@@ -1,80 +0,0 @@
/* Bulb mode demo */
/* 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 */
/* Tested with EOS Rebel XSI (450D) */
/* Camera has to be switched to manual mode */

#include <inttypes.h>
#include <avr/pgmspace.h>

//#include <Spi.h>
#include <Max3421e.h>
#include <Max3421e_constants.h>
#include <Max_LCD.h>
#include <Usb.h>

#include <ptp.h>
#include <canoneos.h>

#define DEV_ADDR 1

// Canon EOS 450D
#define DATA_IN_EP 1
#define DATA_OUT_EP 2
#define INTERRUPT_EP 3
#define CONFIG_NUM 1

#define SHUTTER_SPEED_BULB 0x0c

class CamStateHandlers : public EOSStateHandlers
{
enum CamStates { stInitial, stDisconnected, stConnected };
CamStates stateConnected;
public:
CamStateHandlers() : stateConnected(stInitial)
{
};
virtual void OnDeviceDisconnectedState(PTP *ptp);
virtual void OnDeviceInitializedState(PTP *ptp);
} CamStates;

CanonEOS Eos(DEV_ADDR, DATA_IN_EP, DATA_OUT_EP, INTERRUPT_EP, CONFIG_NUM, &CamStates);

void CamStateHandlers::OnDeviceDisconnectedState(PTP *ptp)
{
if (stateConnected == stConnected || stateConnected == stInitial)
{
stateConnected = stDisconnected;
Notify(PSTR("Camera disconnected\r\n"));
}
}

void CamStateHandlers::OnDeviceInitializedState(PTP *ptp)
{
if (stateConnected == stDisconnected)
{
stateConnected = stConnected;
uint16_t rc = Eos.SetProperty(EOS_DPC_ShutterSpeed,SHUTTER_SPEED_BULB);
if (rc != PTP_RC_OK)
Message(PSTR("Error: "), rc);
}

Eos.StartBulb();
delay(6000);
Eos.StopBulb();
}

void setup()
{
Serial.begin( 115200 );
Serial.println("Start");
Eos.Setup();
delay( 200 );
}

void loop() {
Eos.Task();
}

+ 0
- 556
lib/Arduino_Camera_Control/examples/EOSCamController/EOSCamController.pde View File

@@ -1,556 +0,0 @@
/* Digital camera controller board test sketch */
//#include <Spi.h>
#include <Max3421e.h>
#include <Usb.h>
#include <Max_LCD.h>
#include <simpletimer.h>
#include <valuelist.h>
#include <canoneos.h>
#include <qep_port.h>

#include "camcontroller.h"
#include "controls.h"
#include "eoseventparser.h"
#include "dataitem.h"
#include "screenitem.h"
#include "screen.h"
#include "menu.h"
#include "hdrcapture.h"

#define DEV_ADDR 1

// Canon EOS 400D
#define DATA_IN_EP 1
#define DATA_OUT_EP 2
#define INTERRUPT_EP 3
#define CONFIG_NUM 1

#define EEP_APERTURE_LIST_OFFSET 0
#define EEP_APERTURE_LIST_SIZE 32

#define EEP_SHTSPEED_LIST_OFFSET (EEP_APERTURE_LIST_OFFSET + EEP_APERTURE_LIST_SIZE)
#define EEP_SHTSPEED_LIST_SIZE 64

#define EEP_WBALANCE_LIST_OFFSET (EEP_SHTSPEED_LIST_OFFSET + EEP_SHTSPEED_LIST_SIZE)
#define EEP_WBALANCE_LIST_SIZE 12

#define EEP_PICSTYLE_LIST_OFFSET (EEP_WBALANCE_LIST_OFFSET + EEP_WBALANCE_LIST_SIZE)
#define EEP_PICSTYLE_LIST_SIZE 12

#define EEP_EXPOCOR_LIST_OFFSET (EEP_PICSTYLE_LIST_OFFSET + EEP_PICSTYLE_LIST_SIZE)
#define EEP_EXPOCOR_LIST_SIZE 48

#define EEP_ISO_LIST_OFFSET (EEP_EXPOCOR_LIST_OFFSET + EEP_EXPOCOR_LIST_SIZE)
#define EEP_ISO_LIST_SIZE 8

EEPROMByteList vlAperture(EEP_APERTURE_LIST_OFFSET, EEP_APERTURE_LIST_SIZE);
EEPROMByteList vlShutterSpeed(EEP_SHTSPEED_LIST_OFFSET, EEP_SHTSPEED_LIST_SIZE);
EEPROMByteList vlWhiteBalance(EEP_WBALANCE_LIST_OFFSET, EEP_WBALANCE_LIST_SIZE);
EEPROMByteList vlPictureStyle(EEP_PICSTYLE_LIST_OFFSET, EEP_PICSTYLE_LIST_SIZE);
EEPROMByteList vlIso(EEP_ISO_LIST_OFFSET, EEP_ISO_LIST_SIZE);
EEPROMByteList vlExpCompensation(EEP_EXPOCOR_LIST_OFFSET, EEP_EXPOCOR_LIST_SIZE);

class CamStateHandlers : public EOSStateHandlers
{
bool stateConnected;
public:
CamStateHandlers() : stateConnected(false) {};
virtual void OnDeviceDisconnectedState(PTP *ptp);
virtual void OnDeviceInitializedState(PTP *ptp);
};

class CamHDRCapture : public HDRCapture
{
public:
CamHDRCapture(CanonEOS &eos) : HDRCapture(eos) {};
protected:
virtual void OnFrameCaptured(uint16_t left);
virtual void OnSelfTimerProgress(uint32_t left);
virtual void OnIntrTimerProgress(uint32_t left);
};

CamStateHandlers CamStates;
Max_LCD LCD;
SimpleTimer ControlTimer, PTPPollTimer;

CanonEOS Eos(DEV_ADDR, DATA_IN_EP, DATA_OUT_EP, INTERRUPT_EP, CONFIG_NUM, &CamStates);
CamHDRCapture hdrCapture(Eos);
GPInRegister ExtControls(Eos.GetMax());
QEvent evtTick, evtAbort;

//--- (0) Message Screen ----------------------------------------------------------------------
PgmStringDataItem diFirst(msgCamera);
PgmStringDataItem diSecond(msgDisconnected);

ScreenItem siFirst (5, 0, 16, false, &diFirst);
ScreenItem siSecond (2, 1, 16, false, &diSecond);

ScreenItem *messageScreenItems[] PROGMEM = { &siFirst, &siSecond };
Screen messageScreen(2, (ScreenItem*)messageScreenItems);

//--- (1) Main Menu Screen --------------------------------------------------------------------
ScreenItem siIntervalometer (1, 0, 8, true, (const char*)&msgIntervalometer);
ScreenItem siSettings (1, 1, 8, false, (const char*)&msgSettings);

ScreenItem *mainMenuScreenItems[] PROGMEM = { &siIntervalometer, &siSettings };
Screen scrMainMenu(2, (ScreenItem*)mainMenuScreenItems);

//--- (2) Timer Menu Screen -------------------------------------------------------------------
ScreenItem siSelf (1, 0, 4, true, (const char*)&msgSetSelf);
ScreenItem siFrames (1, 1, 4, false, (const char*)&msgSetFrames);
ScreenItem siBkt (6, 0, 3, false, (const char*)&msgSetBkt);
ScreenItem siInterval (6, 1, 3, false, (const char*)&msgSetInterval);
ScreenItem siRun (10, 0, 4, false, (const char*)&msgSetRun);
ScreenItem siExit (10, 1, 4, false, (const char*)&msgExit);

ScreenItem *timerSettingsScreenItems[] PROGMEM = { &siSelf, &siFrames, &siBkt, &siInterval, &siRun, &siExit };
Screen timerSettingsScreen(6, (ScreenItem*)timerSettingsScreenItems);

//--- (3) Self Timer Screen -------------------------------------------------------------------
DIT_TIMER_DIGIT_PAIR diHourSelf(0), diHourInt(0),
diMinSelf(0), diMinInt(0),
diSecSelf(0), diSecInt(0);

ScreenItem siSelfTimer(0, 0, 16, false, (const char*)&msgSelfTimer);
ScreenItem siHourSelf(3, 1, 2, false, &diHourSelf);
ScreenItem siMinSelf (6, 1, 2, false, &diMinSelf);
ScreenItem siSecSelf (9, 1, 2, false, &diSecSelf);

ScreenItem *scitmSelfTimerSet[] PROGMEM = { &siSelfTimer, &siHourSelf, &siMinSelf, &siSecSelf };
Screen scrSelfTimerSet(4, (ScreenItem*)scitmSelfTimerSet);

//--- (4) Number of Frames Screen -------------------------------------------------------------
IntDataItem<uint16_t, 5> diFramesCount(0);
IntDataItem<uint16_t, 5> diFramesLeft(0);

ScreenItem siFramesText (5, 0, 6, false, (const char*)&msgCntFrames);
ScreenItem siFramesCount (6, 1, 4, false, &diFramesCount);

ScreenItem *scitmFramesSet[] PROGMEM = { &siFramesText, &siFramesCount };
Screen scrFramesSet(2, (ScreenItem*)scitmFramesSet);

//--- (5) Bracketing Screen -------------------------------------------------------------------
KeyValuePairDataItem<uint8_t, 37, 7> diBktEV(0, ExpCompTitles);
KeyValuePairDataItem<uint8_t, 37, 7> diBktStep(0, ExpCompTitles);
uint8_t nBktStep;
uint8_t nBktNegativeIndex;
uint8_t nBktPositiveIndex;

ScreenItem siBracketing(0, 0, 15, false, (const char*)&msgBracketing);
ScreenItem siBktEV (1, 1, 6, false, &diBktEV);
ScreenItem siBktStep (9, 1, 6, false, &diBktStep);

ScreenItem *scitmBkt[] PROGMEM = { &siBracketing, &siBktEV, &siBktStep };
Screen scrBktSet(3, (ScreenItem*)scitmBkt);

//--- (6) Interval Timer Screen ---------------------------------------------------------------
ScreenItem siIntTimer(0, 0, 16, false, (const char*)&msgIntTimer);
ScreenItem siHourInt(3, 1, 2, false, &diHourInt);
ScreenItem siMinInt (6, 1, 2, false, &diMinInt);
ScreenItem siSecInt (9, 1, 2, false, &diSecInt);

ScreenItem *scitmIntTimerSet[] PROGMEM = { &siIntTimer, &siHourInt, &siMinInt, &siSecInt };
Screen scrIntTimerSet(4, (ScreenItem*)scitmIntTimerSet);

//--- (7) Run Screen ---------------------------------------------------------------------------
TimeSpanDataItem diLeftTimer(0);
TimeSpanDataItem diIntTimer(0);

ScreenItem siRunLeftTime( 0, 0, 8, false, &diLeftTimer);
ScreenItem siRunIntTime( 0, 1, 8, false, &diIntTimer);
ScreenItem siRunFramesLeft ( 10, 0, 4, false, &diFramesLeft);
ScreenItem siAbort(10, 1, 5, false, (const char*)&msgAbort);

ScreenItem *scitmRun[] PROGMEM = { &siRunLeftTime, &siRunIntTime, &siRunFramesLeft, &siAbort };
Screen scrRun(4, (ScreenItem*)scitmRun);

//--- (8) Camera Settings Screen ---------------------------------------------------------------
DIT_MODE diMode(0, ModeTitles);
DIT_APERTURE diAperture(0, ApertureTitles);
DIT_WB diWb(0, WbTitles);
DIT_SHUTTER_SPEED diShutterSpeed(0, ShutterSpeedTitles);
DIT_PSTYLE diPStyle(0, PStyleTitles);
DIT_ISO diIso(0, IsoTitles);
DIT_EXPCOMP diExpComp(0, ExpCompTitles);

ScreenItem siMode ( 0, 0, 3, false, &diMode);
ScreenItem siAperture ( 0, 1, 3, false, &diAperture);
ScreenItem siWb ( 4, 0, 3, false, &diWb);
ScreenItem siShutterSpeed( 4, 1, 4, false, &diShutterSpeed);
ScreenItem siPStyle ( 8, 0, 3, false, &diPStyle);
ScreenItem siIso (12, 0, 4, false, &diIso);
ScreenItem siExpComp ( 9, 1, 6, false, &diExpComp);

ScreenItem *scitmSettings[] PROGMEM = { &siMode, &siAperture, &siWb, &siShutterSpeed, &siPStyle, &siIso, &siExpComp };
Screen scrSettings(7, (ScreenItem*)scitmSettings);

IntSpin<DIT_TIMER_DIGIT_PAIR, uint8_t> hourSpinSelf(0, 99, 1, &diHourSelf, NULL);
IntSpin<DIT_TIMER_DIGIT_PAIR, uint8_t> minSpinSelf(0, 99, 1, &diMinSelf, NULL);
IntSpin<DIT_TIMER_DIGIT_PAIR, uint8_t> secSpinSelf(0, 99, 1, &diSecSelf, NULL);

IntSpin<DIT_TIMER_DIGIT_PAIR, uint8_t> hourSpinInt(0, 99, 1, &diHourInt, NULL);
IntSpin<DIT_TIMER_DIGIT_PAIR, uint8_t> minSpinInt(0, 99, 1, &diMinInt, NULL);
IntSpin<DIT_TIMER_DIGIT_PAIR, uint8_t> secSpinInt(0, 99, 1, &diSecInt, NULL);


void SpinSetAperture(DataItemBase *data_item)
{
Eos.SetProperty(EOS_DPC_Aperture, ((DIT_APERTURE*)data_item)->Get());
};

void SpinSetShutterSpeed(DataItemBase *data_item)
{
Eos.SetProperty(EOS_DPC_ShutterSpeed, ((DIT_SHUTTER_SPEED*)data_item)->Get());
};

void SpinSetWb(DataItemBase *data_item)
{
Eos.SetProperty(EOS_DPC_WhiteBalance, ((DIT_WB*)data_item)->Get());
};

void SpinSetPStyle(DataItemBase *data_item)
{
Eos.SetProperty(EOS_DPC_PictureStyle, ((DIT_PSTYLE*)data_item)->Get());
};

void SpinSetIso(DataItemBase *data_item)
{
Eos.SetProperty(EOS_DPC_Iso, ((DIT_ISO*)data_item)->Get());
};

void SpinSetExpComp(DataItemBase *data_item)
{
Eos.SetProperty(EOS_DPC_ExposureCompensation, ((DIT_EXPCOMP*)data_item)->Get());
};

void SpinUpdateBktStepValues(DataItemBase *data_item);
void SpinUpdateBktStep(DataItemBase *data_item);

EEPROMListIntSpin<DIT_APERTURE, VT_APERTURE> spinAperture(&vlAperture, &diAperture, &SpinSetAperture);
EEPROMListIntSpin<DIT_SHUTTER_SPEED, VT_SHSPEED> spinShutterSpeed(&vlShutterSpeed, &diShutterSpeed, &SpinSetShutterSpeed);
EEPROMListIntSpin<DIT_WB, VT_WB> spinWb(&vlWhiteBalance, &diWb, &SpinSetWb);
EEPROMListIntSpin<DIT_PSTYLE, VT_PSTYLE> spinPStyle(&vlPictureStyle, &diPStyle, &SpinSetPStyle);
EEPROMListIntSpin<DIT_ISO, VT_ISO> spinIso(&vlIso, &diIso, &SpinSetIso);

EEPROMListIntSpin<EXP_COMP_DATA_ITEM, VT_EXPCOMP> spinExpComp(&vlExpCompensation, &diExpComp, &SpinSetExpComp);
EEPROMListIntSpin<EXP_COMP_DATA_ITEM, VT_EXPCOMP> spinBktEV (&vlExpCompensation, &diBktEV, &SpinUpdateBktStepValues);

BKT_STEP_VALUE_LIST vlExpCompStep;

SRAMListIntSpin<EXP_COMP_DATA_ITEM, VT_EXPCOMP, BKT_STEP_VALUE_LIST> spinBktStep(&vlExpCompStep, &diBktStep, &SpinUpdateBktStep);


void SpinUpdateBktStepValues(DataItemBase *data_item)
{
uint8_t cur_value = ((EXP_COMP_DATA_ITEM*)data_item)->Get();
vlExpCompStep.SetSize(0);
// Check value for zerro. Exit on zerro.
if (cur_value == 0)
return;
// Calculate negative and positive values of expo compensation
uint8_t negative_value = (cur_value & 0x80) ? cur_value : ~(cur_value - 1);
uint8_t positive_value = (cur_value & 0x80) ? ~(cur_value - 1) : cur_value;
// Get indices of negative and positive expo compensation values
uint16_t negative_index = vlExpCompensation.GetValueIndex(negative_value);
uint16_t positive_index = vlExpCompensation.GetValueIndex(positive_value);

nBktNegativeIndex = negative_index;
nBktPositiveIndex = positive_index;
// Calculate interval length
uint16_t len = positive_index - negative_index;

// Calculate zerro value index
uint16_t zerro_index = vlExpCompensation.GetValueIndex(0);

// Calculate positive index offset
uint16_t zerro_based_offset = positive_index - zerro_index;
// Calculate all possible interval indices
for (uint16_t i = zerro_based_offset, j = positive_index; i>0; i--, j--)
{
// Insert values into the list
if (len % i == 0)
vlExpCompStep.Append(vlExpCompensation.Get(j));
}
diBktStep.Set(cur_value);
diBktStep.SetUpdated(true);
};

void SpinUpdateBktStep(DataItemBase *data_item)
{
uint8_t cur_value = ((EXP_COMP_DATA_ITEM*)data_item)->Get();
nBktStep = vlExpCompensation.GetValueIndex(cur_value) - vlExpCompensation.GetValueIndex(0);
};

void MenuExit();
void MenuSetAperture();
void MenuSetShutterSpeed();
void MenuSetWb();
void MenuSetPStyle();
void MenuSetIso();
void MenuSetExpComp();

extern Menu mainMenu;

//--- Camera Settings Menu -----------------------------------------------------------------
MenuItem settingsMenuItems[] = { {&siMode, &MenuExit}, {&siAperture, &MenuSetAperture}, {&siWb, &MenuSetWb}, {&siShutterSpeed, &MenuSetShutterSpeed}, {&siPStyle, &MenuSetPStyle}, {&siIso, &MenuSetIso}, {&siExpComp, &MenuSetExpComp} };
Menu settingsMenu(8, 7, settingsMenuItems, 0, &mainMenu);

void MenuSetAperture() { spinAperture.SetReturnState(&settingsMenu); StateMachine::SetState(&spinAperture); };
void MenuSetShutterSpeed() { spinShutterSpeed.SetReturnState(&settingsMenu); StateMachine::SetState(&spinShutterSpeed); };
void MenuSetWb(){ spinWb.SetReturnState(&settingsMenu); StateMachine::SetState(&spinWb); };
void MenuSetPStyle(){ spinPStyle.SetReturnState(&settingsMenu); StateMachine::SetState(&spinPStyle); };
void MenuSetIso(){ spinIso.SetReturnState(&settingsMenu); StateMachine::SetState(&spinIso); };
void MenuSetExpComp(){ spinExpComp.SetReturnState(&mainMenu); StateMachine::SetState(&spinExpComp); };

//--- Self Timer Menu ----------------------------------------------------------------------
void MenuSelfSetH();
void MenuSelfSetM();
void MenuSelfSetS();

extern Menu timerSettingsMenu;

MenuItem selfSetMenuItems[] = { {&siHourSelf, &MenuSelfSetH}, {&siMinSelf, &MenuSelfSetM}, {&siSecSelf, &MenuSelfSetS} };
Menu selfSetMenu(3, 3, selfSetMenuItems, 0, &timerSettingsMenu);

void MenuSelfSetH() { hourSpinSelf.SetReturnState(&selfSetMenu); StateMachine::SetState(&hourSpinSelf); };
void MenuSelfSetM() { minSpinSelf.SetReturnState(&selfSetMenu); StateMachine::SetState(&minSpinSelf); };

//--- Timer Settings Menu ------------------------------------------------------------------
void MenuSelf();
void MenuBkt();
void MenuFrames();
void MenuInterval();
void MenuExit();
void MenuRun();

MenuItem timerSettingsMenuItems[] = { {&siSelf, &MenuSelf}, {&siFrames, &MenuFrames}, {&siBkt, &MenuBkt}, {&siInterval, &MenuInterval}, {&siRun, &MenuRun}, {&siExit, &MenuExit} };
Menu timerSettingsMenu(2, 6, timerSettingsMenuItems, 0, &mainMenu);

void MenuSelfSetS() { secSpinSelf.SetReturnState(&timerSettingsMenu); StateMachine::SetState(&secSpinSelf); };

void MenuSelf() { StateMachine::SetState(&selfSetMenu); };

void MenuBktSetStep();
void MenuBktStepExit();

MenuItem bktSetMenuItems[] = { {&siBktEV, &MenuBktSetStep}, {&siBktStep, &MenuBktStepExit} };
Menu bktSetMenu(5, 2, bktSetMenuItems, 0, &timerSettingsMenu);

void MenuBktSetStep()
{
spinBktEV.SetReturnState(&bktSetMenu);

if (vlExpCompensation.GetSize())
StateMachine::SetState(&spinBktEV);
};

void MenuBktStepExit()
{
spinBktStep.SetReturnState(&timerSettingsMenu);

if (vlExpCompensation.GetSize())
StateMachine::SetState(&spinBktStep);
};

void MenuBkt()
{
if (vlExpCompensation.GetSize())
StateMachine::SetState(&bktSetMenu);
};


IntSpin<IntDataItem<uint16_t, 5>, int16_t> framesSpin(0, 9999, 1, &diFramesCount, NULL);

void MenuFrames() { framesSpin.SetReturnState(&timerSettingsMenu); Screen::Set(4); StateMachine::SetState(&framesSpin); };

void MenuIntSetH();
void MenuIntSetM();
void MenuIntSetS();

MenuItem intSetMenuItems[] = { {&siHourInt, &MenuIntSetH}, {&siMinInt, &MenuIntSetM}, {&siSecInt, &MenuIntSetS} };
Menu intSetMenu(6, 3, intSetMenuItems, 0, &timerSettingsMenu);

void MenuIntSetH() { hourSpinInt.SetReturnState(&intSetMenu); StateMachine::SetState(&hourSpinInt); };
void MenuIntSetM() { minSpinInt.SetReturnState(&intSetMenu); StateMachine::SetState(&minSpinInt); };
void MenuIntSetS() { secSpinInt.SetReturnState(&timerSettingsMenu); StateMachine::SetState(&secSpinInt); };

void MenuInterval() { StateMachine::SetState(&intSetMenu); };

void MenuRunAbort()
{
hdrCapture.PostEvent(&evtAbort);
diFramesLeft.Set(0);
StateMachine::SetState(&timerSettingsMenu);
};

MenuItem runMenuItems[] = { {&siAbort, &MenuRunAbort} };
Menu runMenu(7, 1, runMenuItems, 0);

void MenuRun()
{
if (!diFramesCount.Get())
return;
uint32_t intr_timeout = ((uint32_t)diHourInt.Get() * 3600 + (uint32_t)diMinInt.Get() * 60 + (uint32_t)diSecInt.Get());
uint32_t self_timeout = ((uint32_t)diHourSelf.Get() * 3600 + (uint32_t)diMinSelf.Get() * 60 + (uint32_t)diSecSelf.Get());

diFramesLeft.Set(diFramesCount.Get());
diLeftTimer.Set(self_timeout);
diIntTimer.Set(intr_timeout);

SetEvt setEvt;
setEvt.sig = SET_FRAMES_SIG;
setEvt.value = diFramesCount.Get();
hdrCapture.dispatch(&setEvt);
setEvt.sig = SET_FRAME_TIMEOUT_SIG;
setEvt.value = intr_timeout;
hdrCapture.dispatch(&setEvt);
setEvt.sig = SET_SELF_TIMEOUT_SIG;
setEvt.value = self_timeout;
hdrCapture.dispatch(&setEvt);
SetBktEvt setBktEvt;
setBktEvt.sig = SET_BRACKETING_SIG;
setBktEvt.step = nBktStep;
setBktEvt.negative = nBktNegativeIndex;
setBktEvt.positive = nBktPositiveIndex;
hdrCapture.dispatch(&setBktEvt);
StateMachine::SetState(&runMenu);
setEvt.sig = RUN_SIG;
hdrCapture.dispatch(&setEvt);
};

//--- Main Menu ----------------------------------------------------------------------------
void MenuIntervalometer() { StateMachine::SetState(&timerSettingsMenu); };

void MenuSettings()
{
StateMachine::SetState(&settingsMenu);
};

MenuItem mainMenuItems[] = { {&siIntervalometer, &MenuIntervalometer}, {&siSettings, &MenuSettings} };
Menu mainMenu(1, 2, mainMenuItems, 0);

void MenuExit() { StateMachine::SetState(&mainMenu); };

class DummyMenu : public StateMachine
{
public:
virtual bool OnInitialState()
{
Screen::Set(0);
return true;
};
} DisconnectedState;

void CamStateHandlers::OnDeviceDisconnectedState(PTP *ptp)
{
if (stateConnected)
{
stateConnected = false;
PTPPollTimer.Disable();
StateMachine::SetState(&DisconnectedState);
}
}

void CamStateHandlers::OnDeviceInitializedState(PTP *ptp)
{
if (!stateConnected)
{
stateConnected = true;
PTPPollTimer.Enable();
StateMachine::SetState(&mainMenu);
}
hdrCapture.Run();
}

void CamHDRCapture::OnFrameCaptured(uint16_t left)
{
diFramesLeft.Set(left);

if (!left)
StateMachine::SetState(&timerSettingsMenu);
}

void CamHDRCapture::OnSelfTimerProgress(uint32_t left)
{
diLeftTimer.Set(left);
}

void CamHDRCapture::OnIntrTimerProgress(uint32_t left)
{
diIntTimer.Set(left);
}

void OnControlTimer()
{
ExtControls.CheckControls();
hdrCapture.PostEvent(&evtTick);
Screen::Run(&LCD);
}

void OnPTPPollTimer()
{
EOSEventParser prs;
Eos.EventCheck(&prs);
diLeftTimer.SetUpdated(true);
diIntTimer.SetUpdated(true);
}

void setup()
{
StateMachine::SetState(&DisconnectedState);
#ifdef PTPDEBUG
Serial.begin(115200);
#endif

Eos.Setup();
delay( 200 );
// set up the LCD's number of rows and columns:
LCD.begin(16, 2);
LCD.clear();
LCD.home();
LCD.setCursor(0,0);
PTPPollTimer.Set(OnPTPPollTimer, 300);
// 1ms is the perfect interval for encoder polling
ControlTimer.Set(OnControlTimer, 1);
ControlTimer.Enable();
evtTick.sig = TICK_MILLIS_SIG;
evtAbort.sig = ABORT_SIG;
hdrCapture.init();

#ifdef PTPDEBUG
Serial.println("Start");
#endif
}

void loop()
{
Eos.Task();
PTPPollTimer.Run();
ControlTimer.Run();
}

+ 0
- 49
lib/Arduino_Camera_Control/examples/EOSCamController/camcontroller.h View File

@@ -1,49 +0,0 @@
/* Camera controller header */
#ifndef __CAMCONTROLLER_H__
#define __CAMCONTROLLER_H__

#include <inttypes.h>
#include <avr/pgmspace.h>

#include <canoneos.h>
#include <eosvaluetitles.h>
#include "menu.h"

const char msgSetSelf[] PROGMEM = "SELF";
const char msgSetFrames[] PROGMEM = "FRMS";
const char msgSetBkt[] PROGMEM = "BKT";
const char msgSetInterval[] PROGMEM = "INT";
const char msgExit[] PROGMEM = "EXIT";
const char msgSetRun[] PROGMEM = "RUN ";
const char msgAbort[] PROGMEM = "ABORT";
const char msgLeft[] PROGMEM = "LEFT";

const char msgError[] PROGMEM = "ERROR:";
const char msgCamera[] PROGMEM = "CAMERA";
const char msgDisconnected[] PROGMEM = "DISCONNECTED";

const char msgSelfTimer[] PROGMEM = "SELF TIMER h/m/s";
const char msgBracketing[] PROGMEM = "BKT(RANGE/STEP)";
const char msgSteps[] PROGMEM = "steps";
const char msgCntFrames[] PROGMEM = "FRAMES";
const char msgIntTimer[] PROGMEM = "INT TIMER h/m/s";
const char msgIntervalometer[] PROGMEM = "INTERVAL";
const char msgSettings[] PROGMEM = "SETTINGS";
const char msgClock[] PROGMEM = "CLOCK";
const char msgEV[] PROGMEM = "EV";

typedef KeyValuePairDataItem<VT_EXPCOMP, VT_EXPCOMP_COUNT, VT_EXPCOMP_TEXT_LEN> EXP_COMP_DATA_ITEM; // Exposure compensation data item type
typedef SRAMValueList<VT_EXPCOMP, 16> BKT_STEP_VALUE_LIST; // Bracketing step value list type

//--- Data Item Types ---------------------------------------------------------
typedef KeyValuePairDataItem<VT_MODE, VT_MODE_COUNT, VT_MODE_TEXT_LEN> DIT_MODE;
typedef KeyValuePairDataItem<VT_APERTURE, VT_APT_COUNT, VT_APT_TEXT_LEN> DIT_APERTURE;
typedef KeyValuePairDataItem<VT_WB, VT_WB_COUNT, VT_WB_TEXT_LEN> DIT_WB;
typedef KeyValuePairDataItem<VT_SHSPEED, VT_SHSPEED_COUNT, VT_SHSPEED_TEXT_LEN> DIT_SHUTTER_SPEED;
typedef KeyValuePairDataItem<VT_PSTYLE, VT_PSTYLE_COUNT, VT_PSTYLE_TEXT_LEN> DIT_PSTYLE;
typedef KeyValuePairDataItem<VT_ISO, VT_ISO_COUNT, VT_ISO_TEXT_LEN> DIT_ISO;
typedef KeyValuePairDataItem<VT_EXPCOMP, VT_EXPCOMP_COUNT, VT_EXPCOMP_TEXT_LEN> DIT_EXPCOMP;
typedef IntDataItem<uint8_t, 3> DIT_TIMER_DIGIT_PAIR;


#endif //__CAMCONTROLLER_H__

+ 0
- 50
lib/Arduino_Camera_Control/examples/EOSCamController/controls.cpp View File

@@ -1,50 +0,0 @@
#include <Max3421e.h>
#include "controls.h"

StateMachine* StateMachine::currentState = NULL;

void GPInRegister::CheckControls()
{
int8_t enc_states[] = {0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0};
ControlStates previous = controlStates;
controlStates = (pMax->gpioRd() & (GPIN_ENCODER_MASK | GPIN_ENC_BUT_MASK | GPIN_EXT_BUT_MASK));
ControlStates changes = (previous ^ controlStates);
if (previous == controlStates)
return;
ControlEvents *state_machine = (ControlEvents*)StateMachine::GetState();
if ((changes & GPIN_ENCODER_MASK))
{
uint8_t encoder = (previous & GPIN_ENCODER_MASK);
encoder <<= 2;
encoder |= (controlStates & GPIN_ENCODER_MASK);
encoderValue += enc_states[(encoder & 0x0f)];
if (encoderValue > 3 || encoderValue < -3)
{
if (state_machine)
state_machine->OnEncoderChanged(encoderValue >> 2);
encoderValue = 0;
}
}
if (!state_machine)
return;
if ((changes & GPIN_ENC_BUT_MASK))
{
if ((controlStates & GPIN_ENC_BUT_MASK))
state_machine->OnEncButtonUp();
else
state_machine->OnEncButtonDown();
}
if ((changes & GPIN_EXT_BUT_MASK))
{
if ((controlStates & GPIN_EXT_BUT_MASK))
state_machine->OnExtButtonUp();
else
state_machine->OnExtButtonDown();
}
}

+ 0
- 50
lib/Arduino_Camera_Control/examples/EOSCamController/controls.h View File

@@ -1,50 +0,0 @@
#ifndef __CONTROLS_H__
#define __CONTROLS_H__

#include <inttypes.h>
#include <avr/pgmspace.h>

class StateMachine
{
static StateMachine *currentState;
protected:
virtual bool OnInitialState() { return true; };

public:
static void SetState(StateMachine *state) { currentState = state; currentState->OnInitialState(); };
static StateMachine* GetState() { return StateMachine::currentState; };
};

class ControlEvents : public StateMachine
{
public:
virtual bool OnEncoderChanged(int8_t value) { return true; };
virtual bool OnEncButtonUp() { return true; };
virtual bool OnEncButtonDown() { return true; };
virtual bool OnExtButtonUp() { return true; };
virtual bool OnExtButtonDown() { return true; };
};

#define GPIN_ENCODER_MASK 0x03
#define GPIN_ENC_BUT_MASK 0x08
#define GPIN_EXT_BUT_MASK 0x10

#define GPIN_ENC_BUT_MASK 0x04
#define GPIN_EXT_BUT_MASK 0x08


typedef uint8_t ControlStates;

class GPInRegister
{
ControlStates controlStates;
MAX3421E *pMax;
int8_t encoderValue;
public:
GPInRegister(MAX3421E *pmax) : controlStates(GPIN_ENCODER_MASK | GPIN_ENC_BUT_MASK | GPIN_EXT_BUT_MASK), pMax(pMax), encoderValue(0) {};
void CheckControls();
};

#endif // __CONTROLS_H__

+ 0
- 51
lib/Arduino_Camera_Control/examples/EOSCamController/dataitem.cpp View File

@@ -1,51 +0,0 @@
#include "dataitem.h"

char TimeSpanDataItem::textValue[9] = "";
char TimerDataItem::textValue[9] = "";

char* itoa2(int val, uint8_t buf_size, char *buf, int8_t base, char c)
{
char sign = (val < 0) ? '-' : c;
buf[buf_size-1] = 0;

int8_t i = buf_size-2;
for(; val && i ; --i, val /= base)
buf[i] = "0123456789abcdef"[(val < 0) ? -(val % base) : val % base];
for (; i > 0; i--)
buf[i] = c;
buf[0] = sign;
return buf;
}

char* itoa2(uint8_t val, uint8_t buf_size, char *buf, int8_t base, char c)
{
buf[buf_size-1] = 0;

int8_t i = buf_size-2;
for(; val && i>=0 ; --i, val /= base)
buf[i] = "0123456789abcdef"[(val < 0) ? -(val % base) : val % base];
for (; i >= 0; i--)
buf[i] = c;
return buf;
}

char* itoa2(uint16_t val, uint8_t buf_size, char *buf, int8_t base, char c)
{
buf[buf_size-1] = 0;

int8_t i = buf_size-2;
for(; val && i>=0 ; --i, val /= base)
buf[i] = "0123456789abcdef"[val % base];
for (; i >= 0; i--)
buf[i] = c;
return buf;
}

+ 0
- 194
lib/Arduino_Camera_Control/examples/EOSCamController/dataitem.h View File

@@ -1,194 +0,0 @@
#if !defined(__DATAITEM_H__)
#define __DATAITEM_H__

#include <inttypes.h>
#include <canoneos.h>
#include <SimpleTimer.h>
#include <valuelist.h>

#define MUL10( a ) (((a) << 3 ) + ((a) << 1 ))

char* itoa2(int val, uint8_t buf_size, char *buf, int8_t base, char c);
char* itoa2(uint8_t val, uint8_t buf_size, char *buf, int8_t base, char c);
char* itoa2(uint16_t val, uint8_t buf_size, char *buf, int8_t base, char c);

class DataItemBase
{
protected:
bool isUpdated;
public:
virtual void GetText(char** str, bool &is_pgm) = 0;
bool IsUpdated() { return isUpdated; };
void SetUpdated(bool upd) { isUpdated = upd; };
};

class TimeSpanDataItem : public DataItemBase
{
uint32_t dataValue;
static char textValue[9];
public:
TimeSpanDataItem(uint32_t s) : dataValue(s) {};

virtual void GetText(char** str, bool &is_pgm)
{
{
uint16_t h = dataValue / 3600;
itoa2((uint16_t) h, 3, (char*)&textValue, 10, '0');
}
{
textValue[2] = ':';
uint16_t s = dataValue % 3600;
itoa2((uint16_t) s / 60, 3, (char*)(textValue+3), 10, '0');
textValue[5] = ':';
itoa2((uint16_t) s % 60, 3, (char*)(textValue+6), 10, '0');
}
*str = textValue;
is_pgm = false;
};
virtual void Set(uint32_t &val)
{
dataValue = val;
isUpdated = true;
};
};

#define MUL60( a ) (((a) << 6 ) - ((a) << 2 ))
#define MUL3600( a ) (((a) << 12 ) - ((a) << 9 ) + ((a) << 4 ))

class TimerDataItem : public DataItemBase
{
SimpleTimer &dataValue;
static char textValue[9];
public:
TimerDataItem(SimpleTimer &t) : dataValue(t) {};

virtual void GetText(char** str, bool &is_pgm)
{
uint16_t time_left = dataValue.TimeLeft() / 1000;
uint16_t ss = time_left % 60;
time_left /= 60;
uint16_t mm = time_left % 60;
time_left /= 60;
uint16_t hh = time_left;
itoa2((uint16_t)hh, 3, (char*)&textValue, 10, '0');
textValue[2] = ':';
itoa2((uint16_t)mm, 3, (char*)(textValue+3), 10, '0');
textValue[5] = ':';
itoa2((uint16_t)ss, 3, (char*)(textValue+6), 10, '0');
*str = textValue;
is_pgm = false;
};
};

template <class VALUE_TYPE, const uint8_t TABLE_SIZE, const uint8_t TEXT_SIZE>
class KeyValuePairDataItem : public DataItemBase
{
VALUE_TYPE dataValue;
const ValueTitle<VALUE_TYPE, TEXT_SIZE> *ptrTitles;
public:
KeyValuePairDataItem(VALUE_TYPE val, const ValueTitle<VALUE_TYPE, TEXT_SIZE> *p) : dataValue(val), ptrTitles(p)
{};
virtual void GetText(char** str, bool &is_pgm)
{
*str = (char*)FindTitle<VALUE_TYPE, TEXT_SIZE>(TABLE_SIZE, ptrTitles, dataValue);
is_pgm = true;
};
VALUE_TYPE Get() { return dataValue; };
void Set(VALUE_TYPE val) { dataValue = val; isUpdated = true; };
};

template <class VALUE_TYPE, const uint8_t TEXT_LEN>
class IntDataItem : public DataItemBase
{
VALUE_TYPE dataValue;
static char valString[TEXT_LEN];
public:
IntDataItem() : dataValue(0) { isUpdated = true; };
IntDataItem(VALUE_TYPE data) : dataValue(data) {};
virtual void Set(VALUE_TYPE data)
{
dataValue = data;
isUpdated = true;
};
VALUE_TYPE Get() { return dataValue; };
virtual void GetText(char** str, bool &is_pgm)
{
*str = itoa2(dataValue, TEXT_LEN, (char*)&valString, 10, '0');
is_pgm = false;
};
void operator ++(int val)
{
dataValue += val;
isUpdated = true;
};
void operator --(int val)
{
dataValue -= val;
isUpdated = true;
};
};

template <class VALUE_TYPE, const uint8_t TEXT_LEN>
char IntDataItem<VALUE_TYPE,TEXT_LEN>::valString[TEXT_LEN] = "";

class PgmStringDataItem : public DataItemBase
{
const char *pStr;
public:
PgmStringDataItem(const char *str) : pStr(str) { isUpdated = true; };
void SetText(const char *str) { pStr = str; isUpdated = true; };
virtual void GetText(char** str, bool &is_pgm)
{
*str = (char*)pStr;
is_pgm = true;
};
};

template <const uint8_t STRLEN>
class StringDataItem : public DataItemBase
{
char theString[STRLEN];
void CopyString(char *src, char *dst)
{
char *s = src, *d = dst;
for (uint8_t cnt = 0; *s && cnt < STRLEN-1; cnt++, s++, d++)
*d = *s;
*d = 0;
};
public:
StringDataItem() { theString[0] = 0; isUpdated = true; };
StringDataItem(char *str) { CopyString(str, &theString); isUpdated = true; };

void SetText(char *str) { CopyString(str, &theString); isUpdated = true; };
virtual void GetText(char** str, bool &is_pgm)
{
*str = &theString;
is_pgm = false;
};
};


#endif // __DATAITEM_H__

+ 0
- 191
lib/Arduino_Camera_Control/examples/EOSCamController/eoseventparser.cpp View File

@@ -1,191 +0,0 @@
#include "eoseventparser.h"
#include "dataitem.h"
#include "camcontroller.h"

extern DIT_MODE diMode;
extern DIT_APERTURE diAperture;
extern DIT_WB diWb;
extern DIT_SHUTTER_SPEED diShutterSpeed;
extern DIT_PSTYLE diPStyle;
extern DIT_ISO diIso;
</