Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 1701 → Rev 1702

/C-OSD/arducam-osd/libraries/PTPCamera/examples/EOSRemote/EOSConsole.cpp
0,0 → 1,428
#include "eosconsole.h"
#include <eosvaluetitles.h>
#include <valuelist.h>
 
extern CanonEOS Eos;
extern EEPROMByteList vlAperture;
extern EEPROMByteList vlShutterSpeed;
extern EEPROMByteList vlWhiteBalance;
extern EEPROMByteList vlPictureStyle;
extern EEPROMByteList vlIso;
extern EEPROMByteList vlExpCompensation;
 
extern uint8_t dpMode;
extern uint8_t dpAperture;
extern uint8_t dpShutterSpeed;
extern uint8_t dpWb;
extern uint8_t dpPStyle;
extern uint8_t dpIso;
extern uint8_t dpExpComp;
 
/* fixes avr-gcc incompatibility with virtual destructors */
void operator delete( void *p ) {}
 
const char* menuMain[] = {"Capture", "View Settings", "Change Settings"};
const char* menuChangeSettings[] = {"Aperture", "Shutter Speed", "WB", "Pict Style", "ISO", "Exp Comp"};
const char* menuUpDown[] = {"<<", ">>"};
 
void EOSConsole::ShowParams()
{
Notify(PSTR("\r\nMode:"));
Notify((char*)FindTitle<VT_MODE, VT_MODE_TEXT_LEN>(VT_MODE_COUNT, ModeTitles, dpMode));
Notify(PSTR("\r\nF:"));
Notify((char*)FindTitle<VT_APERTURE, VT_APT_TEXT_LEN>(VT_APT_COUNT, ApertureTitles, dpAperture));
Notify(PSTR("\r\nT:"));
Notify((char*)FindTitle<VT_SHSPEED, VT_SHSPEED_TEXT_LEN>(VT_SHSPEED_COUNT, ShutterSpeedTitles, dpShutterSpeed));
Notify(PSTR("\r\nWB:"));
Notify((char*)FindTitle<VT_WB, VT_WB_TEXT_LEN>(VT_WB_COUNT, WbTitles, dpWb));
Notify(PSTR("\r\nPict Style:"));
Notify((char*)FindTitle<VT_PSTYLE, VT_PSTYLE_TEXT_LEN>(VT_PSTYLE_COUNT, PStyleTitles, dpPStyle));
Notify(PSTR("\r\nISO:"));
Notify((char*)FindTitle<VT_ISO, VT_ISO_TEXT_LEN>(VT_ISO_COUNT, IsoTitles, dpIso));
Notify(PSTR("\r\nExp Comp:"));
Notify((char*)FindTitle<VT_EXPCOMP, VT_EXPCOMP_TEXT_LEN>(VT_EXPCOMP_COUNT, ExpCompTitles, dpExpComp));
Notify(PSTR("\r\n"));
}
 
QState EOSConsole::Initial(EOSConsole *me, QEvent const *e)
{
return Q_TRAN(&EOSConsole::Inactive);
}
 
QState EOSConsole::Inactive(EOSConsole *me, QEvent const *e)
{
switch (e->sig)
{
case TICK_SIG:
return Q_TRAN(&EOSConsole::Active);
}
return Q_SUPER(QHsm::top);
}
 
QState EOSConsole::Active(EOSConsole *me, QEvent const *e)
{
switch (e->sig)
{
case Q_INIT_SIG:
return Q_TRAN(&EOSConsole::MainMenu);
case TICK_SIG:
return Q_TRAN(&EOSConsole::Inactive);
}
return Q_SUPER(QHsm::top);
}
 
void EOSConsole::PrintMenuTitles(uint8_t count, const char **menu)
{
Serial.println("");
for (uint8_t i=0; i<=count; i++)
{
Serial.print(i, DEC);
Serial.print(". ");
if (i == 0)
Serial.println("<..>");
else
Serial.println(menu[i-1]);
}
Serial.println("");
}
 
