Move connect and identify methods to internal ones.

This commit is contained in:
Matt McWilliams 2023-03-09 21:26:31 -05:00
parent f49c70ead6
commit d7017af245
4 changed files with 48 additions and 18 deletions

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);