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 () { char McopySerial::loop () {
if (Serial.available()) { if (Serial.available()) {
cmdChar = (char) Serial.read(); cmdChar = (char) Serial.read();
internal();
} else { } else {
cmdChar = 'z'; cmdChar = 'z';
} }
return cmdChar; return cmdChar;
} }
void McopySerial::internal () {
if (cmdChar == DEBUG) {
debugOn = !debugOn;
cmdChar = 'z';
}
}
void McopySerial::setBaud (int baudRate) { void McopySerial::setBaud (int baudRate) {
baud = baudRate; baud = baudRate;
} }

View File

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

View File

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

View File

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