canon_ble #82

Merged
mattmcw merged 149 commits from canon_ble into main 2023-08-01 03:38:52 +00:00
4 changed files with 48 additions and 18 deletions
Showing only changes of commit d7017af245 - Show all commits

View File

@ -10,31 +10,44 @@ 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();
internal(); _internal();
} else { } else {
cmdChar = 'z'; cmdChar = 'z';
} }
return cmdChar; return cmdChar;
} }
void McopySerial::internal () { void McopySerial::_internal () {
if (cmdChar == DEBUG) { if (cmdChar == DEBUG) {
debugOn = !debugOn; debugOn = !debugOn;
cmdChar = 'z'; } else if (cmdChar == CONNECT) {
_connect();
} else if (cmdChar == MCOPY_IDENTIFIER) {
_identify();
} }
} }
void McopySerial::_connect () {
Serial.println(CONNECT);
log("connect()");
}
void McopySerial::_identify () {
Serial.println(id);
log("identify()");
}
void McopySerial::setBaud (int baudRate) { void McopySerial::setBaud (int baudRate) {
baud = baudRate; baud = baudRate;
} }
void McopySerial::setIdentity (char identity) {
id = identity;
}
void McopySerial::debug (bool state) { void McopySerial::debug (bool state) {
debugOn = state; debugOn = state;
} }

View File

@ -11,7 +11,9 @@ class McopySerial {
volatile char cmdChar = 'z'; volatile char cmdChar = 'z';
volatile char id; volatile char id;
void internal (); void _internal ();
void _connect ();
void _identify ();
public: public:
@ -63,8 +65,8 @@ class McopySerial {
void begin(); void begin();
void setBaud(int baudRate); void setBaud(int baudRate);
void setIdentity(char identity);
char loop(); char loop();
void identify(char identity);
void debug (bool state); void debug (bool state);
void log (String message); void log (String message);

View File

@ -10,31 +10,44 @@ 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();
internal(); _internal();
} else { } else {
cmdChar = 'z'; cmdChar = 'z';
} }
return cmdChar; return cmdChar;
} }
void McopySerial::internal () { void McopySerial::_internal () {
if (cmdChar == DEBUG) { if (cmdChar == DEBUG) {
debugOn = !debugOn; debugOn = !debugOn;
cmdChar = 'z'; } else if (cmdChar == CONNECT) {
_connect();
} else if (cmdChar == MCOPY_IDENTIFIER) {
_identify();
} }
} }
void McopySerial::_connect () {
Serial.println(CONNECT);
log("connect()");
}
void McopySerial::_identify () {
Serial.println(id);
log("identify()");
}
void McopySerial::setBaud (int baudRate) { void McopySerial::setBaud (int baudRate) {
baud = baudRate; baud = baudRate;
} }
void McopySerial::setIdentity (char identity) {
id = identity;
}
void McopySerial::debug (bool state) { void McopySerial::debug (bool state) {
debugOn = state; debugOn = state;
} }

View File

@ -11,7 +11,9 @@ class McopySerial {
volatile char cmdChar = 'z'; volatile char cmdChar = 'z';
volatile char id; volatile char id;
void internal (); void _internal ();
void _connect ();
void _identify ();
public: public:
@ -63,8 +65,8 @@ class McopySerial {
void begin(); void begin();
void setBaud(int baudRate); void setBaud(int baudRate);
void setIdentity(char identity);
char loop(); char loop();
void identify(char identity);
void debug (bool state); void debug (bool state);
void log (String message); void log (String message);