mcopy/ino/mcopy_cam_canon_ble/mcopy_cam_canon_ble.ino

95 lines
1.4 KiB
Arduino
Raw Normal View History

2023-02-28 04:16:44 +00:00
/**
*
* Camera Remote Menu
*
*
*
*
*
* Camera Settings
*
*
*
*
*
**/
#include "CanonBLERemote.h"
#include <Arduino.h>
#define RXD2 16
#define TXD2 -1
#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";
CanonBLERemote canon_ble(name_remote);
HardwareSerial Serial2(1);
2023-03-26 20:06:08 +00:00
2023-03-03 15:13:40 +00:00
volatile boolean connected = false;
volatile boolean bleInit = false;
2023-03-03 15:13:40 +00:00
volatile long now;
volatile long last = -1;
volatile char cmdChar = 'z';
void setup () {
esp_log_level_set("*", ESP_LOG_NONE);
delay(500);
Serial2.begin(57600, SERIAL_8N1, RXD2, TXD2);
}
2023-03-03 15:13:40 +00:00
void connectBLE () {
do {
//
}
while(!canon_ble.pair(10));
connected = true;
Serial2.println('C');
}
void loop () {
2023-03-03 15:13:40 +00:00
now = millis();
if (Serial2.available() > 0) {
cmdChar = Serial2.read();
}
if (connected && cmdChar == 'c') {
camera();
}
2023-04-14 00:39:24 +00:00
if (!bleInit && !connected && cmdChar == 'i') {
canon_ble.init();
bleInit = true;
Serial2.println('i');
}
2023-06-29 00:01:53 +00:00
if (!connected && cmdChar == 'C') {
2023-04-14 00:39:24 +00:00
connectBLE();
}
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;
if (!canon_ble.trigger()) {
Serial2.println('E');
2023-03-03 15:13:40 +00:00
}
Serial2.println('c');
2023-03-03 15:13:40 +00:00
2023-04-12 18:52:05 +00:00
end = millis();
}