From 0e3bc563a7066aa34f59e315d911a245089c84c4 Mon Sep 17 00:00:00 2001 From: mattmcw Date: Wed, 1 Mar 2023 13:51:54 -0500 Subject: [PATCH] Update blink functionality. Probably will not work during start? --- ino/mcopy_cam_canon/.gitignore | 1 + ino/mcopy_cam_canon/debug.cfg | 14 --------- ino/mcopy_cam_canon/debug_custom.json | 19 ------------- ino/mcopy_cam_canon/mcopy_cam_canon.ino | 38 ++++++++++++++----------- 4 files changed, 23 insertions(+), 49 deletions(-) create mode 100644 ino/mcopy_cam_canon/.gitignore delete mode 100644 ino/mcopy_cam_canon/debug.cfg delete mode 100644 ino/mcopy_cam_canon/debug_custom.json diff --git a/ino/mcopy_cam_canon/.gitignore b/ino/mcopy_cam_canon/.gitignore new file mode 100644 index 0000000..0a5cc89 --- /dev/null +++ b/ino/mcopy_cam_canon/.gitignore @@ -0,0 +1 @@ +debug* \ No newline at end of file diff --git a/ino/mcopy_cam_canon/debug.cfg b/ino/mcopy_cam_canon/debug.cfg deleted file mode 100644 index aa99b3e..0000000 --- a/ino/mcopy_cam_canon/debug.cfg +++ /dev/null @@ -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] diff --git a/ino/mcopy_cam_canon/debug_custom.json b/ino/mcopy_cam_canon/debug_custom.json deleted file mode 100644 index b890268..0000000 --- a/ino/mcopy_cam_canon/debug_custom.json +++ /dev/null @@ -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" - ] -} \ No newline at end of file diff --git a/ino/mcopy_cam_canon/mcopy_cam_canon.ino b/ino/mcopy_cam_canon/mcopy_cam_canon.ino index 7b1049c..ab65ef1 100644 --- a/ino/mcopy_cam_canon/mcopy_cam_canon.ino +++ b/ino/mcopy_cam_canon/mcopy_cam_canon.ino @@ -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); + } } \ No newline at end of file