UniGraphic-Fork for ST7920-LCD-controller and SH1106. Tested with 128x64 LCD with SPI and 128x64-OLED with IIC
Dependents: UniGraphic-St7920-Test AfficheurUTILECO
Fork of UniGraphic by
TextDisplay.h
00001 /* mbed TextDisplay Library Base Class 00002 * Copyright (c) 2007-2009 sford 00003 * Released under the MIT License: http://mbed.org/license/mit 00004 * 00005 * A common base class for Text displays 00006 * To port a new display, derive from this class and implement 00007 * the constructor (setup the display), character (put a character 00008 * at a location), rows and columns (number of rows/cols) functions. 00009 * Everything else (locate, printf, putc, cls) will come for free 00010 * 00011 * The model is the display will wrap at the right and bottom, so you can 00012 * keep writing and will always get valid characters. The location is 00013 * maintained internally to the class to make this easy 00014 */ 00015 00016 #ifndef MBED_TEXTDISPLAY_H 00017 #define MBED_TEXTDISPLAY_H 00018 00019 #include "mbed.h" 00020 00021 /** A common base class for Text displays 00022 */ 00023 class TextDisplay : public Stream { 00024 public: 00025 00026 // functions needing implementation in derived implementation class 00027 // ---------------------------------------------------------------- 00028 /** Create a TextDisplay interface 00029 * @param name The name used in the path to access the strean through the filesystem 00030 */ 00031 TextDisplay(const char *name = NULL); 00032 00033 /** output a character at the given position 00034 * 00035 * @param column column where charater must be written 00036 * @param row where character must be written 00037 * @param c the character to be written to the TextDisplay 00038 * @note this method may be overridden in a derived class. 00039 */ 00040 virtual void character(int column, int row, int c) = 0; 00041 00042 /** return number of rows on TextDisplay 00043 * @result number of rows 00044 * @note this method must be supported in the derived class. 00045 */ 00046 virtual int rows() = 0; 00047 00048 /** return number of columns on TextDisplay 00049 * @result number of columns 00050 * @note this method must be supported in the derived class. 00051 */ 00052 virtual int columns() = 0; 00053 00054 // functions that come for free, but can be overwritten 00055 // ---------------------------------------------------- 00056 /** redirect output from a stream (stoud, sterr) to display 00057 * @param stream stream that shall be redirected to the TextDisplay 00058 * @note this method may be overridden in a derived class. 00059 * @returns true if the claim succeeded. 00060 */ 00061 virtual bool claim (FILE *stream); 00062 00063 /** clear the entire screen 00064 * @note this method may be overridden in a derived class. 00065 */ 00066 virtual void cls(); 00067 00068 /** locate the cursor at a character position. 00069 * Based on the currently active font, locate the cursor on screen. 00070 * @note this method may be overridden in a derived class. 00071 * @param column is the horizontal offset from the left side. 00072 * @param row is the vertical offset from the top. 00073 */ 00074 virtual void locate(int column, int row); 00075 00076 /** set the foreground color 00077 * @note this method may be overridden in a derived class. 00078 * @param color is color to use for foreground drawing. 00079 */ 00080 virtual void foreground(uint16_t colour); 00081 00082 /** set the background color 00083 * @note this method may be overridden in a derived class. 00084 * @param color is color to use for background drawing. 00085 */ 00086 virtual void background(uint16_t colour); 00087 00088 // putc (from Stream) 00089 // printf (from Stream) 00090 00091 protected: 00092 00093 virtual int _putc(int value); 00094 virtual int _getc(); 00095 00096 // character location 00097 int _column; 00098 int _row; 00099 00100 // colours 00101 volatile uint16_t _foreground; 00102 volatile uint16_t _background; 00103 char *_path; 00104 }; 00105 00106 #endif
Generated on Tue Jul 12 2022 18:00:35 by 1.7.2