Compare commits
	
		
			No commits in common. '5ae907ca5aebd51ee1c273fa4ed5233b47a52b60' and '2d9d72e162a4abae333f019e79e738d477528da6' have entirely different histories. 
		
	
	
		
			5ae907ca5a
			...
			2d9d72e162
		
	
		
	| @ -1,95 +1,30 @@ | ||||
| #include "serialstream.h" | ||||
| #include "../utils/string.h" | ||||
| 
 | ||||
| SerialStream::SerialStream(ComPort port, BaudRate baud_rate, DataBits data_bits, | ||||
|                            StopBits stop_bits, Parity parity) | ||||
|     :Serial(port, baud_rate, data_bits, stop_bits, parity) {} | ||||
| 
 | ||||
| void SerialStream::flush() { | ||||
|   print(buffer, strlen(buffer)); | ||||
|                            StopBits stop_bits, Parity parity) { | ||||
|   (void)port; | ||||
|   (void)baud_rate; | ||||
|   (void)data_bits; | ||||
|   (void)stop_bits; | ||||
|   (void)parity; | ||||
| } | ||||
| 
 | ||||
| // https://stackoverflow.com/questions/3440726/what-is-the-proper-way-of-implementing-a-good-itoa-function
 | ||||
| // Yet, another good itoa implementation
 | ||||
| // returns: the length of the number string
 | ||||
| int itoa(int value, char *sp, int radix) | ||||
| { | ||||
|     char tmp[16];// be careful with the length of the buffer
 | ||||
|     char *tp = tmp; | ||||
|     int i; | ||||
|     unsigned v; | ||||
| 
 | ||||
|     int sign = (radix == 10 && value < 0);     | ||||
|     if (sign) | ||||
|         v = -value; | ||||
|     else | ||||
|         v = (unsigned)value; | ||||
| 
 | ||||
|     while (v || tp == tmp) | ||||
|     { | ||||
|         i = v % radix; | ||||
|         v /= radix; | ||||
|         if (i < 10) | ||||
|           *tp++ = i+'0'; | ||||
|         else | ||||
|           *tp++ = i + 'a' - 10; | ||||
|     } | ||||
| 
 | ||||
|     int len = tp - tmp; | ||||
| 
 | ||||
|     if (sign)  | ||||
|     { | ||||
|         *sp++ = '-'; | ||||
|         len++; | ||||
|     } | ||||
| 
 | ||||
|     while (tp > tmp) | ||||
|         *sp++ = *--tp; | ||||
| void SerialStream::flush() {} | ||||
| 
 | ||||
|     return len; | ||||
| } | ||||
| 
 | ||||
| void SerialStream::setForeground(Color c) { | ||||
|     write(0x1b); | ||||
|     write('['); | ||||
|     write('3'); | ||||
|     write(c + 0x30); | ||||
|     write('m'); | ||||
| } | ||||
| void SerialStream::setForeground(Color c) { (void)c; } | ||||
| 
 | ||||
| void SerialStream::setBackground(Color c) {  | ||||
|     write(0x1b); | ||||
|     write('['); | ||||
|     write('4'); | ||||
|     write(c + 0x30); | ||||
|     write('m'); | ||||
| } | ||||
| void SerialStream::setBackground(Color c) { (void)c; } | ||||
| 
 | ||||
| void SerialStream::setAttribute(Attrib a) { | ||||
|     write(0x1b); | ||||
|     write('['); | ||||
|     write(a + 0x30); | ||||
|     write('m'); | ||||
| } | ||||
| void SerialStream::setAttribute(Attrib a) { (void)a; } | ||||
| 
 | ||||
| void SerialStream::reset() { | ||||
|     write(0x1b); | ||||
|     write('c'); | ||||
| } | ||||
| void SerialStream::reset() {} | ||||
| 
 | ||||
| void SerialStream::setPos(int x, int y) { | ||||
|     //char out[] = {0x1b, '[', 0, 0, ';', 0, 0, 'H', 0};
 | ||||
|     *this << 0x1b; | ||||
|     *this << '['; | ||||
|     *this << dec << x; | ||||
|     *this << ';' << y << 'H' << endl; | ||||
|     flush(); | ||||
|     //itoa(x, &out[2], 10);
 | ||||
|     //itoa(y, &out[5], 10);
 | ||||
|     //print( out , strlen(out));
 | ||||
|   (void)x; | ||||
|   (void)y; | ||||
| } | ||||
| 
 | ||||
| void SerialStream::print(char* str, int length) { | ||||
|     for(int i=0; i < length; i++) | ||||
|         write(str[i]); | ||||
|   (void)str; | ||||
|   (void)length; | ||||
| } | ||||
|  | ||||
| @ -1,21 +1,12 @@ | ||||
| #include "textstream.h" | ||||
| 
 | ||||
| TextStream::TextStream(unsigned from_col,  | ||||
|                        unsigned to_col,  | ||||
|                        unsigned from_row, | ||||
|                        unsigned to_row,  | ||||
|                        bool use_cursor) | ||||
|           : TextWindow(from_col, | ||||
|             to_col, | ||||
|             from_row, | ||||
|             to_row, | ||||
|             use_cursor){} | ||||
| 
 | ||||
| 
 | ||||
| void TextStream::flush() { | ||||
|   print(buffer,pos); | ||||
|   pos = 0; | ||||
|    | ||||
| 
 | ||||
| 
 | ||||
| TextStream::TextStream(unsigned from_col, unsigned to_col, unsigned from_row, | ||||
|                        unsigned to_row, bool use_cursor) { | ||||
|   (void)from_col; | ||||
|   (void)to_col; | ||||
|   (void)from_row; | ||||
|   (void)to_row; | ||||
|   (void)use_cursor; | ||||
| } | ||||
| 
 | ||||
| void TextStream::flush() {} | ||||
|  | ||||
					Loading…
					
					
				
		Reference in New Issue