Rihards Balass / 4DGL-mbed-32PTU
Committer:
CaptainR
Date:
Thu Sep 15 11:52:31 2016 +0000
Revision:
15:86bdf382e6f7
Parent:
12:29f5ad896382
write sector bugfix, couple of array declarations changed to malloc

Who changed what in which revision?

UserRevisionLine numberNew contents of line
CaptainR 1:e2337e2653e1 1 //
CaptainR 2:81eaaa491a02 2 // Picaso_4DGL-32PTU is a class to drive 4D Systems TFT touch screens with PICASO processor
CaptainR 2:81eaaa491a02 3 // Tested with NUCLEO L152RE development board
CaptainR 2:81eaaa491a02 4 // Copyright (C) <2016> Rihards Balass <rihards.balass@gmail.com>
CaptainR 1:e2337e2653e1 5 //
CaptainR 2:81eaaa491a02 6 // Picaso_4DGL-32PTU is free software: you can redistribute it and/or modify
CaptainR 2:81eaaa491a02 7 // it under the terms of the GNU General Public License as published by
CaptainR 2:81eaaa491a02 8 // the Free Software Foundation, either version 3 of the License, or
CaptainR 2:81eaaa491a02 9 // (at your option) any later version.
CaptainR 2:81eaaa491a02 10 //
CaptainR 2:81eaaa491a02 11 // Picaso_4DGL-32PTU is distributed in the hope that it will be useful,
CaptainR 2:81eaaa491a02 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
CaptainR 2:81eaaa491a02 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
CaptainR 2:81eaaa491a02 14 // GNU General Public License for more details.
CaptainR 2:81eaaa491a02 15 //
CaptainR 2:81eaaa491a02 16 // You can see GNU General Public License at <http://www.gnu.org/licenses/>.
CaptainR 1:e2337e2653e1 17 //
CaptainR 0:a5ef6bc3c2e8 18
CaptainR 0:a5ef6bc3c2e8 19 #include "mbed.h"
CaptainR 0:a5ef6bc3c2e8 20 #include "Picaso_4DGL-32PTU.h"
CaptainR 0:a5ef6bc3c2e8 21
CaptainR 0:a5ef6bc3c2e8 22 //**************************************************************************
CaptainR 3:dcfbceb81fef 23 // The Clear Screen command clears the screen using the current background color.
CaptainR 0:a5ef6bc3c2e8 24 // This command brings some of the settings back to default; such as,
CaptainR 0:a5ef6bc3c2e8 25 //  Transparency turned OFF
CaptainR 3:dcfbceb81fef 26 //  Outline color set to BLACK
CaptainR 0:a5ef6bc3c2e8 27 //  Opacity set to OPAQUE
CaptainR 0:a5ef6bc3c2e8 28 //  Pen set to OUTLINE
CaptainR 0:a5ef6bc3c2e8 29 //  Line patterns set to OFF
CaptainR 0:a5ef6bc3c2e8 30 //  Right text margin set to full width
CaptainR 0:a5ef6bc3c2e8 31 //  Text magnifications set to 1
CaptainR 0:a5ef6bc3c2e8 32 //  All origins set to 0:0
CaptainR 0:a5ef6bc3c2e8 33 // The alternative to maintain settings and clear screen is
CaptainR 3:dcfbceb81fef 34 // to draw a filled rectangle with the required background color.
CaptainR 0:a5ef6bc3c2e8 35 //**************************************************************************
CaptainR 3:dcfbceb81fef 36 void PICASO_4DGL :: cls() { // clear screen
CaptainR 0:a5ef6bc3c2e8 37
CaptainR 0:a5ef6bc3c2e8 38 char command[2] = "";
CaptainR 0:a5ef6bc3c2e8 39
CaptainR 2:81eaaa491a02 40 command[0] = (CLS >> (8*1)) & 0xff;
CaptainR 2:81eaaa491a02 41 command[1] = (CLS >> (8*0)) & 0xff;
CaptainR 0:a5ef6bc3c2e8 42
CaptainR 0:a5ef6bc3c2e8 43 writeCOMMAND(command, 2);
CaptainR 5:890ddd974624 44 getResponse(1);
CaptainR 0:a5ef6bc3c2e8 45 }
CaptainR 0:a5ef6bc3c2e8 46
CaptainR 0:a5ef6bc3c2e8 47 //**************************************************************************
CaptainR 3:dcfbceb81fef 48 // The Change Color command changes all oldColor pixels to newColor
CaptainR 0:a5ef6bc3c2e8 49 // within the clipping window area.
CaptainR 0:a5ef6bc3c2e8 50 //**************************************************************************
CaptainR 3:dcfbceb81fef 51 void PICASO_4DGL :: changeColor(short oldColor, short newColor) {
CaptainR 0:a5ef6bc3c2e8 52
CaptainR 0:a5ef6bc3c2e8 53 char command[6] = "";
CaptainR 0:a5ef6bc3c2e8 54
CaptainR 2:81eaaa491a02 55 command[0] = (CHANGE_COLOR >> (8*1)) & 0xff;
CaptainR 2:81eaaa491a02 56 command[1] = (CHANGE_COLOR >> (8*0)) & 0xff;
CaptainR 2:81eaaa491a02 57 command[2] = (oldColor >> (8*1)) & 0xff;
CaptainR 2:81eaaa491a02 58 command[3] = (oldColor >> (8*0)) & 0xff;
CaptainR 2:81eaaa491a02 59 command[4] = (newColor >> (8*1)) & 0xff;
CaptainR 2:81eaaa491a02 60 command[5] = (newColor >> (8*0)) & 0xff;
CaptainR 0:a5ef6bc3c2e8 61
CaptainR 0:a5ef6bc3c2e8 62 writeCOMMAND(command, 6);
CaptainR 5:890ddd974624 63 getResponse(1);
CaptainR 0:a5ef6bc3c2e8 64 }
CaptainR 0:a5ef6bc3c2e8 65
CaptainR 0:a5ef6bc3c2e8 66 //**************************************************************************
CaptainR 0:a5ef6bc3c2e8 67 // The Draw Circle command draws a circle with centre point x, y
CaptainR 3:dcfbceb81fef 68 // with radius r using the specified color.
CaptainR 0:a5ef6bc3c2e8 69 //**************************************************************************
CaptainR 3:dcfbceb81fef 70 void PICASO_4DGL :: drawCircle(short x, short y, short r, short color) {
CaptainR 0:a5ef6bc3c2e8 71
CaptainR 0:a5ef6bc3c2e8 72 char command[10] = "";
CaptainR 0:a5ef6bc3c2e8 73
CaptainR 2:81eaaa491a02 74 command[0] = (DRAW_CIRCLE >> (8*1)) & 0xff;
CaptainR 2:81eaaa491a02 75 command[1] = (DRAW_CIRCLE >> (8*0)) & 0xff;
CaptainR 0:a5ef6bc3c2e8 76 command[2] = (x >> (8*1)) & 0xff;
CaptainR 0:a5ef6bc3c2e8 77 command[3] = (x >> (8*0)) & 0xff;
CaptainR 0:a5ef6bc3c2e8 78 command[4] = (y >> (8*1)) & 0xff;
CaptainR 0:a5ef6bc3c2e8 79 command[5] = (y >> (8*0)) & 0xff;
CaptainR 0:a5ef6bc3c2e8 80 command[6] = (r >> (8*1)) & 0xff;
CaptainR 0:a5ef6bc3c2e8 81 command[7] = (r >> (8*0)) & 0xff;
CaptainR 2:81eaaa491a02 82 command[8] = (color >> (8*1)) & 0xff;
CaptainR 2:81eaaa491a02 83 command[9] = (color >> (8*0)) & 0xff;
CaptainR 0:a5ef6bc3c2e8 84
CaptainR 0:a5ef6bc3c2e8 85 writeCOMMAND(command, 10);
CaptainR 5:890ddd974624 86 getResponse(1);
CaptainR 0:a5ef6bc3c2e8 87 }
CaptainR 0:a5ef6bc3c2e8 88
CaptainR 3:dcfbceb81fef 89 //**************************************************************************
CaptainR 3:dcfbceb81fef 90 // The Draw Circle command draws a solid circle with centre point x1, y1
CaptainR 3:dcfbceb81fef 91 // with radius r using the specified color.
CaptainR 3:dcfbceb81fef 92 // The outline color can be specified with the “Outline Color” command.
CaptainR 3:dcfbceb81fef 93 // If “Outline Color” is set to 0, no outline is drawn.
CaptainR 3:dcfbceb81fef 94 //**************************************************************************
CaptainR 3:dcfbceb81fef 95 void PICASO_4DGL :: drawFilledCircle(short x, short y, short r, short color) {
CaptainR 3:dcfbceb81fef 96
CaptainR 3:dcfbceb81fef 97 char command[10] = "";
CaptainR 3:dcfbceb81fef 98
CaptainR 3:dcfbceb81fef 99 command[0] = (CIRCLE_FILLED >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 100 command[1] = (CIRCLE_FILLED >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 101 command[2] = (x >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 102 command[3] = (x >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 103 command[4] = (y >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 104 command[5] = (y >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 105 command[6] = (r >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 106 command[7] = (r >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 107 command[8] = (color >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 108 command[9] = (color >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 109
CaptainR 3:dcfbceb81fef 110 writeCOMMAND(command, 10);
CaptainR 5:890ddd974624 111 getResponse(1);
CaptainR 3:dcfbceb81fef 112 }
CaptainR 0:a5ef6bc3c2e8 113
CaptainR 3:dcfbceb81fef 114 //**************************************************************************
CaptainR 3:dcfbceb81fef 115 // The Draw Line command draws a line from x1, y1 to x2, y2
CaptainR 3:dcfbceb81fef 116 // using the specified color.
CaptainR 3:dcfbceb81fef 117 //**************************************************************************
CaptainR 3:dcfbceb81fef 118 void PICASO_4DGL :: drawLine(short x1, short y1, short x2, short y2, short color) {
CaptainR 3:dcfbceb81fef 119
CaptainR 3:dcfbceb81fef 120 char command[12] = "";
CaptainR 3:dcfbceb81fef 121
CaptainR 3:dcfbceb81fef 122 command[0] = (DRAW_LINE >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 123 command[1] = (DRAW_LINE >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 124 command[2] = (x1 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 125 command[3] = (x1 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 126 command[4] = (y1 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 127 command[5] = (y1 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 128 command[6] = (x2 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 129 command[7] = (x2 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 130 command[8] = (y2 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 131 command[9] = (y2 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 132 command[10] = (color >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 133 command[11] = (color >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 134
CaptainR 3:dcfbceb81fef 135 writeCOMMAND(command, 12);
CaptainR 5:890ddd974624 136 getResponse(1);
CaptainR 3:dcfbceb81fef 137 }
CaptainR 0:a5ef6bc3c2e8 138
CaptainR 3:dcfbceb81fef 139 //**************************************************************************
CaptainR 3:dcfbceb81fef 140 // The Draw Rectangle command draws a rectangle from x1, y1 to x2, y2
CaptainR 3:dcfbceb81fef 141 // using the specified color.
CaptainR 3:dcfbceb81fef 142 // The line may be tessellated with the “Line Pattern” command.
CaptainR 3:dcfbceb81fef 143 //**************************************************************************
CaptainR 3:dcfbceb81fef 144 void PICASO_4DGL :: drawRectangle(short x1, short y1, short x2, short y2, short color) {
CaptainR 3:dcfbceb81fef 145
CaptainR 3:dcfbceb81fef 146 char command[12] = "";
CaptainR 3:dcfbceb81fef 147
CaptainR 3:dcfbceb81fef 148 command[0] = (DRAW_RECTANGLE >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 149 command[1] = (DRAW_RECTANGLE >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 150 command[2] = (x1 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 151 command[3] = (x1 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 152 command[4] = (y1 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 153 command[5] = (y1 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 154 command[6] = (x2 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 155 command[7] = (x2 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 156 command[8] = (y2 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 157 command[9] = (y2 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 158 command[10] = (color >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 159 command[11] = (color >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 160
CaptainR 3:dcfbceb81fef 161 writeCOMMAND(command, 12);
CaptainR 5:890ddd974624 162 getResponse(1);
CaptainR 3:dcfbceb81fef 163 }
CaptainR 0:a5ef6bc3c2e8 164
CaptainR 3:dcfbceb81fef 165 //**************************************************************************
CaptainR 3:dcfbceb81fef 166 // The Draw Filled Rectangle command draws a solid rectangle from x1, y1 to x2, y2
CaptainR 3:dcfbceb81fef 167 // using the specified color.
CaptainR 3:dcfbceb81fef 168 // The line may be tessellated with the “Line Pattern” command.
CaptainR 3:dcfbceb81fef 169 // The outline color can be specified with the “Outline Color” command.
CaptainR 3:dcfbceb81fef 170 // If “Outline Color” is set to 0, no outline is drawn.
CaptainR 3:dcfbceb81fef 171 //**************************************************************************
CaptainR 3:dcfbceb81fef 172 void PICASO_4DGL :: drawFilledRectangle(short x1, short y1, short x2, short y2, short color) {
CaptainR 3:dcfbceb81fef 173
CaptainR 3:dcfbceb81fef 174 char command[12] = "";
CaptainR 3:dcfbceb81fef 175
CaptainR 3:dcfbceb81fef 176 command[0] = (RECTANGLE_FILLED >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 177 command[1] = (RECTANGLE_FILLED >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 178 command[2] = (x1 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 179 command[3] = (x1 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 180 command[4] = (y1 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 181 command[5] = (y1 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 182 command[6] = (x2 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 183 command[7] = (x2 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 184 command[8] = (y2 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 185 command[9] = (y2 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 186 command[10] = (color >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 187 command[11] = (color >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 188
CaptainR 3:dcfbceb81fef 189 writeCOMMAND(command, 12);
CaptainR 5:890ddd974624 190 getResponse(1);
CaptainR 3:dcfbceb81fef 191 }
CaptainR 0:a5ef6bc3c2e8 192
CaptainR 0:a5ef6bc3c2e8 193
CaptainR 3:dcfbceb81fef 194 //**************************************************************************
CaptainR 3:dcfbceb81fef 195 // The Draw Polyline command plots lines between points specified by a pair of arrays
CaptainR 3:dcfbceb81fef 196 // using the specified color.
CaptainR 3:dcfbceb81fef 197 // The lines may be tessellated with the “Line Pattern” command.
CaptainR 3:dcfbceb81fef 198 // The “Draw Polyline” command can be used to create complex raster graphics
CaptainR 3:dcfbceb81fef 199 // by loading the arrays from serial input or from MEDIA with very little code requirement.
CaptainR 3:dcfbceb81fef 200 //
CaptainR 3:dcfbceb81fef 201 // n - Specifies the number of elements in the x and y arrays specifying the vertices for the polyline.
CaptainR 3:dcfbceb81fef 202 // vx, vy - Specifies the array of elements for the x/y coordinates of the vertices.
CaptainR 3:dcfbceb81fef 203 // Vx1, vx2, …, vxN, vy1, vy2, …, vyN
CaptainR 3:dcfbceb81fef 204 //**************************************************************************
CaptainR 3:dcfbceb81fef 205 void PICASO_4DGL :: drawPolyline(short n, short *vx, short *vy, short color) {
CaptainR 3:dcfbceb81fef 206
CaptainR 3:dcfbceb81fef 207 int size = 6 + (n*4);
CaptainR 3:dcfbceb81fef 208 int i, j = 4;
CaptainR 15:86bdf382e6f7 209 char *command;
CaptainR 15:86bdf382e6f7 210 command = (char *)malloc(sizeof(char) * size);
CaptainR 3:dcfbceb81fef 211 for(i = 0; i < size; i++) command[i] = 0;
CaptainR 3:dcfbceb81fef 212
CaptainR 3:dcfbceb81fef 213 command[0] = (DRAW_POLYLINE >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 214 command[1] = (DRAW_POLYLINE >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 215 command[2] = (n >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 216 command[3] = (n >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 217 for (i = 0; i < n; i++) {
CaptainR 3:dcfbceb81fef 218 command[j] = (vx[i] >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 219 j++;
CaptainR 3:dcfbceb81fef 220 command[j] = (vx[i] >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 221 j++;
CaptainR 3:dcfbceb81fef 222 }
CaptainR 3:dcfbceb81fef 223 for (i = 0; i < n; i++) {
CaptainR 3:dcfbceb81fef 224 command[j] = (vy[i] >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 225 j++;
CaptainR 3:dcfbceb81fef 226 command[j] = (vy[i] >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 227 j++;
CaptainR 3:dcfbceb81fef 228 }
CaptainR 3:dcfbceb81fef 229 command[j] = (color >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 230 command[j+1] = (color >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 231
CaptainR 3:dcfbceb81fef 232 writeCOMMAND(command, size);
CaptainR 5:890ddd974624 233 getResponse(1);
CaptainR 15:86bdf382e6f7 234 free(command);
CaptainR 3:dcfbceb81fef 235 }
CaptainR 0:a5ef6bc3c2e8 236
CaptainR 3:dcfbceb81fef 237 //**************************************************************************
CaptainR 3:dcfbceb81fef 238 // The Draw Polygon command plots lines between points specified by a pair of arrays
CaptainR 3:dcfbceb81fef 239 // using the specified color.
CaptainR 3:dcfbceb81fef 240 // The last point is drawn back to the first point, completing the polygon.
CaptainR 3:dcfbceb81fef 241 // The lines may be tessellated with the “Line Pattern” command.
CaptainR 3:dcfbceb81fef 242 // The Draw Polygon command can be used to create complex raster graphics
CaptainR 3:dcfbceb81fef 243 // by loading the arrays from serial input or from MEDIA with very little code requirement.
CaptainR 3:dcfbceb81fef 244 //
CaptainR 3:dcfbceb81fef 245 // n - Specifies the number of elements in the x and y arrays specifying the vertices for the polygon.
CaptainR 3:dcfbceb81fef 246 // vx, vy - Specifies the array of elements for the x/y coordinates of the vertices.
CaptainR 3:dcfbceb81fef 247 // Vx1, vx2, …, vxN, vy1, vy2, …, vyN
CaptainR 3:dcfbceb81fef 248 //**************************************************************************
CaptainR 3:dcfbceb81fef 249 void PICASO_4DGL :: drawPolygon(short n, short *vx, short *vy, short color) {
CaptainR 3:dcfbceb81fef 250
CaptainR 3:dcfbceb81fef 251 int size = 6 + (n*4);
CaptainR 3:dcfbceb81fef 252 int i, j = 4;
CaptainR 15:86bdf382e6f7 253 char *command;
CaptainR 15:86bdf382e6f7 254 command = (char *)malloc(sizeof(char) * size);
CaptainR 3:dcfbceb81fef 255 for(i = 0; i < size; i++) command[i] = 0;
CaptainR 3:dcfbceb81fef 256
CaptainR 3:dcfbceb81fef 257 command[0] = (DRAW_POLYGON >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 258 command[1] = (DRAW_POLYGON >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 259 command[2] = (n >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 260 command[3] = (n >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 261 for (i = 0; i < n; i++) {
CaptainR 3:dcfbceb81fef 262 command[j] = (vx[i] >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 263 j++;
CaptainR 3:dcfbceb81fef 264 command[j] = (vx[i] >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 265 j++;
CaptainR 3:dcfbceb81fef 266 }
CaptainR 3:dcfbceb81fef 267 for (i = 0; i < n; i++) {
CaptainR 3:dcfbceb81fef 268 command[j] = (vy[i] >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 269 j++;
CaptainR 3:dcfbceb81fef 270 command[j] = (vy[i] >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 271 j++;
CaptainR 3:dcfbceb81fef 272 }
CaptainR 3:dcfbceb81fef 273 command[j] = (color >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 274 command[j+1] = (color >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 275
CaptainR 3:dcfbceb81fef 276 writeCOMMAND(command, size);
CaptainR 5:890ddd974624 277 getResponse(1);
CaptainR 15:86bdf382e6f7 278 free(command);
CaptainR 3:dcfbceb81fef 279 }
CaptainR 0:a5ef6bc3c2e8 280
CaptainR 3:dcfbceb81fef 281 //**************************************************************************
CaptainR 3:dcfbceb81fef 282 // The Draw Filled Polygon command draws a solid Polygon between specified vertices:
CaptainR 3:dcfbceb81fef 283 // x1, y1 x2, y2, .... , xn, yn using the specified color.
CaptainR 3:dcfbceb81fef 284 // The last point is drawn back to the first point, completing the polygon.
CaptainR 3:dcfbceb81fef 285 // Vertices must be a minimum of 3 and can be specified in any fashion.
CaptainR 3:dcfbceb81fef 286 //
CaptainR 3:dcfbceb81fef 287 // n - Specifies the number of elements in the x and y arrays specifying the vertices for the polygon.
CaptainR 3:dcfbceb81fef 288 // vx, vy - Specifies the array of elements for the x/y coordinates of the vertices.
CaptainR 3:dcfbceb81fef 289 // Vx1, vx2, …, vxN, vy1, vy2, …, vyN
CaptainR 3:dcfbceb81fef 290 //**************************************************************************
CaptainR 3:dcfbceb81fef 291 void PICASO_4DGL :: drawFilledPolygon(short n, short *vx, short *vy, short color) {
CaptainR 3:dcfbceb81fef 292
CaptainR 3:dcfbceb81fef 293 if (n >= 3) {
CaptainR 3:dcfbceb81fef 294 int size = 6 + (n*4);
CaptainR 3:dcfbceb81fef 295 int i, j = 4;
CaptainR 15:86bdf382e6f7 296 char *command;
CaptainR 15:86bdf382e6f7 297 command = (char *)malloc(sizeof(char) * size);
CaptainR 3:dcfbceb81fef 298 for(i = 0; i < size; i++) command[i] = 0;
CaptainR 3:dcfbceb81fef 299
CaptainR 3:dcfbceb81fef 300 command[0] = (POLYGON_FILLED >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 301 command[1] = (POLYGON_FILLED >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 302 command[2] = (n >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 303 command[3] = (n >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 304 for (i = 0; i < n; i++) {
CaptainR 3:dcfbceb81fef 305 command[j] = (vx[i] >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 306 j++;
CaptainR 3:dcfbceb81fef 307 command[j] = (vx[i] >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 308 j++;
CaptainR 3:dcfbceb81fef 309 }
CaptainR 3:dcfbceb81fef 310 for (i = 0; i < n; i++) {
CaptainR 3:dcfbceb81fef 311 command[j] = (vy[i] >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 312 j++;
CaptainR 3:dcfbceb81fef 313 command[j] = (vy[i] >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 314 j++;
CaptainR 3:dcfbceb81fef 315 }
CaptainR 3:dcfbceb81fef 316 command[j] = (color >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 317 command[j+1] = (color >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 318
CaptainR 3:dcfbceb81fef 319 writeCOMMAND(command, size);
CaptainR 5:890ddd974624 320 getResponse(1);
CaptainR 15:86bdf382e6f7 321 free(command);
CaptainR 3:dcfbceb81fef 322 }
CaptainR 11:3ebd2263f3e9 323 else pc.printf("\n\r ERROR_POLYGON_FILLED: There has to be at least 3 vertices!\n\r");
CaptainR 3:dcfbceb81fef 324 }
CaptainR 3:dcfbceb81fef 325
CaptainR 3:dcfbceb81fef 326 //**************************************************************************
CaptainR 3:dcfbceb81fef 327 // The Draw Triangle command draws a triangle outline between vertices
CaptainR 3:dcfbceb81fef 328 // x1,y1 , x2,y2 and x3,y3 using the specified color.
CaptainR 3:dcfbceb81fef 329 // The line may be tessellated with the “Line Pattern” command.
CaptainR 3:dcfbceb81fef 330 //**************************************************************************
CaptainR 3:dcfbceb81fef 331 void PICASO_4DGL :: drawTriangle(short x1, short y1, short x2, short y2, short x3, short y3, short color) {
CaptainR 3:dcfbceb81fef 332
CaptainR 3:dcfbceb81fef 333 char command[16] = "";
CaptainR 3:dcfbceb81fef 334
CaptainR 3:dcfbceb81fef 335 command[0] = (DRAW_TRIANGLE >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 336 command[1] = (DRAW_TRIANGLE >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 337 command[2] = (x1 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 338 command[3] = (x1 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 339 command[4] = (y1 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 340 command[5] = (y1 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 341 command[6] = (x2 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 342 command[7] = (x2 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 343 command[8] = (y2 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 344 command[9] = (y2 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 345 command[10] = (x3 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 346 command[11] = (x3 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 347 command[12] = (y3 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 348 command[13] = (y3 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 349 command[14] = (color >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 350 command[15] = (color >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 351
CaptainR 3:dcfbceb81fef 352 writeCOMMAND(command, 16);
CaptainR 5:890ddd974624 353 getResponse(1);
CaptainR 3:dcfbceb81fef 354 }
CaptainR 3:dcfbceb81fef 355
CaptainR 3:dcfbceb81fef 356 //**************************************************************************
CaptainR 3:dcfbceb81fef 357 // The Draw Filled Triangle command draws a solid triangle between vertices
CaptainR 3:dcfbceb81fef 358 // x1, y1, x2, y2 and x3, y3 using the specified color.
CaptainR 3:dcfbceb81fef 359 //**************************************************************************
CaptainR 3:dcfbceb81fef 360 void PICASO_4DGL :: drawFilledTriangle(short x1, short y1, short x2, short y2, short x3, short y3, short color) {
CaptainR 3:dcfbceb81fef 361
CaptainR 3:dcfbceb81fef 362 char command[16] = "";
CaptainR 3:dcfbceb81fef 363
CaptainR 3:dcfbceb81fef 364 command[0] = (TRIANGLE_FILLED >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 365 command[1] = (TRIANGLE_FILLED >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 366 command[2] = (x1 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 367 command[3] = (x1 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 368 command[4] = (y1 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 369 command[5] = (y1 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 370 command[6] = (x2 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 371 command[7] = (x2 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 372 command[8] = (y2 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 373 command[9] = (y2 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 374 command[10] = (x3 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 375 command[11] = (x3 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 376 command[12] = (y3 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 377 command[13] = (y3 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 378 command[14] = (color >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 379 command[15] = (color >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 380
CaptainR 3:dcfbceb81fef 381 writeCOMMAND(command, 16);
CaptainR 5:890ddd974624 382 getResponse(1);
CaptainR 3:dcfbceb81fef 383 }
CaptainR 0:a5ef6bc3c2e8 384
CaptainR 4:50511ed54ab4 385 //**************************************************************************
CaptainR 4:50511ed54ab4 386 // The Calculate Orbit command calculates the x, y coordinates of a distant point relative
CaptainR 4:50511ed54ab4 387 // to the current origin, where the only known parameters are the angle and the distance
CaptainR 4:50511ed54ab4 388 // from the current origin. The new coordinates are calculated and then placed in the
CaptainR 4:50511ed54ab4 389 // destination variables Xdest and Ydest.
CaptainR 4:50511ed54ab4 390 //**************************************************************************
CaptainR 4:50511ed54ab4 391 void PICASO_4DGL :: calculateOrbit(short angle, short distance) {
CaptainR 4:50511ed54ab4 392
CaptainR 4:50511ed54ab4 393 char command[6] = "";
CaptainR 4:50511ed54ab4 394
CaptainR 4:50511ed54ab4 395 command[0] = (CALCULATE_ORBIT >> (8*1)) & 0xff;
CaptainR 4:50511ed54ab4 396 command[1] = (CALCULATE_ORBIT >> (8*0)) & 0xff;
CaptainR 4:50511ed54ab4 397 command[2] = (angle >> (8*1)) & 0xff;
CaptainR 4:50511ed54ab4 398 command[3] = (angle >> (8*0)) & 0xff;
CaptainR 4:50511ed54ab4 399 command[4] = (distance >> (8*1)) & 0xff;
CaptainR 4:50511ed54ab4 400 command[5] = (distance >> (8*0)) & 0xff;
CaptainR 4:50511ed54ab4 401
CaptainR 4:50511ed54ab4 402 writeCOMMAND(command, 6);
CaptainR 6:a1a85f2bc04b 403 calculateOrbitResponse();
CaptainR 6:a1a85f2bc04b 404 }
CaptainR 6:a1a85f2bc04b 405
CaptainR 6:a1a85f2bc04b 406 //**************************************************************************
CaptainR 6:a1a85f2bc04b 407 // The Put Pixel command draws a pixel at position x, y using the specified color.
CaptainR 6:a1a85f2bc04b 408 //**************************************************************************
CaptainR 6:a1a85f2bc04b 409 void PICASO_4DGL :: putPixel(short x, short y, short color) {
CaptainR 6:a1a85f2bc04b 410
CaptainR 6:a1a85f2bc04b 411 char command[8] = "";
CaptainR 6:a1a85f2bc04b 412
CaptainR 6:a1a85f2bc04b 413 command[0] = (PUT_PIXEL >> (8*1)) & 0xff;
CaptainR 6:a1a85f2bc04b 414 command[1] = (PUT_PIXEL >> (8*0)) & 0xff;
CaptainR 6:a1a85f2bc04b 415 command[2] = (x >> (8*1)) & 0xff;
CaptainR 6:a1a85f2bc04b 416 command[3] = (x >> (8*0)) & 0xff;
CaptainR 6:a1a85f2bc04b 417 command[4] = (y >> (8*1)) & 0xff;
CaptainR 6:a1a85f2bc04b 418 command[5] = (y >> (8*0)) & 0xff;
CaptainR 6:a1a85f2bc04b 419 command[6] = (color >> (8*1)) & 0xff;
CaptainR 6:a1a85f2bc04b 420 command[7] = (color >> (8*0)) & 0xff;
CaptainR 6:a1a85f2bc04b 421
CaptainR 6:a1a85f2bc04b 422 writeCOMMAND(command, 8);
CaptainR 6:a1a85f2bc04b 423 getResponse(1);
CaptainR 6:a1a85f2bc04b 424 }
CaptainR 6:a1a85f2bc04b 425
CaptainR 6:a1a85f2bc04b 426 //**************************************************************************
CaptainR 6:a1a85f2bc04b 427 // The Move Origin command moves the origin to a new position, which is suitable for
CaptainR 6:a1a85f2bc04b 428 // specifying the location for both graphics and text.
CaptainR 6:a1a85f2bc04b 429 //**************************************************************************
CaptainR 6:a1a85f2bc04b 430 void PICASO_4DGL :: moveOrigin(short x, short y) {
CaptainR 6:a1a85f2bc04b 431
CaptainR 6:a1a85f2bc04b 432 char command[6] = "";
CaptainR 6:a1a85f2bc04b 433
CaptainR 7:f064ae670553 434 command[0] = (MOVE_ORIGIN >> (8*1)) & 0xff;
CaptainR 7:f064ae670553 435 command[1] = (MOVE_ORIGIN >> (8*0)) & 0xff;
CaptainR 6:a1a85f2bc04b 436 command[2] = (x >> (8*1)) & 0xff;
CaptainR 6:a1a85f2bc04b 437 command[3] = (x >> (8*0)) & 0xff;
CaptainR 6:a1a85f2bc04b 438 command[4] = (y >> (8*1)) & 0xff;
CaptainR 6:a1a85f2bc04b 439 command[5] = (y >> (8*0)) & 0xff;
CaptainR 6:a1a85f2bc04b 440
CaptainR 8:b634ac9c92f8 441 writeCOMMAND(command, 6);
CaptainR 8:b634ac9c92f8 442 getResponse(1);
CaptainR 8:b634ac9c92f8 443 }
CaptainR 8:b634ac9c92f8 444
CaptainR 8:b634ac9c92f8 445 //**************************************************************************
CaptainR 8:b634ac9c92f8 446 // The Draw Line & Move Origin command draws a line from the current origin
CaptainR 8:b634ac9c92f8 447 // to a new position. The Origin is then set to the new position.
CaptainR 8:b634ac9c92f8 448 // The line is drawn using the current object colour, using the
CaptainR 8:b634ac9c92f8 449 // “Set Graphics Parameters” – “Object Colour” command. The line may be
CaptainR 8:b634ac9c92f8 450 // tessellated with the “Line Pattern” command.
CaptainR 8:b634ac9c92f8 451 //
CaptainR 8:b634ac9c92f8 452 // Note: this command is mostly useful with the “Calculate Orbit” command,
CaptainR 8:b634ac9c92f8 453 // and usually the “Draw Line” command would be used
CaptainR 8:b634ac9c92f8 454 //**************************************************************************
CaptainR 8:b634ac9c92f8 455 void PICASO_4DGL :: lineTo(short x, short y) {
CaptainR 8:b634ac9c92f8 456
CaptainR 8:b634ac9c92f8 457 char command[6] = "";
CaptainR 8:b634ac9c92f8 458
CaptainR 8:b634ac9c92f8 459 command[0] = (LINE_TO >> (8*1)) & 0xff;
CaptainR 8:b634ac9c92f8 460 command[1] = (LINE_TO >> (8*0)) & 0xff;
CaptainR 8:b634ac9c92f8 461 command[2] = (x >> (8*1)) & 0xff;
CaptainR 8:b634ac9c92f8 462 command[3] = (x >> (8*0)) & 0xff;
CaptainR 8:b634ac9c92f8 463 command[4] = (y >> (8*1)) & 0xff;
CaptainR 8:b634ac9c92f8 464 command[5] = (y >> (8*0)) & 0xff;
CaptainR 8:b634ac9c92f8 465
CaptainR 8:b634ac9c92f8 466 writeCOMMAND(command, 6);
CaptainR 6:a1a85f2bc04b 467 getResponse(1);
CaptainR 4:50511ed54ab4 468 }
CaptainR 4:50511ed54ab4 469
CaptainR 9:32eb75c01e9d 470 //**************************************************************************
CaptainR 9:32eb75c01e9d 471 // The Set Clip Window command specifies a clipping window region on the screen such
CaptainR 9:32eb75c01e9d 472 // that any objects and text placed onto the screen will be clipped and displayed only
CaptainR 9:32eb75c01e9d 473 // within that region. For the clipping window to take effect, the clipping setting must be
CaptainR 9:32eb75c01e9d 474 // enabled separately using the “Clipping” command
CaptainR 9:32eb75c01e9d 475 //**************************************************************************
CaptainR 9:32eb75c01e9d 476 void PICASO_4DGL :: setClipWindow(short x1, short y1, short x2, short y2) {
CaptainR 9:32eb75c01e9d 477
CaptainR 9:32eb75c01e9d 478 char command[10] = "";
CaptainR 9:32eb75c01e9d 479
CaptainR 9:32eb75c01e9d 480 command[0] = (SET_CLIP_WINDOW >> (8*1)) & 0xff;
CaptainR 9:32eb75c01e9d 481 command[1] = (SET_CLIP_WINDOW >> (8*0)) & 0xff;
CaptainR 9:32eb75c01e9d 482 command[2] = (x1 >> (8*1)) & 0xff;
CaptainR 9:32eb75c01e9d 483 command[3] = (x1 >> (8*0)) & 0xff;
CaptainR 9:32eb75c01e9d 484 command[4] = (y1 >> (8*1)) & 0xff;
CaptainR 9:32eb75c01e9d 485 command[5] = (y1 >> (8*0)) & 0xff;
CaptainR 9:32eb75c01e9d 486 command[6] = (x2 >> (8*1)) & 0xff;
CaptainR 9:32eb75c01e9d 487 command[7] = (x2 >> (8*0)) & 0xff;
CaptainR 9:32eb75c01e9d 488 command[8] = (y2 >> (8*1)) & 0xff;
CaptainR 9:32eb75c01e9d 489 command[9] = (y2 >> (8*0)) & 0xff;
CaptainR 9:32eb75c01e9d 490
CaptainR 9:32eb75c01e9d 491 writeCOMMAND(command, 10);
CaptainR 9:32eb75c01e9d 492 getResponse(1);
CaptainR 9:32eb75c01e9d 493 }
CaptainR 4:50511ed54ab4 494
CaptainR 9:32eb75c01e9d 495 //**************************************************************************
CaptainR 9:32eb75c01e9d 496 // The Clipping command Enables or Disables the ability for Clipping to be used.
CaptainR 9:32eb75c01e9d 497 // The clipping points are set with “Set Clip Window” and must be set first.
CaptainR 9:32eb75c01e9d 498 //**************************************************************************
CaptainR 9:32eb75c01e9d 499 void PICASO_4DGL :: clipping(short value) {
CaptainR 9:32eb75c01e9d 500
CaptainR 9:32eb75c01e9d 501 char command[4] = "";
CaptainR 9:32eb75c01e9d 502
CaptainR 9:32eb75c01e9d 503 command[0] = (CLIPPING >> (8*1)) & 0xff;
CaptainR 9:32eb75c01e9d 504 command[1] = (CLIPPING >> (8*0)) & 0xff;
CaptainR 9:32eb75c01e9d 505 command[2] = (value >> (8*1)) & 0xff;
CaptainR 9:32eb75c01e9d 506 command[3] = (value >> (8*0)) & 0xff;
CaptainR 9:32eb75c01e9d 507
CaptainR 9:32eb75c01e9d 508 writeCOMMAND(command, 4);
CaptainR 9:32eb75c01e9d 509 getResponse(1);
CaptainR 9:32eb75c01e9d 510 }
CaptainR 4:50511ed54ab4 511
CaptainR 9:32eb75c01e9d 512 //**************************************************************************
CaptainR 9:32eb75c01e9d 513 // The Extend Clip Region command forces the clip region to the extent
CaptainR 9:32eb75c01e9d 514 // of the last text that was printed, or the last image that was shown.
CaptainR 9:32eb75c01e9d 515 //**************************************************************************
CaptainR 9:32eb75c01e9d 516 void PICASO_4DGL :: extendClipRegion() {
CaptainR 9:32eb75c01e9d 517
CaptainR 9:32eb75c01e9d 518 char command[2] = "";
CaptainR 9:32eb75c01e9d 519
CaptainR 9:32eb75c01e9d 520 command[0] = (EXTEND_CLIP >> (8*1)) & 0xff;
CaptainR 9:32eb75c01e9d 521 command[1] = (EXTEND_CLIP >> (8*0)) & 0xff;
CaptainR 9:32eb75c01e9d 522
CaptainR 9:32eb75c01e9d 523 writeCOMMAND(command, 2);
CaptainR 9:32eb75c01e9d 524 getResponse(1);
CaptainR 9:32eb75c01e9d 525 }
CaptainR 9:32eb75c01e9d 526
CaptainR 10:b959bb206e6b 527 //**************************************************************************
CaptainR 10:b959bb206e6b 528 // The Draw Ellipse command plots a colored Ellipse on the screen at centre
CaptainR 10:b959bb206e6b 529 // x, y with x-radius = xrad and y-radius = yrad.
CaptainR 10:b959bb206e6b 530 //**************************************************************************
CaptainR 10:b959bb206e6b 531 void PICASO_4DGL :: drawElipse(short x, short y, short xRad, short yRad, short color) {
CaptainR 10:b959bb206e6b 532
CaptainR 10:b959bb206e6b 533 char command[12] = "";
CaptainR 10:b959bb206e6b 534
CaptainR 10:b959bb206e6b 535 command[0] = (DRAW_ELIPSE >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 536 command[1] = (DRAW_ELIPSE >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 537 command[2] = (x >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 538 command[3] = (x >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 539 command[4] = (y >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 540 command[5] = (y >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 541 command[6] = (xRad >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 542 command[7] = (xRad >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 543 command[8] = (yRad >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 544 command[9] = (yRad >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 545 command[10] = (color >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 546 command[11] = (color >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 547
CaptainR 10:b959bb206e6b 548 writeCOMMAND(command, 12);
CaptainR 10:b959bb206e6b 549 getResponse(1);
CaptainR 10:b959bb206e6b 550 }
CaptainR 10:b959bb206e6b 551
CaptainR 10:b959bb206e6b 552 //**************************************************************************
CaptainR 10:b959bb206e6b 553 // The Draw Filled Ellipse command plots a solid colored Ellipse on the screen at centre
CaptainR 10:b959bb206e6b 554 // x, y with x-radius = xrad and y-radius = yrad.
CaptainR 10:b959bb206e6b 555 //**************************************************************************
CaptainR 10:b959bb206e6b 556 void PICASO_4DGL :: drawFilledElipse(short x, short y, short xRad, short yRad, short color) {
CaptainR 10:b959bb206e6b 557
CaptainR 10:b959bb206e6b 558 char command[12] = "";
CaptainR 10:b959bb206e6b 559
CaptainR 10:b959bb206e6b 560 command[0] = (ELIPSE_FILLED >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 561 command[1] = (ELIPSE_FILLED >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 562 command[2] = (x >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 563 command[3] = (x >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 564 command[4] = (y >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 565 command[5] = (y >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 566 command[6] = (xRad >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 567 command[7] = (xRad >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 568 command[8] = (yRad >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 569 command[9] = (yRad >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 570 command[10] = (color >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 571 command[11] = (color >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 572
CaptainR 10:b959bb206e6b 573 writeCOMMAND(command, 12);
CaptainR 10:b959bb206e6b 574 getResponse(1);
CaptainR 10:b959bb206e6b 575 }
CaptainR 10:b959bb206e6b 576
CaptainR 10:b959bb206e6b 577 //**************************************************************************
CaptainR 10:b959bb206e6b 578 // The Draw Button command draws a 3 dimensional Text Button at screen location
CaptainR 10:b959bb206e6b 579 // defined by x, y parameters (top left corner). The size of the button depends
CaptainR 10:b959bb206e6b 580 // on the font, width, height and length of the text. The button can contain
CaptainR 10:b959bb206e6b 581 // multiple lines of text by having the \n character embedded in the string
CaptainR 10:b959bb206e6b 582 // for the end of line marker. In this case, the widest text in the string sets
CaptainR 10:b959bb206e6b 583 // the overall width, and the height of the button is set by the number of
CaptainR 10:b959bb206e6b 584 // text lines. In the case of multiple lines, each line is left justified.
CaptainR 10:b959bb206e6b 585 // If you wish to centre or right justify the text, you will need to prepare
CaptainR 10:b959bb206e6b 586 // the text string according to your requirements.
CaptainR 10:b959bb206e6b 587 //
CaptainR 10:b959bb206e6b 588 // state - Appearance of button, 0 = Button depressed; 1 = Button raised.
CaptainR 10:b959bb206e6b 589 // x, y - Specifies the top left corner position of the button on the screen.
CaptainR 10:b959bb206e6b 590 //**************************************************************************
CaptainR 10:b959bb206e6b 591 void PICASO_4DGL :: drawButton(short state, short x, short y, short btnColor, short txtColor, short font, short txtW, short txtH, char *txt) {
CaptainR 10:b959bb206e6b 592
CaptainR 15:86bdf382e6f7 593 int size = (19 + (strlen(txt)));
CaptainR 10:b959bb206e6b 594 int i, j = 18;
CaptainR 15:86bdf382e6f7 595 char *command;
CaptainR 15:86bdf382e6f7 596 command = (char *)malloc(sizeof(char) * size);
CaptainR 10:b959bb206e6b 597 for(i = 0; i < size; i++) command[i] = 0;
CaptainR 10:b959bb206e6b 598
CaptainR 10:b959bb206e6b 599 command[0] = (DRAW_BUTTON >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 600 command[1] = (DRAW_BUTTON >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 601 command[2] = (state >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 602 command[3] = (state >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 603 command[4] = (x >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 604 command[5] = (x >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 605 command[6] = (y >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 606 command[7] = (y >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 607 command[8] = (btnColor >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 608 command[9] = (btnColor >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 609 command[10] = (txtColor >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 610 command[11] = (txtColor >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 611 command[12] = (font >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 612 command[13] = (font >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 613 command[14] = (txtW >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 614 command[15] = (txtW >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 615 command[16] = (txtH >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 616 command[17] = (txtH >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 617 for (i = 0; i < strlen(txt); i++) {
CaptainR 10:b959bb206e6b 618 command[j] = txt[i];
CaptainR 10:b959bb206e6b 619 j++;
CaptainR 10:b959bb206e6b 620 }
CaptainR 10:b959bb206e6b 621 command[j] = 0;
CaptainR 10:b959bb206e6b 622
CaptainR 10:b959bb206e6b 623 writeCOMMAND(command, size);
CaptainR 10:b959bb206e6b 624 getResponse(1);
CaptainR 15:86bdf382e6f7 625 free(command);
CaptainR 10:b959bb206e6b 626 }
CaptainR 10:b959bb206e6b 627
CaptainR 10:b959bb206e6b 628 //**************************************************************************
CaptainR 10:b959bb206e6b 629 // The Draw Panel command draws a 3 dimensional rectangular panel at a screen
CaptainR 10:b959bb206e6b 630 // location defined by x, y parameters (top left corner). The size of the panel
CaptainR 10:b959bb206e6b 631 // is set with the width and height parameters. The colour is defined by colour.
CaptainR 10:b959bb206e6b 632 // The state parameter determines the appearance of the panel, 0 = recessed, 1 = raised.
CaptainR 10:b959bb206e6b 633 //**************************************************************************
CaptainR 10:b959bb206e6b 634 void PICASO_4DGL :: drawPanel(short state, short x, short y, short width, short height, short color) {
CaptainR 10:b959bb206e6b 635
CaptainR 10:b959bb206e6b 636 char command[14] = "";
CaptainR 10:b959bb206e6b 637
CaptainR 10:b959bb206e6b 638 command[0] = (DRAW_PANEL >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 639 command[1] = (DRAW_PANEL >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 640 command[2] = (state >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 641 command[3] = (state >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 642 command[4] = (x >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 643 command[5] = (x >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 644 command[6] = (y >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 645 command[7] = (y >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 646 command[8] = (width >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 647 command[9] = (width >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 648 command[10] = (height >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 649 command[11] = (height >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 650 command[12] = (color >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 651 command[13] = (color >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 652
CaptainR 10:b959bb206e6b 653 writeCOMMAND(command, 14);
CaptainR 10:b959bb206e6b 654 getResponse(1);
CaptainR 10:b959bb206e6b 655 }
CaptainR 10:b959bb206e6b 656
CaptainR 10:b959bb206e6b 657 //**************************************************************************
CaptainR 10:b959bb206e6b 658 // The Draw Slider command draws a vertical or horizontal slider bar on the screen.
CaptainR 10:b959bb206e6b 659 // The Draw Slider command has several different modes of operation.
CaptainR 10:b959bb206e6b 660 // In order to minimise the amount of graphics functions we need, all modes of operation
CaptainR 10:b959bb206e6b 661 // are selected naturally depending on the parameter values.
CaptainR 10:b959bb206e6b 662 // Selection rules:
CaptainR 10:b959bb206e6b 663 // 1a) if x2-x1 > y2-y1 slider is assumed to be horizontal
CaptainR 10:b959bb206e6b 664 // (ie: if width > height, slider is horizontal)
CaptainR 10:b959bb206e6b 665 // 1b) if x2-x1 <= y2-y1 slider is assumed to be vertical
CaptainR 10:b959bb206e6b 666 // (ie: if height <= width, slider is horizontal)
CaptainR 10:b959bb206e6b 667 // 2a) If value is positive, thumb is set to the position that is the proportion
CaptainR 10:b959bb206e6b 668 // of value to the scale parameter.(used to set the control to the actual value of a variable)
CaptainR 10:b959bb206e6b 669 // 2b) If value is negative, thumb is driven to the graphics position set by the
CaptainR 10:b959bb206e6b 670 // ABSolute of value. (used to set thumb to its actual graphical position (usually by touch screen)
CaptainR 10:b959bb206e6b 671 // 3) The thumb colour is determine by the “Set Graphics Parameters” –
CaptainR 10:b959bb206e6b 672 // “Object Colour” command, however, if the current object colour is BLACK,
CaptainR 10:b959bb206e6b 673 // a darkened shade of the colour parameter is used for the thumb .
CaptainR 10:b959bb206e6b 674 //
CaptainR 10:b959bb206e6b 675 // mode - mode = 0 : Slider Indented, mode = 1 : Slider Raised, mode 2, Slider Hidden (background colour).
CaptainR 10:b959bb206e6b 676 // Scale - scale = n : sets the full scale range of the slider for the thumb from 0 to n.
CaptainR 10:b959bb206e6b 677 // Value - If value positive, sets the relative position of the thumb on the slider bar, else set thumb to ABS position of the negative number.
CaptainR 10:b959bb206e6b 678 //**************************************************************************
CaptainR 10:b959bb206e6b 679 void PICASO_4DGL :: drawSlider(short state, short x1, short y1, short x2, short y2, short color, short scale, short value) {
CaptainR 10:b959bb206e6b 680
CaptainR 10:b959bb206e6b 681 char command[18] = "";
CaptainR 10:b959bb206e6b 682
CaptainR 10:b959bb206e6b 683 command[0] = (DRAW_SLIDER >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 684 command[1] = (DRAW_SLIDER >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 685 command[2] = (state >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 686 command[3] = (state >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 687 command[4] = (x1 >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 688 command[5] = (x1 >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 689 command[6] = (y1 >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 690 command[7] = (y1 >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 691 command[8] = (x2 >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 692 command[9] = (x2 >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 693 command[10] = (y2 >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 694 command[11] = (y2 >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 695 command[12] = (color >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 696 command[13] = (color >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 697 command[14] = (scale >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 698 command[15] = (scale >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 699 command[16] = (value >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 700 command[17] = (value >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 701
CaptainR 10:b959bb206e6b 702 writeCOMMAND(command, 18);
CaptainR 10:b959bb206e6b 703 getResponse(1);
CaptainR 10:b959bb206e6b 704 }
CaptainR 10:b959bb206e6b 705
CaptainR 10:b959bb206e6b 706 //**************************************************************************
CaptainR 10:b959bb206e6b 707 // The Screen Copy Paste command copies an area of a screen from xs, ys of size given
CaptainR 10:b959bb206e6b 708 // by width and height parameters and pastes it to another location determined by xd, yd.
CaptainR 10:b959bb206e6b 709 //**************************************************************************
CaptainR 10:b959bb206e6b 710 void PICASO_4DGL :: screenCopyPaste(short xs, short ys, short xd, short yd, short width, short height) {
CaptainR 10:b959bb206e6b 711
CaptainR 10:b959bb206e6b 712 char command[14] = "";
CaptainR 10:b959bb206e6b 713
CaptainR 10:b959bb206e6b 714 command[0] = (SCREEN_CP >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 715 command[1] = (SCREEN_CP >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 716 command[2] = (xs >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 717 command[3] = (xs >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 718 command[4] = (ys >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 719 command[5] = (ys >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 720 command[6] = (xd >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 721 command[7] = (xd >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 722 command[8] = (yd >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 723 command[9] = (yd >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 724 command[10] = (width >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 725 command[11] = (width >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 726 command[12] = (height >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 727 command[13] = (height >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 728
CaptainR 10:b959bb206e6b 729 writeCOMMAND(command, 14);
CaptainR 10:b959bb206e6b 730 getResponse(1);
CaptainR 10:b959bb206e6b 731 }
CaptainR 10:b959bb206e6b 732
CaptainR 10:b959bb206e6b 733 //**************************************************************************
CaptainR 10:b959bb206e6b 734 // The Bevel Shadow command changes the graphics “Draw Button” commands bevel shadow depth
CaptainR 10:b959bb206e6b 735 // value - 0 = No Bevel Shadow 1-4 = Number of Pixels Deep (Default = 3)
CaptainR 10:b959bb206e6b 736 //**************************************************************************
CaptainR 11:3ebd2263f3e9 737 bool PICASO_4DGL :: bevelShadow(short value) {
CaptainR 11:3ebd2263f3e9 738
CaptainR 11:3ebd2263f3e9 739 if (value <= 4) {
CaptainR 11:3ebd2263f3e9 740 char command[4] = "";
CaptainR 11:3ebd2263f3e9 741
CaptainR 11:3ebd2263f3e9 742 command[0] = (BEVEL_SHADOW >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 743 command[1] = (BEVEL_SHADOW >> (8*0)) & 0xff;
CaptainR 11:3ebd2263f3e9 744 command[2] = (value >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 745 command[3] = (value >> (8*0)) & 0xff;
CaptainR 11:3ebd2263f3e9 746
CaptainR 11:3ebd2263f3e9 747 writeCOMMAND(command, 4);
CaptainR 11:3ebd2263f3e9 748 getResponse(3);
CaptainR 11:3ebd2263f3e9 749 return true;
CaptainR 11:3ebd2263f3e9 750 }
CaptainR 11:3ebd2263f3e9 751 else {
CaptainR 11:3ebd2263f3e9 752 pc.printf("\n\r ERROR_BEVEL_SHADOW: Value has to be (0 - 4)\n\r");
CaptainR 11:3ebd2263f3e9 753 return false;
CaptainR 11:3ebd2263f3e9 754 }
CaptainR 11:3ebd2263f3e9 755 }
CaptainR 11:3ebd2263f3e9 756
CaptainR 11:3ebd2263f3e9 757 //**************************************************************************
CaptainR 11:3ebd2263f3e9 758 // The Bevel Width command changes the graphics “Draw Button” commands bevel width
CaptainR 11:3ebd2263f3e9 759 //**************************************************************************
CaptainR 11:3ebd2263f3e9 760 bool PICASO_4DGL :: bevelWidth(short value) {
CaptainR 11:3ebd2263f3e9 761
CaptainR 11:3ebd2263f3e9 762 if (value <= 15) {
CaptainR 11:3ebd2263f3e9 763 char command[4] = "";
CaptainR 11:3ebd2263f3e9 764
CaptainR 11:3ebd2263f3e9 765 command[0] = (BEVEL_WIDTH >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 766 command[1] = (BEVEL_WIDTH >> (8*0)) & 0xff;
CaptainR 11:3ebd2263f3e9 767 command[2] = (value >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 768 command[3] = (value >> (8*0)) & 0xff;
CaptainR 11:3ebd2263f3e9 769
CaptainR 11:3ebd2263f3e9 770 writeCOMMAND(command, 4);
CaptainR 11:3ebd2263f3e9 771 getResponse(3);
CaptainR 11:3ebd2263f3e9 772 return true;
CaptainR 11:3ebd2263f3e9 773 }
CaptainR 11:3ebd2263f3e9 774 else {
CaptainR 11:3ebd2263f3e9 775 pc.printf("\n\r ERROR_BEVEL_WIDTH: Value has to be (0 - 15)\n\r");
CaptainR 11:3ebd2263f3e9 776 return false;
CaptainR 11:3ebd2263f3e9 777 }
CaptainR 11:3ebd2263f3e9 778 }
CaptainR 11:3ebd2263f3e9 779
CaptainR 11:3ebd2263f3e9 780 //**************************************************************************
CaptainR 11:3ebd2263f3e9 781 // The Background Colour command sets the screen background colour
CaptainR 11:3ebd2263f3e9 782 //**************************************************************************
CaptainR 11:3ebd2263f3e9 783 void PICASO_4DGL :: bgColor(short color) {
CaptainR 11:3ebd2263f3e9 784
CaptainR 11:3ebd2263f3e9 785 char command[4] = "";
CaptainR 11:3ebd2263f3e9 786
CaptainR 11:3ebd2263f3e9 787 command[0] = (BG_COLOR >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 788 command[1] = (BG_COLOR >> (8*0)) & 0xff;
CaptainR 11:3ebd2263f3e9 789 command[2] = (color >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 790 command[3] = (color >> (8*0)) & 0xff;
CaptainR 11:3ebd2263f3e9 791
CaptainR 11:3ebd2263f3e9 792 writeCOMMAND(command, 4);
CaptainR 11:3ebd2263f3e9 793 getResponse(3);
CaptainR 11:3ebd2263f3e9 794 }
CaptainR 11:3ebd2263f3e9 795
CaptainR 11:3ebd2263f3e9 796 //**************************************************************************
CaptainR 11:3ebd2263f3e9 797 // The Outline Colour command sets the outline colour for rectangles and circles.
CaptainR 11:3ebd2263f3e9 798 //**************************************************************************
CaptainR 11:3ebd2263f3e9 799 void PICASO_4DGL :: outlineColor(short color) {
CaptainR 10:b959bb206e6b 800
CaptainR 10:b959bb206e6b 801 char command[4] = "";
CaptainR 10:b959bb206e6b 802
CaptainR 11:3ebd2263f3e9 803 command[0] = (OUTLINE_COLOR >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 804 command[1] = (OUTLINE_COLOR >> (8*0)) & 0xff;
CaptainR 11:3ebd2263f3e9 805 command[2] = (color >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 806 command[3] = (color >> (8*0)) & 0xff;
CaptainR 11:3ebd2263f3e9 807
CaptainR 11:3ebd2263f3e9 808 writeCOMMAND(command, 4);
CaptainR 11:3ebd2263f3e9 809 getResponse(3);
CaptainR 11:3ebd2263f3e9 810 }
CaptainR 11:3ebd2263f3e9 811
CaptainR 11:3ebd2263f3e9 812 //**************************************************************************
CaptainR 11:3ebd2263f3e9 813 // The Contrast Command sets the contrast of the display, or turns it On/Off
CaptainR 11:3ebd2263f3e9 814 // depending on display model
CaptainR 11:3ebd2263f3e9 815 // Contrast 0 = display OFF, non-zero = display ON
CaptainR 11:3ebd2263f3e9 816 // EXCEPTION:
CaptainR 11:3ebd2263f3e9 817 // uLCD-43 supports Contrast values from 1-15 and 0 to turn the Display off.
CaptainR 11:3ebd2263f3e9 818 // 3202X-P1 supports Contrast values from 1 to 9 and 0 to turn the Display off.
CaptainR 11:3ebd2263f3e9 819 // Note: Does not apply to uVGA-II/III modules.
CaptainR 11:3ebd2263f3e9 820 //**************************************************************************
CaptainR 11:3ebd2263f3e9 821 void PICASO_4DGL :: contrast(short contrast) {
CaptainR 11:3ebd2263f3e9 822
CaptainR 11:3ebd2263f3e9 823 char command[4] = "";
CaptainR 11:3ebd2263f3e9 824
CaptainR 11:3ebd2263f3e9 825 command[0] = (CONTRAST >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 826 command[1] = (CONTRAST >> (8*0)) & 0xff;
CaptainR 11:3ebd2263f3e9 827 command[2] = (contrast >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 828 command[3] = (contrast >> (8*0)) & 0xff;
CaptainR 11:3ebd2263f3e9 829
CaptainR 11:3ebd2263f3e9 830 writeCOMMAND(command, 4);
CaptainR 11:3ebd2263f3e9 831 getResponse(3);
CaptainR 11:3ebd2263f3e9 832 }
CaptainR 11:3ebd2263f3e9 833
CaptainR 11:3ebd2263f3e9 834 //**************************************************************************
CaptainR 11:3ebd2263f3e9 835 // The Frame Delay command sets the inter frame delay for the “Media Video” command
CaptainR 11:3ebd2263f3e9 836 // 0-255 milliseconds
CaptainR 11:3ebd2263f3e9 837 //**************************************************************************
CaptainR 11:3ebd2263f3e9 838 bool PICASO_4DGL :: frameDelay(short msec) {
CaptainR 11:3ebd2263f3e9 839
CaptainR 11:3ebd2263f3e9 840 if (msec <= 255) {
CaptainR 11:3ebd2263f3e9 841 char command[4] = "";
CaptainR 11:3ebd2263f3e9 842
CaptainR 11:3ebd2263f3e9 843 command[0] = (FRAME_DELAY >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 844 command[1] = (FRAME_DELAY >> (8*0)) & 0xff;
CaptainR 11:3ebd2263f3e9 845 command[2] = (msec >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 846 command[3] = (msec >> (8*0)) & 0xff;
CaptainR 11:3ebd2263f3e9 847
CaptainR 11:3ebd2263f3e9 848 writeCOMMAND(command, 4);
CaptainR 11:3ebd2263f3e9 849 getResponse(3);
CaptainR 11:3ebd2263f3e9 850 return true;
CaptainR 11:3ebd2263f3e9 851 }
CaptainR 11:3ebd2263f3e9 852 else {
CaptainR 11:3ebd2263f3e9 853 pc.printf("\n\r ERROR_FRAME_DELAY: Value has to be (0 - 255)\n\r");
CaptainR 11:3ebd2263f3e9 854 return false;
CaptainR 11:3ebd2263f3e9 855 }
CaptainR 11:3ebd2263f3e9 856 }
CaptainR 11:3ebd2263f3e9 857
CaptainR 11:3ebd2263f3e9 858 //**************************************************************************
CaptainR 11:3ebd2263f3e9 859 // The Line Pattern command sets the line draw pattern for line drawing.
CaptainR 11:3ebd2263f3e9 860 // If set to zero, lines are solid, else each '1' bit represents a pixel
CaptainR 11:3ebd2263f3e9 861 // that is turned off.
CaptainR 11:3ebd2263f3e9 862 //**************************************************************************
CaptainR 11:3ebd2263f3e9 863 void PICASO_4DGL :: linePatern(short patern) {
CaptainR 11:3ebd2263f3e9 864
CaptainR 11:3ebd2263f3e9 865 char command[4] = "";
CaptainR 11:3ebd2263f3e9 866
CaptainR 11:3ebd2263f3e9 867 command[0] = (LINE_PATERN >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 868 command[1] = (LINE_PATERN >> (8*0)) & 0xff;
CaptainR 11:3ebd2263f3e9 869 command[2] = (patern >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 870 command[3] = (patern >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 871
CaptainR 10:b959bb206e6b 872 writeCOMMAND(command, 4);
CaptainR 10:b959bb206e6b 873 getResponse(3);
CaptainR 10:b959bb206e6b 874 }
CaptainR 11:3ebd2263f3e9 875
CaptainR 11:3ebd2263f3e9 876 //**************************************************************************
CaptainR 11:3ebd2263f3e9 877 // The Screen Mode command alters the graphics orientation LANDSCAPE,
CaptainR 11:3ebd2263f3e9 878 // LANDSCAPE_R, PORTRAIT, PORTRAIT_R
CaptainR 11:3ebd2263f3e9 879 //**************************************************************************
CaptainR 11:3ebd2263f3e9 880 void PICASO_4DGL :: screenMode(char c) { // select screen orientation
CaptainR 11:3ebd2263f3e9 881 char command[4] = "";
CaptainR 11:3ebd2263f3e9 882 command[0] = (ORIENTATION >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 883 command[1] = (ORIENTATION >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 884
CaptainR 11:3ebd2263f3e9 885 switch (c) {
CaptainR 11:3ebd2263f3e9 886 case 1 :
CaptainR 11:3ebd2263f3e9 887 command[2] = (LANDSCAPE >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 888 command[3] = (LANDSCAPE >> (8*0)) & 0xff;
CaptainR 12:29f5ad896382 889 currentMode = 1;
CaptainR 11:3ebd2263f3e9 890 break;
CaptainR 11:3ebd2263f3e9 891 case 2 :
CaptainR 11:3ebd2263f3e9 892 command[2] = (LANDSCAPE_R >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 893 command[3] = (LANDSCAPE_R >> (8*0)) & 0xff;
CaptainR 12:29f5ad896382 894 currentMode = 2;
CaptainR 11:3ebd2263f3e9 895 break;
CaptainR 11:3ebd2263f3e9 896 case 3 :
CaptainR 11:3ebd2263f3e9 897 command[2] = (PORTRAIT >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 898 command[3] = (PORTRAIT >> (8*0)) & 0xff;
CaptainR 12:29f5ad896382 899 currentMode = 3;
CaptainR 11:3ebd2263f3e9 900 break;
CaptainR 11:3ebd2263f3e9 901 case 4 :
CaptainR 11:3ebd2263f3e9 902 command[2] = (PORTRAIT_R >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 903 command[3] = (PORTRAIT_R >> (8*0)) & 0xff;
CaptainR 12:29f5ad896382 904 currentMode = 4;
CaptainR 11:3ebd2263f3e9 905 break;
CaptainR 11:3ebd2263f3e9 906 }
CaptainR 10:b959bb206e6b 907
CaptainR 11:3ebd2263f3e9 908 writeCOMMAND(command, 4);
CaptainR 11:3ebd2263f3e9 909 getResponse(3);
CaptainR 11:3ebd2263f3e9 910 }
CaptainR 11:3ebd2263f3e9 911
CaptainR 11:3ebd2263f3e9 912 //**************************************************************************
CaptainR 11:3ebd2263f3e9 913 // The Transparency command turns the transparency ON or OFF. Transparency
CaptainR 11:3ebd2263f3e9 914 // is automatically turned OFF after the next image or video command.
CaptainR 11:3ebd2263f3e9 915 //**************************************************************************
CaptainR 11:3ebd2263f3e9 916 void PICASO_4DGL :: transparency(short mode) {
CaptainR 10:b959bb206e6b 917
CaptainR 11:3ebd2263f3e9 918 char command[4] = "";
CaptainR 11:3ebd2263f3e9 919
CaptainR 11:3ebd2263f3e9 920 command[0] = (TRANSPARENCY >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 921 command[1] = (TRANSPARENCY >> (8*0)) & 0xff;
CaptainR 11:3ebd2263f3e9 922 command[2] = (mode >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 923 command[3] = (mode >> (8*0)) & 0xff;
CaptainR 11:3ebd2263f3e9 924
CaptainR 11:3ebd2263f3e9 925 writeCOMMAND(command, 4);
CaptainR 11:3ebd2263f3e9 926 getResponse(3);
CaptainR 11:3ebd2263f3e9 927 }
CaptainR 11:3ebd2263f3e9 928
CaptainR 11:3ebd2263f3e9 929 //**************************************************************************
CaptainR 11:3ebd2263f3e9 930 // The Transparent Colour command alters the colour that needs to be made transparent.
CaptainR 11:3ebd2263f3e9 931 //**************************************************************************
CaptainR 11:3ebd2263f3e9 932 void PICASO_4DGL :: transparentColor(short color) {
CaptainR 11:3ebd2263f3e9 933
CaptainR 11:3ebd2263f3e9 934 char command[4] = "";
CaptainR 11:3ebd2263f3e9 935
CaptainR 11:3ebd2263f3e9 936 command[0] = (TRANSPARENT_COLOR >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 937 command[1] = (TRANSPARENT_COLOR >> (8*0)) & 0xff;
CaptainR 11:3ebd2263f3e9 938 command[2] = (color >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 939 command[3] = (color >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 940
CaptainR 11:3ebd2263f3e9 941 writeCOMMAND(command, 4);
CaptainR 11:3ebd2263f3e9 942 getResponse(3);
CaptainR 11:3ebd2263f3e9 943 }
CaptainR 11:3ebd2263f3e9 944
CaptainR 11:3ebd2263f3e9 945 //**************************************************************************
CaptainR 11:3ebd2263f3e9 946 // Sets various graphics parameters:
CaptainR 11:3ebd2263f3e9 947 // Function = 18 Object Colour - Sets the Object colour used in various functions
CaptainR 11:3ebd2263f3e9 948 // such as Draw Slider and Draw Line & Move Origin (0 – 65535 or 0 - 0xFFFF)
CaptainR 11:3ebd2263f3e9 949 //
CaptainR 11:3ebd2263f3e9 950 // Function = 32 Screen Resolution - Set VGA Screen resolution. Applies to uVGA-II and uVGA-III only
CaptainR 11:3ebd2263f3e9 951 // (0 for 320x240, 1 for 640 x 480, 2 for 800 x 480)
CaptainR 11:3ebd2263f3e9 952 //
CaptainR 11:3ebd2263f3e9 953 // Function = 33 Page Display - Choose Page to be displayed. Value depends on the resolution set.
CaptainR 11:3ebd2263f3e9 954 // Applies to uVGA-II, uVGA-III and uLCD-43 range only.
CaptainR 11:3ebd2263f3e9 955 // e.g. 0-4 for 320x240 resolution on a uVGA-II and uVGA-III
CaptainR 11:3ebd2263f3e9 956 //
CaptainR 11:3ebd2263f3e9 957 // Function = 34 Page Read - Choose the Page to be read. Value depends on the resolution set.
CaptainR 11:3ebd2263f3e9 958 // Applies to uVGA-II, uVGA-III and uLCD-43 range only..
CaptainR 11:3ebd2263f3e9 959 // e.g. 0-4 for 320x240 resolution on a uVGA-II and uVGA-III
CaptainR 11:3ebd2263f3e9 960 //
CaptainR 11:3ebd2263f3e9 961 // Function = 35 Page Write - Choose the Page to be written. Value depends on the resolution set.
CaptainR 11:3ebd2263f3e9 962 // Applies to uVGA-II, uVGA-III and uLCD-43 range only.
CaptainR 11:3ebd2263f3e9 963 // e.g. 0-4 for 320x240 resolution on a uVGA-II and uVGA-III
CaptainR 11:3ebd2263f3e9 964 //
CaptainR 11:3ebd2263f3e9 965 //**************************************************************************
CaptainR 11:3ebd2263f3e9 966 void PICASO_4DGL :: setGraphics(short function, short value) { // set graphics parameters
CaptainR 11:3ebd2263f3e9 967
CaptainR 11:3ebd2263f3e9 968 char command[6] = "";
CaptainR 10:b959bb206e6b 969
CaptainR 11:3ebd2263f3e9 970 command[0] = (SET_GRAPHICS >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 971 command[1] = (SET_GRAPHICS >> (8*0)) & 0xff;
CaptainR 11:3ebd2263f3e9 972 command[2] = (function >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 973 command[3] = (function >> (8*0)) & 0xff;
CaptainR 11:3ebd2263f3e9 974 command[4] = (value >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 975 command[5] = (value >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 976
CaptainR 11:3ebd2263f3e9 977 writeCOMMAND(command, 6);
CaptainR 11:3ebd2263f3e9 978 getResponse(1);
CaptainR 11:3ebd2263f3e9 979 }
CaptainR 11:3ebd2263f3e9 980
CaptainR 11:3ebd2263f3e9 981 //**************************************************************************
CaptainR 11:3ebd2263f3e9 982 // Returns various graphics parameters to the caller.
CaptainR 11:3ebd2263f3e9 983 // mode = 0 : Current orientations maximum X value (X_MAX)
CaptainR 11:3ebd2263f3e9 984 // mode = 1 : Current orientations maximum Y value (Y_MAX)
CaptainR 11:3ebd2263f3e9 985 // mode = 2 : Left location of last Object
CaptainR 11:3ebd2263f3e9 986 // mode = 3 : Top location of Object
CaptainR 11:3ebd2263f3e9 987 // mode = 4 : Right location of last Object
CaptainR 11:3ebd2263f3e9 988 // mode = 5 : Bottom location of Object
CaptainR 11:3ebd2263f3e9 989 //
CaptainR 11:3ebd2263f3e9 990 //**************************************************************************
CaptainR 11:3ebd2263f3e9 991 short PICASO_4DGL :: getGraphics(short mode) { // set graphics parameters
CaptainR 11:3ebd2263f3e9 992
CaptainR 11:3ebd2263f3e9 993 short answer = 0;
CaptainR 11:3ebd2263f3e9 994 char command[4] = "";
CaptainR 11:3ebd2263f3e9 995
CaptainR 11:3ebd2263f3e9 996 command[0] = (GET_GRAPHICS >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 997 command[1] = (GET_GRAPHICS >> (8*0)) & 0xff;
CaptainR 11:3ebd2263f3e9 998 command[2] = (mode >> (8*1)) & 0xff;
CaptainR 11:3ebd2263f3e9 999 command[3] = (mode >> (8*0)) & 0xff;
CaptainR 11:3ebd2263f3e9 1000
CaptainR 11:3ebd2263f3e9 1001 writeCOMMAND(command, 4);
CaptainR 11:3ebd2263f3e9 1002 answer = getGraphicsResponse();
CaptainR 11:3ebd2263f3e9 1003 pc.printf("\n\ranswer = %i\n\r", answer);
CaptainR 11:3ebd2263f3e9 1004 return answer;
CaptainR 11:3ebd2263f3e9 1005 }
CaptainR 11:3ebd2263f3e9 1006
CaptainR 11:3ebd2263f3e9 1007
CaptainR 11:3ebd2263f3e9 1008
CaptainR 11:3ebd2263f3e9 1009
CaptainR 11:3ebd2263f3e9 1010
CaptainR 11:3ebd2263f3e9 1011
CaptainR 11:3ebd2263f3e9 1012
CaptainR 11:3ebd2263f3e9 1013
CaptainR 11:3ebd2263f3e9 1014
CaptainR 11:3ebd2263f3e9 1015
CaptainR 11:3ebd2263f3e9 1016
CaptainR 11:3ebd2263f3e9 1017
CaptainR 11:3ebd2263f3e9 1018
CaptainR 11:3ebd2263f3e9 1019
CaptainR 11:3ebd2263f3e9 1020
CaptainR 11:3ebd2263f3e9 1021
CaptainR 11:3ebd2263f3e9 1022
CaptainR 11:3ebd2263f3e9 1023
CaptainR 11:3ebd2263f3e9 1024