Lozi fractal map

Committer:
JLS
Date:
Sun Dec 26 20:26:09 2010 +0000
Revision:
1:89b1a06c1828
update

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JLS 1:89b1a06c1828 1 //
JLS 1:89b1a06c1828 2 // TFT_4DGL is a class to drive 4D Systems TFT touch screens
JLS 1:89b1a06c1828 3 //
JLS 1:89b1a06c1828 4 // Copyright (C) <2010> Stephane ROCHON <stephane.rochon at free.fr>
JLS 1:89b1a06c1828 5 //
JLS 1:89b1a06c1828 6 // TFT_4DGL is free software: you can redistribute it and/or modify
JLS 1:89b1a06c1828 7 // it under the terms of the GNU General Public License as published by
JLS 1:89b1a06c1828 8 // the Free Software Foundation, either version 3 of the License, or
JLS 1:89b1a06c1828 9 // (at your option) any later version.
JLS 1:89b1a06c1828 10 //
JLS 1:89b1a06c1828 11 // TFT_4DGL is distributed in the hope that it will be useful,
JLS 1:89b1a06c1828 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
JLS 1:89b1a06c1828 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
JLS 1:89b1a06c1828 14 // GNU General Public License for more details.
JLS 1:89b1a06c1828 15 //
JLS 1:89b1a06c1828 16 // You should have received a copy of the GNU General Public License
JLS 1:89b1a06c1828 17 // along with TFT_4DGL. If not, see <http://www.gnu.org/licenses/>.
JLS 1:89b1a06c1828 18
JLS 1:89b1a06c1828 19 #include "mbed.h"
JLS 1:89b1a06c1828 20 #include "TFT_4DGL.h"
JLS 1:89b1a06c1828 21
JLS 1:89b1a06c1828 22
JLS 1:89b1a06c1828 23 //****************************************************************************************************
JLS 1:89b1a06c1828 24 void TFT_4DGL :: circle(int x, int y , int radius, int color) { // draw a circle in (x,y)
JLS 1:89b1a06c1828 25 char command[9]= "";
JLS 1:89b1a06c1828 26
JLS 1:89b1a06c1828 27 command[0] = CIRCLE;
JLS 1:89b1a06c1828 28
JLS 1:89b1a06c1828 29 command[1] = (x >> 8) & 0xFF;
JLS 1:89b1a06c1828 30 command[2] = x & 0xFF;
JLS 1:89b1a06c1828 31
JLS 1:89b1a06c1828 32 command[3] = (y >> 8) & 0xFF;
JLS 1:89b1a06c1828 33 command[4] = y & 0xFF;
JLS 1:89b1a06c1828 34
JLS 1:89b1a06c1828 35 command[5] = (radius >> 8) & 0xFF;
JLS 1:89b1a06c1828 36 command[6] = radius & 0xFF;
JLS 1:89b1a06c1828 37
JLS 1:89b1a06c1828 38 int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits
JLS 1:89b1a06c1828 39 int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits
JLS 1:89b1a06c1828 40 int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits
JLS 1:89b1a06c1828 41
JLS 1:89b1a06c1828 42 command[7] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color
JLS 1:89b1a06c1828 43 command[8] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color
JLS 1:89b1a06c1828 44
JLS 1:89b1a06c1828 45 writeCOMMAND(command, 9);
JLS 1:89b1a06c1828 46 }
JLS 1:89b1a06c1828 47
JLS 1:89b1a06c1828 48 //****************************************************************************************************
JLS 1:89b1a06c1828 49 void TFT_4DGL :: triangle(int x1, int y1 , int x2, int y2, int x3, int y3, int color) { // draw a traingle
JLS 1:89b1a06c1828 50 char command[15]= "";
JLS 1:89b1a06c1828 51
JLS 1:89b1a06c1828 52 command[0] = TRIANGLE;
JLS 1:89b1a06c1828 53
JLS 1:89b1a06c1828 54 command[1] = (x1 >> 8) & 0xFF;
JLS 1:89b1a06c1828 55 command[2] = x1 & 0xFF;
JLS 1:89b1a06c1828 56
JLS 1:89b1a06c1828 57 command[3] = (y1 >> 8) & 0xFF;
JLS 1:89b1a06c1828 58 command[4] = y1 & 0xFF;
JLS 1:89b1a06c1828 59
JLS 1:89b1a06c1828 60 command[5] = (x2 >> 8) & 0xFF;
JLS 1:89b1a06c1828 61 command[6] = x2 & 0xFF;
JLS 1:89b1a06c1828 62
JLS 1:89b1a06c1828 63 command[7] = (y2 >> 8) & 0xFF;
JLS 1:89b1a06c1828 64 command[8] = y2 & 0xFF;
JLS 1:89b1a06c1828 65
JLS 1:89b1a06c1828 66 command[9] = (x3 >> 8) & 0xFF;
JLS 1:89b1a06c1828 67 command[10] = x3 & 0xFF;
JLS 1:89b1a06c1828 68
JLS 1:89b1a06c1828 69 command[11] = (y3 >> 8) & 0xFF;
JLS 1:89b1a06c1828 70 command[12] = y3 & 0xFF;
JLS 1:89b1a06c1828 71
JLS 1:89b1a06c1828 72 int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits
JLS 1:89b1a06c1828 73 int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits
JLS 1:89b1a06c1828 74 int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits
JLS 1:89b1a06c1828 75
JLS 1:89b1a06c1828 76 command[13] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color
JLS 1:89b1a06c1828 77 command[14] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color
JLS 1:89b1a06c1828 78
JLS 1:89b1a06c1828 79 writeCOMMAND(command, 15);
JLS 1:89b1a06c1828 80 }
JLS 1:89b1a06c1828 81
JLS 1:89b1a06c1828 82 //****************************************************************************************************
JLS 1:89b1a06c1828 83 void TFT_4DGL :: line(int x1, int y1 , int x2, int y2, int color) { // draw a line
JLS 1:89b1a06c1828 84 char command[11]= "";
JLS 1:89b1a06c1828 85
JLS 1:89b1a06c1828 86 command[0] = LINE;
JLS 1:89b1a06c1828 87
JLS 1:89b1a06c1828 88 command[1] = (x1 >> 8) & 0xFF;
JLS 1:89b1a06c1828 89 command[2] = x1 & 0xFF;
JLS 1:89b1a06c1828 90
JLS 1:89b1a06c1828 91 command[3] = (y1 >> 8) & 0xFF;
JLS 1:89b1a06c1828 92 command[4] = y1 & 0xFF;
JLS 1:89b1a06c1828 93
JLS 1:89b1a06c1828 94 command[5] = (x2 >> 8) & 0xFF;
JLS 1:89b1a06c1828 95 command[6] = x2 & 0xFF;
JLS 1:89b1a06c1828 96
JLS 1:89b1a06c1828 97 command[7] = (y2 >> 8) & 0xFF;
JLS 1:89b1a06c1828 98 command[8] = y2 & 0xFF;
JLS 1:89b1a06c1828 99
JLS 1:89b1a06c1828 100 int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits
JLS 1:89b1a06c1828 101 int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits
JLS 1:89b1a06c1828 102 int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits
JLS 1:89b1a06c1828 103
JLS 1:89b1a06c1828 104 command[9] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color
JLS 1:89b1a06c1828 105 command[10] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color
JLS 1:89b1a06c1828 106
JLS 1:89b1a06c1828 107 writeCOMMAND(command, 11);
JLS 1:89b1a06c1828 108 }
JLS 1:89b1a06c1828 109
JLS 1:89b1a06c1828 110 //****************************************************************************************************
JLS 1:89b1a06c1828 111 void TFT_4DGL :: rectangle(int x1, int y1 , int x2, int y2, int color) { // draw a rectangle
JLS 1:89b1a06c1828 112 char command[11]= "";
JLS 1:89b1a06c1828 113
JLS 1:89b1a06c1828 114 command[0] = RECTANGLE;
JLS 1:89b1a06c1828 115
JLS 1:89b1a06c1828 116 command[1] = (x1 >> 8) & 0xFF;
JLS 1:89b1a06c1828 117 command[2] = x1 & 0xFF;
JLS 1:89b1a06c1828 118
JLS 1:89b1a06c1828 119 command[3] = (y1 >> 8) & 0xFF;
JLS 1:89b1a06c1828 120 command[4] = y1 & 0xFF;
JLS 1:89b1a06c1828 121
JLS 1:89b1a06c1828 122 command[5] = (x2 >> 8) & 0xFF;
JLS 1:89b1a06c1828 123 command[6] = x2 & 0xFF;
JLS 1:89b1a06c1828 124
JLS 1:89b1a06c1828 125 command[7] = (y2 >> 8) & 0xFF;
JLS 1:89b1a06c1828 126 command[8] = y2 & 0xFF;
JLS 1:89b1a06c1828 127
JLS 1:89b1a06c1828 128 int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits
JLS 1:89b1a06c1828 129 int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits
JLS 1:89b1a06c1828 130 int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits
JLS 1:89b1a06c1828 131
JLS 1:89b1a06c1828 132 command[9] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color
JLS 1:89b1a06c1828 133 command[10] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color
JLS 1:89b1a06c1828 134
JLS 1:89b1a06c1828 135 writeCOMMAND(command, 11);
JLS 1:89b1a06c1828 136 }
JLS 1:89b1a06c1828 137
JLS 1:89b1a06c1828 138 //****************************************************************************************************
JLS 1:89b1a06c1828 139 void TFT_4DGL :: ellipse(int x, int y , int radius_x, int radius_y, int color) { // draw an ellipse
JLS 1:89b1a06c1828 140 char command[11]= "";
JLS 1:89b1a06c1828 141
JLS 1:89b1a06c1828 142 command[0] = ELLIPSE;
JLS 1:89b1a06c1828 143
JLS 1:89b1a06c1828 144 command[1] = (x >> 8) & 0xFF;
JLS 1:89b1a06c1828 145 command[2] = x & 0xFF;
JLS 1:89b1a06c1828 146
JLS 1:89b1a06c1828 147 command[3] = (y >> 8) & 0xFF;
JLS 1:89b1a06c1828 148 command[4] = y & 0xFF;
JLS 1:89b1a06c1828 149
JLS 1:89b1a06c1828 150 command[5] = (radius_x >> 8) & 0xFF;
JLS 1:89b1a06c1828 151 command[6] = radius_x & 0xFF;
JLS 1:89b1a06c1828 152
JLS 1:89b1a06c1828 153 command[7] = (radius_y >> 8) & 0xFF;
JLS 1:89b1a06c1828 154 command[8] = radius_y & 0xFF;
JLS 1:89b1a06c1828 155
JLS 1:89b1a06c1828 156 int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits
JLS 1:89b1a06c1828 157 int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits
JLS 1:89b1a06c1828 158 int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits
JLS 1:89b1a06c1828 159
JLS 1:89b1a06c1828 160 command[9] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color
JLS 1:89b1a06c1828 161 command[10] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color
JLS 1:89b1a06c1828 162
JLS 1:89b1a06c1828 163 writeCOMMAND(command, 11);
JLS 1:89b1a06c1828 164 }
JLS 1:89b1a06c1828 165
JLS 1:89b1a06c1828 166 //****************************************************************************************************
JLS 1:89b1a06c1828 167 void TFT_4DGL :: pixel(int x, int y, int color) { // draw a pixel
JLS 1:89b1a06c1828 168 char command[7]= "";
JLS 1:89b1a06c1828 169
JLS 1:89b1a06c1828 170 command[0] = PIXEL;
JLS 1:89b1a06c1828 171
JLS 1:89b1a06c1828 172 command[1] = (x >> 8) & 0xFF;
JLS 1:89b1a06c1828 173 command[2] = x & 0xFF;
JLS 1:89b1a06c1828 174
JLS 1:89b1a06c1828 175 command[3] = (y >> 8) & 0xFF;
JLS 1:89b1a06c1828 176 command[4] = y & 0xFF;
JLS 1:89b1a06c1828 177
JLS 1:89b1a06c1828 178 int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits
JLS 1:89b1a06c1828 179 int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits
JLS 1:89b1a06c1828 180 int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits
JLS 1:89b1a06c1828 181
JLS 1:89b1a06c1828 182 command[5] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color
JLS 1:89b1a06c1828 183 command[6] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color
JLS 1:89b1a06c1828 184
JLS 1:89b1a06c1828 185 writeCOMMAND(command, 7);
JLS 1:89b1a06c1828 186 }
JLS 1:89b1a06c1828 187
JLS 1:89b1a06c1828 188 //******************************************************************************************************
JLS 1:89b1a06c1828 189 int TFT_4DGL :: read_pixel(int x, int y) { // read screen info and populate data
JLS 1:89b1a06c1828 190
JLS 1:89b1a06c1828 191 char command[5]= "";
JLS 1:89b1a06c1828 192
JLS 1:89b1a06c1828 193 command[0] = READPIXEL;
JLS 1:89b1a06c1828 194
JLS 1:89b1a06c1828 195 command[1] = (x >> 8) & 0xFF;
JLS 1:89b1a06c1828 196 command[2] = x & 0xFF;
JLS 1:89b1a06c1828 197
JLS 1:89b1a06c1828 198 command[3] = (y >> 8) & 0xFF;
JLS 1:89b1a06c1828 199 command[4] = y & 0xFF;
JLS 1:89b1a06c1828 200
JLS 1:89b1a06c1828 201 int i, temp = 0, color = 0, resp = 0;
JLS 1:89b1a06c1828 202 char response[2] = "";
JLS 1:89b1a06c1828 203
JLS 1:89b1a06c1828 204 freeBUFFER();
JLS 1:89b1a06c1828 205
JLS 1:89b1a06c1828 206 for (i = 0; i < 5; i++) { // send all chars to serial port
JLS 1:89b1a06c1828 207 writeBYTE(command[i]);
JLS 1:89b1a06c1828 208 }
JLS 1:89b1a06c1828 209
JLS 1:89b1a06c1828 210 while (!_cmd.readable()) wait_ms(TEMPO); // wait for screen answer
JLS 1:89b1a06c1828 211
JLS 1:89b1a06c1828 212 while (_cmd.readable()) {
JLS 1:89b1a06c1828 213 temp = _cmd.getc();
JLS 1:89b1a06c1828 214 response[resp++] = (char)temp;
JLS 1:89b1a06c1828 215 }
JLS 1:89b1a06c1828 216
JLS 1:89b1a06c1828 217 color = ((response[0] << 8) + response[1]);
JLS 1:89b1a06c1828 218
JLS 1:89b1a06c1828 219 return color; // WARNING : this is 16bits color, not 24bits... need to be fixed
JLS 1:89b1a06c1828 220 }
JLS 1:89b1a06c1828 221
JLS 1:89b1a06c1828 222 //******************************************************************************************************
JLS 1:89b1a06c1828 223 void TFT_4DGL :: screen_copy(int xs, int ys , int xd, int yd , int width, int height) {
JLS 1:89b1a06c1828 224
JLS 1:89b1a06c1828 225 char command[13]= "";
JLS 1:89b1a06c1828 226
JLS 1:89b1a06c1828 227 command[0] = SCREENCOPY;
JLS 1:89b1a06c1828 228
JLS 1:89b1a06c1828 229 command[1] = (xs >> 8) & 0xFF;
JLS 1:89b1a06c1828 230 command[2] = xs & 0xFF;
JLS 1:89b1a06c1828 231
JLS 1:89b1a06c1828 232 command[3] = (ys >> 8) & 0xFF;
JLS 1:89b1a06c1828 233 command[4] = ys & 0xFF;
JLS 1:89b1a06c1828 234
JLS 1:89b1a06c1828 235 command[5] = (xd >> 8) & 0xFF;
JLS 1:89b1a06c1828 236 command[6] = xd & 0xFF;
JLS 1:89b1a06c1828 237
JLS 1:89b1a06c1828 238 command[7] = (yd >> 8) & 0xFF;
JLS 1:89b1a06c1828 239 command[8] = yd & 0xFF;
JLS 1:89b1a06c1828 240
JLS 1:89b1a06c1828 241 command[9] = (width >> 8) & 0xFF;
JLS 1:89b1a06c1828 242 command[10] = width & 0xFF;
JLS 1:89b1a06c1828 243
JLS 1:89b1a06c1828 244 command[11] = (height >> 8) & 0xFF;
JLS 1:89b1a06c1828 245 command[12] = height & 0xFF;
JLS 1:89b1a06c1828 246
JLS 1:89b1a06c1828 247 writeCOMMAND(command, 13);
JLS 1:89b1a06c1828 248 }
JLS 1:89b1a06c1828 249
JLS 1:89b1a06c1828 250 //****************************************************************************************************
JLS 1:89b1a06c1828 251 void TFT_4DGL :: pen_size(char mode) { // set pen to SOLID or WIREFRAME
JLS 1:89b1a06c1828 252 char command[2]= "";
JLS 1:89b1a06c1828 253
JLS 1:89b1a06c1828 254 command[0] = PENSIZE;
JLS 1:89b1a06c1828 255 command[1] = mode;
JLS 1:89b1a06c1828 256
JLS 1:89b1a06c1828 257 writeCOMMAND(command, 2);
JLS 1:89b1a06c1828 258 }
JLS 1:89b1a06c1828 259
JLS 1:89b1a06c1828 260 //****************************************************************************************************
JLS 1:89b1a06c1828 261 // This plays a .wav file from the FAT partition of an uSD Card
JLS 1:89b1a06c1828 262 // Not really recommended as the speaker on the uLCD-32PT is really bad!
JLS 1:89b1a06c1828 263 //****************************************************************************************************
JLS 1:89b1a06c1828 264 void TFT_4DGL :: SD_Card_Wav(char *Filename) {
JLS 1:89b1a06c1828 265 char command[21]= "";
JLS 1:89b1a06c1828 266 int Lgt=0;
JLS 1:89b1a06c1828 267
JLS 1:89b1a06c1828 268 command[0] = 0x40; //ext_cmd
JLS 1:89b1a06c1828 269 command[1] = 0x6C; //Play Audio
JLS 1:89b1a06c1828 270 command[2] = 0x01; //Option 0x00=Return at end, 0x01=Return now, 0x02=Stop, 0x03=Pause, 0x04=Resume, 0x05=Loop.
JLS 1:89b1a06c1828 271 for(int i=0;Filename[i]!=0x00;i++){
JLS 1:89b1a06c1828 272 command[i+3] = Filename[i];
JLS 1:89b1a06c1828 273 Lgt = i;
JLS 1:89b1a06c1828 274 }
JLS 1:89b1a06c1828 275 command[Lgt+4] = 0x2E; //.
JLS 1:89b1a06c1828 276 command[Lgt+5] = 0x77; //w
JLS 1:89b1a06c1828 277 command[Lgt+6] = 0x61; //a
JLS 1:89b1a06c1828 278 command[Lgt+7] = 0x76; //v
JLS 1:89b1a06c1828 279 command[Lgt+8] = 0x00; //terminator
JLS 1:89b1a06c1828 280
JLS 1:89b1a06c1828 281 writeCOMMAND(command, Lgt+9);
JLS 1:89b1a06c1828 282 }
JLS 1:89b1a06c1828 283
JLS 1:89b1a06c1828 284 //****************************************************************************************************
JLS 1:89b1a06c1828 285 // This sets the volume for the speaker on the uLCD-32PT
JLS 1:89b1a06c1828 286 //****************************************************************************************************
JLS 1:89b1a06c1828 287 void TFT_4DGL :: Set_Volume(char vol) {
JLS 1:89b1a06c1828 288
JLS 1:89b1a06c1828 289 char command[2]= "";
JLS 1:89b1a06c1828 290
JLS 1:89b1a06c1828 291 command[0] = 0x76; //cmd
JLS 1:89b1a06c1828 292 command[1] = vol; //set volume
JLS 1:89b1a06c1828 293
JLS 1:89b1a06c1828 294 writeCOMMAND(command, 2);
JLS 1:89b1a06c1828 295 }
JLS 1:89b1a06c1828 296
JLS 1:89b1a06c1828 297 //****************************************************************************************************
JLS 1:89b1a06c1828 298 // This displays an image on the screen that is stored on the FAT partition of an uSD Card
JLS 1:89b1a06c1828 299 // Sent Filename, X-pos, Y-pos, Sector Address - Display from the RAW partition is quicker
JLS 1:89b1a06c1828 300 //****************************************************************************************************
JLS 1:89b1a06c1828 301 void TFT_4DGL :: uSD_FAT_Image(char *Filename, int x, int y, long s) {
JLS 1:89b1a06c1828 302 char X_MSB, X_LSB, Y_MSB, Y_LSB, S0, S1, S2, S3;
JLS 1:89b1a06c1828 303 char command[25]= "";
JLS 1:89b1a06c1828 304 int Lgt=0;
JLS 1:89b1a06c1828 305
JLS 1:89b1a06c1828 306 X_LSB = x&0x00FF;
JLS 1:89b1a06c1828 307 X_MSB = (x >> 8);
JLS 1:89b1a06c1828 308 Y_LSB = y&0x00FF;
JLS 1:89b1a06c1828 309 Y_MSB = (y >> 8);
JLS 1:89b1a06c1828 310
JLS 1:89b1a06c1828 311 S0 = (s >> 20)&0x000000FF;
JLS 1:89b1a06c1828 312 S1 = (s >> 16)&0x0000FF;
JLS 1:89b1a06c1828 313 S2 = (s >> 8)&0x0000FF;
JLS 1:89b1a06c1828 314 S3 = s&0x0000FF;;
JLS 1:89b1a06c1828 315
JLS 1:89b1a06c1828 316 command[0] = '@'; //ext_cmd
JLS 1:89b1a06c1828 317 command[1] = 'm'; //FAT Image
JLS 1:89b1a06c1828 318 for(int i=0;Filename[i]!=0x00;i++){
JLS 1:89b1a06c1828 319 command[i+2] = Filename[i];
JLS 1:89b1a06c1828 320 Lgt = i;
JLS 1:89b1a06c1828 321 }
JLS 1:89b1a06c1828 322 command[Lgt+3] = '.'; //.
JLS 1:89b1a06c1828 323 command[Lgt+4] = 'G'; //G
JLS 1:89b1a06c1828 324 command[Lgt+5] = 'C'; //C
JLS 1:89b1a06c1828 325 command[Lgt+6] = 'I'; //I
JLS 1:89b1a06c1828 326 command[Lgt+7] = 0x00; //Terminator
JLS 1:89b1a06c1828 327 command[Lgt+8] = X_MSB; //X-Position MSB
JLS 1:89b1a06c1828 328 command[Lgt+9] = X_LSB; //X-Position LSB
JLS 1:89b1a06c1828 329 command[Lgt+10] = Y_MSB; //Y-Position MSB
JLS 1:89b1a06c1828 330 command[Lgt+11] = Y_LSB; //Y-Position LSB
JLS 1:89b1a06c1828 331 command[Lgt+12] = S0; //Sector Address 4 bytes
JLS 1:89b1a06c1828 332 command[Lgt+13] = S1;
JLS 1:89b1a06c1828 333 command[Lgt+14] = S2;
JLS 1:89b1a06c1828 334 command[Lgt+15] = S3;
JLS 1:89b1a06c1828 335
JLS 1:89b1a06c1828 336 writeCOMMAND(command, Lgt+16);
JLS 1:89b1a06c1828 337 }
JLS 1:89b1a06c1828 338
JLS 1:89b1a06c1828 339 //****************************************************************************************************
JLS 1:89b1a06c1828 340 // This displays an image on the screen in the NEW FORMAT
JLS 1:89b1a06c1828 341 // Sent X-pos, Y-pos, Sector Address - This is the recommended way to display images
JLS 1:89b1a06c1828 342 //****************************************************************************************************
JLS 1:89b1a06c1828 343 void TFT_4DGL :: uSD_Image(int x, int y, long s) {
JLS 1:89b1a06c1828 344 char S1, S2, S3;
JLS 1:89b1a06c1828 345 char X_MSB, X_LSB, Y_MSB, Y_LSB;
JLS 1:89b1a06c1828 346 char command[9]= "";
JLS 1:89b1a06c1828 347
JLS 1:89b1a06c1828 348 X_LSB = x&0x00FF; //Work out the x position
JLS 1:89b1a06c1828 349 X_MSB = (x >> 8);
JLS 1:89b1a06c1828 350 Y_LSB = y&0x00FF; //Work out the y position
JLS 1:89b1a06c1828 351 Y_MSB = (y >> 8);
JLS 1:89b1a06c1828 352
JLS 1:89b1a06c1828 353 S1 = (s >> 16)&0x0000FF; //Work out the sector address
JLS 1:89b1a06c1828 354 S2 = (s >> 8)&0x0000FF;
JLS 1:89b1a06c1828 355 S3 = s&0x0000FF;
JLS 1:89b1a06c1828 356
JLS 1:89b1a06c1828 357 command[0] = 0x40; //ext_cmd
JLS 1:89b1a06c1828 358 command[1] = 0x49; //Display image
JLS 1:89b1a06c1828 359 command[2] = X_MSB; //X position - 2 bytes
JLS 1:89b1a06c1828 360 command[3] = X_LSB;
JLS 1:89b1a06c1828 361 command[4] = Y_MSB; //Y position - 2 bytes
JLS 1:89b1a06c1828 362 command[5] = Y_LSB;
JLS 1:89b1a06c1828 363 command[6] = S1; //Sector address - 3 bytes
JLS 1:89b1a06c1828 364 command[7] = S2;
JLS 1:89b1a06c1828 365 command[8] = S3;
JLS 1:89b1a06c1828 366
JLS 1:89b1a06c1828 367 writeCOMMAND(command, 9);
JLS 1:89b1a06c1828 368 }
JLS 1:89b1a06c1828 369
JLS 1:89b1a06c1828 370 //****************************************************************************************************
JLS 1:89b1a06c1828 371 // This displays an video on the screen in the NEW FORMAT
JLS 1:89b1a06c1828 372 // Sent X-pos, Y-pos, Sector Address - This is the recommended way to display video
JLS 1:89b1a06c1828 373 //****************************************************************************************************
JLS 1:89b1a06c1828 374 void TFT_4DGL :: uSD_Video(int x, int y, long s) {
JLS 1:89b1a06c1828 375 char S1, S2, S3;
JLS 1:89b1a06c1828 376 char X_MSB, X_LSB, Y_MSB, Y_LSB;
JLS 1:89b1a06c1828 377 char command[10]= "";
JLS 1:89b1a06c1828 378
JLS 1:89b1a06c1828 379 X_LSB = x&0x00FF;
JLS 1:89b1a06c1828 380 X_MSB = (x >> 8);
JLS 1:89b1a06c1828 381 Y_LSB = y&0x00FF;
JLS 1:89b1a06c1828 382 Y_MSB = (y >> 8);
JLS 1:89b1a06c1828 383
JLS 1:89b1a06c1828 384 S1 = (s >> 16)&0x0000FF;
JLS 1:89b1a06c1828 385 S2 = (s >> 8)&0x0000FF;
JLS 1:89b1a06c1828 386 S3 = s&0x0000FF;
JLS 1:89b1a06c1828 387
JLS 1:89b1a06c1828 388 command[0] = 0x40; //ext_cmd
JLS 1:89b1a06c1828 389 command[1] = 0x56; //Display video
JLS 1:89b1a06c1828 390 command[2] = X_MSB; //X position - 2 bytes
JLS 1:89b1a06c1828 391 command[3] = X_LSB;
JLS 1:89b1a06c1828 392 command[4] = Y_MSB; //Y position - 2 bytes
JLS 1:89b1a06c1828 393 command[5] = Y_LSB;
JLS 1:89b1a06c1828 394 command[6] = 0x00; //delay between frames
JLS 1:89b1a06c1828 395 command[7] = S1; //Sector address - 3 bytes
JLS 1:89b1a06c1828 396 command[8] = S2;
JLS 1:89b1a06c1828 397 command[9] = S3;
JLS 1:89b1a06c1828 398
JLS 1:89b1a06c1828 399 writeCOMMAND(command, 10);
JLS 1:89b1a06c1828 400 }