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