QState EOSConsole::MainMenu(EOSConsole *me, QEvent const *e)
{
switch (e->sig)
{
case Q_ENTRY_SIG:
PrintMenuTitles(3, menuMain);
return Q_HANDLED();
case MENU_SELECT_SIG:
{
switch (((MenuSelectEvt*)e)->item_index)
{
case 0:
PrintMenuTitles(3, menuMain);
return Q_HANDLED();
case 1:
Eos.Capture();
return Q_HANDLED();
case 2:
ShowParams();
PrintMenuTitles(3, menuMain);
return Q_HANDLED();
case 3:
return Q_TRAN(&EOSConsole::ChangeSettingsMenu);
}
}
}
return Q_SUPER(&EOSConsole::Active);
}
 
QState EOSConsole::ChangeSettingsMenu(EOSConsole *me, QEvent const *e)
{
switch (e->sig)
{
case Q_ENTRY_SIG:
PrintMenuTitles(6, menuChangeSettings);
return Q_HANDLED();
case MENU_SELECT_SIG:
{
switch (((MenuSelectEvt*)e)->item_index)
{
case 0:
return Q_TRAN(&EOSConsole::MainMenu);
case 1: // Aperture
return Q_TRAN(&EOSConsole::ChangeApertureMenu);
case 2: // Shutter Speed
return Q_TRAN(&EOSConsole::ChangeShutterSpeedMenu);
case 3: // White Balance
return Q_TRAN(&EOSConsole::ChangeWBMenu);
case 4: // Picture Style
return Q_TRAN(&EOSConsole::ChangePStyleMenu);
case 5: // ISO
return Q_TRAN(&EOSConsole::ChangeIsoMenu);
case 6: // Exposure Compensation
return Q_TRAN(&EOSConsole::ChangeExpCompMenu);
} // switch
}
}
return Q_SUPER(&EOSConsole::Active);
}
 
QState EOSConsole::ChangeApertureMenu(EOSConsole *me, QEvent const *e)
{
switch (e->sig)
{
case Q_ENTRY_SIG:
PrintMenuTitles(2, menuUpDown);
return Q_HANDLED();
case MENU_SELECT_SIG:
{
uint8_t new_value;
switch (((MenuSelectEvt*)e)->item_index)
{
case 0:
return Q_TRAN(&EOSConsole::ChangeSettingsMenu);
case 2:
if (vlAperture.GetSize() > 0)
{
new_value = vlAperture.GetNext(dpAperture, 1);
Eos.SetProperty(EOS_DPC_Aperture, new_value);
}
return Q_HANDLED();
case 1:
if (vlAperture.GetSize() > 0)
{
new_value = vlAperture.GetPrev(dpAperture, 1);
Eos.SetProperty(EOS_DPC_Aperture, new_value);
}
return Q_HANDLED();
} // switch (((MenuSelectEvt*)e)->item_index)
} // case MENU_SELECT_SIG:
}
return Q_SUPER(&EOSConsole::Active);
}
 
QState EOSConsole::ChangeShutterSpeedMenu(EOSConsole *me, QEvent const *e)
{
switch (e->sig)
{
case Q_ENTRY_SIG:
PrintMenuTitles(2, menuUpDown);
return Q_HANDLED();
case MENU_SELECT_SIG:
{
uint8_t new_value;
switch (((MenuSelectEvt*)e)->item_index)
{
case 0:
return Q_TRAN(&EOSConsole::ChangeSettingsMenu);
case 2:
if (vlShutterSpeed.GetSize() > 0)
{
new_value = vlShutterSpeed.GetNext(dpShutterSpeed, 1);
Eos.SetProperty(EOS_DPC_ShutterSpeed, new_value);
}
return Q_HANDLED();
case 1:
if (vlShutterSpeed.GetSize() > 0)
{
new_value = vlShutterSpeed.GetPrev(dpShutterSpeed, 1);
Eos.SetProperty(EOS_DPC_ShutterSpeed, new_value);
}
return Q_HANDLED();
} // switch (((MenuSelectEvt*)e)->item_index)
} // case MENU_SELECT_SIG:
}
return Q_SUPER(&EOSConsole::Active);
}
 
