Create Library
MCC0G42005A6W.h@1:3ea320ddd830, 2021-04-13 (annotated)
- Committer:
- qynx
- Date:
- Tue Apr 13 13:06:59 2021 +0000
- Revision:
- 1:3ea320ddd830
- Parent:
- 0:bf6598759869
Small changes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
qynx | 0:bf6598759869 | 1 | #ifndef _MCC0G42005A6W_H |
qynx | 0:bf6598759869 | 2 | #define _MCC0G42005A6W_H |
qynx | 0:bf6598759869 | 3 | |
qynx | 0:bf6598759869 | 4 | #include <stdarg.h> |
qynx | 0:bf6598759869 | 5 | #include "mbed.h" |
qynx | 0:bf6598759869 | 6 | #include "MCC0G42005A6W.h" |
qynx | 0:bf6598759869 | 7 | |
qynx | 0:bf6598759869 | 8 | /** |
qynx | 0:bf6598759869 | 9 | * LCD example |
qynx | 0:bf6598759869 | 10 | * |
qynx | 0:bf6598759869 | 11 | * @code |
qynx | 0:bf6598759869 | 12 | * #include <stdarg.h> |
qynx | 0:bf6598759869 | 13 | * #include "mbed.h" |
qynx | 0:bf6598759869 | 14 | * #include "MCC0G42005A6W.h" |
qynx | 0:bf6598759869 | 15 | * |
qynx | 0:bf6598759869 | 16 | * // MCCOG42005A6W-BNMLWI |
qynx | 0:bf6598759869 | 17 | * // Alphanumeric LCD, 20 x 4, White on Blue, 3V to 5V, I2C, English, Japanese, Transmissive |
qynx | 0:bf6598759869 | 18 | * // Farnell nr. 2218946 |
qynx | 0:bf6598759869 | 19 | * // example PCB LCD I2C 4x20 https://circuitmaker.com/User/Details/Rob-Keij-4 |
qynx | 0:bf6598759869 | 20 | * |
qynx | 0:bf6598759869 | 21 | * LCD_COG lcd(SDA, SCL, "==LCD=Driver=V1.00=="); // SDA, SCL |
qynx | 0:bf6598759869 | 22 | * |
qynx | 0:bf6598759869 | 23 | * int main() |
qynx | 0:bf6598759869 | 24 | * { |
qynx | 0:bf6598759869 | 25 | * lcd.printf( 0, 0, "Hello world!" ); |
qynx | 0:bf6598759869 | 26 | * lcd.printf( 4, 1, "pi = %.6f", 3.14159265 ); |
qynx | 0:bf6598759869 | 27 | * lcd.printf( 2, 2, "This is Row %d",2 ); |
qynx | 0:bf6598759869 | 28 | * lcd.printf( 3, 3, "This is Row %d",3 ); |
qynx | 0:bf6598759869 | 29 | * |
qynx | 0:bf6598759869 | 30 | * while(1) { |
qynx | 0:bf6598759869 | 31 | * |
qynx | 0:bf6598759869 | 32 | * } |
qynx | 0:bf6598759869 | 33 | * } |
qynx | 0:bf6598759869 | 34 | * @endcode |
qynx | 0:bf6598759869 | 35 | */ |
qynx | 0:bf6598759869 | 36 | |
qynx | 0:bf6598759869 | 37 | |
qynx | 0:bf6598759869 | 38 | class LCD_COG |
qynx | 0:bf6598759869 | 39 | { |
qynx | 0:bf6598759869 | 40 | public: |
qynx | 0:bf6598759869 | 41 | |
qynx | 0:bf6598759869 | 42 | /** Create a LCD instance which is connected to specified I2C pins with specified address |
qynx | 0:bf6598759869 | 43 | * |
qynx | 0:bf6598759869 | 44 | * @param I2C_sda I2C-bus SDA pin |
qynx | 0:bf6598759869 | 45 | * @param I2C_scl I2C-bus SCL pin |
qynx | 0:bf6598759869 | 46 | * @param init_message string to initialize the LCD |
qynx | 0:bf6598759869 | 47 | */ |
qynx | 0:bf6598759869 | 48 | LCD_COG( PinName I2C_sda, PinName I2C_scl, const char *init_message = NULL ); |
qynx | 0:bf6598759869 | 49 | |
qynx | 0:bf6598759869 | 50 | /** Create a LCD instance connected to specified I2C pins with specified address |
qynx | 0:bf6598759869 | 51 | * |
qynx | 0:bf6598759869 | 52 | * @param I2C object (instance) |
qynx | 0:bf6598759869 | 53 | * @param init_message string to initialize the LCD |
qynx | 0:bf6598759869 | 54 | */ |
qynx | 0:bf6598759869 | 55 | LCD_COG( I2C &i2c_, const char* init_message = NULL ); |
qynx | 0:bf6598759869 | 56 | |
qynx | 0:bf6598759869 | 57 | /** Destructor |
qynx | 0:bf6598759869 | 58 | */ |
qynx | 0:bf6598759869 | 59 | ~LCD_COG(); |
qynx | 0:bf6598759869 | 60 | |
qynx | 0:bf6598759869 | 61 | /** Printf |
qynx | 0:bf6598759869 | 62 | * |
qynx | 0:bf6598759869 | 63 | * printf function with line number. |
qynx | 0:bf6598759869 | 64 | * it can be used like |
qynx | 0:bf6598759869 | 65 | * |
qynx | 0:bf6598759869 | 66 | * lcd.printf( 0, "Hello world!" ); |
qynx | 0:bf6598759869 | 67 | * lcd.printf( 1, "pi = %.6f", 3.14159265 ); |
qynx | 0:bf6598759869 | 68 | * lcd.printf( 2, "This is Row %d",2 ); |
qynx | 0:bf6598759869 | 69 | * lcd.printf( 3, "This is Row %d",3 ); |
qynx | 0:bf6598759869 | 70 | * |
qynx | 0:bf6598759869 | 71 | * @param line line# (0 for upper, 1 for lower) |
qynx | 0:bf6598759869 | 72 | * @param format following parameters are compatible to stdout's printf |
qynx | 0:bf6598759869 | 73 | */ |
qynx | 0:bf6598759869 | 74 | void printf( char line, const char *format, ... ); |
qynx | 0:bf6598759869 | 75 | |
qynx | 0:bf6598759869 | 76 | /** Printf |
qynx | 0:bf6598759869 | 77 | * |
qynx | 0:bf6598759869 | 78 | * printf function with X and Y character position on the LCD. |
qynx | 0:bf6598759869 | 79 | * it can be used like |
qynx | 0:bf6598759869 | 80 | * |
qynx | 0:bf6598759869 | 81 | * lcd.printf( 0, 0, "Hello world!" ); |
qynx | 0:bf6598759869 | 82 | * lcd.printf( 4, 1, "pi = %.6f", 3.14159265 ); |
qynx | 0:bf6598759869 | 83 | * lcd.printf( 2, 2, "This is Row %d",2 ); |
qynx | 0:bf6598759869 | 84 | * lcd.printf( 3, 3, "This is Row %d",3 ); |
qynx | 0:bf6598759869 | 85 | * |
qynx | 0:bf6598759869 | 86 | * @param x X horizontal character position on the LCD |
qynx | 0:bf6598759869 | 87 | * @param y Y vertical character position on the LCD |
qynx | 0:bf6598759869 | 88 | * @param format following parameters are compatible to stdout's printf |
qynx | 0:bf6598759869 | 89 | */ |
qynx | 0:bf6598759869 | 90 | void printf( char x, unsigned char y, const char *format, ... ); |
qynx | 0:bf6598759869 | 91 | |
qynx | 0:bf6598759869 | 92 | /** Put character : "putc()" |
qynx | 0:bf6598759869 | 93 | * |
qynx | 0:bf6598759869 | 94 | * @param line line# (0 for upper, 1 for lower) |
qynx | 0:bf6598759869 | 95 | * @param c character code |
qynx | 0:bf6598759869 | 96 | */ |
qynx | 0:bf6598759869 | 97 | void putc( unsigned char line, char c ); |
qynx | 0:bf6598759869 | 98 | |
qynx | 0:bf6598759869 | 99 | /** Put string : "puts()" |
qynx | 0:bf6598759869 | 100 | * |
qynx | 0:bf6598759869 | 101 | * @param line line# (0 for upper, 1 for lower) |
qynx | 0:bf6598759869 | 102 | * @param s pointer to a string data |
qynx | 0:bf6598759869 | 103 | */ |
qynx | 0:bf6598759869 | 104 | void puts( char line, const char *s ); |
qynx | 0:bf6598759869 | 105 | |
qynx | 0:bf6598759869 | 106 | /** Put character into specified screen position |
qynx | 0:bf6598759869 | 107 | * |
qynx | 0:bf6598759869 | 108 | * @param c character code |
qynx | 0:bf6598759869 | 109 | * @param x horizontal character position on the LCD |
qynx | 0:bf6598759869 | 110 | * @param y vertical character position on the LCD |
qynx | 0:bf6598759869 | 111 | */ |
qynx | 0:bf6598759869 | 112 | void putcxy( char c, unsigned char x, unsigned char y ); |
qynx | 0:bf6598759869 | 113 | |
qynx | 0:bf6598759869 | 114 | /** Clear the LCD |
qynx | 0:bf6598759869 | 115 | */ |
qynx | 0:bf6598759869 | 116 | void clear( void ); |
qynx | 0:bf6598759869 | 117 | |
qynx | 0:bf6598759869 | 118 | /** Contrast adjustment |
qynx | 0:bf6598759869 | 119 | * |
qynx | 0:bf6598759869 | 120 | * @param contrast value (from 0x00 to 0x3E) |
qynx | 0:bf6598759869 | 121 | */ |
qynx | 0:bf6598759869 | 122 | void contrast( char contrast ); |
qynx | 0:bf6598759869 | 123 | |
qynx | 0:bf6598759869 | 124 | /** Put a custom character given as bitmap data |
qynx | 0:bf6598759869 | 125 | * |
qynx | 0:bf6598759869 | 126 | * @param c_code character code |
qynx | 0:bf6598759869 | 127 | * @param cg pointer to bitmap data (array of 8 bytes) |
qynx | 0:bf6598759869 | 128 | * @param x horizontal character position on the LCD |
qynx | 0:bf6598759869 | 129 | * @param y vertical character position on the LCD |
qynx | 0:bf6598759869 | 130 | */ |
qynx | 0:bf6598759869 | 131 | void put_custom_char( char c_code, const char *cg, char x, char y ); |
qynx | 0:bf6598759869 | 132 | |
qynx | 0:bf6598759869 | 133 | /** Set CGRAM (set custom bitmap as a character) |
qynx | 0:bf6598759869 | 134 | * |
qynx | 0:bf6598759869 | 135 | * @param c_code character code |
qynx | 0:bf6598759869 | 136 | * @param cg pointer to bitmap data (array of 8 bytes) |
qynx | 0:bf6598759869 | 137 | */ |
qynx | 0:bf6598759869 | 138 | void set_CGRAM( char char_code, const char* cg ); |
qynx | 0:bf6598759869 | 139 | |
qynx | 0:bf6598759869 | 140 | /** Set CGRAM (set custom bitmap as a character) |
qynx | 0:bf6598759869 | 141 | * |
qynx | 0:bf6598759869 | 142 | * @param c_code character code |
qynx | 0:bf6598759869 | 143 | * @param v bitmap data (5 bit pattern in this variable are copied to all row of a character bitmap) |
qynx | 0:bf6598759869 | 144 | */ |
qynx | 0:bf6598759869 | 145 | void set_CGRAM( char char_code, char v ); |
qynx | 0:bf6598759869 | 146 | |
qynx | 0:bf6598759869 | 147 | |
qynx | 0:bf6598759869 | 148 | /** Set number of characters in a line |
qynx | 0:bf6598759869 | 149 | * |
qynx | 0:bf6598759869 | 150 | * @param ch number of charactors in a line |
qynx | 0:bf6598759869 | 151 | */ |
qynx | 0:bf6598759869 | 152 | void setCharsInLine( char ch ) |
qynx | 0:bf6598759869 | 153 | { |
qynx | 0:bf6598759869 | 154 | charsInLine = ch; |
qynx | 0:bf6598759869 | 155 | }; |
qynx | 0:bf6598759869 | 156 | |
qynx | 0:bf6598759869 | 157 | private: |
qynx | 0:bf6598759869 | 158 | |
qynx | 0:bf6598759869 | 159 | typedef enum { |
qynx | 0:bf6598759869 | 160 | |
qynx | 0:bf6598759869 | 161 | SLAVEADRESS = 0x78, |
qynx | 0:bf6598759869 | 162 | LINES = 4, |
qynx | 0:bf6598759869 | 163 | LCD_HOME_L1 = 0x80, |
qynx | 0:bf6598759869 | 164 | LINE1 = 0x00, |
qynx | 0:bf6598759869 | 165 | LINE2 = LINE1+0x20, |
qynx | 0:bf6598759869 | 166 | LINE3 = LINE1+0x40, |
qynx | 0:bf6598759869 | 167 | LINE4 = LINE1+0x60, |
qynx | 0:bf6598759869 | 168 | |
qynx | 0:bf6598759869 | 169 | DISPLAY_ON = 0x04, |
qynx | 0:bf6598759869 | 170 | DISPLAY_OFF = 0x03, |
qynx | 0:bf6598759869 | 171 | CURSOR_ON = 0x02, |
qynx | 0:bf6598759869 | 172 | CURSOR_OFF = 0x05, |
qynx | 0:bf6598759869 | 173 | BLINK_ON = 0x01, |
qynx | 0:bf6598759869 | 174 | BLINK_OFF = 0x06, |
qynx | 0:bf6598759869 | 175 | |
qynx | 0:bf6598759869 | 176 | TOPVIEW = 0x05, |
qynx | 0:bf6598759869 | 177 | BOTTOMVIEW = 0x06, |
qynx | 0:bf6598759869 | 178 | |
qynx | 0:bf6598759869 | 179 | ROMA = 0x00, |
qynx | 0:bf6598759869 | 180 | ROMB = 0x04, |
qynx | 0:bf6598759869 | 181 | ROMC = 0x0C, |
qynx | 0:bf6598759869 | 182 | |
qynx | 0:bf6598759869 | 183 | Comm_FunctionSet_Normal = 0x38, |
qynx | 0:bf6598759869 | 184 | Comm_FunctionSet_Extended = 0x39, |
qynx | 0:bf6598759869 | 185 | Comm_InternalOscFrequency = 0x14, |
qynx | 0:bf6598759869 | 186 | Comm_DisplayOnOff = 0x0C, |
qynx | 0:bf6598759869 | 187 | Comm_ClearDisplay = 0x01, |
qynx | 0:bf6598759869 | 188 | Comm_ReturnHome = 0x02, |
qynx | 0:bf6598759869 | 189 | Comm_ContrastSet = 0x70, |
qynx | 0:bf6598759869 | 190 | Comm_PwrIconContrast = 0x5C, |
qynx | 0:bf6598759869 | 191 | Comm_FollowerCtrl = 0x60, |
qynx | 0:bf6598759869 | 192 | Comm_EntryModeSet = 0x04, |
qynx | 0:bf6598759869 | 193 | Comm_SetCGRAM = 0x40 |
qynx | 0:bf6598759869 | 194 | |
qynx | 0:bf6598759869 | 195 | |
qynx | 0:bf6598759869 | 196 | //Instruction IS RE RS R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0 Description |
qynx | 0:bf6598759869 | 197 | //Clear display XX00 0 0 0 0 0 0 0 1 Write "20H" to DDRAM. and set DDRAM address to "00H" from AC. |
qynx | 0:bf6598759869 | 198 | //Comm_ClearDisplay = 0x01, |
qynx | 0:bf6598759869 | 199 | // |
qynx | 0:bf6598759869 | 200 | //Return home X000 0 0 0 0 0 0 1 X Set DDRAM address to "00H" from AC and return cursor to its original position if shifted. The contents of DDRAM are not changed. |
qynx | 0:bf6598759869 | 201 | //Comm_ReturnHome = 0x02, |
qynx | 0:bf6598759869 | 202 | // |
qynx | 0:bf6598759869 | 203 | //Power down mode X100 0 0 0 0 0 0 1 PD Set power down mode bit. PD = "1": power down mode set, PD = "0": power down mode disable (POR) |
qynx | 0:bf6598759869 | 204 | // |
qynx | 0:bf6598759869 | 205 | //Entry mode set X000 0 0 0 0 0 1 I/D S Assign cursor/ blink moving direction with DDRAM address I/D = "1": cursor/ blink moves to right |
qynx | 0:bf6598759869 | 206 | // and DDRAM address is increased by 1 (POR) |
qynx | 0:bf6598759869 | 207 | // I/D = "0": cursor/ blink moves to left and DDRAM address is decreased by 1 |
qynx | 0:bf6598759869 | 208 | // Assign display shift with DDRAM address S = "1": make display shift of the enabled lines by the DS4 to DS1 bits in the shift enable instruction. |
qynx | 0:bf6598759869 | 209 | // Left/right direction depends on I/D bit selection. S = "0": display shift disable (POR) |
qynx | 0:bf6598759869 | 210 | // |
qynx | 0:bf6598759869 | 211 | // X100 0 0 0 0 0 1 BDC BDS Segment bi-direction function. |
qynx | 0:bf6598759869 | 212 | // BDS = "0": Seg100 -> Seg1, |
qynx | 0:bf6598759869 | 213 | // BDS = "1": Seg1 -> Seg100. |
qynx | 0:bf6598759869 | 214 | // Segment bi-direction function. |
qynx | 0:bf6598759869 | 215 | // BDC = "0": Com32 -> Com1 |
qynx | 0:bf6598759869 | 216 | // BDC = "1": Com1 -> Com32 |
qynx | 0:bf6598759869 | 217 | // |
qynx | 0:bf6598759869 | 218 | //Display On/Off control X000 0 0 0 0 1 D C B Set display/cursor/blink on/off |
qynx | 0:bf6598759869 | 219 | //Comm_DisplayOnOff = 0x0C, // 0000 1100 |
qynx | 0:bf6598759869 | 220 | // D = "1": display on, |
qynx | 0:bf6598759869 | 221 | // D = "0": display off (POR), |
qynx | 0:bf6598759869 | 222 | // C = "1": cursor on, |
qynx | 0:bf6598759869 | 223 | // C = "0": cursor off (POR), |
qynx | 0:bf6598759869 | 224 | // B = "1": blink on, |
qynx | 0:bf6598759869 | 225 | // B = "0": blink off (POR). |
qynx | 0:bf6598759869 | 226 | // |
qynx | 0:bf6598759869 | 227 | //Extended function set X100 0 0 0 0 1 FW B/W NW Assign font width, black/white inverting of cursor, and 4-line display mode control bit. |
qynx | 0:bf6598759869 | 228 | // FW = "1": 6-dot font width, |
qynx | 0:bf6598759869 | 229 | // FW = "0": 5-dot font width (POR), |
qynx | 0:bf6598759869 | 230 | // B/W = "1": black/white inverting of cursor enable, |
qynx | 0:bf6598759869 | 231 | // B/W = "0": black/white inverting of cursor disable (POR) |
qynx | 0:bf6598759869 | 232 | // NW = "1": 3-line or 4-line display mode, |
qynx | 0:bf6598759869 | 233 | // NW = "0": 1-line or 2-line display mode |
qynx | 0:bf6598759869 | 234 | // |
qynx | 0:bf6598759869 | 235 | //Cursor or display shift 0000 0 0 0 1 S/C R/L x x Set cursor moving and display shift control bit, and the direction, without changing DDRAM data. |
qynx | 0:bf6598759869 | 236 | // S/C = "1": display shift, |
qynx | 0:bf6598759869 | 237 | // S/C = "0": cursor shift, |
qynx | 0:bf6598759869 | 238 | // R/L = "1": shift to right, |
qynx | 0:bf6598759869 | 239 | // R/L = "0": shift to left. |
qynx | 0:bf6598759869 | 240 | // |
qynx | 0:bf6598759869 | 241 | //Double height(4-line)/ 0100 0 0 0 1 UD2 UD1 BS1 DH’ UD2~1: Assign different doubt height format (POR=11) |
qynx | 0:bf6598759869 | 242 | //Bias/Display-dotshift BS1:BS0 = “00”: 1/5 bias (POR) |
qynx | 0:bf6598759869 | 243 | // BS1:BS0 = “01”: 1/4 bias |
qynx | 0:bf6598759869 | 244 | // BS1:BS0 = “10”: 1/7 bias |
qynx | 0:bf6598759869 | 245 | // BS1:BS0 = “11”: 1/6 bias |
qynx | 0:bf6598759869 | 246 | // DH’ = "1": display shift enable |
qynx | 0:bf6598759869 | 247 | // DH’ = "0": dot scroll enable (POR) |
qynx | 0:bf6598759869 | 248 | |
qynx | 0:bf6598759869 | 249 | |
qynx | 0:bf6598759869 | 250 | //Internal OSC frequency 1000 0 0 0 1 BS0 F2 F1 F0 F2~0: adjust internal OSC frequency for FE frequency (POR: 011) |
qynx | 0:bf6598759869 | 251 | //Comm_InternalOscFrequency = 0x14, |
qynx | 0:bf6598759869 | 252 | // |
qynx | 0:bf6598759869 | 253 | //Shiftenable 1100 0 0 0 1 DS4 DS3 DS2 DS1 (when DH’ = "1") POR DS4~1=1111 Determine the line for display shift. |
qynx | 0:bf6598759869 | 254 | // DS1 = "1/0": 1st line display shift enable/disable |
qynx | 0:bf6598759869 | 255 | // DS2 = "1/0": 2nd line display shift enable/disable |
qynx | 0:bf6598759869 | 256 | // DS3 = "1/0": 3rd line display shift enable/disable |
qynx | 0:bf6598759869 | 257 | // DS4 = "1/0": 4th line display shift enable/disable. |
qynx | 0:bf6598759869 | 258 | //Scroll enable 1100 0 0 0 1 HS4 HS3 HS2 HS1 (when DH’ = "0") POR HS4~1=1111 Determine the line for horizontal smooth scroll. |
qynx | 0:bf6598759869 | 259 | // HS1 = "1/0": 1st line dot scroll enable/disable |
qynx | 0:bf6598759869 | 260 | // HS2 = "1/0": 2nd line dot scroll enable/disable |
qynx | 0:bf6598759869 | 261 | // HS3 = "1/0": 3rd line dot scroll enable/disable |
qynx | 0:bf6598759869 | 262 | // HS4 = "1/0": 4th line dot scroll enable/disable. |
qynx | 0:bf6598759869 | 263 | // |
qynx | 0:bf6598759869 | 264 | //Function set X000 0 0 1 DL N DH RE(0) IS Set interface data length DL = "1": 8-bit (POR), |
qynx | 0:bf6598759869 | 265 | // DL = "0": 4-bit |
qynx | 0:bf6598759869 | 266 | // Numbers of display line N = "1": 2-line (NW=0)/ 4-line(NW=1), |
qynx | 0:bf6598759869 | 267 | // N = "0": 1-line (NW=0)/ 3-line(NW=1) |
qynx | 0:bf6598759869 | 268 | // Extension register, RE("0") at this instruction, RE must be "0". |
qynx | 0:bf6598759869 | 269 | // Shift/scroll enable DH = “ 1/0”: Double height font control for 2-line mode enable/ disable (POR=0) |
qynx | 0:bf6598759869 | 270 | // IS Special registers enable bit at this moment, must be "0". |
qynx | 0:bf6598759869 | 271 | |
qynx | 0:bf6598759869 | 272 | |
qynx | 0:bf6598759869 | 273 | //Comm_FunctionSet_Normal = 0x3a, // 0011 1010 |
qynx | 0:bf6598759869 | 274 | //Comm_FunctionSet_Normal = 0x38, // 0011 1000 |
qynx | 0:bf6598759869 | 275 | |
qynx | 0:bf6598759869 | 276 | |
qynx | 0:bf6598759869 | 277 | // |
qynx | 0:bf6598759869 | 278 | // |
qynx | 0:bf6598759869 | 279 | // X100 0 0 1 DL N BE RE(1) REV Set DL, N, RE("1") CGRAM/SEGRAM blink enable BE = " 1/0": CGRAM/SEGRAM blink enable/disable (POR=0) |
qynx | 0:bf6598759869 | 280 | // Reverse bit REV = "1": reverse display, REV = "0": normal display (POR). |
qynx | 0:bf6598759869 | 281 | // |
qynx | 0:bf6598759869 | 282 | //set CGRAM address 0000 0 1 AC5 AC4 AC3 AC2 AC1 AC0 Set CGRAM address in address counter. (POR=00 0000) |
qynx | 0:bf6598759869 | 283 | |
qynx | 0:bf6598759869 | 284 | //set SEGRAM address 1000 0 1 0 0 AC3 AC2 AC1 AC0 Set SEGRAM address in address counter. (POR=0000) |
qynx | 0:bf6598759869 | 285 | // |
qynx | 0:bf6598759869 | 286 | //Power/ |
qynx | 0:bf6598759869 | 287 | //Icon control/ |
qynx | 0:bf6598759869 | 288 | //Contrast set 1000 0 1 0 1 Ion Bon C5 C4 Ion = “1/0”: ICON (SEGRAM) display on/off (POR=0) |
qynx | 0:bf6598759869 | 289 | // Bon = “1/0”: set booster and regulator circuit on/off (POR=0) |
qynx | 0:bf6598759869 | 290 | // C5, C4: Contrast set for internal follower mode (POR=10) |
qynx | 0:bf6598759869 | 291 | // |
qynx | 0:bf6598759869 | 292 | //Follower Control 1000 0 1 1 0 Don Rab2 Rab1 Rab0 Don: Set divider circuit on/ off (POR=0) |
qynx | 0:bf6598759869 | 293 | // Rab2~0: Select Amplifier internal resistor ratio (POR=010) |
qynx | 0:bf6598759869 | 294 | // |
qynx | 0:bf6598759869 | 295 | //Contrast Set 1000 0 1 1 1 C3 C2 C1 C0 C3~0: Contrast set for internal follower mode (POR=0000) |
qynx | 0:bf6598759869 | 296 | // |
qynx | 0:bf6598759869 | 297 | //set DDRAM address X000 1 AC6 AC5 AC4 AC3 AC2 AC1 AC0 Set DDRAM address in address counter. (POR=000 0000) |
qynx | 0:bf6598759869 | 298 | // |
qynx | 0:bf6598759869 | 299 | //set scroll quantity X100 1 X SQ5 SQ4 SQ3 SQ2 SQ1 SQ0 Set the quantity of horizontal dot scroll. (POR=00 0000) |
qynx | 0:bf6598759869 | 300 | // |
qynx | 0:bf6598759869 | 301 | //Read busy flag and Can be known whether during internal operation or not by reading BF. |
qynx | 0:bf6598759869 | 302 | //address/part ID XX01 BF AC6 AC5 AC4 AC3 AC2 AC1 AC0 The contents of address counter or the part ID can also be read. |
qynx | 0:bf6598759869 | 303 | // / / / / / / / When it is read the first time, the address counter can be read. |
qynx | 0:bf6598759869 | 304 | // ID6 ID5 ID4 ID3 ID2 ID1 ID0 When it is read the second time, the part ID can be read. |
qynx | 0:bf6598759869 | 305 | // |
qynx | 0:bf6598759869 | 306 | // BF = "1": busy state |
qynx | 0:bf6598759869 | 307 | // BF = "0": ready state |
qynx | 0:bf6598759869 | 308 | // |
qynx | 0:bf6598759869 | 309 | //write data XX10 D7 D6 D5 D4 D3 D2 D1 D0 Write data into internal RAM (DDRAM / CGRAM / SEGRAM). |
qynx | 0:bf6598759869 | 310 | //read data XX11 D7 D6 D5 D4 D3 D2 D1 D0 Read data from internal RAM (DDRAM / CGRAM / SEGRAM). |
qynx | 0:bf6598759869 | 311 | // |
qynx | 0:bf6598759869 | 312 | // |
qynx | 0:bf6598759869 | 313 | |
qynx | 0:bf6598759869 | 314 | |
qynx | 0:bf6598759869 | 315 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
qynx | 0:bf6598759869 | 316 | // Extended Instruction Set |
qynx | 0:bf6598759869 | 317 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
qynx | 0:bf6598759869 | 318 | // |
qynx | 0:bf6598759869 | 319 | //Temperature X100 0 1 1 1 0 1 1 0 Set Temperature Coefficient TC2~0: |
qynx | 0:bf6598759869 | 320 | //Coefficient 000: Reserved |
qynx | 0:bf6598759869 | 321 | //Control 001: Reserved |
qynx | 0:bf6598759869 | 322 | // 010: -0.05%/゚C (POR) |
qynx | 0:bf6598759869 | 323 | //Temperature XX10 0 0 0 0 0 TC2 TC1 TC0 011: Reserved |
qynx | 0:bf6598759869 | 324 | //Coefficient 100: -0.10%/゚C |
qynx | 0:bf6598759869 | 325 | //Control 101: Reserved |
qynx | 0:bf6598759869 | 326 | //Settings 110: -0.15%/゚C |
qynx | 0:bf6598759869 | 327 | // 111: -0.20%/゚C |
qynx | 0:bf6598759869 | 328 | // |
qynx | 0:bf6598759869 | 329 | //ROM Selection X100 0 1 1 1 0 0 1 0 Writing data into ROM selection |
qynx | 0:bf6598759869 | 330 | //ROM Selection Settings XX10 0 0 0 0 ROM2 ROM1 0 0 register enables the selection of |
qynx | 0:bf6598759869 | 331 | // ROM A, B or C. |
qynx | 0:bf6598759869 | 332 | // ROM2~1: |
qynx | 0:bf6598759869 | 333 | // 00: ROMA |
qynx | 0:bf6598759869 | 334 | // 01: ROMB |
qynx | 0:bf6598759869 | 335 | // 10: ROMC |
qynx | 0:bf6598759869 | 336 | // 11: Invalid |
qynx | 0:bf6598759869 | 337 | |
qynx | 0:bf6598759869 | 338 | } _commands; |
qynx | 0:bf6598759869 | 339 | |
qynx | 0:bf6598759869 | 340 | typedef enum { |
qynx | 0:bf6598759869 | 341 | MaxCharsInALine = 0x14, // buffer depth for one line (no scroll function used) |
qynx | 0:bf6598759869 | 342 | COMMAND = 0x00, |
qynx | 0:bf6598759869 | 343 | DATA = 0x40 |
qynx | 0:bf6598759869 | 344 | } _constants; |
qynx | 0:bf6598759869 | 345 | |
qynx | 0:bf6598759869 | 346 | |
qynx | 0:bf6598759869 | 347 | char curs[LINES]; // Character position on line |
qynx | 0:bf6598759869 | 348 | void init( const char* init_message ); |
qynx | 0:bf6598759869 | 349 | void clear_rest_of_line( unsigned char line ); |
qynx | 0:bf6598759869 | 350 | int lcd_write( char first, char second ); |
qynx | 0:bf6598759869 | 351 | int lcd_command( char command ); |
qynx | 0:bf6598759869 | 352 | int lcd_data( char data ); |
qynx | 0:bf6598759869 | 353 | I2C *i2c_p; |
qynx | 0:bf6598759869 | 354 | I2C &i2c; |
qynx | 0:bf6598759869 | 355 | char i2c_addr; |
qynx | 0:bf6598759869 | 356 | char charsInLine; |
qynx | 0:bf6598759869 | 357 | |
qynx | 0:bf6598759869 | 358 | }; |
qynx | 0:bf6598759869 | 359 | |
qynx | 0:bf6598759869 | 360 | |
qynx | 0:bf6598759869 | 361 | #endif |
qynx | 0:bf6598759869 | 362 | |
qynx | 0:bf6598759869 | 363 | |
qynx | 0:bf6598759869 | 364 | |
qynx | 0:bf6598759869 | 365 | |
qynx | 0:bf6598759869 | 366 | |
qynx | 0:bf6598759869 | 367 | |
qynx | 0:bf6598759869 | 368 | |
qynx | 0:bf6598759869 | 369 | |
qynx | 0:bf6598759869 | 370 | |
qynx | 0:bf6598759869 | 371 |