4DGL-uLCD-SE with removed color defines

Fork of 4DGL-uLCD-SE by jim hamblen

Committer:
4180_1
Date:
Fri Nov 22 02:44:37 2013 +0000
Revision:
5:8936798c19a3
Parent:
2:edae99e4abe7
Child:
7:e39a44de229a
ver1.4

Who changed what in which revision?

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