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