Update blink functionality. Probably will not work during start?

This commit is contained in:
Matt McWilliams 2023-03-01 13:51:54 -05:00
parent d0ef5d410d
commit 0e3bc563a7
4 changed files with 23 additions and 49 deletions

1
ino/mcopy_cam_canon/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
debug*

View File

@ -1,14 +0,0 @@
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Example OpenOCD configuration file for ESP32-WROVER-KIT board.
#
# For example, OpenOCD can be started for ESP32 debugging on
#
# openocd -f board/esp32-wrover-kit-3.3v.cfg
#
# Source the JTAG interface configuration file
source [find interface/ftdi/esp32_devkitj_v1.cfg]
set ESP32_FLASH_VOLTAGE 3.3
# Source the ESP32 configuration file
source [find target/esp32.cfg]

View File

@ -1,19 +0,0 @@
{
"name":"Arduino on ESP32",
"toolchainPrefix":"xtensa-esp32-elf",
"svdFile":"esp32.svd",
"request":"attach",
"postAttachCommands":[
"set remote hardware-watchpoint-limit 2",
"monitor reset halt",
"monitor gdb_sync",
"thb setup",
"c"
],
"overrideRestartCommands":[
"monitor reset halt",
"monitor gdb_sync",
"thb setup",
"c"
]
}

View File

@ -26,14 +26,16 @@
#define SHUTTTER_BTN 14
#define FOCUS_BTN 12
#define LED 2
#define LED 22
void blink();
bool ledState;
String name_remote = "mcopy";
CanonBLERemote canon_ble(name_remote);
TickTwo blinker(blink, 500, 0, MILLIS);
TickTwo blinker(blink, 500);
boolean connected = false;
long last = -1;
void blink(){
digitalWrite(LED, ledState);
@ -58,8 +60,13 @@ void setup()
}
while(!canon_ble.pair(10));
blinker.stop();
connected = true;
blinker.pause();
blinker.interval(100);
digitalWrite(LED, HIGH);
delay(1000);
Serial.println("Camera paired");
Serial.println(canon_ble.getPairedAddressString());
}
@ -67,24 +74,23 @@ void setup()
void loop()
{
// Shutter
if (digitalRead(SHUTTTER_BTN) == LOW){
blinker.pause();
Serial.println("Shutter pressed");
if (digitalRead(SHUTTTER_BTN) == LOW && last + 1000 < millis()){
digitalWrite(LED, LOW);
blinker.resume();
Serial.println("Shutter pressed");
if(!canon_ble.trigger()){
Serial.println("Trigger Failed");
}
blinker.resume();
}
// Focus
else if (digitalRead(FOCUS_BTN) == LOW){
blinker.pause();
Serial.println("Focus pressed");
digitalWrite(LED, LOW);
if(!canon_ble.focus()){
Serial.println("Focus failed");
}
blinker.resume();
digitalWrite(LED, HIGH);
last = millis();
}
blinker.update();
if (connected && !canon_ble.isConnected()) {
connected = false;
Serial.println("Disconnected");
blinker.interval(500);
}
}