Class Module for EA DOGS102 Graphic LCD display SPI Interface
Dependents: mDotEVBM2X MTDOT-EVB-LinkCheck-AL MTDOT-EVBDemo-DRH MTDOT_BOX_EVB_LCD_Helloworld ... more
DOGS102.h
00001 /** 00002 * @file DOGS102.h 00003 * @brief Device driver - DOGS102 102x64 pixel Graphic LCD display W/RTOS support 00004 * @author Tim Barr 00005 * @version 1.0 00006 * @see http://www.lcd-module.com/eng/pdf/grafik/dogs102-6e.pdf 00007 * @see http://www.lcd-module.com/eng/pdf/zubehoer/uc1701.pdf 00008 * 00009 * Copyright (c) 2015 00010 * 00011 * Licensed under the Apache License, Version 2.0 (the "License"); 00012 * you may not use this file except in compliance with the License. 00013 * You may obtain a copy of the License at 00014 * 00015 * http://www.apache.org/licenses/LICENSE-2.0 00016 * 00017 * Unless required by applicable law or agreed to in writing, software 00018 * distributed under the License is distributed on an "AS IS" BASIS, 00019 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00020 * See the License for the specific language governing permissions and 00021 * limitations under the License. 00022 * 00023 */ 00024 00025 #ifndef DOGS102_H 00026 #define DOGS102_H 00027 00028 #include "mbed.h" 00029 00030 /** Using the Multitech MTDOT-EVB 00031 * 00032 * Example: 00033 * @code 00034 * #include "mbed.h" 00035 * #include "DOGS102.h" 00036 * 00037 00038 * 00039 * int main() 00040 * { 00041 00042 * } 00043 * @endcode 00044 */ 00045 00046 /** 00047 * @class DOGS102 00048 * @brief API abstraction for the DOGS102 Liquid Crystal Graphics Display 00049 * initial version will be polling only. Interrupt service will 00050 * be added at a later point 00051 */ 00052 #define LCDWIDTH 102 00053 #define LCDHEIGHT 64 00054 #define LCDPAGES 8 // LCDHEIGHT/8 00055 /* 00056 00057 Each page is 8 lines, one byte per column 00058 00059 Col0 00060 +---+-- 00061 | 0 | 00062 Page 0 | 1 | 00063 | 2 | 00064 | 3 | 00065 | 4 | 00066 | 5 | 00067 | 6 | 00068 | 7 | 00069 +---+-- 00070 */ 00071 00072 class DOGS102 00073 { 00074 public: 00075 00076 /** 00077 * @enum DATAMASKS 00078 * @brief collection of data masks for commands 00079 */ 00080 00081 enum DATAMASKS 00082 { 00083 LSBMASK = 0x01, 00084 WAMASK = 0x03, 00085 PCMASK = 0x07, 00086 LC1MASK = 0x08, 00087 COLMASK = 0x0F, 00088 SLMASK = 0x3F, 00089 TCMASK = 0x80 00090 }; 00091 00092 /** 00093 * @enum COMMANDS 00094 * @brief The device command register map 00095 */ 00096 00097 enum COMMANDs 00098 { 00099 SETCOLADDRLSB = 0x00, // use COLMASK for data 00100 SETCOLADDRMSB = 0x10, // use COLMASK for data 00101 SETPWRCTRL = 0x28, // use PCMASK for data 00102 SETSCROLLLINE = 0X40, // use SLMASK for data 00103 SETPGADDR = 0xB0, // use COLMASK for data 00104 SETVLCDRESRATIO = 0x20, // use PCMASK for data 00105 SETELECVOL = 0x81, // double byte command use SLMASK for data 00106 SETALLPIXELON = 0xA4, // use LSBMASK for data 00107 SETINVDISP = 0xA6, // use LSBMASK for data 00108 SETDISPEN = 0xAE, // use LSBMASK for data 00109 SETSEGDIR = 0xA0, // use LSBMASK for data 00110 SETCOMDIR = 0xC0, // use LC1MASK for data 00111 SOFTRESET = 0xE2, // no data mask needed 00112 SETLCDBIAS = 0xA2, // use LSBMASK for data 00113 SETAPROGCTRL = 0xFA // Double byte command use WAMASK and TCMASK for data 00114 }; 00115 00116 /** Create the DOGS102 object 00117 * @param spi - A defined SPI object 00118 * @param spi_cs - a defined DigitalOut connected to CS pin of LCD 00119 * @param cmnd_data - a defined Digitalout connected to Command/Data pin of LCD 00120 */ 00121 DOGS102(SPI &spi, DigitalOut &spi_cs, DigitalOut &cmnd_data ); 00122 00123 /** Clears the buffer memory 00124 * This commands clears the display buffer if Update flag is set 00125 * it clears the display directly if Update flagis cleared 00126 */ 00127 void clearBuffer(void); 00128 00129 /* 00130 * Writes text to display using specified font table 00131 * @column - bit column where write starts 00132 * @page - Page that write starts (0-7 valid) A page is 8 pixels vertical on display. 00133 * @*font_address - address pointer to font table to use 00134 * @*str - pointer to string array to display 00135 * @size - size of data in str 00136 */ 00137 void writeText(uint8_t column, uint8_t page, const uint8_t *font_address, const char *str, const uint8_t size); 00138 00139 /* 00140 *Writes text to display using specified font table 00141 * @column - bit column where write starts 00142 * @page - Page that write starts (0-7 valid). A page is 8 pixels vertical on display. 00143 * @*bm_address - pointer to uint8_t array with bitmap data to display 00144 */ 00145 void writeBitmap(uint8_t column, uint8_t page, const uint8_t *bm_address); 00146 00147 /* 00148 * Allows LCD buffer to be update without changing LCD 00149 * Each call increments the Update semaphore and required a matching endUpdate 00150 */ 00151 void startUpdate(void); 00152 00153 /* 00154 * Enables direct updates to LCD and sends buffer to LCD 00155 * Each call decrements the Update semephore. If the Update semaphore is cleared, 00156 * the LCD is updated. 00157 */ 00158 void endUpdate(void); 00159 00160 /** Gets state of update semaphore 00161 * @return update semaphore flag state 0 = direct update of LCD >0 is update LCD buffer only 00162 */ 00163 uint8_t getUpdateState(void); 00164 00165 00166 private: 00167 00168 SPI *_spi; 00169 DigitalOut *_lcd_cs; 00170 DigitalOut *_cmnd_data; 00171 uint8_t _lcdbuffer[LCDWIDTH*LCDPAGES]; 00172 uint8_t _update_flag; 00173 00174 uint8_t init(void); 00175 00176 void sendBuffer(const uint8_t* buffer); 00177 00178 /** Write to a command register 00179 * @param reg - The register to be written 00180 * @param data - pointer to char data buffer 00181 * @param count - size of char data buffer, default 1 if not defined 00182 */ 00183 uint8_t writeCommand(uint8_t const reg, uint8_t const data = 0) const; 00184 00185 /** Write data to LCD screen buffer (exposed for debugging reasons) 00186 * @param count - Size of the char data buffer 00187 * @param data - pointer to char data buffer 00188 * @return The status 00189 */ 00190 void writeData(const uint8_t* data, uint8_t count) const; 00191 00192 /** Sets the cursor location 00193 * @param xcur - x-cursor location in pixels. value is clipped if outside display size 00194 * @param ycur - y-cursor location in pixels. value is clipped if outside display size 00195 * @return - modulus of page that data needs to be shifted 00196 */ 00197 uint8_t setCursor(uint8_t xcur, uint8_t ycur); 00198 00199 }; 00200 00201 #endif
Generated on Sat Jul 16 2022 10:59:31 by
1.7.2