QState EOSConsole::ChangeWBMenu(EOSConsole *me, QEvent const *e)
{
switch (e->sig)
{
case Q_ENTRY_SIG:
PrintMenuTitles(2, menuUpDown);
return Q_HANDLED();
case MENU_SELECT_SIG:
{
uint8_t new_value;
switch (((MenuSelectEvt*)e)->item_index)
{
case 0:
return Q_TRAN(&EOSConsole::ChangeSettingsMenu);
case 2:
if (vlWhiteBalance.GetSize() > 0)
{
new_value = vlWhiteBalance.GetNext(dpWb, 1);
Eos.SetProperty(EOS_DPC_WhiteBalance, new_value);
}
return Q_HANDLED();
case 1:
if (vlAperture.GetSize() > 0)
{
new_value = vlWhiteBalance.GetPrev(dpWb, 1);
Eos.SetProperty(EOS_DPC_WhiteBalance, new_value);
}
return Q_HANDLED();
} // switch (((MenuSelectEvt*)e)->item_index)
} // case MENU_SELECT_SIG:
}
return Q_SUPER(&EOSConsole::Active);
}
 
QState EOSConsole::ChangeIsoMenu(EOSConsole *me, QEvent const *e)
{
switch (e->sig)
{
case Q_ENTRY_SIG:
PrintMenuTitles(2, menuUpDown);
return Q_HANDLED();
case MENU_SELECT_SIG:
{
uint8_t new_value;
switch (((MenuSelectEvt*)e)->item_index)
{
case 0:
return Q_TRAN(&EOSConsole::ChangeSettingsMenu);
case 2:
if (vlIso.GetSize() > 0)
{
new_value = vlIso.GetNext(dpIso, 1);
Eos.SetProperty(EOS_DPC_Iso, new_value);
}
return Q_HANDLED();
case 1:
if (vlAperture.GetSize() > 0)
{
new_value = vlIso.GetPrev(dpIso, 1);
Eos.SetProperty(EOS_DPC_Iso, new_value);
}
return Q_HANDLED();
} // switch (((MenuSelectEvt*)e)->item_index)
} // case MENU_SELECT_SIG:
}
return Q_SUPER(&EOSConsole::Active);
}
 
QState EOSConsole::ChangePStyleMenu(EOSConsole *me, QEvent const *e)
{
switch (e->sig)
{
case Q_ENTRY_SIG:
PrintMenuTitles(2, menuUpDown);
return Q_HANDLED();
case MENU_SELECT_SIG:
{
uint8_t new_value;
switch (((MenuSelectEvt*)e)->item_index)
{
case 0:
return Q_TRAN(&EOSConsole::ChangeSettingsMenu);
case 2:
if (vlPictureStyle.GetSize() > 0)
{
new_value = vlPictureStyle.GetNext(dpPStyle, 1);
Eos.SetProperty(EOS_DPC_PictureStyle, new_value);
}
return Q_HANDLED();
case 1:
if (vlPictureStyle.GetSize() > 0)
{
new_value = vlPictureStyle.GetPrev(dpPStyle, 1);
Eos.SetProperty(EOS_DPC_PictureStyle, new_value);
}
return Q_HANDLED();
} // switch (((MenuSelectEvt*)e)->item_index)
} // case MENU_SELECT_SIG:
}
return Q_SUPER(&EOSConsole::Active);
}
 
QState EOSConsole::ChangeExpCompMenu(EOSConsole *me, QEvent const *e)
{
switch (e->sig)
{
case Q_ENTRY_SIG:
PrintMenuTitles(2, menuUpDown);
return Q_HANDLED();
case MENU_SELECT_SIG:
{
uint8_t new_value;
switch (((MenuSelectEvt*)e)->item_index)
{
case 0:
return Q_TRAN(&EOSConsole::ChangeSettingsMenu);
case 2:
if (vlExpCompensation.GetSize() > 0)
{
new_value = vlExpCompensation.GetNext(dpExpComp, 1);
Eos.SetProperty(EOS_DPC_ExposureCompensation, new_value);
}
return Q_HANDLED();
case 1:
if (vlExpCompensation.GetSize() > 0)
{
new_value = vlExpCompensation.GetPrev(dpExpComp, 1);
Eos.SetProperty(EOS_DPC_ExposureCompensation, new_value);
}
return Q_HANDLED();
} // switch (((MenuSelectEvt*)e)->item_index)
} // case MENU_SELECT_SIG:
}
return Q_SUPER(&EOSConsole::Active);
}
 
//static EOSConsole menu;
static TickEvt tick_evt;
//static MenuSelectEvt menu_sel_evt;
 
//............................................................................
 
//void setup()
//{
// Serial.begin( 115200 );
//
// menu.init(); // take the initial transition
//
// tick_evt.sig = TICK_SIG;
// tick_evt.fine_time = 0;
//}
 
int8_t EOSConsole::MenuSelect()
{
if( !Serial.available())
return -1;
uint8_t char_count = 0;
uint8_t index = 0;
while (Serial.available() > 0 && char_count < 2)
{
uint8_t key = Serial.read();
key -= '0';
if (index)
{
uint8_t tmp = index;
// index *= 10;
index <<= 3;
index += tmp;
index += tmp;
}
index += key;
char_count ++;
}
return (char_count) ? (int8_t)index : (int8_t)-1;
}
 
//void loop()
//{
// delay(100); // 100 ms delay
//
// if (++tick_evt.fine_time == 10)
// tick_evt.fine_time = 0;
//
// menu.dispatch(&tick_evt); // dispatch TICK event
//
// int8_t index = MenuSelect();
//
// if (index >= 0)
// {
// menu_sel_evt.sig = MENU_SELECT_SIG;
// menu_sel_evt.item_index = index;
// menu.dispatch(&menu_sel_evt); // dispatch the event
// }
//}
 
/C-OSD/arducam-osd/libraries/PTPCamera/examples/EOSRemote/EOSConsole.h
0,0 → 1,51
#if !defined(__EOSCONSOLE_H__)
#define __EOSCONSOLE_H__
 
#include <inttypes.h>
#include <avr/pgmspace.h>
#include <qep_port.h>
#include <WProgram.h>
#include <canoneos.h>
 
enum TextMenuSignals
{
MENU_SELECT_SIG = Q_USER_SIG,
TICK_SIG
};
 
struct TickEvt : public QEvent
{
uint8_t fine_time; // the fine 1/10 s counter
};
 
struct MenuSelectEvt : public QEvent
{
uint8_t item_index;
};
 
class EOSConsole : public QHsm
{
static void PrintMenuTitles(uint8_t count, const char **menu);
static void ShowParams();
public:
EOSConsole()
: QHsm((QStateHandler)&EOSConsole::Initial)
{};
int8_t MenuSelect();
 
protected:
static QState Initial(EOSConsole *me, QEvent const *e);
static QState Inactive(EOSConsole *me, QEvent const *e);
static QState Active(EOSConsole *me, QEvent const *e);
static QState MainMenu(EOSConsole *me, QEvent const *e);
static QState ChangeSettingsMenu(EOSConsole *me, QEvent const *e);
static QState ChangeApertureMenu(EOSConsole *me, QEvent const *e);
static QState ChangeShutterSpeedMenu(EOSConsole *me, QEvent const *e);
static QState ChangeWBMenu(EOSConsole *me, QEvent const *e);
static QState ChangePStyleMenu(EOSConsole *me, QEvent const *e);
static QState ChangeExpCompMenu(EOSConsole *me, QEvent const *e);
static QState ChangeIsoMenu(EOSConsole *me, QEvent const *e);
};
 
