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