2023-02-28 04:16:44 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Camera Remote Menu
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Camera Settings
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
|
2023-02-26 03:24:29 +00:00
|
|
|
#include "CanonBLERemote.h"
|
|
|
|
#include <Arduino.h>
|
|
|
|
|
2023-06-28 19:06:11 +00:00
|
|
|
#define RXD2 16
|
|
|
|
#define TXD2 -1
|
|
|
|
|
2023-02-26 03:24:29 +00:00
|
|
|
#define LOG_LOCAL_LEVEL ESP_LOG_INFO
|
|
|
|
#include "esp_log.h"
|
|
|
|
#include <esp32-hal-log.h>
|
|
|
|
|
2023-03-03 15:13:40 +00:00
|
|
|
const String name_remote = "mcopy";
|
2023-02-26 03:24:29 +00:00
|
|
|
CanonBLERemote canon_ble(name_remote);
|
2023-06-28 19:06:11 +00:00
|
|
|
HardwareSerial Serial2(1);
|
2023-03-26 20:06:08 +00:00
|
|
|
|
2023-03-03 15:13:40 +00:00
|
|
|
volatile boolean connected = false;
|
2023-04-21 02:50:48 +00:00
|
|
|
volatile boolean bleInit = false;
|
2023-03-03 15:13:40 +00:00
|
|
|
|
|
|
|
volatile long now;
|
|
|
|
volatile long last = -1;
|
|
|
|
|
2023-04-12 03:26:12 +00:00
|
|
|
volatile char cmdChar = 'z';
|
2023-02-26 03:24:29 +00:00
|
|
|
|
2023-06-28 19:06:11 +00:00
|
|
|
void setup () {
|
2023-04-21 02:50:48 +00:00
|
|
|
esp_log_level_set("*", ESP_LOG_NONE);
|
2023-06-28 19:06:11 +00:00
|
|
|
delay(500);
|
|
|
|
Serial2.begin(57600, SERIAL_8N1, RXD2, TXD2);
|
2023-04-12 03:26:12 +00:00
|
|
|
}
|
|
|
|
|
2023-03-03 15:13:40 +00:00
|
|
|
void connectBLE () {
|
2023-02-26 03:24:29 +00:00
|
|
|
do {
|
2023-06-28 16:41:54 +00:00
|
|
|
//
|
2023-02-26 03:24:29 +00:00
|
|
|
}
|
|
|
|
while(!canon_ble.pair(10));
|
|
|
|
|
2023-03-01 18:51:54 +00:00
|
|
|
connected = true;
|
2023-06-28 19:06:11 +00:00
|
|
|
Serial2.println('C');
|
2023-02-26 03:24:29 +00:00
|
|
|
}
|
|
|
|
|
2023-06-28 19:06:11 +00:00
|
|
|
void loop () {
|
2023-03-03 15:13:40 +00:00
|
|
|
now = millis();
|
2023-03-10 02:18:10 +00:00
|
|
|
|
2023-06-28 19:06:11 +00:00
|
|
|
if (Serial2.available() > 0) {
|
|
|
|
cmdChar = Serial2.read();
|
2023-02-26 03:24:29 +00:00
|
|
|
}
|
2023-03-10 02:30:59 +00:00
|
|
|
|
2023-06-28 19:06:11 +00:00
|
|
|
if (connected && cmdChar == 'c') {
|
|
|
|
camera();
|
2023-03-01 18:51:54 +00:00
|
|
|
}
|
2023-04-14 00:39:24 +00:00
|
|
|
|
2023-06-28 19:06:11 +00:00
|
|
|
if (!bleInit && !connected && cmdChar == 'i') {
|
2023-04-21 02:50:48 +00:00
|
|
|
canon_ble.init();
|
|
|
|
bleInit = true;
|
2023-06-28 19:06:11 +00:00
|
|
|
Serial2.println('i');
|
2023-04-21 02:50:48 +00:00
|
|
|
}
|
|
|
|
|
2023-06-29 00:01:53 +00:00
|
|
|
if (!connected && cmdChar == 'C') {
|
2023-04-14 00:39:24 +00:00
|
|
|
connectBLE();
|
|
|
|
}
|
2023-06-28 19:06:11 +00:00
|
|
|
|
|
|
|
if (connected && !canon_ble.isConnected()) {
|
|
|
|
connected = false;
|
|
|
|
Serial2.println('d');
|
|
|
|
}
|
|
|
|
|
|
|
|
cmdChar = 'z';
|
2023-03-03 15:13:40 +00:00
|
|
|
}
|
|
|
|
|
2023-04-12 18:52:05 +00:00
|
|
|
void camera () {
|
|
|
|
long start = now;
|
|
|
|
long end;
|
|
|
|
|
2023-06-28 19:06:11 +00:00
|
|
|
if (!canon_ble.trigger()) {
|
|
|
|
Serial2.println('E');
|
2023-03-03 15:13:40 +00:00
|
|
|
}
|
2023-06-28 19:06:11 +00:00
|
|
|
Serial2.println('c');
|
2023-03-03 15:13:40 +00:00
|
|
|
|
2023-04-12 18:52:05 +00:00
|
|
|
end = millis();
|
|
|
|
}
|