#endif // __EOSCONSOLE_H__
/C-OSD/arducam-osd/libraries/PTPCamera/examples/EOSRemote/EOSRemote.pde
0,0 → 1,147
/* EOS control terminal */
//#include <Spi.h>
#include <Max3421e.h>
#include <Usb.h>
#include <simpletimer.h>
#include <ptp.h>
#include <canoneos.h>
#include <qep_port.h>
#include <valuelist.h>
#include <eosvaluetitles.h>
 
#include "eoseventparser.h"
#include "eosconsole.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_EXPOCOR_LIST_OFFSET, EEP_EXPOCOR_LIST_SIZE);
EEPROMByteList vlExpCompensation(EEP_EXPOCOR_LIST_OFFSET, EEP_EXPOCOR_LIST_SIZE);
 
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);
};
 
CamStateHandlers CamStates;
SimpleTimer ControlTimer, PTPPollTimer;
 
CanonEOS Eos(DEV_ADDR, DATA_IN_EP, DATA_OUT_EP, INTERRUPT_EP, CONFIG_NUM, &CamStates);
QEvent evtTick, evtAbort;
EOSConsole eosConsole;
 
uint8_t dpMode = 0;
uint8_t dpAperture = 0;
uint8_t dpShutterSpeed = 0;
uint8_t dpWb = 0;
uint8_t dpPStyle = 0;
uint8_t dpIso = 0;
uint8_t dpExpComp = 0;
 
void CamStateHandlers::OnDeviceDisconnectedState(PTP *ptp)
{
if (stateConnected == stConnected || stateConnected == stInitial)
{
stateConnected = stDisconnected;
PTPPollTimer.Disable();
Notify(PSTR("Camera disconnected.\r\n"));
if (stateConnected == stConnected)
eosConsole.dispatch(&evtTick);
}
}
 
void CamStateHandlers::OnDeviceInitializedState(PTP *ptp)
{
if (stateConnected == stDisconnected)
{
stateConnected = stConnected;
PTPPollTimer.Enable();
eosConsole.dispatch(&evtTick);
}
int8_t index = eosConsole.MenuSelect();
if (index >= 0)
{
MenuSelectEvt menu_sel_evt;
menu_sel_evt.sig = MENU_SELECT_SIG;
menu_sel_evt.item_index = index;
eosConsole.dispatch(&menu_sel_evt); // dispatch the event
}
}
 
void OnControlTimer()
{
// ExtControls.CheckControls();
// hdrCapture.PostEvent(&evtTick);
// Screen::Run(&LCD);
}
 
void OnPTPPollTimer()
{
EOSEventParser prs;
Eos.EventCheck(&prs);
}
 
void setup()
{
Serial.begin(115200);
Eos.Setup();
delay( 200 );
PTPPollTimer.Set(OnPTPPollTimer, 300);
// 1ms is the perfect interval for encoder polling
ControlTimer.Set(OnControlTimer, 1);
ControlTimer.Enable();
evtTick.sig = TICK_SIG;
// evtAbort.sig = ABORT_SIG;
eosConsole.init();
 
Serial.println("Start");
}
 
void loop()
{
Eos.Task();
PTPPollTimer.Run();
ControlTimer.Run();
}
/C-OSD/arducam-osd/libraries/PTPCamera/examples/EOSRemote/eoseventparser.cpp
0,0 → 1,212
#include "eoseventparser.h"
#include <eosvaluetitles.h>
 
