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" #include "McopySerial.h"
McopySerial::McopySerial () { McopySerial::McopySerial () {
//create mcopy serial
} }
void McopySerial::on()
void McopySerial::begin () { void McopySerial::begin () {
Serial.begin(baud); Serial.begin(baud);
} }
void McopySerial::loop () { char McopySerial::loop () {
if (Serial.available()) { if (Serial.available()) {
cmdChar = (char) Serial.read(); cmdChar = (char) Serial.read();
} } else {
if (cmdChar != 'z') {
//cmd(cmdChar);
cmdChar = 'z'; cmdChar = 'z';
} }
return cmdChar;
} }
void McopySerial::setBaud (int baudRate) { void McopySerial::setBaud (int baudRate) {

View File

@ -3,8 +3,6 @@
#include "Arduino.h" #include "Arduino.h"
typedef void (*mcopy_callback)(void);
class McopySerial { class McopySerial {
private: private:
@ -13,14 +11,60 @@ class McopySerial {
volatile char cmdChar = 'z'; volatile char cmdChar = 'z';
public: 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(); McopySerial();
void begin(); void begin();
void setBaud(int baudRate); void setBaud(int baudRate);
void loop(); char loop();
void debug (bool state); void debug (bool state);
void log (String message); void log (String message);
}; };
#endif #endif

View File

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

View File

@ -3,8 +3,6 @@
#include "Arduino.h" #include "Arduino.h"
typedef void (*mcopy_callback)(void);
class McopySerial { class McopySerial {
private: private:
@ -13,14 +11,60 @@ class McopySerial {
volatile char cmdChar = 'z'; volatile char cmdChar = 'z';
public: 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(); McopySerial();
void begin(); void begin();
void setBaud(int baudRate); void setBaud(int baudRate);
void loop(); char loop();
void debug (bool state); void debug (bool state);
void log (String message); void log (String message);
}; };
#endif #endif

View File

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

View File

@ -1,5 +1,19 @@
#!/bin/bash #!/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/ cp ino/lib/McopySerial/McopySerial.* ino/mcopy_cam_canon/