mirror of
https://github.com/eddyem/stm32samples.git
synced 2026-05-07 05:17:03 +03:00
add enable/disable command
This commit is contained in:
@@ -172,6 +172,7 @@ void canon_init(){
|
||||
*/
|
||||
void canon_proc(){
|
||||
static uint32_t Tconn = 0;
|
||||
if(state == LENS_DISABLED) return;
|
||||
if(state == LENS_DISCONNECTED){
|
||||
if(!LENSCONNECTED()){
|
||||
Tconn = 0;
|
||||
@@ -404,3 +405,25 @@ int canon_getinfo(){
|
||||
uint16_t canon_getstate(){
|
||||
return state | (inistate << 8);
|
||||
}
|
||||
|
||||
void canon_disable(){
|
||||
if(state == LENS_DISABLED) return;
|
||||
state = LENS_DISABLED;
|
||||
LENS_OFF();
|
||||
ready = 0;
|
||||
}
|
||||
|
||||
void canon_enable(){
|
||||
if(state != LENS_DISABLED) return;
|
||||
if(OVERCURRENT()){
|
||||
state = LENS_OVERCURRENT;
|
||||
return;
|
||||
}
|
||||
if(!LENSCONNECTED()){
|
||||
state = LENS_DISCONNECTED;
|
||||
return;
|
||||
}
|
||||
LENS_ON();
|
||||
state = LENS_SLEEPING;
|
||||
ready = 1;
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@ typedef enum{
|
||||
LENS_INITIALIZED, // initializing process
|
||||
LENS_READY, // ready to operate
|
||||
LENS_ERR, // some error occured - reconnect after REINIT_PAUSE
|
||||
LENS_DISABLED, // powered off by command
|
||||
LENS_S_AMOUNT
|
||||
} lens_state;
|
||||
|
||||
@@ -109,6 +110,8 @@ typedef enum{
|
||||
|
||||
void canon_init();
|
||||
void canon_proc();
|
||||
void canon_disable();
|
||||
void canon_enable();
|
||||
int canon_diaphragm(char command);
|
||||
int canon_focus(int16_t val);
|
||||
int canon_sendcmd(uint8_t cmd);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 18.0.0, 2026-03-25T15:00:48. -->
|
||||
<!-- Written by QtCreator 18.0.0, 2026-04-14T09:27:26. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
||||
Binary file not shown.
@@ -48,6 +48,7 @@ int main(void){
|
||||
|
||||
uint32_t SPIctr = Tms;
|
||||
while(1){
|
||||
// TODO: add CAN bus parsing
|
||||
IWDG->KR = IWDG_REFRESH;
|
||||
if(Tms - SPIctr > CANONPROC_INTERVAL){ // not more than once per 10ms
|
||||
SPIctr = Tms;
|
||||
|
||||
@@ -31,6 +31,8 @@ static const char *OK = "OK", *FAIL = "FAIL";
|
||||
|
||||
const char* helpmsg =
|
||||
"https://github.com/eddyem/stm32samples/tree/master/F1-nolib/Canon_managing_device build#" BUILD_NUMBER " @ " BUILD_DATE "\n"
|
||||
"# - turn off lens power\n"
|
||||
"* - turn on lens power\n"
|
||||
"0 - move to smallest foc value (e.g. 2.5m)\n"
|
||||
"1 - move to largest foc value (e.g. infinity)\n"
|
||||
"a - move focus to given ABSOLUTE position or get current value (without number)\n"
|
||||
@@ -105,6 +107,7 @@ const char *connmsgs[LENS_S_AMOUNT+1] = {
|
||||
[LENS_INITIALIZED] = "initialized",
|
||||
[LENS_READY] = "ready",
|
||||
[LENS_ERR] = "error",
|
||||
[LENS_DISABLED] = "turned off",
|
||||
[LENS_S_AMOUNT] = "wrong state"
|
||||
};
|
||||
const char *inimsgs[INI_S_AMOUNT+1] = {
|
||||
@@ -128,6 +131,14 @@ void parse_cmd(const char *buf){
|
||||
lastFloodTime= FALSE;
|
||||
if(buf[1] == '\n' || !buf[1]){ // one symbol commands
|
||||
switch(*buf){
|
||||
case '*':
|
||||
canon_enable();
|
||||
USB_sendstr(OK);
|
||||
break;
|
||||
case '#':
|
||||
canon_disable();
|
||||
USB_sendstr(OK);
|
||||
break;
|
||||
case 'a':
|
||||
case 'f':
|
||||
errw(canon_focus(-1));
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#define BUILD_NUMBER "114"
|
||||
#define BUILD_DATE "2025-03-12"
|
||||
#define BUILD_NUMBER "133"
|
||||
#define BUILD_DATE "2026-04-14"
|
||||
|
||||
Reference in New Issue
Block a user