extern EEPROMByteList vlAperture;
extern EEPROMByteList vlShutterSpeed;
extern EEPROMByteList vlWhiteBalance;
extern EEPROMByteList vlPictureStyle;
extern EEPROMByteList vlExpCompensation;
extern EEPROMByteList vlIso;
 
extern uint8_t dpMode;
extern uint8_t dpAperture;
extern uint8_t dpShutterSpeed;
extern uint8_t dpWb;
extern uint8_t dpPStyle;
extern uint8_t dpIso;
extern uint8_t dpExpComp;
 
 
bool EOSEventParser::EventRecordParse(uint8_t **pp, uint16_t *pcntdn)
{
switch (nRecStage)
{
case 0:
// Retrieves the size of the event record
if (!valueParser.Parse(pp, pcntdn))
return false;
 
nRecSize = (uint16_t)varBuffer;
 
// calculates the number of event parameters ( size / 4 - 1 )
paramCountdown = (nRecSize >> 2) - 1;
paramCount = 1;
nRecSize -= 4;
nRecStage ++;
case 1:
for (; paramCountdown; paramCountdown--, paramCount++, nRecSize -= 4)
{
if (!valueParser.Parse(pp, pcntdn))
return false;
 
switch (paramCount)
{
// Event Code
case 1:
eosEvent.eventCode = (uint16_t)varBuffer;
break;
// Property Code
case 2:
// if (eosEvent.eventCode == EOS_EC_ObjectCreated)
// {
// }
eosEvent.propCode = (uint16_t)varBuffer;
break;
// C189 - Property Value, C18A - Enumerator Type
case 3:
eosEvent.propValue = varBuffer;
if (eosEvent.eventCode == EOS_EC_DevPropChanged)
{
switch (eosEvent.propCode)
{
case EOS_DPC_Aperture:
dpAperture = (uint8_t) varBuffer;
Notify(PSTR("F:"));
Notify((char*)FindTitle<VT_APERTURE, VT_APT_TEXT_LEN>(VT_APT_COUNT, ApertureTitles, dpAperture));
Notify(PSTR("\r\n"));
break;
case EOS_DPC_ShutterSpeed:
dpShutterSpeed = (uint8_t) varBuffer;
Notify(PSTR("T:"));
Notify((char*)FindTitle<VT_SHSPEED, VT_SHSPEED_TEXT_LEN>(VT_SHSPEED_COUNT, ShutterSpeedTitles, dpShutterSpeed));
Notify(PSTR("\r\n"));
break;
case EOS_DPC_ShootingMode:
dpMode = (uint8_t) varBuffer;
Notify(PSTR("Mode:"));
Notify((char*)FindTitle<VT_MODE, VT_MODE_TEXT_LEN>(VT_MODE_COUNT, ModeTitles, dpMode));
Notify(PSTR("\r\n"));
break;
case EOS_DPC_WhiteBalance:
dpWb = (uint8_t) varBuffer;
Notify(PSTR("WB:"));
Notify((char*)FindTitle<VT_WB, VT_WB_TEXT_LEN>(VT_WB_COUNT, WbTitles, dpWb));
Notify(PSTR("\r\n"));
break;
case EOS_DPC_PictureStyle:
dpPStyle = (uint8_t) varBuffer;
Notify(PSTR("Pict Style:"));
Notify((char*)FindTitle<VT_PSTYLE, VT_PSTYLE_TEXT_LEN>(VT_PSTYLE_COUNT, PStyleTitles, dpPStyle));
Notify(PSTR("\r\n"));
break;
case EOS_DPC_Iso:
dpIso = (uint8_t) varBuffer;
Notify(PSTR("ISO:"));
Notify((char*)FindTitle<VT_ISO, VT_ISO_TEXT_LEN>(VT_ISO_COUNT, IsoTitles, dpIso));
Notify(PSTR("\r\n"));
break;
case EOS_DPC_ExposureCompensation:
dpExpComp = (uint8_t) varBuffer;
Notify(PSTR("Exp Comp:"));
Notify((char*)FindTitle<VT_EXPCOMP, VT_EXPCOMP_TEXT_LEN>(VT_EXPCOMP_COUNT, ExpCompTitles, dpExpComp));
Notify(PSTR("\r\n"));
break;
};
}
break;
// C18A/enumType == 3 - Size of enumerator array
case 4:
if (eosEvent.eventCode == EOS_EC_DevPropValuesAccepted)
{
switch (eosEvent.propCode)
{
case EOS_DPC_Aperture:
vlAperture.SetSize((uint8_t)varBuffer);
break;
case EOS_DPC_ShutterSpeed:
vlShutterSpeed.SetSize((uint8_t)varBuffer);
break;
case EOS_DPC_WhiteBalance:
vlWhiteBalance.SetSize((uint8_t)varBuffer);
break;
case EOS_DPC_PictureStyle:
vlPictureStyle.SetSize((uint8_t)varBuffer);
break;
case EOS_DPC_Iso:
vlIso.SetSize((uint8_t)varBuffer);
break;
case EOS_DPC_ExposureCompensation:
vlExpCompensation.SetSize((uint8_t)varBuffer);
break;
};
}
break;
// C18A/enumType == 3 - Enumerator Values
default:
if (eosEvent.eventCode == EOS_EC_DevPropValuesAccepted)
{
switch (eosEvent.propCode)
{
case EOS_DPC_Aperture:
vlAperture.Set(paramCount-5, (uint8_t)varBuffer);
break;
case EOS_DPC_ShutterSpeed:
vlShutterSpeed.Set(paramCount-5, (uint8_t)varBuffer);
break;
case EOS_DPC_WhiteBalance:
vlWhiteBalance.Set(paramCount-5, (uint8_t)varBuffer);
break;
case EOS_DPC_PictureStyle:
vlPictureStyle.Set(paramCount-5, (uint8_t)varBuffer);
break;
case EOS_DPC_ExposureCompensation:
vlExpCompensation.Set(paramCount-5, (uint8_t)varBuffer);
break;
case EOS_DPC_Iso:
vlIso.Set(paramCount-5, (uint8_t)varBuffer);
break;
} // switch (eosEvent.propCode)
}
} // switch (paramCount)
} // for
nRecStage ++;
case 2:
if (nRecSize)
if (!byteSkipper.Skip(pp, pcntdn, nRecSize))
return false;
 
nRecSize = 0;
nRecStage = 0;
}
return true;
}
 
