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.
glcd.h
00001 #ifndef GLCD_H 00002 #define GLCD_H 00003 //------------includes----------------- 00004 #include "mbed.h" 00005 //------------ 00006 /** 00007 * Graphic LCD 128x64 Library 00008 * 00009 * Example: 00010 * @code 00011 * 00012 * @endcode 00013 */ 00014 //------------defines------------------ 00015 #define BLACK 1 00016 #define WHITE 0 00017 #define OPAC 0 00018 #define TRANS 1 00019 #define FILL 1 00020 #define NOFILL 0 00021 #define LEFT 0 00022 #define RIGHT 1 00023 #define DASH 0xFF // All pixel set on line 00024 #define DASHOFF 0x00 00025 #define BIT_SET(x,n) (x=x | (0x01<<n)) 00026 #define BIT_TEST(x,n) (x & (0x01<<n)) 00027 #define BIT_CLEAR(x,n) (x=x & ~(0x01<<n)) 00028 #define PI 3.14159265 00029 // -----------font--------------------- 00030 // Font 3x5 00031 static char FONT_3x5[] = { 00032 // @Font start 3x5 00033 3, // witdh 00034 5, // height 00035 ' ', // First char 00036 '>', // Last char 00037 0x00, 0x00, 0x00, // Space 00038 0x00, 0x17, 0x00, // ! 00039 0x07, 0x00, 0x03, // " 00040 0x0A, 0x1F, 0x0A, // # 00041 0x12, 0x17, 0x12, // +/- old $ 00042 0x03, 0x1B, 0x18, // % 00043 0xFF, 0x05, 0x07, // _||_ Pulse 00044 0x00, 0x03, 0x00, // ' 00045 0x1F, 0x15, 0x11, // ( // E ete 00046 0x1F, 0x04, 0x1F, // ) // H hivers 00047 0x0A, 0x04, 0x0A, // * 00048 0x04, 0x0E, 0x04, // + 00049 0x00, 0x10, 0x00, // , 00050 0x04, 0x04, 0x04, // - 00051 0x00, 0x08, 0x00, // . 00052 0x08, 0x04, 0x02, // / 00053 0x0F, 0x11, 0x1E, // 0 00054 0x12, 0x1F, 0x10, // 1 00055 0x0D, 0x15, 0x16, // 2 00056 0x11, 0x15, 0x0E, // 3 00057 0x07, 0x04, 0x1E, // 4 00058 0x17, 0x15, 0x09, // 5 00059 0x0F, 0x15, 0x18, // 6 00060 0x01, 0x1D, 0x03, // 7 00061 0x0F, 0x15, 0x1E, // 8 00062 0x07, 0x15, 0x1E, // 9 00063 0x00, 0x0A, 0x00, // : 00064 0x10, 0x08, 0x00, // ; 00065 0x04, 0x0A, 0x11, // < 00066 0x0A, 0x0A, 0x0A, // = 00067 0x11, 0x0A, 0x04, // > 00068 // @Font end 3x5 00069 }; 00070 00071 // Font 5x7 00072 static char FONT_5x7[] = { 00073 // @Font start 5x7 00074 5, // witdh 00075 7, // height 00076 ' ', // First char 00077 '~', // Last char 00078 0x00, 0x00, 0x00, 0x00, 0x00, // SPACE 00079 0x00, 0x00, 0x5F, 0x00, 0x00, // ! 00080 0x00, 0x03, 0x00, 0x03, 0x00, // " 00081 0x14, 0x3E, 0x14, 0x3E, 0x14, // # 00082 0x00, 0x22, 0x27, 0x22, 0x00, // now +/- before 0x24, 0x2A, 0x7F, 0x2A, 0x12, // $ 00083 0x43, 0x33, 0x08, 0x66, 0x61, // % 00084 0x40, 0x7F, 0x02, 0x7F, 0x40, // Now _||_ before 0x36, 0x49, 0x55, 0x22, 0x50, // & 00085 0x00, 0x05, 0x03, 0x00, 0x00, // ' 00086 0x00, 0x1C, 0x22, 0x41, 0x00, // ( 00087 0x00, 0x41, 0x22, 0x1C, 0x00, // ) 00088 0x14, 0x08, 0x3E, 0x08, 0x14, // * 00089 0x08, 0x08, 0x3E, 0x08, 0x08, // + 00090 0x00, 0x50, 0x30, 0x00, 0x00, // , 00091 0x08, 0x08, 0x08, 0x08, 0x08, // - 00092 0x00, 0x60, 0x60, 0x00, 0x00, // . 00093 0x20, 0x10, 0x08, 0x04, 0x02, // / 00094 0x3E, 0x51, 0x49, 0x45, 0x3E, // 0 00095 0x04, 0x02, 0x7F, 0x00, 0x00, // 1 00096 0x42, 0x61, 0x51, 0x49, 0x46, // 2 00097 0x22, 0x41, 0x49, 0x49, 0x36, // 3 00098 0x18, 0x14, 0x12, 0x7F, 0x10, // 4 00099 0x27, 0x45, 0x45, 0x45, 0x39, // 5 00100 0x3E, 0x49, 0x49, 0x49, 0x32, // 6 00101 0x01, 0x01, 0x71, 0x09, 0x07, // 7 00102 0x36, 0x49, 0x49, 0x49, 0x36, // 8 00103 0x26, 0x49, 0x49, 0x49, 0x3E, // 9 00104 0x00, 0x36, 0x36, 0x00, 0x00, // : 00105 0x00, 0x56, 0x36, 0x00, 0x00, // ; 00106 0x08, 0x14, 0x22, 0x41, 0x00, // < 00107 0x14, 0x14, 0x14, 0x14, 0x14, // = 00108 0x00, 0x41, 0x22, 0x14, 0x08, // > 00109 0x02, 0x01, 0x51, 0x09, 0x06, // ? 00110 0x3E, 0x41, 0x59, 0x55, 0x5E, // @ 00111 0x7E, 0x09, 0x09, 0x09, 0x7E, // A 00112 0x7F, 0x49, 0x49, 0x49, 0x36, // B 00113 0x3E, 0x41, 0x41, 0x41, 0x22, // C 00114 0x7F, 0x41, 0x41, 0x41, 0x3E, // D 00115 0x7F, 0x49, 0x49, 0x49, 0x41, // E 00116 0x7F, 0x09, 0x09, 0x09, 0x01, // F 00117 0x3E, 0x41, 0x41, 0x49, 0x3A, // G 00118 0x7F, 0x08, 0x08, 0x08, 0x7F, // H 00119 0x00, 0x41, 0x7F, 0x41, 0x00, // I 00120 0x30, 0x40, 0x40, 0x40, 0x3F, // J 00121 0x7F, 0x08, 0x14, 0x22, 0x41, // K 00122 0x7F, 0x40, 0x40, 0x40, 0x40, // L 00123 0x7F, 0x02, 0x0C, 0x02, 0x7F, // M 00124 0x7F, 0x02, 0x04, 0x08, 0x7F, // N 00125 0x3E, 0x41, 0x41, 0x41, 0x3E, // O 00126 0x7F, 0x09, 0x09, 0x09, 0x06, // P 00127 0x1E, 0x21, 0x21, 0x21, 0x5E, // Q 00128 0x7F, 0x09, 0x09, 0x09, 0x76, // R 00129 0x26, 0x49, 0x49, 0x49, 0x32, // S 00130 0x01, 0x01, 0x7F, 0x01, 0x01, // T 00131 0x3F, 0x40, 0x40, 0x40, 0x3F, // U 00132 0x1F, 0x20, 0x40, 0x20, 0x1F, // V 00133 0x7F, 0x20, 0x10, 0x20, 0x7F, // W 00134 0x41, 0x22, 0x1C, 0x22, 0x41, // X 00135 0x07, 0x08, 0x70, 0x08, 0x07, // Y 00136 0x61, 0x51, 0x49, 0x45, 0x43, // Z 00137 0x00, 0x7F, 0x41, 0x00, 0x00, // [ 00138 0x02, 0x04, 0x08, 0x10, 0x20, // "\" 00139 0x00, 0x00, 0x41, 0x7F, 0x00, // ] 00140 0x04, 0x02, 0x01, 0x02, 0x04, // ^ 00141 0x40, 0x40, 0x40, 0x40, 0x40, // _ 00142 0x01, 0x3E, 0x41, 0x41, 0x22, // ` now �C Before 0x00, 0x01, 0x02, 0x04, 0x00, 00143 0x20, 0x54, 0x54, 0x54, 0x78, // a 00144 0x7F, 0x44, 0x44, 0x44, 0x38, // b 00145 0x38, 0x44, 0x44, 0x44, 0x44, // c 00146 0x38, 0x44, 0x44, 0x44, 0x7F, // d 00147 0x38, 0x54, 0x54, 0x54, 0x18, // e 00148 0x04, 0x04, 0x7E, 0x05, 0x05, // f 00149 0x08, 0x54, 0x54, 0x54, 0x3C, // g 00150 0x7F, 0x08, 0x04, 0x04, 0x78, // h 00151 0x00, 0x44, 0x7D, 0x40, 0x00, // i 00152 0x20, 0x40, 0x44, 0x3D, 0x00, // j 00153 0x7F, 0x10, 0x28, 0x44, 0x00, // k 00154 0x00, 0x41, 0x7F, 0x40, 0x00, // l 00155 0x7C, 0x04, 0x78, 0x04, 0x78, // m 00156 0x7C, 0x08, 0x04, 0x04, 0x78, // n 00157 0x38, 0x44, 0x44, 0x44, 0x38, // o 00158 0x7C, 0x14, 0x14, 0x14, 0x08, // p 00159 0x08, 0x14, 0x14, 0x14, 0x7C, // q 00160 0x00, 0x7C, 0x08, 0x04, 0x04, // r 00161 0x48, 0x54, 0x54, 0x54, 0x20, // s 00162 0x04, 0x04, 0x3F, 0x44, 0x44, // t 00163 0x3C, 0x40, 0x40, 0x20, 0x7C, // u 00164 0x1C, 0x20, 0x40, 0x20, 0x1C, // v 00165 0x3C, 0x40, 0x30, 0x40, 0x3C, // w 00166 0x44, 0x28, 0x10, 0x28, 0x44, // x 00167 0x0C, 0x50, 0x50, 0x50, 0x3C, // y 00168 0x44, 0x64, 0x54, 0x4C, 0x44, // z 00169 0x00, 0x08, 0x36, 0x41, 0x41, // { 00170 0x00, 0x00, 0x7F, 0x00, 0x00, // | 00171 0x41, 0x41, 0x36, 0x08, 0x00, // } 00172 0x02, 0x01, 0x02, 0x04, 0x02, // ~ 00173 // @Font end 5x7 suite 00174 }; 00175 00176 static char ICON_Question[] = { 00177 5, 00178 8, 00179 0x0e,0x11,0x11,0x08,0x04,0x04,0x00,0x04 00180 }; 00181 //------------class-------------------- 00182 class GLCD { 00183 //-----------methodes ----------------- 00184 public: 00185 /** 00186 *@brief Constructor, initializes the lcd on the respective pins. 00187 *@param control pins DI,RW,E,CS2,CS1 00188 *@param databus DB0-DB7 data pins 00189 *@return none 00190 */ 00191 GLCD (PinName _DI, PinName _RW, PinName _E, PinName _CS1, PinName _CS2, BusInOut *BUSLCD); 00192 void setTest(int mode); 00193 void drawText(int mode); 00194 void repaint(); 00195 bool isUsed(); 00196 bool getXor(); 00197 void setXor( bool s); 00198 void init(bool mode); 00199 void fillScreen( bool color); 00200 // void clean( bool h, bool b); 00201 // void repaint (bool h, bool b); 00202 void setPixel( unsigned short x, unsigned short y, bool color); 00203 bool getPixel( unsigned short x, unsigned short y); 00204 void lineh( unsigned short x0, unsigned short y0, unsigned short x1, bool color); 00205 void linev( unsigned short x0, unsigned short y0, unsigned short y1, bool color); 00206 void line( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, char dash, bool color); 00207 void rectangle( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, char dash, bool fill, bool color); 00208 void bar( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int width, bool color); 00209 void circle( unsigned short x, unsigned short y, unsigned short radius, bool fill, bool color); 00210 unsigned short ellipse(unsigned short x, unsigned short y,unsigned short a, unsigned short b, float angle, unsigned short step, bool color); 00211 unsigned short icon( unsigned short x, unsigned short y, const char* iconptr, bool color, bool transparency); 00212 unsigned short text( unsigned short x, unsigned short y, const char* textptr, const char* fontptr, unsigned char size, bool color, bool transparency); 00213 private: 00214 void reset_pins(int mode); 00215 void writeByte(unsigned char side, unsigned char data); 00216 unsigned char readByte(unsigned char side); 00217 //---------- local variables ---------- 00218 private: 00219 BusInOut* LCD_PORT; 00220 DigitalOut GLCD_DI; 00221 DigitalOut GLCD_RW; 00222 DigitalOut GLCD_E; 00223 DigitalOut GLCD_CS2; 00224 DigitalOut GLCD_CS1; 00225 char left[512]; 00226 char right[512]; 00227 volatile bool isused; 00228 bool _xor; 00229 bool ready; 00230 //------------------------------------- 00231 }; 00232 #endif
Generated on Tue Jul 12 2022 19:44:09 by
1.7.2