diff --git a/device/serialstream.cc b/device/serialstream.cc index 86a2585..3cab162 100644 --- a/device/serialstream.cc +++ b/device/serialstream.cc @@ -1,21 +1,33 @@ #include "serialstream.h" SerialStream::SerialStream(ComPort port, BaudRate baud_rate, DataBits data_bits, - StopBits stop_bits, Parity parity) { - (void)port; - (void)baud_rate; - (void)data_bits; - (void)stop_bits; - (void)parity; -} + StopBits stop_bits, Parity parity) + :Serial(port, baud_rate, data_bits, stop_bits, parity) {} void SerialStream::flush() {} -void SerialStream::setForeground(Color c) { (void)c; } +void SerialStream::setForeground(Color c) { + write(0x1b); + write('['); + write('3'); + write(c + 0x30); + write('m'); +} -void SerialStream::setBackground(Color c) { (void)c; } +void SerialStream::setBackground(Color c) { + write(0x1b); + write('['); + write('4'); + write(c + 0x30); + write('m'); +} -void SerialStream::setAttribute(Attrib a) { (void)a; } +void SerialStream::setAttribute(Attrib a) { + write(0x1b); + write('['); + write(a + 0x30); + write('m'); +} void SerialStream::reset() {} @@ -25,6 +37,6 @@ void SerialStream::setPos(int x, int y) { } void SerialStream::print(char* str, int length) { - (void)str; - (void)length; + for(int i=0; i < length; i++) + write(str[i]); } diff --git a/main.cc b/main.cc index 29a6d64..6c1086e 100644 --- a/main.cc +++ b/main.cc @@ -5,6 +5,7 @@ #include "arch/cga.h" #include "arch/textwindow.h" #include "arch/serial.h" +#include "device/serialstream.h" // Main function // (the bootstrap processor starts here)} @@ -33,9 +34,20 @@ extern "C" int main() { //tw.getPos(x,y); //tw.setPos(x+1,y); - //test Serial - Serial s = Serial(); - s.write('a'); + ////test Serial + //Serial s = Serial(); + //s.write('a'); + + // test SerialStream + SerialStream ss = SerialStream(); + ss.print("test", 4); + ss.setAttribute(SerialStream::UNDERSCORE); + ss.print("test", 4); + ss.setAttribute(SerialStream::RESET); + ss.setForeground(SerialStream::MAGENTA); + ss.print("test", 4); + ss.setBackground(SerialStream::CYAN); + ss.print("test", 4); /* Start application processors * To avoid unexpected behaviour, make sure that interrupts are not