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.
Dependents: demoUI whrmDemoUI Host_Software_MAX32664GWEB_HR_EXTENDED Host_Software_MAX32664GWEC_SpO2_HR-_EXTE ... more
TextDisplay.cpp
00001 /* mbed TextDisplay Display Library Base Class 00002 * Copyright (c) 2007-2009 sford 00003 * Released under the MIT License: http://mbed.org/license/mit 00004 */ 00005 00006 #include "../screen/TextDisplay.h" 00007 00008 #include <cstdarg> 00009 00010 TextDisplay::TextDisplay(const char *name){ 00011 _row = 0; 00012 _column = 0; 00013 00014 if (name == NULL) { 00015 _path = NULL; 00016 } else { 00017 _path = new char[strlen(name) + 2]; 00018 sprintf(_path, "/%s", name); 00019 } 00020 } 00021 00022 int TextDisplay::_putc(int value) { 00023 if(value == '\n') { 00024 _column = 0; 00025 _row++; 00026 if(_row >= rows()) { 00027 _row = 0; 00028 } 00029 } else { 00030 character(_column, _row, value); 00031 _column++; 00032 if(_column >= columns()) { 00033 _column = 0; 00034 _row++; 00035 if(_row >= rows()) { 00036 _row = 0; 00037 } 00038 } 00039 } 00040 return value; 00041 } 00042 00043 // crude cls implementation, should generally be overwritten in derived class 00044 void TextDisplay::cls() { 00045 locate(0, 0); 00046 for(int i=0; i<columns()*rows(); i++) { 00047 _putc(' '); 00048 } 00049 } 00050 00051 void TextDisplay::set_font(const unsigned char * f) { 00052 font = f; 00053 if(font==NULL) { 00054 externalfont = 0; // set display.font 00055 locate(0, 0); 00056 } 00057 else{ 00058 externalfont = 1; 00059 locate(0, 0); 00060 } 00061 } 00062 00063 void TextDisplay::locate(int column, int row) { 00064 _column = column; 00065 _row = row; 00066 char_x = column; 00067 char_y = row; 00068 } 00069 00070 int TextDisplay::_getc() { 00071 return -1; 00072 } 00073 00074 void TextDisplay::foreground(uint16_t colour) { 00075 _foreground = colour; 00076 } 00077 00078 void TextDisplay::background(uint16_t colour) { 00079 _background = colour; 00080 } 00081 00082 void TextDisplay::printf(const char* format, ...) { 00083 char buffer[MAX_PRINTF_CHARS + 1] = { 0 }; 00084 uint32_t iterator = 0; 00085 va_list args; 00086 va_start(args, format); 00087 vsprintf(buffer, format, args); 00088 va_end(args); 00089 00090 while((buffer[iterator] != 0) && (iterator < MAX_PRINTF_CHARS)) { 00091 _putc(buffer[iterator++]); 00092 } 00093 }
Generated on Thu Jul 14 2022 00:59:54 by
1.7.2