mcopy/ino/mcopy_cam_canon_ble/mcopy_cam_canon_ble.ino

92 lines
1.3 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 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);
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);
}
2023-03-03 15:13:40 +00:00
void connectBLE () {
do {
//
}
while(!canon_ble.pair(10));
connected = true;
//mc.log("Camera paired");
//mc.log(canon_ble.getPairedAddressString());
}
void loop()
{
2023-03-03 15:13:40 +00:00
now = millis();
// Shutter
2023-06-28 16:43:24 +00:00
if (connected){ //&&
2023-04-12 18:52:05 +00:00
camera();
}
if (connected && !canon_ble.isConnected()) {
connected = false;
}
2023-04-14 00:39:24 +00:00
if (!bleInit && mc.connected && mc.identified) {
2023-06-28 16:43:24 +00:00
//mc.log("Initializing BLE...");
canon_ble.init();
bleInit = true;
delay(1000);
}
if (!connected && mc.connected && mc.identified) {
2023-06-28 16:43:24 +00:00
//mc.log("Connecting BLE...");
2023-04-14 00:39:24 +00:00
connectBLE();
}
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 16:43:24 +00:00
//mc.log("Shutter pressed");
2023-03-03 15:13:40 +00:00
if(!canon_ble.trigger()){
2023-06-28 16:43:24 +00:00
//mc.log("camera() failed");
2023-03-03 15:13:40 +00:00
}
2023-04-12 18:52:05 +00:00
end = millis();
}