Automatically toggle debug state internally

This commit is contained in:
Matt McWilliams 2023-03-09 21:08:36 -05:00
parent 844bb286a5
commit 9a89dbe6a5
4 changed files with 20 additions and 0 deletions

View File

@ -13,12 +13,20 @@ void McopySerial::begin () {
char McopySerial::loop () {
if (Serial.available()) {
cmdChar = (char) Serial.read();
internal();
} else {
cmdChar = 'z';
}
return cmdChar;
}
void McopySerial::internal () {
if (cmdChar == DEBUG) {
debugOn = !debugOn;
cmdChar = 'z';
}
}
void McopySerial::setBaud (int baudRate) {
baud = baudRate;
}

View File

@ -10,6 +10,8 @@ class McopySerial {
volatile bool debugOn = false;
volatile char cmdChar = 'z';
void internal ();
public:
/* CMD FLAGS */

View File

@ -13,12 +13,20 @@ void McopySerial::begin () {
char McopySerial::loop () {
if (Serial.available()) {
cmdChar = (char) Serial.read();
internal();
} else {
cmdChar = 'z';
}
return cmdChar;
}
void McopySerial::internal () {
if (cmdChar == DEBUG) {
debugOn = !debugOn;
cmdChar = 'z';
}
}
void McopySerial::setBaud (int baudRate) {
baud = baudRate;
}

View File

@ -10,6 +10,8 @@ class McopySerial {
volatile bool debugOn = false;
volatile char cmdChar = 'z';
void internal ();
public:
/* CMD FLAGS */