canon_ble #82

Merged
mattmcw merged 149 commits from canon_ble into main 2023-08-01 03:38:52 +00:00
6 changed files with 125 additions and 31 deletions
Showing only changes of commit 844bb286a5 - Show all commits

View File

@ -3,23 +3,20 @@
#include "McopySerial.h"
McopySerial::McopySerial () {
//create mcopy serial
}
void McopySerial::on()
void McopySerial::begin () {
Serial.begin(baud);
}
void McopySerial::loop () {
char McopySerial::loop () {
if (Serial.available()) {
cmdChar = (char) Serial.read();
}
if (cmdChar != 'z') {
//cmd(cmdChar);
} else {
cmdChar = 'z';
}
return cmdChar;
}
void McopySerial::setBaud (int baudRate) {

View File

@ -3,8 +3,6 @@
#include "Arduino.h"
typedef void (*mcopy_callback)(void);
class McopySerial {
private:
@ -13,14 +11,60 @@ class McopySerial {
volatile char cmdChar = 'z';
public:
/* CMD FLAGS */
char BLACK = 'b';
char CAMERA = 'c';
char CAMERA_BACKWARD = 'f';
char CAMERA_CAPPER_IDENTIFIER = '8';
char CAMERA_CAPPER_PROJECTOR_IDENTIFIER = '9';
char CAMERA_CAPPER_PROJECTORS_IDENTIFIER = '0';
char CAMERA_FORWARD = 'e';
char CAMERA_IDENTIFIER = 'k';
char CAMERA_PROJECTORS_IDENTIFIER = '5';
char CAMERA_SECOND = '3';
char CAMERA_SECOND_BACKWARD = '2';
char CAMERA_SECOND_FORWARD = '1';
char CAMERA_SECOND_IDENTIFIER = 'y';
char CAMERA_TIMED = 'n';
char CAMERAS = '4';
char CAMERAS_IDENTIFIER = 'a';
char CAMERAS_PROJECTOR_IDENTIFIER = '6';
char CAMERAS_PROJECTORS_IDENTIFIER = '7';
char CAPPER_IDENTIFIER = 'C';
char CAPPER_OFF = 'B';
char CAPPER_ON = 'A';
char CONNECT = 'i';
char DEBUG = 'd';
char LIGHT = 'l';
char LIGHT_IDENTIFIER = 'o';
char MCOPY_IDENTIFIER = 'm';
char PROJECTOR = 'p';
char PROJECTOR_BACKWARD = 'h';
char PROJECTOR_CAMERA_IDENTIFIER = 's';
char PROJECTOR_CAMERA_LIGHT_IDENTIFIER = 'r';
char PROJECTOR_FORWARD = 'g';
char PROJECTOR_IDENTIFIER = 'j';
char PROJECTOR_LIGHT_IDENTIFIER = 'q';
char PROJECTOR_SECOND = 'w';
char PROJECTOR_SECOND_BACKWARD = 'v';
char PROJECTOR_SECOND_FORWARD = 'u';
char PROJECTOR_SECOND_IDENTIFIER = 't';
char PROJECTORS = 'x';
char PROJECTORS_IDENTIFIER = 'd';
char TAKEUP_BACKWARD = 'E';
char TAKEUP_FORWARD = 'D';
/* END CMD FLAGS */
McopySerial();
void begin();
void setBaud(int baudRate);
void loop();
char loop();
void debug (bool state);
void log (String message);
};
#endif
#endif

View File

@ -3,23 +3,20 @@
#include "McopySerial.h"
McopySerial::McopySerial () {
//create mcopy serial
}
void McopySerial::on()
void McopySerial::begin () {
Serial.begin(baud);
}
void McopySerial::loop () {
char McopySerial::loop () {
if (Serial.available()) {
cmdChar = (char) Serial.read();
}
if (cmdChar != 'z') {
//cmd(cmdChar);
} else {
cmdChar = 'z';
}
return cmdChar;
}
void McopySerial::setBaud (int baudRate) {

View File

@ -3,8 +3,6 @@
#include "Arduino.h"
typedef void (*mcopy_callback)(void);
class McopySerial {
private:
@ -13,14 +11,60 @@ class McopySerial {
volatile char cmdChar = 'z';
public:
/* CMD FLAGS */
char BLACK = 'b';
char CAMERA = 'c';
char CAMERA_BACKWARD = 'f';
char CAMERA_CAPPER_IDENTIFIER = '8';
char CAMERA_CAPPER_PROJECTOR_IDENTIFIER = '9';
char CAMERA_CAPPER_PROJECTORS_IDENTIFIER = '0';
char CAMERA_FORWARD = 'e';
char CAMERA_IDENTIFIER = 'k';
char CAMERA_PROJECTORS_IDENTIFIER = '5';
char CAMERA_SECOND = '3';
char CAMERA_SECOND_BACKWARD = '2';
char CAMERA_SECOND_FORWARD = '1';
char CAMERA_SECOND_IDENTIFIER = 'y';
char CAMERA_TIMED = 'n';
char CAMERAS = '4';
char CAMERAS_IDENTIFIER = 'a';
char CAMERAS_PROJECTOR_IDENTIFIER = '6';
char CAMERAS_PROJECTORS_IDENTIFIER = '7';
char CAPPER_IDENTIFIER = 'C';
char CAPPER_OFF = 'B';
char CAPPER_ON = 'A';
char CONNECT = 'i';
char DEBUG = 'd';
char LIGHT = 'l';
char LIGHT_IDENTIFIER = 'o';
char MCOPY_IDENTIFIER = 'm';
char PROJECTOR = 'p';
char PROJECTOR_BACKWARD = 'h';
char PROJECTOR_CAMERA_IDENTIFIER = 's';
char PROJECTOR_CAMERA_LIGHT_IDENTIFIER = 'r';
char PROJECTOR_FORWARD = 'g';
char PROJECTOR_IDENTIFIER = 'j';
char PROJECTOR_LIGHT_IDENTIFIER = 'q';
char PROJECTOR_SECOND = 'w';
char PROJECTOR_SECOND_BACKWARD = 'v';
char PROJECTOR_SECOND_FORWARD = 'u';
char PROJECTOR_SECOND_IDENTIFIER = 't';
char PROJECTORS = 'x';
char PROJECTORS_IDENTIFIER = 'd';
char TAKEUP_BACKWARD = 'E';
char TAKEUP_FORWARD = 'D';
/* END CMD FLAGS */
McopySerial();
void begin();
void setBaud(int baudRate);
void loop();
char loop();
void debug (bool state);
void log (String message);
};
#endif
#endif

View File

@ -33,14 +33,14 @@ volatile bool ledState;
const String name_remote = "mcopy";
CanonBLERemote canon_ble(name_remote);
TickTwo blinker(blink, 500);
//McopySerial mc;
McopySerial mc;
volatile boolean connected = false;
volatile long now;
volatile long last = -1;
volatile byte cmd_char;
volatile byte cmd;
void blink(){
digitalWrite(LED, ledState);
@ -81,14 +81,12 @@ void connectBLE () {
void loop()
{
now = millis();
if (Serial.available()) {
/* read the most recent byte */
cmd_char = (char)Serial.read();
}
if (cmd_char == 'c' && last + 1000 < now) {
cmd = mc.loop();
if (cmd == 'c' && last + 1000 < now) {
shutter();
cmd_char = 'z';
}
// Shutter
if (digitalRead(SHUTTTER_BTN) == LOW && last + 1000 < now){
shutter();

View File

@ -1,5 +1,19 @@
#!/bin/bash
#sync libs
#sync libs'
if [ -f "$(which jq)" ]; then
HEADER=ino/lib/McopySerial/McopySerial.h
TMP_FILE=$(mktemp)
awk '{print} /CMD FLAGS/ {exit}' "${HEADER}" > "${TMP_FILE}"
cat ./data/cfg.json | jq -r '.arduino.cmd | keys[] as $k | " char \($k) = '"'"'\(.[$k])'"'"';"' | awk '{print "\t"$1" "toupper($2)" "$3" "$4}' >> "${TMP_FILE}"
awk '/END CMD/,EOF { print $0 }' "${HEADER}" >> "${TMP_FILE}"
cp "${TMP_FILE}" "${HEADER}"
rm -f "${TMP_FILE}"
fi
cp ino/lib/McopySerial/McopySerial.* ino/mcopy_cam_canon/