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);
}
void McopySerial::identify (char identity) {
id = identity;
}
char McopySerial::loop () {
if (Serial.available()) {
cmdChar = (char) Serial.read();
internal();
_internal();
} else {
cmdChar = 'z';
}
return cmdChar;
}
void McopySerial::internal () {
void McopySerial::_internal () {
if (cmdChar == DEBUG) {
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) {
baud = baudRate;
}
void McopySerial::setIdentity (char identity) {
id = identity;
}
void McopySerial::debug (bool state) {
debugOn = state;
}

View File

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

View File

@ -10,31 +10,44 @@ void McopySerial::begin () {
Serial.begin(baud);
}
void McopySerial::identify (char identity) {
id = identity;
}
char McopySerial::loop () {
if (Serial.available()) {
cmdChar = (char) Serial.read();
internal();
_internal();
} else {
cmdChar = 'z';
}
return cmdChar;
}
void McopySerial::internal () {
void McopySerial::_internal () {
if (cmdChar == DEBUG) {
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) {
baud = baudRate;
}
void McopySerial::setIdentity (char identity) {
id = identity;
}
void McopySerial::debug (bool state) {
debugOn = state;
}

View File

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