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.
PCD8544MS.h
00001 /* mbed PCD8544MS - Graphic Library for driving multi monochrome displays based on PCD8544 00002 * used in Nokia 3310, 3315, 3330, 3350, 3410, 3210, 5110, 5120, 5130, 5160, 6110, 6150 00003 * 00004 * Copyright (c) 2011, Wim De Roeve 00005 * partial port of the code found on http://serdisplib.sourceforge.net/ser/pcd8544.html#links 00006 * and by Petras Saduikis <petras@petras.co.uk> 00007 * 00008 * it uses a PCF8574 / PCF8575 for control line handling (/CS RESET and DC) 00009 * and SPI for data handling 00010 * up to 6 screens 00011 * 00012 * Permission is hereby granted, free of charge, to any person obtaining a copy 00013 * of this software and associated documentation files (the "Software"), to deal 00014 * in the Software without restriction, including without limitation the rights 00015 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00016 * copies of the Software, and to permit persons to whom the Software is 00017 * furnished to do so, subject to the following conditions: 00018 * 00019 * The above copyright notice and this permission notice shall be included in 00020 * all copies or substantial portions of the Software. 00021 * 00022 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00023 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00024 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00025 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00026 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00027 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00028 * THE SOFTWARE. 00029 */ 00030 #ifndef PCD8544MS_H 00031 #define PCD8544MS_H 00032 00033 // the Nokia 3310 has a resolution of 84 x 48 00034 // the Nokia 3410 has a resolution of 102 x 72 officialy 84x64 00035 00036 #include "mbed.h" 00037 00038 #define LCD_X_RES 102 //84 00039 #define LCD_Y_RES 72 //48 00040 #define LCD_BANKS (LCD_Y_RES / 8) 00041 00042 #define LCD_CACHE_SIZE ((LCD_X_RES * LCD_Y_RES) / 8) 00043 00044 #define MAX_ADR_X (LCD_X_RES)-1 00045 #define MAX_ADR_Y LCD_BANKS-1 00046 //#define MAXSCREENS 1 00047 00048 typedef uint8_t BYTE; 00049 00050 class PCD8544MS { 00051 00052 /* PCD8544 from Philips Semiconductors is 00053 48 x 84 pixels monochrome matrix LCD controller/driver 00054 00055 The PCD8544 has a 504 byte memory with NO read function. 00056 Each bit is a pixel 00057 You can only write 1 byte at a time in vertical or horizontal mode. 00058 There is no read functionality with the controller. 00059 Caching a copy of the LCD-memory is the only solution to set one pixel at a time. 00060 00061 00062 * wiring SPI 00063 * mosi // yellow 00064 * miso NC 00065 * sclk //green 00066 00067 * PCF8575/PCF8574 to PCD8544 LCD 00068 * ---------------------- 00069 * P0 - CS1 //gray 00070 * P1 - DC //blue 00071 * P2 - RESET //white 00072 * P3 - CS2 00073 * P4 - CS3 00074 * P5 - CS4 00075 * P6 - CS5 00076 * P7 - CS6 00077 * 00078 */ 00079 // yellow green //gray //blue //white 00080 // PCD8544MS lcd(p11,NC,p13,p15,p16,p17); //mosi miso sclk cs dc reset 00081 00082 00083 public: 00084 00085 /** LCD panel format */ 00086 typedef enum { 00087 PIXEL_OFF = 0, 00088 PIXEL_ON = 1, 00089 PIXEL_XOR = 2 00090 }ePixelMode; 00091 00092 typedef enum { 00093 FILL_OFF = 0, 00094 FILL_ON = 1 00095 }eFillMode; 00096 00097 typedef enum { 00098 RASTER_OFF = 0, 00099 RASTER_ON = 1 00100 }eRasterMode; 00101 00102 typedef enum { 00103 DRAW_OVERWRITE = 0, 00104 DRAW_MERGE = 1 00105 }eDrawMode; 00106 00107 00108 typedef enum { 00109 VERYSMALLFONT = 0, //3x5 00110 TINYFONT = 1, //5x7 00111 SMALLFONT = 2, //6x8 00112 NORMALFONT = 3, //8x8 00113 BIGFONT = 4, //8x12� 00114 TIMENUMBERFONT= 5, //16x20 00115 BIGNUMBERFONT= 6 00116 }eFonts; 00117 00118 typedef enum { 00119 C_POINT = 0, //point 00120 C_LINE = 1, //line 00121 C_VLINE = 2, //Vertical Line 00122 C_HLINE = 3, //Horizontal Line 00123 }eChartMode; 00124 00125 typedef enum { 00126 SPACE_NONE = 0, 00127 SPACE_NORMAL = 1 00128 }eSpaceMode; 00129 00130 enum eDisplayMode {DISPLAY_NORMAL, DISPLAY_HIGHLIGHT}; 00131 00132 enum LCDType { 00133 LCD3310, 00134 LCD3410, 00135 LCD6100, /**< Nokia 6100, as found on sparkfun board (default) */ 00136 LCD6610, /**< Nokia 6610, as found on olimex board */ 00137 PCF8833 00138 }; 00139 00140 00141 PCD8544MS(PinName mosi, PinName miso, PinName sclk, PinName sda, PinName scl,int i2cAddress,bool TextLCD, bool backlight); 00142 00143 /** init() 00144 * 00145 * Initialise the device. 00146 * @param PinName SPI mosi 00147 * @param PinName SPI miso 00148 * @param PinName SPI sclk 00149 * @param PinName sda 00150 * @param PinName sck 00151 * @param PinName i2cAddress 00152 * @param int maxscreens // number of screens used 00153 */ 00154 00155 #if 0 // Inhereted from Stream, for documentation only 00156 /* Function: putc 00157 * Write a character 00158 * 00159 * Variables: 00160 * c - The character to write to the serial port 00161 */ 00162 int putc(int c); 00163 00164 /* Function: printf 00165 * Write a formated string 00166 * 00167 * Variables: 00168 * format - A printf-style format string, followed by the 00169 * variables to use in formating the string. 00170 */ 00171 int printf(const char* format, ...); 00172 #endif 00173 00174 00175 virtual void TLCD_locate(int column, int row); 00176 00177 /* Function: cls 00178 * Clear the screen, and locate to 0,0 00179 */ 00180 virtual void TLCD_cls(); 00181 00182 /* Function: backlight 00183 * Sets the backlight on or off 00184 * 00185 * Variables: 00186 * on (true or false) 00187 */ 00188 00189 00190 virtual void TLCD_backlight(bool on); 00191 00192 00193 /** cls() 00194 * clears the cached copy of the screen 00195 * and the screen itself 00196 */ 00197 void GLCD_cls(int screen,bool fupdate=true); 00198 00199 /** update() 00200 * copies the cached memory to the screen 00201 * use this to update the screen after 00202 * - drawBitmap 00203 */ 00204 void GLCD_update(int screen); 00205 00206 /** close() 00207 * screen display OFF 00208 */ 00209 void GLCD_close(); 00210 00211 /** locate(x,y) 00212 * sets the cursor on position x,y 00213 */ 00214 void GLCD_locate (BYTE x0, BYTE y0); 00215 00216 void chooseFont(eFonts font); 00217 void GLCD_writeString (BYTE x0, BYTE y0, char* string, eFonts font,ePixelMode pmode,eDisplayMode dmode,eSpaceMode smode, BYTE fupdate,int screen ); 00218 void GLCD_writeChar (BYTE x0, BYTE y0, BYTE ch, eFonts font,ePixelMode pmode,eDisplayMode mode, BYTE fupdate,int screen); 00219 00220 /** drawBitmap(x,y,bitmap,xsize,ysize) 00221 * draw a monochrome bitmap on position x,y 00222 * with size xsize,ysize 00223 */ 00224 void GLCD_drawBitmap (BYTE x0, BYTE y0, const unsigned char* bitmap, BYTE bmpXSize, BYTE bmpYSize, BYTE fupdate,int screen ); 00225 00226 void GLCD_drawpixel (BYTE x0, BYTE y0, ePixelMode pmode, BYTE fupdate,int screen ); 00227 void GLCD_drawline (BYTE x0, BYTE y0, BYTE x1,BYTE y1, ePixelMode pmode, BYTE fupdate,int screen ); 00228 void GLCD_drawcircle (BYTE x0, BYTE y0, BYTE radius, eFillMode fill,ePixelMode pmode, BYTE fupdate,int screen ); 00229 void GLCD_drawrectangle (BYTE x0, BYTE y0, BYTE x1,BYTE y1, eFillMode fill, ePixelMode pmode, BYTE fupdate,int screen ); 00230 void GLCD_drawprogressbar(BYTE x0, BYTE y0, BYTE w, BYTE h, BYTE percentage, BYTE fupdate,int screen ); 00231 void GLCD_drawchart (BYTE x0, BYTE y0, BYTE w, BYTE h, BYTE unitx, BYTE unity, 00232 eRasterMode rMode, eChartMode cMode, eDrawMode dMode,int16_t * val, int size, int t,int screen ); 00233 00234 private: 00235 00236 SPI _spi; 00237 I2C _i2c; 00238 int _i2cAddress; 00239 // LCDType _type; 00240 00241 // int _lcd_x_res,_lcd_y_res,_lcd_cache_size; 00242 00243 00244 void TLCD_reset(); 00245 void TLCD_writeData(int data); 00246 void TLCD_writeCommand(int command); 00247 void TLCD_writeByte(int value, bool rs); 00248 void TLCD_writeNibble(int value, bool rs); 00249 00250 void GLCD_reset(); 00251 void GLCD_writeCmd(BYTE data, BYTE CF,int screen); 00252 void GLCD_writeData(BYTE data, BYTE CF,int screen); 00253 void GLCD_writeI2C(bool reset, bool dc, bool cs,int screen ); 00254 00255 void writeI2CByte(int data); 00256 int readI2C(); 00257 00258 virtual int _putc(int c); 00259 virtual int _getc(); 00260 virtual void TLCD_newline(); 00261 00262 int _row; 00263 int _column; 00264 int _columns; 00265 int _rows; 00266 00267 bool _backlight; 00268 00269 //BYTE LcdCache[][_lcd_cache_size]; // __attribute__((section("AHBSRAM0"))); 00270 BYTE LcdCache[LCD_CACHE_SIZE]; // __attribute__((section("AHBSRAM0"))); 00271 00272 int LcdCacheIdx; 00273 int _LoMark; 00274 int _HiMark; 00275 int Scale; 00276 00277 BYTE _font_width; 00278 BYTE _font_height; 00279 BYTE _font_start; 00280 BYTE _font_end; 00281 BYTE _font_bytes; 00282 unsigned char* _pFont; 00283 00284 00285 00286 }; 00287 00288 #endif
Generated on Thu Jul 14 2022 04:23:19 by
1.7.2