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