Define all command chars as static constants. Provide an identity when initializing and allow for setting with another method.
This commit is contained in:
parent
9a89dbe6a5
commit
f49c70ead6
|
@ -2,14 +2,18 @@
|
||||||
|
|
||||||
#include "McopySerial.h"
|
#include "McopySerial.h"
|
||||||
|
|
||||||
McopySerial::McopySerial () {
|
McopySerial::McopySerial (char identity) {
|
||||||
//create mcopy serial
|
id = identity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void McopySerial::begin () {
|
void McopySerial::begin () {
|
||||||
Serial.begin(baud);
|
Serial.begin(baud);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void McopySerial::identify (char identity) {
|
||||||
|
id = identity;
|
||||||
|
}
|
||||||
|
|
||||||
char McopySerial::loop () {
|
char McopySerial::loop () {
|
||||||
if (Serial.available()) {
|
if (Serial.available()) {
|
||||||
cmdChar = (char) Serial.read();
|
cmdChar = (char) Serial.read();
|
||||||
|
|
|
@ -9,60 +9,62 @@ class McopySerial {
|
||||||
volatile int baud = 57600;
|
volatile int baud = 57600;
|
||||||
volatile bool debugOn = false;
|
volatile bool debugOn = false;
|
||||||
volatile char cmdChar = 'z';
|
volatile char cmdChar = 'z';
|
||||||
|
volatile char id;
|
||||||
|
|
||||||
void internal ();
|
void internal ();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/* CMD FLAGS */
|
/* CMD FLAGS */
|
||||||
char BLACK = 'b';
|
static const char BLACK = 'b';
|
||||||
char CAMERA = 'c';
|
static const char CAMERA = 'c';
|
||||||
char CAMERA_BACKWARD = 'f';
|
static const char CAMERA_BACKWARD = 'f';
|
||||||
char CAMERA_CAPPER_IDENTIFIER = '8';
|
static const char CAMERA_CAPPER_IDENTIFIER = '8';
|
||||||
char CAMERA_CAPPER_PROJECTOR_IDENTIFIER = '9';
|
static const char CAMERA_CAPPER_PROJECTOR_IDENTIFIER = '9';
|
||||||
char CAMERA_CAPPER_PROJECTORS_IDENTIFIER = '0';
|
static const char CAMERA_CAPPER_PROJECTORS_IDENTIFIER = '0';
|
||||||
char CAMERA_FORWARD = 'e';
|
static const char CAMERA_FORWARD = 'e';
|
||||||
char CAMERA_IDENTIFIER = 'k';
|
static const char CAMERA_IDENTIFIER = 'k';
|
||||||
char CAMERA_PROJECTORS_IDENTIFIER = '5';
|
static const char CAMERA_PROJECTORS_IDENTIFIER = '5';
|
||||||
char CAMERA_SECOND = '3';
|
static const char CAMERA_SECOND = '3';
|
||||||
char CAMERA_SECOND_BACKWARD = '2';
|
static const char CAMERA_SECOND_BACKWARD = '2';
|
||||||
char CAMERA_SECOND_FORWARD = '1';
|
static const char CAMERA_SECOND_FORWARD = '1';
|
||||||
char CAMERA_SECOND_IDENTIFIER = 'y';
|
static const char CAMERA_SECOND_IDENTIFIER = 'y';
|
||||||
char CAMERA_TIMED = 'n';
|
static const char CAMERA_TIMED = 'n';
|
||||||
char CAMERAS = '4';
|
static const char CAMERAS = '4';
|
||||||
char CAMERAS_IDENTIFIER = 'a';
|
static const char CAMERAS_IDENTIFIER = 'a';
|
||||||
char CAMERAS_PROJECTOR_IDENTIFIER = '6';
|
static const char CAMERAS_PROJECTOR_IDENTIFIER = '6';
|
||||||
char CAMERAS_PROJECTORS_IDENTIFIER = '7';
|
static const char CAMERAS_PROJECTORS_IDENTIFIER = '7';
|
||||||
char CAPPER_IDENTIFIER = 'C';
|
static const char CAPPER_IDENTIFIER = 'C';
|
||||||
char CAPPER_OFF = 'B';
|
static const char CAPPER_OFF = 'B';
|
||||||
char CAPPER_ON = 'A';
|
static const char CAPPER_ON = 'A';
|
||||||
char CONNECT = 'i';
|
static const char CONNECT = 'i';
|
||||||
char DEBUG = 'd';
|
static const char DEBUG = 'd';
|
||||||
char LIGHT = 'l';
|
static const char LIGHT = 'l';
|
||||||
char LIGHT_IDENTIFIER = 'o';
|
static const char LIGHT_IDENTIFIER = 'o';
|
||||||
char MCOPY_IDENTIFIER = 'm';
|
static const char MCOPY_IDENTIFIER = 'm';
|
||||||
char PROJECTOR = 'p';
|
static const char PROJECTOR = 'p';
|
||||||
char PROJECTOR_BACKWARD = 'h';
|
static const char PROJECTOR_BACKWARD = 'h';
|
||||||
char PROJECTOR_CAMERA_IDENTIFIER = 's';
|
static const char PROJECTOR_CAMERA_IDENTIFIER = 's';
|
||||||
char PROJECTOR_CAMERA_LIGHT_IDENTIFIER = 'r';
|
static const char PROJECTOR_CAMERA_LIGHT_IDENTIFIER = 'r';
|
||||||
char PROJECTOR_FORWARD = 'g';
|
static const char PROJECTOR_FORWARD = 'g';
|
||||||
char PROJECTOR_IDENTIFIER = 'j';
|
static const char PROJECTOR_IDENTIFIER = 'j';
|
||||||
char PROJECTOR_LIGHT_IDENTIFIER = 'q';
|
static const char PROJECTOR_LIGHT_IDENTIFIER = 'q';
|
||||||
char PROJECTOR_SECOND = 'w';
|
static const char PROJECTOR_SECOND = 'w';
|
||||||
char PROJECTOR_SECOND_BACKWARD = 'v';
|
static const char PROJECTOR_SECOND_BACKWARD = 'v';
|
||||||
char PROJECTOR_SECOND_FORWARD = 'u';
|
static const char PROJECTOR_SECOND_FORWARD = 'u';
|
||||||
char PROJECTOR_SECOND_IDENTIFIER = 't';
|
static const char PROJECTOR_SECOND_IDENTIFIER = 't';
|
||||||
char PROJECTORS = 'x';
|
static const char PROJECTORS = 'x';
|
||||||
char PROJECTORS_IDENTIFIER = 'd';
|
static const char PROJECTORS_IDENTIFIER = 'd';
|
||||||
char TAKEUP_BACKWARD = 'E';
|
static const char TAKEUP_BACKWARD = 'E';
|
||||||
char TAKEUP_FORWARD = 'D';
|
static const char TAKEUP_FORWARD = 'D';
|
||||||
/* END CMD FLAGS */
|
/* END CMD FLAGS */
|
||||||
|
|
||||||
McopySerial();
|
McopySerial(char identity);
|
||||||
|
|
||||||
void begin();
|
void begin();
|
||||||
void setBaud(int baudRate);
|
void setBaud(int baudRate);
|
||||||
char loop();
|
char loop();
|
||||||
|
void identify(char identity);
|
||||||
|
|
||||||
void debug (bool state);
|
void debug (bool state);
|
||||||
void log (String message);
|
void log (String message);
|
||||||
|
|
|
@ -2,14 +2,18 @@
|
||||||
|
|
||||||
#include "McopySerial.h"
|
#include "McopySerial.h"
|
||||||
|
|
||||||
McopySerial::McopySerial () {
|
McopySerial::McopySerial (char identity) {
|
||||||
//create mcopy serial
|
id = identity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void McopySerial::begin () {
|
void McopySerial::begin () {
|
||||||
Serial.begin(baud);
|
Serial.begin(baud);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void McopySerial::identify (char identity) {
|
||||||
|
id = identity;
|
||||||
|
}
|
||||||
|
|
||||||
char McopySerial::loop () {
|
char McopySerial::loop () {
|
||||||
if (Serial.available()) {
|
if (Serial.available()) {
|
||||||
cmdChar = (char) Serial.read();
|
cmdChar = (char) Serial.read();
|
||||||
|
|
|
@ -9,60 +9,62 @@ class McopySerial {
|
||||||
volatile int baud = 57600;
|
volatile int baud = 57600;
|
||||||
volatile bool debugOn = false;
|
volatile bool debugOn = false;
|
||||||
volatile char cmdChar = 'z';
|
volatile char cmdChar = 'z';
|
||||||
|
volatile char id;
|
||||||
|
|
||||||
void internal ();
|
void internal ();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/* CMD FLAGS */
|
/* CMD FLAGS */
|
||||||
char BLACK = 'b';
|
static const char BLACK = 'b';
|
||||||
char CAMERA = 'c';
|
static const char CAMERA = 'c';
|
||||||
char CAMERA_BACKWARD = 'f';
|
static const char CAMERA_BACKWARD = 'f';
|
||||||
char CAMERA_CAPPER_IDENTIFIER = '8';
|
static const char CAMERA_CAPPER_IDENTIFIER = '8';
|
||||||
char CAMERA_CAPPER_PROJECTOR_IDENTIFIER = '9';
|
static const char CAMERA_CAPPER_PROJECTOR_IDENTIFIER = '9';
|
||||||
char CAMERA_CAPPER_PROJECTORS_IDENTIFIER = '0';
|
static const char CAMERA_CAPPER_PROJECTORS_IDENTIFIER = '0';
|
||||||
char CAMERA_FORWARD = 'e';
|
static const char CAMERA_FORWARD = 'e';
|
||||||
char CAMERA_IDENTIFIER = 'k';
|
static const char CAMERA_IDENTIFIER = 'k';
|
||||||
char CAMERA_PROJECTORS_IDENTIFIER = '5';
|
static const char CAMERA_PROJECTORS_IDENTIFIER = '5';
|
||||||
char CAMERA_SECOND = '3';
|
static const char CAMERA_SECOND = '3';
|
||||||
char CAMERA_SECOND_BACKWARD = '2';
|
static const char CAMERA_SECOND_BACKWARD = '2';
|
||||||
char CAMERA_SECOND_FORWARD = '1';
|
static const char CAMERA_SECOND_FORWARD = '1';
|
||||||
char CAMERA_SECOND_IDENTIFIER = 'y';
|
static const char CAMERA_SECOND_IDENTIFIER = 'y';
|
||||||
char CAMERA_TIMED = 'n';
|
static const char CAMERA_TIMED = 'n';
|
||||||
char CAMERAS = '4';
|
static const char CAMERAS = '4';
|
||||||
char CAMERAS_IDENTIFIER = 'a';
|
static const char CAMERAS_IDENTIFIER = 'a';
|
||||||
char CAMERAS_PROJECTOR_IDENTIFIER = '6';
|
static const char CAMERAS_PROJECTOR_IDENTIFIER = '6';
|
||||||
char CAMERAS_PROJECTORS_IDENTIFIER = '7';
|
static const char CAMERAS_PROJECTORS_IDENTIFIER = '7';
|
||||||
char CAPPER_IDENTIFIER = 'C';
|
static const char CAPPER_IDENTIFIER = 'C';
|
||||||
char CAPPER_OFF = 'B';
|
static const char CAPPER_OFF = 'B';
|
||||||
char CAPPER_ON = 'A';
|
static const char CAPPER_ON = 'A';
|
||||||
char CONNECT = 'i';
|
static const char CONNECT = 'i';
|
||||||
char DEBUG = 'd';
|
static const char DEBUG = 'd';
|
||||||
char LIGHT = 'l';
|
static const char LIGHT = 'l';
|
||||||
char LIGHT_IDENTIFIER = 'o';
|
static const char LIGHT_IDENTIFIER = 'o';
|
||||||
char MCOPY_IDENTIFIER = 'm';
|
static const char MCOPY_IDENTIFIER = 'm';
|
||||||
char PROJECTOR = 'p';
|
static const char PROJECTOR = 'p';
|
||||||
char PROJECTOR_BACKWARD = 'h';
|
static const char PROJECTOR_BACKWARD = 'h';
|
||||||
char PROJECTOR_CAMERA_IDENTIFIER = 's';
|
static const char PROJECTOR_CAMERA_IDENTIFIER = 's';
|
||||||
char PROJECTOR_CAMERA_LIGHT_IDENTIFIER = 'r';
|
static const char PROJECTOR_CAMERA_LIGHT_IDENTIFIER = 'r';
|
||||||
char PROJECTOR_FORWARD = 'g';
|
static const char PROJECTOR_FORWARD = 'g';
|
||||||
char PROJECTOR_IDENTIFIER = 'j';
|
static const char PROJECTOR_IDENTIFIER = 'j';
|
||||||
char PROJECTOR_LIGHT_IDENTIFIER = 'q';
|
static const char PROJECTOR_LIGHT_IDENTIFIER = 'q';
|
||||||
char PROJECTOR_SECOND = 'w';
|
static const char PROJECTOR_SECOND = 'w';
|
||||||
char PROJECTOR_SECOND_BACKWARD = 'v';
|
static const char PROJECTOR_SECOND_BACKWARD = 'v';
|
||||||
char PROJECTOR_SECOND_FORWARD = 'u';
|
static const char PROJECTOR_SECOND_FORWARD = 'u';
|
||||||
char PROJECTOR_SECOND_IDENTIFIER = 't';
|
static const char PROJECTOR_SECOND_IDENTIFIER = 't';
|
||||||
char PROJECTORS = 'x';
|
static const char PROJECTORS = 'x';
|
||||||
char PROJECTORS_IDENTIFIER = 'd';
|
static const char PROJECTORS_IDENTIFIER = 'd';
|
||||||
char TAKEUP_BACKWARD = 'E';
|
static const char TAKEUP_BACKWARD = 'E';
|
||||||
char TAKEUP_FORWARD = 'D';
|
static const char TAKEUP_FORWARD = 'D';
|
||||||
/* END CMD FLAGS */
|
/* END CMD FLAGS */
|
||||||
|
|
||||||
McopySerial();
|
McopySerial(char identity);
|
||||||
|
|
||||||
void begin();
|
void begin();
|
||||||
void setBaud(int baudRate);
|
void setBaud(int baudRate);
|
||||||
char loop();
|
char loop();
|
||||||
|
void identify(char identity);
|
||||||
|
|
||||||
void debug (bool state);
|
void debug (bool state);
|
||||||
void log (String message);
|
void log (String message);
|
||||||
|
|
|
@ -33,7 +33,7 @@ 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(McopySerial::CAMERA);
|
||||||
|
|
||||||
volatile boolean connected = false;
|
volatile boolean connected = false;
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ void loop()
|
||||||
if (cmd == 'c' && last + 1000 < now) {
|
if (cmd == 'c' && last + 1000 < now) {
|
||||||
shutter();
|
shutter();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shutter
|
// Shutter
|
||||||
if (digitalRead(SHUTTTER_BTN) == LOW && last + 1000 < now){
|
if (digitalRead(SHUTTTER_BTN) == LOW && last + 1000 < now){
|
||||||
shutter();
|
shutter();
|
||||||
|
|
|
@ -8,7 +8,7 @@ if [ -f "$(which jq)" ]; then
|
||||||
|
|
||||||
awk '{print} /CMD FLAGS/ {exit}' "${HEADER}" > "${TMP_FILE}"
|
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}"
|
cat ./data/cfg.json | jq -r '.arduino.cmd | keys[] as $k | " static const char \($k) = '"'"'\(.[$k])'"'"';"' | awk '{print "\t"$1" "$2" "$3" "toupper($4)" "$5" "$6}' >> "${TMP_FILE}"
|
||||||
|
|
||||||
awk '/END CMD/,EOF { print $0 }' "${HEADER}" >> "${TMP_FILE}"
|
awk '/END CMD/,EOF { print $0 }' "${HEADER}" >> "${TMP_FILE}"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue