Can the predefined variable "Serial" be used as parameter for a new class?
It should be possible to use a statement like this:
console.clearScreen();
and the initialization could look like:
AnsiTerm console(Serial);
(maybe with some pointers instead (I have tried))
Here is my code:
#include <Stream.h>
class AnsiTerm {
public:
AnsiTerm(Stream);
clearScreen();
private:
Serial_ _stream;
};
AnsiTerm::AnsiTerm(Stream useStream)
{
_stream = useStream;
}
AnsiTerm::clearScreen()
{
_stream.print(F("\e[2J"));
}
AnsiTerm console(Serial);
void setup() {
Serial.begin(9600);
console.clearScreen();
}
void loop() {
}
The Stream class says it misses some overloading, which make sence. So I tried to use the Serial_ class but it gave other errors.
I have made this construction before in C++, but then the whole code was designed with that in purpose. Here I want to use the existing "Serial" variable.