ajfja
Fork of 4DGL-uLCD-SE by
uLCD_4DGL_Text.cpp@1:df77db998389, 2015-05-01 (annotated)
- Committer:
- anevil14
- Date:
- Fri May 01 16:49:27 2015 +0000
- Revision:
- 1:df77db998389
No Changes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
anevil14 | 1:df77db998389 | 1 | // |
anevil14 | 1:df77db998389 | 2 | // uLCD_4DGL is a class to drive 4D Systems TFT touch screens |
anevil14 | 1:df77db998389 | 3 | // |
anevil14 | 1:df77db998389 | 4 | // Copyright (C) <2010> Stephane ROCHON <stephane.rochon at free.fr> |
anevil14 | 1:df77db998389 | 5 | // Modifed for Goldelox processor <2013> Jim Hamblen |
anevil14 | 1:df77db998389 | 6 | // |
anevil14 | 1:df77db998389 | 7 | // uLCD_4DGL is free software: you can redistribute it and/or modify |
anevil14 | 1:df77db998389 | 8 | // it under the terms of the GNU General Public License as published by |
anevil14 | 1:df77db998389 | 9 | // the Free Software Foundation, either version 3 of the License, or |
anevil14 | 1:df77db998389 | 10 | // (at your option) any later version. |
anevil14 | 1:df77db998389 | 11 | // |
anevil14 | 1:df77db998389 | 12 | // uLCD_4DGL is distributed in the hope that it will be useful, |
anevil14 | 1:df77db998389 | 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
anevil14 | 1:df77db998389 | 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
anevil14 | 1:df77db998389 | 15 | // GNU General Public License for more details. |
anevil14 | 1:df77db998389 | 16 | // |
anevil14 | 1:df77db998389 | 17 | // You should have received a copy of the GNU General Public License |
anevil14 | 1:df77db998389 | 18 | // along with uLCD_4DGL. If not, see <http://www.gnu.org/licenses/>. |
anevil14 | 1:df77db998389 | 19 | |
anevil14 | 1:df77db998389 | 20 | #include "mbed.h" |
anevil14 | 1:df77db998389 | 21 | #include "uLCD_4DGL.h" |
anevil14 | 1:df77db998389 | 22 | |
anevil14 | 1:df77db998389 | 23 | //**************************************************************************************************** |
anevil14 | 1:df77db998389 | 24 | void uLCD_4DGL :: set_font_size(char width, char height) // set font size |
anevil14 | 1:df77db998389 | 25 | { |
anevil14 | 1:df77db998389 | 26 | if (current_orientation == IS_PORTRAIT) { |
anevil14 | 1:df77db998389 | 27 | current_fx = width; |
anevil14 | 1:df77db998389 | 28 | current_fy = height; |
anevil14 | 1:df77db998389 | 29 | } else { |
anevil14 | 1:df77db998389 | 30 | current_fy = height; |
anevil14 | 1:df77db998389 | 31 | current_fx = width; |
anevil14 | 1:df77db998389 | 32 | } |
anevil14 | 1:df77db998389 | 33 | max_col = current_w / (current_fx*current_wf); |
anevil14 | 1:df77db998389 | 34 | max_row = current_h / (current_fy*current_hf); |
anevil14 | 1:df77db998389 | 35 | } |
anevil14 | 1:df77db998389 | 36 | |
anevil14 | 1:df77db998389 | 37 | //**************************************************************************************************** |
anevil14 | 1:df77db998389 | 38 | void uLCD_4DGL :: set_font(char mode) // set font - system or SD media |
anevil14 | 1:df77db998389 | 39 | { |
anevil14 | 1:df77db998389 | 40 | char command[3]= ""; |
anevil14 | 1:df77db998389 | 41 | |
anevil14 | 1:df77db998389 | 42 | command[0] = SETFONT; |
anevil14 | 1:df77db998389 | 43 | command[1] = 0; |
anevil14 | 1:df77db998389 | 44 | command[2] = mode; |
anevil14 | 1:df77db998389 | 45 | |
anevil14 | 1:df77db998389 | 46 | current_font = mode; |
anevil14 | 1:df77db998389 | 47 | |
anevil14 | 1:df77db998389 | 48 | if (current_orientation == IS_PORTRAIT) { |
anevil14 | 1:df77db998389 | 49 | current_w = SIZE_X; |
anevil14 | 1:df77db998389 | 50 | current_h = SIZE_Y; |
anevil14 | 1:df77db998389 | 51 | } else { |
anevil14 | 1:df77db998389 | 52 | current_w = SIZE_Y; |
anevil14 | 1:df77db998389 | 53 | current_h = SIZE_X; |
anevil14 | 1:df77db998389 | 54 | } |
anevil14 | 1:df77db998389 | 55 | |
anevil14 | 1:df77db998389 | 56 | switch (mode) { |
anevil14 | 1:df77db998389 | 57 | case FONT_5X7 : |
anevil14 | 1:df77db998389 | 58 | |
anevil14 | 1:df77db998389 | 59 | current_fx = 6; |
anevil14 | 1:df77db998389 | 60 | current_fy = 8; |
anevil14 | 1:df77db998389 | 61 | break; |
anevil14 | 1:df77db998389 | 62 | case FONT_7X8 : |
anevil14 | 1:df77db998389 | 63 | current_fx = 7; |
anevil14 | 1:df77db998389 | 64 | current_fy = 8; |
anevil14 | 1:df77db998389 | 65 | break; |
anevil14 | 1:df77db998389 | 66 | case FONT_8X8 : |
anevil14 | 1:df77db998389 | 67 | current_fx = 8; |
anevil14 | 1:df77db998389 | 68 | current_fy = 8; |
anevil14 | 1:df77db998389 | 69 | break; |
anevil14 | 1:df77db998389 | 70 | case FONT_8X12 : |
anevil14 | 1:df77db998389 | 71 | current_fx = 8; |
anevil14 | 1:df77db998389 | 72 | current_fy = 12; |
anevil14 | 1:df77db998389 | 73 | break; |
anevil14 | 1:df77db998389 | 74 | case FONT_12X16 : |
anevil14 | 1:df77db998389 | 75 | current_fx = 12; |
anevil14 | 1:df77db998389 | 76 | current_fy = 16; |
anevil14 | 1:df77db998389 | 77 | break; |
anevil14 | 1:df77db998389 | 78 | default: |
anevil14 | 1:df77db998389 | 79 | current_fx = 8; |
anevil14 | 1:df77db998389 | 80 | current_fy = 8; |
anevil14 | 1:df77db998389 | 81 | } |
anevil14 | 1:df77db998389 | 82 | |
anevil14 | 1:df77db998389 | 83 | max_col = current_w / (current_fx*current_wf); |
anevil14 | 1:df77db998389 | 84 | max_row = current_h / (current_fy*current_hf); |
anevil14 | 1:df77db998389 | 85 | |
anevil14 | 1:df77db998389 | 86 | writeCOMMAND(command, 3); |
anevil14 | 1:df77db998389 | 87 | } |
anevil14 | 1:df77db998389 | 88 | |
anevil14 | 1:df77db998389 | 89 | |
anevil14 | 1:df77db998389 | 90 | |
anevil14 | 1:df77db998389 | 91 | //**************************************************************************************************** |
anevil14 | 1:df77db998389 | 92 | void uLCD_4DGL :: text_mode(char mode) // set text mode |
anevil14 | 1:df77db998389 | 93 | { |
anevil14 | 1:df77db998389 | 94 | char command[3]= ""; |
anevil14 | 1:df77db998389 | 95 | |
anevil14 | 1:df77db998389 | 96 | command[0] = TEXTMODE; |
anevil14 | 1:df77db998389 | 97 | command[1] = 0; |
anevil14 | 1:df77db998389 | 98 | command[2] = mode; |
anevil14 | 1:df77db998389 | 99 | |
anevil14 | 1:df77db998389 | 100 | writeCOMMAND(command, 3); |
anevil14 | 1:df77db998389 | 101 | } |
anevil14 | 1:df77db998389 | 102 | |
anevil14 | 1:df77db998389 | 103 | //**************************************************************************************************** |
anevil14 | 1:df77db998389 | 104 | void uLCD_4DGL :: text_bold(char mode) // set text mode |
anevil14 | 1:df77db998389 | 105 | { |
anevil14 | 1:df77db998389 | 106 | char command[3]= ""; |
anevil14 | 1:df77db998389 | 107 | |
anevil14 | 1:df77db998389 | 108 | command[0] = TEXTBOLD; |
anevil14 | 1:df77db998389 | 109 | command[1] = 0; |
anevil14 | 1:df77db998389 | 110 | command[2] = mode; |
anevil14 | 1:df77db998389 | 111 | |
anevil14 | 1:df77db998389 | 112 | writeCOMMAND(command, 3); |
anevil14 | 1:df77db998389 | 113 | } |
anevil14 | 1:df77db998389 | 114 | |
anevil14 | 1:df77db998389 | 115 | //**************************************************************************************************** |
anevil14 | 1:df77db998389 | 116 | void uLCD_4DGL :: text_italic(char mode) // set text mode |
anevil14 | 1:df77db998389 | 117 | { |
anevil14 | 1:df77db998389 | 118 | char command[3]= ""; |
anevil14 | 1:df77db998389 | 119 | |
anevil14 | 1:df77db998389 | 120 | command[0] = TEXTITALIC; |
anevil14 | 1:df77db998389 | 121 | command[1] = 0; |
anevil14 | 1:df77db998389 | 122 | command[2] = mode; |
anevil14 | 1:df77db998389 | 123 | |
anevil14 | 1:df77db998389 | 124 | writeCOMMAND(command, 3); |
anevil14 | 1:df77db998389 | 125 | } |
anevil14 | 1:df77db998389 | 126 | |
anevil14 | 1:df77db998389 | 127 | //**************************************************************************************************** |
anevil14 | 1:df77db998389 | 128 | void uLCD_4DGL :: text_inverse(char mode) // set text mode |
anevil14 | 1:df77db998389 | 129 | { |
anevil14 | 1:df77db998389 | 130 | char command[3]= ""; |
anevil14 | 1:df77db998389 | 131 | |
anevil14 | 1:df77db998389 | 132 | command[0] = TEXTINVERSE; |
anevil14 | 1:df77db998389 | 133 | command[1] = 0; |
anevil14 | 1:df77db998389 | 134 | command[2] = mode; |
anevil14 | 1:df77db998389 | 135 | |
anevil14 | 1:df77db998389 | 136 | writeCOMMAND(command, 3); |
anevil14 | 1:df77db998389 | 137 | } |
anevil14 | 1:df77db998389 | 138 | |
anevil14 | 1:df77db998389 | 139 | //**************************************************************************************************** |
anevil14 | 1:df77db998389 | 140 | void uLCD_4DGL :: text_underline(char mode) // set text mode |
anevil14 | 1:df77db998389 | 141 | { |
anevil14 | 1:df77db998389 | 142 | char command[3]= ""; |
anevil14 | 1:df77db998389 | 143 | |
anevil14 | 1:df77db998389 | 144 | command[0] = TEXTUNDERLINE; |
anevil14 | 1:df77db998389 | 145 | command[1] = 0; |
anevil14 | 1:df77db998389 | 146 | command[2] = mode; |
anevil14 | 1:df77db998389 | 147 | |
anevil14 | 1:df77db998389 | 148 | writeCOMMAND(command, 3); |
anevil14 | 1:df77db998389 | 149 | } |
anevil14 | 1:df77db998389 | 150 | |
anevil14 | 1:df77db998389 | 151 | //**************************************************************************************************** |
anevil14 | 1:df77db998389 | 152 | void uLCD_4DGL :: text_width(char width) // set text width |
anevil14 | 1:df77db998389 | 153 | { |
anevil14 | 1:df77db998389 | 154 | char command[3]= ""; |
anevil14 | 1:df77db998389 | 155 | |
anevil14 | 1:df77db998389 | 156 | command[0] = TEXTWIDTH; |
anevil14 | 1:df77db998389 | 157 | command[1] = 0; |
anevil14 | 1:df77db998389 | 158 | command[2] = width; |
anevil14 | 1:df77db998389 | 159 | current_wf = width; |
anevil14 | 1:df77db998389 | 160 | max_col = current_w / (current_fx*current_wf); |
anevil14 | 1:df77db998389 | 161 | writeCOMMAND(command, 3); |
anevil14 | 1:df77db998389 | 162 | } |
anevil14 | 1:df77db998389 | 163 | |
anevil14 | 1:df77db998389 | 164 | //**************************************************************************************************** |
anevil14 | 1:df77db998389 | 165 | void uLCD_4DGL :: text_height(char height) // set text height |
anevil14 | 1:df77db998389 | 166 | { |
anevil14 | 1:df77db998389 | 167 | char command[3]= ""; |
anevil14 | 1:df77db998389 | 168 | |
anevil14 | 1:df77db998389 | 169 | command[0] = TEXTHEIGHT; |
anevil14 | 1:df77db998389 | 170 | command[1] = 0; |
anevil14 | 1:df77db998389 | 171 | command[2] = height; |
anevil14 | 1:df77db998389 | 172 | current_hf = height; |
anevil14 | 1:df77db998389 | 173 | max_row = current_h / (current_fy*current_hf); |
anevil14 | 1:df77db998389 | 174 | writeCOMMAND(command, 3); |
anevil14 | 1:df77db998389 | 175 | } |
anevil14 | 1:df77db998389 | 176 | |
anevil14 | 1:df77db998389 | 177 | |
anevil14 | 1:df77db998389 | 178 | //**************************************************************************************************** |
anevil14 | 1:df77db998389 | 179 | void uLCD_4DGL :: text_char(char c, char col, char row, int color) // draw a text char |
anevil14 | 1:df77db998389 | 180 | { |
anevil14 | 1:df77db998389 | 181 | char command[6]= ""; |
anevil14 | 1:df77db998389 | 182 | command[0] = 0xE4; //move cursor |
anevil14 | 1:df77db998389 | 183 | command[1] = 0; |
anevil14 | 1:df77db998389 | 184 | command[2] = row; |
anevil14 | 1:df77db998389 | 185 | command[3] = 0; |
anevil14 | 1:df77db998389 | 186 | command[4] = col; |
anevil14 | 1:df77db998389 | 187 | writeCOMMAND(command, 5); |
anevil14 | 1:df77db998389 | 188 | |
anevil14 | 1:df77db998389 | 189 | command[0] = 0x7F; //set color |
anevil14 | 1:df77db998389 | 190 | |
anevil14 | 1:df77db998389 | 191 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
anevil14 | 1:df77db998389 | 192 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
anevil14 | 1:df77db998389 | 193 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
anevil14 | 1:df77db998389 | 194 | |
anevil14 | 1:df77db998389 | 195 | command[1] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
anevil14 | 1:df77db998389 | 196 | command[2] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
anevil14 | 1:df77db998389 | 197 | writeCOMMAND(command, 3); |
anevil14 | 1:df77db998389 | 198 | |
anevil14 | 1:df77db998389 | 199 | command[0] = TEXTCHAR; //print char |
anevil14 | 1:df77db998389 | 200 | command[1] = 0; |
anevil14 | 1:df77db998389 | 201 | command[2] = c; |
anevil14 | 1:df77db998389 | 202 | writeCOMMAND(command, 3); |
anevil14 | 1:df77db998389 | 203 | |
anevil14 | 1:df77db998389 | 204 | } |
anevil14 | 1:df77db998389 | 205 | |
anevil14 | 1:df77db998389 | 206 | |
anevil14 | 1:df77db998389 | 207 | //**************************************************************************************************** |
anevil14 | 1:df77db998389 | 208 | void uLCD_4DGL :: text_string(char *s, char col, char row, char font, int color) // draw a text string |
anevil14 | 1:df77db998389 | 209 | { |
anevil14 | 1:df77db998389 | 210 | |
anevil14 | 1:df77db998389 | 211 | char command[1000]= ""; |
anevil14 | 1:df77db998389 | 212 | int size = strlen(s); |
anevil14 | 1:df77db998389 | 213 | int i = 0; |
anevil14 | 1:df77db998389 | 214 | |
anevil14 | 1:df77db998389 | 215 | set_font(font); |
anevil14 | 1:df77db998389 | 216 | |
anevil14 | 1:df77db998389 | 217 | command[0] = 0xE4; //move cursor |
anevil14 | 1:df77db998389 | 218 | command[1] = 0; |
anevil14 | 1:df77db998389 | 219 | command[2] = row; |
anevil14 | 1:df77db998389 | 220 | command[3] = 0; |
anevil14 | 1:df77db998389 | 221 | command[4] = col; |
anevil14 | 1:df77db998389 | 222 | writeCOMMAND(command, 5); |
anevil14 | 1:df77db998389 | 223 | |
anevil14 | 1:df77db998389 | 224 | command[0] = 0x7F; //set color |
anevil14 | 1:df77db998389 | 225 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
anevil14 | 1:df77db998389 | 226 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
anevil14 | 1:df77db998389 | 227 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
anevil14 | 1:df77db998389 | 228 | |
anevil14 | 1:df77db998389 | 229 | command[1] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
anevil14 | 1:df77db998389 | 230 | command[2] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
anevil14 | 1:df77db998389 | 231 | writeCOMMAND(command, 3); |
anevil14 | 1:df77db998389 | 232 | |
anevil14 | 1:df77db998389 | 233 | command[0] = TEXTSTRING; |
anevil14 | 1:df77db998389 | 234 | for (i=0; i<size; i++) command[1+i] = s[i]; |
anevil14 | 1:df77db998389 | 235 | command[1+size] = 0; |
anevil14 | 1:df77db998389 | 236 | writeCOMMANDnull(command, 2 + size); |
anevil14 | 1:df77db998389 | 237 | } |
anevil14 | 1:df77db998389 | 238 | |
anevil14 | 1:df77db998389 | 239 | |
anevil14 | 1:df77db998389 | 240 | |
anevil14 | 1:df77db998389 | 241 | //**************************************************************************************************** |
anevil14 | 1:df77db998389 | 242 | void uLCD_4DGL :: locate(char col, char row) // place text curssor at col, row |
anevil14 | 1:df77db998389 | 243 | { |
anevil14 | 1:df77db998389 | 244 | char command[5] = ""; |
anevil14 | 1:df77db998389 | 245 | current_col = col; |
anevil14 | 1:df77db998389 | 246 | current_row = row; |
anevil14 | 1:df77db998389 | 247 | command[0] = MOVECURSOR; //move cursor |
anevil14 | 1:df77db998389 | 248 | command[1] = 0; |
anevil14 | 1:df77db998389 | 249 | command[2] = current_row; |
anevil14 | 1:df77db998389 | 250 | command[3] = 0; |
anevil14 | 1:df77db998389 | 251 | command[4] = current_col; |
anevil14 | 1:df77db998389 | 252 | writeCOMMAND(command, 5); |
anevil14 | 1:df77db998389 | 253 | } |
anevil14 | 1:df77db998389 | 254 | |
anevil14 | 1:df77db998389 | 255 | //**************************************************************************************************** |
anevil14 | 1:df77db998389 | 256 | void uLCD_4DGL :: color(int color) // set text color |
anevil14 | 1:df77db998389 | 257 | { |
anevil14 | 1:df77db998389 | 258 | char command[5] = ""; |
anevil14 | 1:df77db998389 | 259 | current_color = color; |
anevil14 | 1:df77db998389 | 260 | command[0] = 0x7F; //set color |
anevil14 | 1:df77db998389 | 261 | |
anevil14 | 1:df77db998389 | 262 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
anevil14 | 1:df77db998389 | 263 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
anevil14 | 1:df77db998389 | 264 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
anevil14 | 1:df77db998389 | 265 | |
anevil14 | 1:df77db998389 | 266 | command[1] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
anevil14 | 1:df77db998389 | 267 | command[2] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
anevil14 | 1:df77db998389 | 268 | writeCOMMAND(command, 3); |
anevil14 | 1:df77db998389 | 269 | } |
anevil14 | 1:df77db998389 | 270 | |
anevil14 | 1:df77db998389 | 271 | //**************************************************************************************************** |
anevil14 | 1:df77db998389 | 272 | void uLCD_4DGL :: putc(char c) // place char at current cursor position |
anevil14 | 1:df77db998389 | 273 | //used by virtual printf function _putc |
anevil14 | 1:df77db998389 | 274 | { |
anevil14 | 1:df77db998389 | 275 | char command[6] =""; |
anevil14 | 1:df77db998389 | 276 | if(c<0x20) { |
anevil14 | 1:df77db998389 | 277 | if(c=='\n') { |
anevil14 | 1:df77db998389 | 278 | current_col = 0; |
anevil14 | 1:df77db998389 | 279 | current_row++; |
anevil14 | 1:df77db998389 | 280 | command[0] = MOVECURSOR; //move cursor to start of next line |
anevil14 | 1:df77db998389 | 281 | command[1] = 0; |
anevil14 | 1:df77db998389 | 282 | command[2] = current_row; |
anevil14 | 1:df77db998389 | 283 | command[3] = 0; |
anevil14 | 1:df77db998389 | 284 | command[4] = current_col; |
anevil14 | 1:df77db998389 | 285 | writeCOMMAND(command, 5); |
anevil14 | 1:df77db998389 | 286 | } |
anevil14 | 1:df77db998389 | 287 | if(c=='\r') { |
anevil14 | 1:df77db998389 | 288 | current_col = 0; |
anevil14 | 1:df77db998389 | 289 | command[0] = MOVECURSOR; //move cursor to start of line |
anevil14 | 1:df77db998389 | 290 | command[1] = 0; |
anevil14 | 1:df77db998389 | 291 | command[2] = current_row; |
anevil14 | 1:df77db998389 | 292 | command[3] = 0; |
anevil14 | 1:df77db998389 | 293 | command[4] = current_col; |
anevil14 | 1:df77db998389 | 294 | writeCOMMAND(command, 5); |
anevil14 | 1:df77db998389 | 295 | } |
anevil14 | 1:df77db998389 | 296 | if(c=='\f') { |
anevil14 | 1:df77db998389 | 297 | uLCD_4DGL::cls(); //clear screen on form feed |
anevil14 | 1:df77db998389 | 298 | } |
anevil14 | 1:df77db998389 | 299 | } else { |
anevil14 | 1:df77db998389 | 300 | command[0] = PUTCHAR; |
anevil14 | 1:df77db998389 | 301 | command[1] = 0x00; |
anevil14 | 1:df77db998389 | 302 | command[2] = c; |
anevil14 | 1:df77db998389 | 303 | writeCOMMAND(command,3); |
anevil14 | 1:df77db998389 | 304 | current_col++; |
anevil14 | 1:df77db998389 | 305 | } |
anevil14 | 1:df77db998389 | 306 | if (current_col == max_col) { |
anevil14 | 1:df77db998389 | 307 | current_col = 0; |
anevil14 | 1:df77db998389 | 308 | current_row++; |
anevil14 | 1:df77db998389 | 309 | command[0] = MOVECURSOR; //move cursor to next line |
anevil14 | 1:df77db998389 | 310 | command[1] = 0; |
anevil14 | 1:df77db998389 | 311 | command[2] = current_row; |
anevil14 | 1:df77db998389 | 312 | command[3] = 0; |
anevil14 | 1:df77db998389 | 313 | command[4] = current_col; |
anevil14 | 1:df77db998389 | 314 | writeCOMMAND(command, 5); |
anevil14 | 1:df77db998389 | 315 | } |
anevil14 | 1:df77db998389 | 316 | if (current_row == max_row) { |
anevil14 | 1:df77db998389 | 317 | current_row = 0; |
anevil14 | 1:df77db998389 | 318 | command[0] = MOVECURSOR; //move cursor back to start |
anevil14 | 1:df77db998389 | 319 | command[1] = 0; |
anevil14 | 1:df77db998389 | 320 | command[2] = current_row; |
anevil14 | 1:df77db998389 | 321 | command[3] = 0; |
anevil14 | 1:df77db998389 | 322 | command[4] = current_col; |
anevil14 | 1:df77db998389 | 323 | writeCOMMAND(command, 5); |
anevil14 | 1:df77db998389 | 324 | } |
anevil14 | 1:df77db998389 | 325 | } |
anevil14 | 1:df77db998389 | 326 | |
anevil14 | 1:df77db998389 | 327 | |
anevil14 | 1:df77db998389 | 328 | //**************************************************************************************************** |
anevil14 | 1:df77db998389 | 329 | void uLCD_4DGL :: puts(char *s) // place string at current cursor position |
anevil14 | 1:df77db998389 | 330 | { |
anevil14 | 1:df77db998389 | 331 | |
anevil14 | 1:df77db998389 | 332 | text_string(s, current_col, current_row, current_font, current_color); |
anevil14 | 1:df77db998389 | 333 | |
anevil14 | 1:df77db998389 | 334 | current_col += strlen(s); |
anevil14 | 1:df77db998389 | 335 | |
anevil14 | 1:df77db998389 | 336 | if (current_col >= max_col) { |
anevil14 | 1:df77db998389 | 337 | current_row += current_col / max_col; |
anevil14 | 1:df77db998389 | 338 | current_col %= max_col; |
anevil14 | 1:df77db998389 | 339 | } |
anevil14 | 1:df77db998389 | 340 | if (current_row >= max_row) { |
anevil14 | 1:df77db998389 | 341 | current_row %= max_row; |
anevil14 | 1:df77db998389 | 342 | } |
anevil14 | 1:df77db998389 | 343 | } |