canon work
This commit is contained in:
parent
0e3bc563a7
commit
dc746fe6f4
|
@ -14,8 +14,6 @@
|
|||
*
|
||||
**/
|
||||
|
||||
|
||||
|
||||
#include "CanonBLERemote.h"
|
||||
#include <Arduino.h>
|
||||
#include "TickTwo.h"
|
||||
|
@ -24,18 +22,22 @@
|
|||
#include "esp_log.h"
|
||||
#include <esp32-hal-log.h>
|
||||
|
||||
#define SHUTTTER_BTN 14
|
||||
#define FOCUS_BTN 12
|
||||
#define SHUTTTER_BTN 12
|
||||
#define RELAY_PIN 14
|
||||
#define LED 22
|
||||
|
||||
void blink();
|
||||
bool ledState;
|
||||
volatile bool ledState;
|
||||
|
||||
String name_remote = "mcopy";
|
||||
const String name_remote = "mcopy";
|
||||
CanonBLERemote canon_ble(name_remote);
|
||||
TickTwo blinker(blink, 500);
|
||||
boolean connected = false;
|
||||
long last = -1;
|
||||
volatile boolean connected = false;
|
||||
|
||||
volatile long now;
|
||||
volatile long last = -1;
|
||||
|
||||
volatile byte cmd_char;
|
||||
|
||||
void blink(){
|
||||
digitalWrite(LED, ledState);
|
||||
|
@ -48,13 +50,14 @@ void setup()
|
|||
esp_log_level_set("*", ESP_LOG_INFO);
|
||||
|
||||
pinMode(SHUTTTER_BTN, INPUT_PULLUP);
|
||||
pinMode(FOCUS_BTN, INPUT_PULLUP);
|
||||
pinMode(LED, OUTPUT);
|
||||
|
||||
canon_ble.init();
|
||||
delay(1000);
|
||||
blinker.start();
|
||||
}
|
||||
|
||||
void connectBLE () {
|
||||
do {
|
||||
Serial.println("Pairing...");
|
||||
}
|
||||
|
@ -73,8 +76,29 @@ void setup()
|
|||
|
||||
void loop()
|
||||
{
|
||||
now = millis();
|
||||
if (Serial.available()) {
|
||||
/* read the most recent byte */
|
||||
cmd_char = (char)Serial.read();
|
||||
}
|
||||
if (cmd_char == 'c' && last + 1000 < now) {
|
||||
shutter();
|
||||
cmd_char = 'z';
|
||||
}
|
||||
// Shutter
|
||||
if (digitalRead(SHUTTTER_BTN) == LOW && last + 1000 < millis()){
|
||||
if (digitalRead(SHUTTTER_BTN) == LOW && last + 1000 < now){
|
||||
shutter();
|
||||
}
|
||||
blinker.update();
|
||||
if (connected && !canon_ble.isConnected()) {
|
||||
connected = false;
|
||||
Serial.println("Disconnected");
|
||||
blinker.interval(500);
|
||||
blinker.resume();
|
||||
}
|
||||
}
|
||||
|
||||
void shutter () {
|
||||
digitalWrite(LED, LOW);
|
||||
blinker.resume();
|
||||
Serial.println("Shutter pressed");
|
||||
|
@ -87,10 +111,3 @@ void loop()
|
|||
digitalWrite(LED, HIGH);
|
||||
last = millis();
|
||||
}
|
||||
blinker.update();
|
||||
if (connected && !canon_ble.isConnected()) {
|
||||
connected = false;
|
||||
Serial.println("Disconnected");
|
||||
blinker.interval(500);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue