fixed schematics @ canon managing, add initialization for absolute positioning, TODO: add CAN bus management

This commit is contained in:
2023-03-15 17:50:49 +03:00
parent 46c77abaed
commit 681f3253d7
37 changed files with 2535 additions and 1735 deletions

View File

@@ -22,12 +22,26 @@
// all data sent in big-endian format
// max length of commands
// max length of commands buffer
#define MAXCMDLEN (32)
// connection timeout (100ms): do nothing until this timeout
#define CONN_TIMEOUT (100)
// pause after error before next reinit
#define REINIT_PAUSE (5000)
// waiting for starting moving - 0.25s
#define MOVING_PAUSE (250)
// answer for cmd "POLL"
#define CANON_POLLANS (0xaa)
// bad focus value - 32767
#define BADFOCVAL (0x7fff)
// maximal
typedef enum{
CANON_LONGID = 0x00, // long ID ???
CANON_ID = 0x01, // lens ID and other info ???
@@ -37,7 +51,7 @@ typedef enum{
CANON_FMIN = 0x06, // =//= min
CANON_POWERON = 0x07, // turn on motors' power
CANON_POWEROFF = 0x08, // turn off power
CANON_POLL = 0x0a, // bysu poll (ans 0xaa when ready or last command code)
CANON_POLL = 0x0a, // busy poll (ans 0xaa when ready or last command code)
CANON_DIAPHRAGM = 0x13, // open/close diaphragm by given (int8_t) value of steps
CANON_FOCMOVE = 0x44, // move focus dial by given amount of steps (int16)
CANON_FOCBYHANDS= 0x5e, // turn on focus move by hands (to turn off send 4,5 or 6)
@@ -48,11 +62,33 @@ typedef enum{
CANON_GETFOCM = 0xc2, // get focus position in meters (not for all lenses)
} canon_commands;
typedef enum{
LENS_DISCONNECTED, // no lens found
LENS_SLEEPING, // do nothing until init
LENS_OVERCURRENT, // short circuit
LENS_INITIALIZED, // initializing process
LENS_READY, // ready to operate
LENS_ERR, // some error occured - reconnect after REINIT_PAUSE
LENS_S_AMOUNT
} lens_state;
typedef enum{
INI_START, // base init done, start F initialization
INI_FGOTOZ, // wait until focus gone to minimal value
INI_FPREPMAX, // prepare to go to max
INI_FGOTOMAX, // go to max F value
INI_FPREPOLD, // prepare to go to old
INI_FGOTOOLD, // go to starting F value
INI_READY, // all OK
INI_ERR, // error on any init step
INI_S_AMOUNT
} lensinit_state;
void canon_init();
void canon_proc();
int canon_diaphragm(char command);
int canon_focus(int16_t val);
int canon_sendcmd(uint8_t cmd);
int canon_asku16(uint8_t cmd);
void canon_setlastcmd(uint8_t x);
int canon_getinfo();
uint16_t canon_getstate();