mcopy/ino/lib/McopySerial/McopySerial.cpp

42 lines
629 B
C++
Raw Normal View History

/// mcopy Serial Library
2023-03-05 00:04:55 +00:00
#include "McopySerial.h"
2023-03-04 23:52:51 +00:00
McopySerial::McopySerial () {
//create mcopy serial
2023-03-04 23:52:51 +00:00
}
void McopySerial::begin () {
Serial.begin(baud);
}
2023-03-04 23:52:51 +00:00
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;
2023-03-04 23:52:51 +00:00
}
void McopySerial::debug (bool state) {
debugOn = state;
}
void McopySerial::log (String message) {
if (debugOn) {
Serial.println(message);
}
}