4 errors
Dependencies: KS0108_PCF8574 mbed
menbed/displays/menbedDisplayHD44780.cpp@0:936f1c020120, 2012-09-05 (annotated)
- Committer:
- GuiTwo
- Date:
- Wed Sep 05 07:21:59 2012 +0000
- Revision:
- 0:936f1c020120
With KS0108;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GuiTwo | 0:936f1c020120 | 1 | /* This code based on mbed TextLCD Library, for a 4-bit LCD based on HD44780, |
GuiTwo | 0:936f1c020120 | 2 | * Copyright (c) 2007-2010, sford, http://mbed.org |
GuiTwo | 0:936f1c020120 | 3 | * |
GuiTwo | 0:936f1c020120 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
GuiTwo | 0:936f1c020120 | 5 | * of this software and associated documentation files (the "Software"), to deal |
GuiTwo | 0:936f1c020120 | 6 | * in the Software without restriction, including without limitation the rights |
GuiTwo | 0:936f1c020120 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
GuiTwo | 0:936f1c020120 | 8 | * copies of the Software, and to permit persons to whom the Software is |
GuiTwo | 0:936f1c020120 | 9 | * furnished to do so, subject to the following conditions: |
GuiTwo | 0:936f1c020120 | 10 | * |
GuiTwo | 0:936f1c020120 | 11 | * The above copyright notice and this permission notice shall be included in |
GuiTwo | 0:936f1c020120 | 12 | * all copies or substantial portions of the Software. |
GuiTwo | 0:936f1c020120 | 13 | * |
GuiTwo | 0:936f1c020120 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
GuiTwo | 0:936f1c020120 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
GuiTwo | 0:936f1c020120 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
GuiTwo | 0:936f1c020120 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
GuiTwo | 0:936f1c020120 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
GuiTwo | 0:936f1c020120 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
GuiTwo | 0:936f1c020120 | 20 | * THE SOFTWARE. |
GuiTwo | 0:936f1c020120 | 21 | */ |
GuiTwo | 0:936f1c020120 | 22 | |
GuiTwo | 0:936f1c020120 | 23 | #include "mbed.h" |
GuiTwo | 0:936f1c020120 | 24 | #include "include/menbedDisplayHD44780.h" |
GuiTwo | 0:936f1c020120 | 25 | #include "menbedDisplay.h" |
GuiTwo | 0:936f1c020120 | 26 | |
GuiTwo | 0:936f1c020120 | 27 | MenbedDisplayHD44780::MenbedDisplayHD44780 (PinName rs, PinName e, |
GuiTwo | 0:936f1c020120 | 28 | PinName d4, PinName d5, PinName d6, PinName d7, LCDSize size) : |
GuiTwo | 0:936f1c020120 | 29 | rs(rs), e(e), d(d4, d5, d6, d7), size(size) |
GuiTwo | 0:936f1c020120 | 30 | { |
GuiTwo | 0:936f1c020120 | 31 | this->e = 1; |
GuiTwo | 0:936f1c020120 | 32 | this->rs = 0; |
GuiTwo | 0:936f1c020120 | 33 | |
GuiTwo | 0:936f1c020120 | 34 | upArrowVisible = false; |
GuiTwo | 0:936f1c020120 | 35 | downArrowVisible = false; |
GuiTwo | 0:936f1c020120 | 36 | topLineSelected = false; |
GuiTwo | 0:936f1c020120 | 37 | bottomLineSelected = false; |
GuiTwo | 0:936f1c020120 | 38 | cursorCol = -1; |
GuiTwo | 0:936f1c020120 | 39 | cursorRow = -1; |
GuiTwo | 0:936f1c020120 | 40 | |
GuiTwo | 0:936f1c020120 | 41 | wait(0.015); // Wait 15ms to ensure powered up |
GuiTwo | 0:936f1c020120 | 42 | |
GuiTwo | 0:936f1c020120 | 43 | // send "Display Settings" 3 times (Only top nibble of 0x30 as we've got 4-bit bus) |
GuiTwo | 0:936f1c020120 | 44 | for (int i=0; i<3; i++) { |
GuiTwo | 0:936f1c020120 | 45 | writeByte(0x3); |
GuiTwo | 0:936f1c020120 | 46 | wait(0.00164); // this command takes 1.64ms, so wait for it |
GuiTwo | 0:936f1c020120 | 47 | } |
GuiTwo | 0:936f1c020120 | 48 | |
GuiTwo | 0:936f1c020120 | 49 | writeByte(0x2); // 4-bit mode |
GuiTwo | 0:936f1c020120 | 50 | wait(0.000040f); // most instructions take 40us |
GuiTwo | 0:936f1c020120 | 51 | |
GuiTwo | 0:936f1c020120 | 52 | writeCommand(0x28); // Function set 001 BW N F - - |
GuiTwo | 0:936f1c020120 | 53 | writeCommand(0x0C); // Display on but keep cursor and blinking off |
GuiTwo | 0:936f1c020120 | 54 | writeCommand(0x6); // Cursor Direction and Display Shift : 0000 01 CD S (CD 0-left, 1-right S(hift) 0-no, 1-yes |
GuiTwo | 0:936f1c020120 | 55 | |
GuiTwo | 0:936f1c020120 | 56 | loadCustomChars(); |
GuiTwo | 0:936f1c020120 | 57 | |
GuiTwo | 0:936f1c020120 | 58 | clear(); |
GuiTwo | 0:936f1c020120 | 59 | } |
GuiTwo | 0:936f1c020120 | 60 | |
GuiTwo | 0:936f1c020120 | 61 | |
GuiTwo | 0:936f1c020120 | 62 | bool MenbedDisplayHD44780::writeLine (const char *line, uint8_t row) |
GuiTwo | 0:936f1c020120 | 63 | { |
GuiTwo | 0:936f1c020120 | 64 | int i = 0; |
GuiTwo | 0:936f1c020120 | 65 | int cursorPos = -1; |
GuiTwo | 0:936f1c020120 | 66 | |
GuiTwo | 0:936f1c020120 | 67 | if (row >= rows()) |
GuiTwo | 0:936f1c020120 | 68 | return false; |
GuiTwo | 0:936f1c020120 | 69 | |
GuiTwo | 0:936f1c020120 | 70 | // Skip writing to the left-most column to leave space for the selector |
GuiTwo | 0:936f1c020120 | 71 | // and up/down arrows that will be filled in later. |
GuiTwo | 0:936f1c020120 | 72 | gotoPosition (row, 1); |
GuiTwo | 0:936f1c020120 | 73 | |
GuiTwo | 0:936f1c020120 | 74 | while ((line[i] != '\0') && (line[i] != '\n') && (i+1 < columns())) |
GuiTwo | 0:936f1c020120 | 75 | { |
GuiTwo | 0:936f1c020120 | 76 | // Place the cursor at the end of the active parameter, when it exists. |
GuiTwo | 0:936f1c020120 | 77 | // A parameter is active when it is highlighted as indicated by the |
GuiTwo | 0:936f1c020120 | 78 | // MSB of the character code being set. |
GuiTwo | 0:936f1c020120 | 79 | if ((i > 0) && (line[i-1] & 0x80) && !(line[i] & 0x80)) |
GuiTwo | 0:936f1c020120 | 80 | cursorPos = i-1; |
GuiTwo | 0:936f1c020120 | 81 | |
GuiTwo | 0:936f1c020120 | 82 | // Print each character to the display after clearing its MSB so that |
GuiTwo | 0:936f1c020120 | 83 | // it prints as a standard ASCII character. |
GuiTwo | 0:936f1c020120 | 84 | writeData (line[i] & ~0x80); |
GuiTwo | 0:936f1c020120 | 85 | i++; |
GuiTwo | 0:936f1c020120 | 86 | } |
GuiTwo | 0:936f1c020120 | 87 | |
GuiTwo | 0:936f1c020120 | 88 | // If the first character of the line is not highlighted but the last is, |
GuiTwo | 0:936f1c020120 | 89 | // a parameter must be selected for editing, and we place the cursor at |
GuiTwo | 0:936f1c020120 | 90 | // the end of the parameter which, in this special case, corresponds to |
GuiTwo | 0:936f1c020120 | 91 | // the end of the line. |
GuiTwo | 0:936f1c020120 | 92 | if (!(line[0] & 0x80) && (line[i-1] & 0x80)) |
GuiTwo | 0:936f1c020120 | 93 | cursorPos = i-1; |
GuiTwo | 0:936f1c020120 | 94 | |
GuiTwo | 0:936f1c020120 | 95 | // Fill the remainder of the row with spaces to overwrite any old data |
GuiTwo | 0:936f1c020120 | 96 | while (i++ < columns() - 1) |
GuiTwo | 0:936f1c020120 | 97 | writeData(' '); |
GuiTwo | 0:936f1c020120 | 98 | |
GuiTwo | 0:936f1c020120 | 99 | // Now go back and fill in the selector and up/down arrows |
GuiTwo | 0:936f1c020120 | 100 | gotoPosition(row, 0); |
GuiTwo | 0:936f1c020120 | 101 | if ((line[0] & 0x80) && (cursorPos == -1)) |
GuiTwo | 0:936f1c020120 | 102 | { |
GuiTwo | 0:936f1c020120 | 103 | if (row == 0) |
GuiTwo | 0:936f1c020120 | 104 | topLineSelected = true; |
GuiTwo | 0:936f1c020120 | 105 | else if (row == rows() - 1) |
GuiTwo | 0:936f1c020120 | 106 | bottomLineSelected = true; |
GuiTwo | 0:936f1c020120 | 107 | |
GuiTwo | 0:936f1c020120 | 108 | if ((row == 0) && upArrowVisible) |
GuiTwo | 0:936f1c020120 | 109 | writeData (CharUP_SELECT); |
GuiTwo | 0:936f1c020120 | 110 | else if ((row == rows() - 1) && downArrowVisible) |
GuiTwo | 0:936f1c020120 | 111 | writeData (CharDOWN_SELECT); |
GuiTwo | 0:936f1c020120 | 112 | else |
GuiTwo | 0:936f1c020120 | 113 | writeData (CharSELECT); |
GuiTwo | 0:936f1c020120 | 114 | } |
GuiTwo | 0:936f1c020120 | 115 | else |
GuiTwo | 0:936f1c020120 | 116 | { |
GuiTwo | 0:936f1c020120 | 117 | if (row == 0) |
GuiTwo | 0:936f1c020120 | 118 | topLineSelected = false; |
GuiTwo | 0:936f1c020120 | 119 | else if (row == rows() - 1) |
GuiTwo | 0:936f1c020120 | 120 | bottomLineSelected = false; |
GuiTwo | 0:936f1c020120 | 121 | |
GuiTwo | 0:936f1c020120 | 122 | if ((row == 0) && upArrowVisible) |
GuiTwo | 0:936f1c020120 | 123 | writeData (CharUP); |
GuiTwo | 0:936f1c020120 | 124 | else if ((row == rows() - 1) && downArrowVisible) |
GuiTwo | 0:936f1c020120 | 125 | writeData (CharDOWN); |
GuiTwo | 0:936f1c020120 | 126 | else |
GuiTwo | 0:936f1c020120 | 127 | writeData (' '); |
GuiTwo | 0:936f1c020120 | 128 | } |
GuiTwo | 0:936f1c020120 | 129 | |
GuiTwo | 0:936f1c020120 | 130 | // If a parameter is being edited, we turn on the blinking cursor. |
GuiTwo | 0:936f1c020120 | 131 | if (cursorPos != -1) |
GuiTwo | 0:936f1c020120 | 132 | { |
GuiTwo | 0:936f1c020120 | 133 | cursorRow = row; |
GuiTwo | 0:936f1c020120 | 134 | cursorCol = cursorPos + 1; |
GuiTwo | 0:936f1c020120 | 135 | gotoPosition (cursorRow, cursorCol); // Add 1 to account for selector col. |
GuiTwo | 0:936f1c020120 | 136 | cursorOn(); |
GuiTwo | 0:936f1c020120 | 137 | } |
GuiTwo | 0:936f1c020120 | 138 | // If this line used to contain the cursor but should not any more reset |
GuiTwo | 0:936f1c020120 | 139 | // the cursor row and column position and turn it off. |
GuiTwo | 0:936f1c020120 | 140 | else if (row == cursorRow) |
GuiTwo | 0:936f1c020120 | 141 | { |
GuiTwo | 0:936f1c020120 | 142 | cursorRow = -1; |
GuiTwo | 0:936f1c020120 | 143 | cursorCol = -1; |
GuiTwo | 0:936f1c020120 | 144 | cursorOff(); |
GuiTwo | 0:936f1c020120 | 145 | } |
GuiTwo | 0:936f1c020120 | 146 | |
GuiTwo | 0:936f1c020120 | 147 | return true; |
GuiTwo | 0:936f1c020120 | 148 | } |
GuiTwo | 0:936f1c020120 | 149 | |
GuiTwo | 0:936f1c020120 | 150 | |
GuiTwo | 0:936f1c020120 | 151 | void MenbedDisplayHD44780::showUpArrow (bool show) |
GuiTwo | 0:936f1c020120 | 152 | { |
GuiTwo | 0:936f1c020120 | 153 | upArrowVisible = show; |
GuiTwo | 0:936f1c020120 | 154 | |
GuiTwo | 0:936f1c020120 | 155 | gotoPosition (0, 0); |
GuiTwo | 0:936f1c020120 | 156 | |
GuiTwo | 0:936f1c020120 | 157 | if (show && topLineSelected) |
GuiTwo | 0:936f1c020120 | 158 | writeData (CharUP_SELECT); |
GuiTwo | 0:936f1c020120 | 159 | else if (!show && topLineSelected) |
GuiTwo | 0:936f1c020120 | 160 | writeData (CharSELECT); |
GuiTwo | 0:936f1c020120 | 161 | else if (show && !topLineSelected) |
GuiTwo | 0:936f1c020120 | 162 | writeData (CharUP); |
GuiTwo | 0:936f1c020120 | 163 | else |
GuiTwo | 0:936f1c020120 | 164 | writeData(' '); |
GuiTwo | 0:936f1c020120 | 165 | |
GuiTwo | 0:936f1c020120 | 166 | // Return cursor to its original location |
GuiTwo | 0:936f1c020120 | 167 | if ((cursorRow >= 0) && (cursorCol >= 0)) |
GuiTwo | 0:936f1c020120 | 168 | gotoPosition (cursorRow, cursorCol); |
GuiTwo | 0:936f1c020120 | 169 | } |
GuiTwo | 0:936f1c020120 | 170 | |
GuiTwo | 0:936f1c020120 | 171 | |
GuiTwo | 0:936f1c020120 | 172 | void MenbedDisplayHD44780::showDownArrow (bool show) |
GuiTwo | 0:936f1c020120 | 173 | { |
GuiTwo | 0:936f1c020120 | 174 | downArrowVisible = show; |
GuiTwo | 0:936f1c020120 | 175 | |
GuiTwo | 0:936f1c020120 | 176 | gotoPosition (rows() - 1, 0); |
GuiTwo | 0:936f1c020120 | 177 | |
GuiTwo | 0:936f1c020120 | 178 | if (show && bottomLineSelected) |
GuiTwo | 0:936f1c020120 | 179 | writeData (CharDOWN_SELECT); |
GuiTwo | 0:936f1c020120 | 180 | else if (!show && bottomLineSelected) |
GuiTwo | 0:936f1c020120 | 181 | writeData (CharSELECT); |
GuiTwo | 0:936f1c020120 | 182 | else if (show && !bottomLineSelected) |
GuiTwo | 0:936f1c020120 | 183 | writeData (CharDOWN); |
GuiTwo | 0:936f1c020120 | 184 | else |
GuiTwo | 0:936f1c020120 | 185 | writeData(' '); |
GuiTwo | 0:936f1c020120 | 186 | |
GuiTwo | 0:936f1c020120 | 187 | // Return cursor to its original location |
GuiTwo | 0:936f1c020120 | 188 | if ((cursorRow >= 0) && (cursorCol >= 0)) |
GuiTwo | 0:936f1c020120 | 189 | gotoPosition (cursorRow, cursorCol); |
GuiTwo | 0:936f1c020120 | 190 | } |
GuiTwo | 0:936f1c020120 | 191 | |
GuiTwo | 0:936f1c020120 | 192 | |
GuiTwo | 0:936f1c020120 | 193 | uint8_t MenbedDisplayHD44780::getLines (void) |
GuiTwo | 0:936f1c020120 | 194 | { |
GuiTwo | 0:936f1c020120 | 195 | return rows(); |
GuiTwo | 0:936f1c020120 | 196 | } |
GuiTwo | 0:936f1c020120 | 197 | |
GuiTwo | 0:936f1c020120 | 198 | |
GuiTwo | 0:936f1c020120 | 199 | uint8_t MenbedDisplayHD44780::getLineLength (void) |
GuiTwo | 0:936f1c020120 | 200 | { |
GuiTwo | 0:936f1c020120 | 201 | return columns(); |
GuiTwo | 0:936f1c020120 | 202 | } |
GuiTwo | 0:936f1c020120 | 203 | |
GuiTwo | 0:936f1c020120 | 204 | |
GuiTwo | 0:936f1c020120 | 205 | void MenbedDisplayHD44780::clear() |
GuiTwo | 0:936f1c020120 | 206 | { |
GuiTwo | 0:936f1c020120 | 207 | writeCommand (0x01); // Clear, and set cursor to 0 |
GuiTwo | 0:936f1c020120 | 208 | wait (0.050f); |
GuiTwo | 0:936f1c020120 | 209 | gotoPosition (0, 0); |
GuiTwo | 0:936f1c020120 | 210 | } |
GuiTwo | 0:936f1c020120 | 211 | |
GuiTwo | 0:936f1c020120 | 212 | |
GuiTwo | 0:936f1c020120 | 213 | bool MenbedDisplayHD44780::gotoPosition(int row, int column) |
GuiTwo | 0:936f1c020120 | 214 | { |
GuiTwo | 0:936f1c020120 | 215 | if ((column < 0) || (column >= columns()) || (row < 0) || (row >= rows())) |
GuiTwo | 0:936f1c020120 | 216 | return false; |
GuiTwo | 0:936f1c020120 | 217 | |
GuiTwo | 0:936f1c020120 | 218 | writeCommand (address (row, column)); |
GuiTwo | 0:936f1c020120 | 219 | return true; |
GuiTwo | 0:936f1c020120 | 220 | } |
GuiTwo | 0:936f1c020120 | 221 | |
GuiTwo | 0:936f1c020120 | 222 | |
GuiTwo | 0:936f1c020120 | 223 | void MenbedDisplayHD44780::cursorOn() |
GuiTwo | 0:936f1c020120 | 224 | { |
GuiTwo | 0:936f1c020120 | 225 | writeCommand(0x0D); // Display and blinking on, cursor off |
GuiTwo | 0:936f1c020120 | 226 | } |
GuiTwo | 0:936f1c020120 | 227 | |
GuiTwo | 0:936f1c020120 | 228 | |
GuiTwo | 0:936f1c020120 | 229 | void MenbedDisplayHD44780::cursorOff() |
GuiTwo | 0:936f1c020120 | 230 | { |
GuiTwo | 0:936f1c020120 | 231 | writeCommand(0x0C); // Display on, cursor and blinking off |
GuiTwo | 0:936f1c020120 | 232 | } |
GuiTwo | 0:936f1c020120 | 233 | |
GuiTwo | 0:936f1c020120 | 234 | |
GuiTwo | 0:936f1c020120 | 235 | void MenbedDisplayHD44780::writeCommand(int command) { |
GuiTwo | 0:936f1c020120 | 236 | rs = 0; |
GuiTwo | 0:936f1c020120 | 237 | writeByte(command); |
GuiTwo | 0:936f1c020120 | 238 | } |
GuiTwo | 0:936f1c020120 | 239 | |
GuiTwo | 0:936f1c020120 | 240 | |
GuiTwo | 0:936f1c020120 | 241 | void MenbedDisplayHD44780::writeData(int data) { |
GuiTwo | 0:936f1c020120 | 242 | rs = 1; |
GuiTwo | 0:936f1c020120 | 243 | writeByte(data); |
GuiTwo | 0:936f1c020120 | 244 | } |
GuiTwo | 0:936f1c020120 | 245 | |
GuiTwo | 0:936f1c020120 | 246 | |
GuiTwo | 0:936f1c020120 | 247 | void MenbedDisplayHD44780::writeByte(int value) { |
GuiTwo | 0:936f1c020120 | 248 | d = value >> 4; |
GuiTwo | 0:936f1c020120 | 249 | wait(0.000040f); // most instructions take 40us |
GuiTwo | 0:936f1c020120 | 250 | e = 0; |
GuiTwo | 0:936f1c020120 | 251 | wait(0.000040f); |
GuiTwo | 0:936f1c020120 | 252 | e = 1; |
GuiTwo | 0:936f1c020120 | 253 | d = value >> 0; |
GuiTwo | 0:936f1c020120 | 254 | wait(0.000040f); |
GuiTwo | 0:936f1c020120 | 255 | e = 0; |
GuiTwo | 0:936f1c020120 | 256 | wait(0.000040f); // most instructions take 40us |
GuiTwo | 0:936f1c020120 | 257 | e = 1; |
GuiTwo | 0:936f1c020120 | 258 | } |
GuiTwo | 0:936f1c020120 | 259 | |
GuiTwo | 0:936f1c020120 | 260 | |
GuiTwo | 0:936f1c020120 | 261 | int MenbedDisplayHD44780::address(int row, int column) { |
GuiTwo | 0:936f1c020120 | 262 | switch (size) { |
GuiTwo | 0:936f1c020120 | 263 | case LCD20x4: |
GuiTwo | 0:936f1c020120 | 264 | switch (row) { |
GuiTwo | 0:936f1c020120 | 265 | case 0: |
GuiTwo | 0:936f1c020120 | 266 | return 0x80 + column; |
GuiTwo | 0:936f1c020120 | 267 | case 1: |
GuiTwo | 0:936f1c020120 | 268 | return 0xc0 + column; |
GuiTwo | 0:936f1c020120 | 269 | case 2: |
GuiTwo | 0:936f1c020120 | 270 | return 0x94 + column; |
GuiTwo | 0:936f1c020120 | 271 | case 3: |
GuiTwo | 0:936f1c020120 | 272 | return 0xd4 + column; |
GuiTwo | 0:936f1c020120 | 273 | } |
GuiTwo | 0:936f1c020120 | 274 | case LCD16x2B: |
GuiTwo | 0:936f1c020120 | 275 | return 0x80 + (row * 40) + column; |
GuiTwo | 0:936f1c020120 | 276 | case LCD16x2: |
GuiTwo | 0:936f1c020120 | 277 | case LCD20x2: |
GuiTwo | 0:936f1c020120 | 278 | default: |
GuiTwo | 0:936f1c020120 | 279 | return 0x80 + (row * 0x40) + column; |
GuiTwo | 0:936f1c020120 | 280 | } |
GuiTwo | 0:936f1c020120 | 281 | } |
GuiTwo | 0:936f1c020120 | 282 | |
GuiTwo | 0:936f1c020120 | 283 | |
GuiTwo | 0:936f1c020120 | 284 | int MenbedDisplayHD44780::columns() |
GuiTwo | 0:936f1c020120 | 285 | { |
GuiTwo | 0:936f1c020120 | 286 | switch (size) { |
GuiTwo | 0:936f1c020120 | 287 | case LCD20x4: |
GuiTwo | 0:936f1c020120 | 288 | case LCD20x2: |
GuiTwo | 0:936f1c020120 | 289 | return 20; |
GuiTwo | 0:936f1c020120 | 290 | case LCD16x2: |
GuiTwo | 0:936f1c020120 | 291 | case LCD16x2B: |
GuiTwo | 0:936f1c020120 | 292 | default: |
GuiTwo | 0:936f1c020120 | 293 | return 16; |
GuiTwo | 0:936f1c020120 | 294 | } |
GuiTwo | 0:936f1c020120 | 295 | } |
GuiTwo | 0:936f1c020120 | 296 | |
GuiTwo | 0:936f1c020120 | 297 | |
GuiTwo | 0:936f1c020120 | 298 | int MenbedDisplayHD44780::rows() |
GuiTwo | 0:936f1c020120 | 299 | { |
GuiTwo | 0:936f1c020120 | 300 | switch (size) { |
GuiTwo | 0:936f1c020120 | 301 | case LCD20x4: |
GuiTwo | 0:936f1c020120 | 302 | return 4; |
GuiTwo | 0:936f1c020120 | 303 | case LCD16x2: |
GuiTwo | 0:936f1c020120 | 304 | case LCD16x2B: |
GuiTwo | 0:936f1c020120 | 305 | case LCD20x2: |
GuiTwo | 0:936f1c020120 | 306 | default: |
GuiTwo | 0:936f1c020120 | 307 | return 2; |
GuiTwo | 0:936f1c020120 | 308 | } |
GuiTwo | 0:936f1c020120 | 309 | } |
GuiTwo | 0:936f1c020120 | 310 | |
GuiTwo | 0:936f1c020120 | 311 | |
GuiTwo | 0:936f1c020120 | 312 | void MenbedDisplayHD44780::loadCustomChars (void) |
GuiTwo | 0:936f1c020120 | 313 | { |
GuiTwo | 0:936f1c020120 | 314 | |
GuiTwo | 0:936f1c020120 | 315 | // Up arrow |
GuiTwo | 0:936f1c020120 | 316 | writeCommand(0x40 + (8 * CharUP)); |
GuiTwo | 0:936f1c020120 | 317 | writeData(0x04); |
GuiTwo | 0:936f1c020120 | 318 | writeData(0x0E); |
GuiTwo | 0:936f1c020120 | 319 | writeData(0x1F); |
GuiTwo | 0:936f1c020120 | 320 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 321 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 322 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 323 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 324 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 325 | |
GuiTwo | 0:936f1c020120 | 326 | // Up arrow with selector |
GuiTwo | 0:936f1c020120 | 327 | writeCommand(0x40 + (8 * CharUP_SELECT)); |
GuiTwo | 0:936f1c020120 | 328 | writeData(0x04); |
GuiTwo | 0:936f1c020120 | 329 | writeData(0x0E); |
GuiTwo | 0:936f1c020120 | 330 | writeData(0x1F); |
GuiTwo | 0:936f1c020120 | 331 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 332 | writeData(0x1F); |
GuiTwo | 0:936f1c020120 | 333 | writeData(0x1F); |
GuiTwo | 0:936f1c020120 | 334 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 335 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 336 | |
GuiTwo | 0:936f1c020120 | 337 | // Selector alone |
GuiTwo | 0:936f1c020120 | 338 | writeCommand(0x40 + (8 * CharSELECT)); |
GuiTwo | 0:936f1c020120 | 339 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 340 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 341 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 342 | writeData(0x1F); |
GuiTwo | 0:936f1c020120 | 343 | writeData(0x1F); |
GuiTwo | 0:936f1c020120 | 344 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 345 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 346 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 347 | |
GuiTwo | 0:936f1c020120 | 348 | // Down arrow with selector |
GuiTwo | 0:936f1c020120 | 349 | writeCommand(0x40 + (8 * CharDOWN_SELECT)); |
GuiTwo | 0:936f1c020120 | 350 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 351 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 352 | writeData(0x1F); |
GuiTwo | 0:936f1c020120 | 353 | writeData(0x1F); |
GuiTwo | 0:936f1c020120 | 354 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 355 | writeData(0x1F); |
GuiTwo | 0:936f1c020120 | 356 | writeData(0x0E); |
GuiTwo | 0:936f1c020120 | 357 | writeData(0x04); |
GuiTwo | 0:936f1c020120 | 358 | |
GuiTwo | 0:936f1c020120 | 359 | // Down arrow |
GuiTwo | 0:936f1c020120 | 360 | writeCommand(0x40 + (8 * CharDOWN)); |
GuiTwo | 0:936f1c020120 | 361 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 362 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 363 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 364 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 365 | writeData(0x00); |
GuiTwo | 0:936f1c020120 | 366 | writeData(0x1F); |
GuiTwo | 0:936f1c020120 | 367 | writeData(0x0E); |
GuiTwo | 0:936f1c020120 | 368 | writeData(0x04); |
GuiTwo | 0:936f1c020120 | 369 | } |