void EOSEventParser::InitEOSEventStruct()
{
eosEvent.eventCode = constInitialEventCode;
eosEvent.propCode = 0;
eosEvent.propValue = 0;
}
 
 
void EOSEventParser::Parse(const uint16_t len, const uint8_t *pbuf, const uint32_t &offset)
{
uint8_t *p = (uint8_t*) pbuf;
uint16_t cntdn = len;
 
switch (nStage)
{
case 0:
p += 12;
cntdn -= 12;
nStage ++;
case 1:
theBuffer.valueSize = 4;
valueParser.Initialize(&theBuffer);
InitEOSEventStruct();
nStage ++;
case 2:
while (1)
{
if (!EventRecordParse(&p, &cntdn))
return;
if (IsLastEventRecord())
break;
InitEOSEventStruct();
}
nStage = 0;
}
}
/C-OSD/arducam-osd/libraries/PTPCamera/examples/EOSRemote/eoseventparser.h
0,0 → 1,74
#ifndef __EOSEVENTPARSER_H__
#define __EOSEVENTPARSER_H__
 
#include <inttypes.h>
#include <avr/pgmspace.h>
#include <ptpcallback.h>
#include <canoneos.h>
 
 
struct EOSParamValues
{
uint8_t upperValue;
uint8_t currentValue;
uint8_t lowerValue;
};
 
#define MAX_OBJ_IN_LIST 8
 
