Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
TextDisplay.cpp
00001 // ST7735 8 Bit SPI Library 00002 00003 #include "TextDisplay.h" 00004 00005 TextDisplay::TextDisplay(const char *name) : Stream(name){ 00006 _row = 0; 00007 _column = 0; 00008 if (name == NULL) { 00009 _path = NULL; 00010 } else { 00011 _path = new char[strlen(name) + 2]; 00012 sprintf(_path, "/%s", name); 00013 } 00014 } 00015 00016 int TextDisplay::_putc(int value) { 00017 if(value == '\n') { 00018 _column = 0; 00019 _row++; 00020 if(_row >= rows()) { 00021 _row = 0; 00022 } 00023 } else { 00024 character(_column, _row, value); 00025 _column++; 00026 if(_column >= columns()) { 00027 _column = 0; 00028 _row++; 00029 if(_row >= rows()) { 00030 _row = 0; 00031 } 00032 } 00033 } 00034 return value; 00035 } 00036 void TextDisplay::cls() { 00037 locate(0, 0); 00038 for(int i=0; i<columns()*rows(); i++) { 00039 putc(' '); 00040 } 00041 } 00042 void TextDisplay::locate(int column, int row) { 00043 _column = column; 00044 _row = row; 00045 } 00046 int TextDisplay::_getc() { 00047 return -1; 00048 } 00049 void TextDisplay::foreground(uint16_t colour) { 00050 _foreground = colour; 00051 } 00052 void TextDisplay::background(uint16_t colour) { 00053 _background = colour; 00054 } 00055 bool TextDisplay::claim (FILE *stream) { 00056 if ( _path == NULL) { 00057 fprintf(stderr, "claim requires a name to be given in the instantioator of the TextDisplay instance!\r\n"); 00058 return false; 00059 } 00060 if (freopen(_path, "w", stream) == NULL) { 00061 // Failed, should not happen 00062 return false; 00063 } 00064 // make sure we use line buffering 00065 setvbuf(stdout, NULL, _IOLBF, columns()); 00066 return true; 00067 }
Generated on Fri Jul 29 2022 11:38:09 by
1.7.2