class EOSEventParser : public PTPReadParser
{
const uint16_t constInitialEventCode;
 
uint8_t paramsChanged;
 
struct EOSEvent
{
uint16_t eventCode;
uint16_t propCode;
uint32_t propValue;
};
 
uint8_t nStage;
uint8_t nRecStage;
uint16_t nRecSize;
MultiValueBuffer theBuffer;
uint32_t varBuffer;
EOSEvent eosEvent;
uint16_t paramCountdown;
uint16_t paramCount;
 
MultiByteValueParser valueParser;
ByteSkipper byteSkipper;
 
bool EventRecordParse(uint8_t **pp, uint16_t *pcntdn);
bool IsLastEventRecord() { return (eosEvent.eventCode == 0); };
void InitEOSEventStruct();
 
public:
EOSEventParser() :
constInitialEventCode(0xFFFF),
nStage(0),
nRecStage(0),
nRecSize(0),
varBuffer(0),
paramCountdown(0),
paramsChanged(0)
{
theBuffer.pValue = &varBuffer;
};
 
void Reset()
{
nStage = 0;
nRecStage = 0;
nRecSize = 0;
varBuffer = 0;
paramCountdown = 0;
paramsChanged = 0;
};
 
virtual void Parse(const uint16_t len, const uint8_t *pbuf, const uint32_t &offset);
};
 
#endif // __EOSEVENTPARSER_H__
/C-OSD/arducam-osd/libraries/PTPCamera/examples/EOSRemote/valuetitles.h
0,0 → 1,263
/* Camera controller header */
#ifndef __VALUETITLES_H__
#define __VALUETITLES_H__
 
#include <inttypes.h>
#include <avr/pgmspace.h>
 
#include <canoneos.h>
#include <valuelist.h>
 
#define VT_MODE_COUNT 16
#define VT_APT_COUNT 54
#define VT_WB_COUNT 7
#define VT_SHSPEED_COUNT 74
#define VT_PSTYLE_COUNT 9
#define VT_ISO_COUNT 19
#define VT_EXPCOR_COUNT 37
 
const ValueTitle<uint8_t, 4> 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<uint8_t, 5> 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<uint8_t, 5> 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} }
};
 
const ValueTitle<uint8_t, 7> ExpCorTitles[] 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} }
};
 
const ValueTitle<uint8_t, 4> ModeTitles[] PROGMEM =
{
{0, {'P',' ',' ',0} },
{1, {'T','v',' ',0} },
{2, {'A','v',' ',0} },
{3, {'M',' ',' ',0} },
{4, {'B','l','b',0} },
{5, {'A','-','D',0} },
{6, {'D','E','P',0} },
{7, {'C',' ',' ',0} },
{8, {'L','c','k',0} },
{9, {'G','r','n',0} },
{10, {'N','g','h',0} },
{11, {'S','p','r',0} },
{13, {'L','n','d',0} },
{14, {'C','l','s',0} },
{15, {'N','/','F',0} }
};
 
const ValueTitle<uint8_t, 4> WbTitles[] PROGMEM =
{
{0, {'A','W','B',0} },
{1, {'D','a','y',0} },
{2, {'C','l','d',0} },
{3, {'T','n','g',0} },
{4, {'F','l','r',0} },
{5, {'S','t','r',0} },
{6, {'W','/','P',0} },
{8, {'S','h','d',0} }
};
 
const ValueTitle<uint8_t, 4> PStyleTitles[] PROGMEM =
{
{0x21, {'U','s','1',0} },
{0x22, {'U','s','2',0} },
{0x23, {'U','s','3',0} },
{0x81, {'S','t','d',0} },
{0x82, {'P','r','t',0} },
{0x83, {'L','n','d',0} },
{0x84, {'N','t','l',0} },
{0x85, {'F','t','h',0} },
{0x86, {'M','o','n',0} }
};
 
#endif //__VALUETITLES_H__