Rihards Balass / 4DGL-mbed-32PTU
Committer:
CaptainR
Date:
Tue Sep 13 05:53:39 2016 +0000
Revision:
10:b959bb206e6b
Parent:
9:32eb75c01e9d
Child:
11:3ebd2263f3e9
drawElipse, drawFilledElipse, drawTextButton, drawPanel, DrawSlider, ScreenCopyPaste, BevelShadow

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 3:dcfbceb81fef 209 char command[size];
CaptainR 3:dcfbceb81fef 210 for(i = 0; i < size; i++) command[i] = 0;
CaptainR 3:dcfbceb81fef 211
CaptainR 3:dcfbceb81fef 212 command[0] = (DRAW_POLYLINE >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 213 command[1] = (DRAW_POLYLINE >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 214 command[2] = (n >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 215 command[3] = (n >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 216 for (i = 0; i < n; i++) {
CaptainR 3:dcfbceb81fef 217 command[j] = (vx[i] >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 218 j++;
CaptainR 3:dcfbceb81fef 219 command[j] = (vx[i] >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 220 j++;
CaptainR 3:dcfbceb81fef 221 }
CaptainR 3:dcfbceb81fef 222 for (i = 0; i < n; i++) {
CaptainR 3:dcfbceb81fef 223 command[j] = (vy[i] >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 224 j++;
CaptainR 3:dcfbceb81fef 225 command[j] = (vy[i] >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 226 j++;
CaptainR 3:dcfbceb81fef 227 }
CaptainR 3:dcfbceb81fef 228 command[j] = (color >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 229 command[j+1] = (color >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 230
CaptainR 3:dcfbceb81fef 231 writeCOMMAND(command, size);
CaptainR 5:890ddd974624 232 getResponse(1);
CaptainR 3:dcfbceb81fef 233 }
CaptainR 0:a5ef6bc3c2e8 234
CaptainR 3:dcfbceb81fef 235 //**************************************************************************
CaptainR 3:dcfbceb81fef 236 // The Draw Polygon command plots lines between points specified by a pair of arrays
CaptainR 3:dcfbceb81fef 237 // using the specified color.
CaptainR 3:dcfbceb81fef 238 // The last point is drawn back to the first point, completing the polygon.
CaptainR 3:dcfbceb81fef 239 // The lines may be tessellated with the “Line Pattern” command.
CaptainR 3:dcfbceb81fef 240 // The Draw Polygon command can be used to create complex raster graphics
CaptainR 3:dcfbceb81fef 241 // by loading the arrays from serial input or from MEDIA with very little code requirement.
CaptainR 3:dcfbceb81fef 242 //
CaptainR 3:dcfbceb81fef 243 // n - Specifies the number of elements in the x and y arrays specifying the vertices for the polygon.
CaptainR 3:dcfbceb81fef 244 // vx, vy - Specifies the array of elements for the x/y coordinates of the vertices.
CaptainR 3:dcfbceb81fef 245 // Vx1, vx2, …, vxN, vy1, vy2, …, vyN
CaptainR 3:dcfbceb81fef 246 //**************************************************************************
CaptainR 3:dcfbceb81fef 247 void PICASO_4DGL :: drawPolygon(short n, short *vx, short *vy, short color) {
CaptainR 3:dcfbceb81fef 248
CaptainR 3:dcfbceb81fef 249 int size = 6 + (n*4);
CaptainR 3:dcfbceb81fef 250 int i, j = 4;
CaptainR 3:dcfbceb81fef 251 char command[size];
CaptainR 3:dcfbceb81fef 252 for(i = 0; i < size; i++) command[i] = 0;
CaptainR 3:dcfbceb81fef 253
CaptainR 3:dcfbceb81fef 254 command[0] = (DRAW_POLYGON >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 255 command[1] = (DRAW_POLYGON >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 256 command[2] = (n >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 257 command[3] = (n >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 258 for (i = 0; i < n; i++) {
CaptainR 3:dcfbceb81fef 259 command[j] = (vx[i] >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 260 j++;
CaptainR 3:dcfbceb81fef 261 command[j] = (vx[i] >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 262 j++;
CaptainR 3:dcfbceb81fef 263 }
CaptainR 3:dcfbceb81fef 264 for (i = 0; i < n; i++) {
CaptainR 3:dcfbceb81fef 265 command[j] = (vy[i] >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 266 j++;
CaptainR 3:dcfbceb81fef 267 command[j] = (vy[i] >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 268 j++;
CaptainR 3:dcfbceb81fef 269 }
CaptainR 3:dcfbceb81fef 270 command[j] = (color >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 271 command[j+1] = (color >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 272
CaptainR 3:dcfbceb81fef 273 writeCOMMAND(command, size);
CaptainR 5:890ddd974624 274 getResponse(1);
CaptainR 3:dcfbceb81fef 275 }
CaptainR 0:a5ef6bc3c2e8 276
CaptainR 3:dcfbceb81fef 277 //**************************************************************************
CaptainR 3:dcfbceb81fef 278 // The Draw Filled Polygon command draws a solid Polygon between specified vertices:
CaptainR 3:dcfbceb81fef 279 // x1, y1 x2, y2, .... , xn, yn using the specified color.
CaptainR 3:dcfbceb81fef 280 // The last point is drawn back to the first point, completing the polygon.
CaptainR 3:dcfbceb81fef 281 // Vertices must be a minimum of 3 and can be specified in any fashion.
CaptainR 3:dcfbceb81fef 282 //
CaptainR 3:dcfbceb81fef 283 // n - Specifies the number of elements in the x and y arrays specifying the vertices for the polygon.
CaptainR 3:dcfbceb81fef 284 // vx, vy - Specifies the array of elements for the x/y coordinates of the vertices.
CaptainR 3:dcfbceb81fef 285 // Vx1, vx2, …, vxN, vy1, vy2, …, vyN
CaptainR 3:dcfbceb81fef 286 //**************************************************************************
CaptainR 3:dcfbceb81fef 287 void PICASO_4DGL :: drawFilledPolygon(short n, short *vx, short *vy, short color) {
CaptainR 3:dcfbceb81fef 288
CaptainR 3:dcfbceb81fef 289 if (n >= 3) {
CaptainR 3:dcfbceb81fef 290 int size = 6 + (n*4);
CaptainR 3:dcfbceb81fef 291 int i, j = 4;
CaptainR 3:dcfbceb81fef 292 char command[size];
CaptainR 3:dcfbceb81fef 293 for(i = 0; i < size; i++) command[i] = 0;
CaptainR 3:dcfbceb81fef 294
CaptainR 3:dcfbceb81fef 295 command[0] = (POLYGON_FILLED >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 296 command[1] = (POLYGON_FILLED >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 297 command[2] = (n >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 298 command[3] = (n >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 299 for (i = 0; i < n; i++) {
CaptainR 3:dcfbceb81fef 300 command[j] = (vx[i] >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 301 j++;
CaptainR 3:dcfbceb81fef 302 command[j] = (vx[i] >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 303 j++;
CaptainR 3:dcfbceb81fef 304 }
CaptainR 3:dcfbceb81fef 305 for (i = 0; i < n; i++) {
CaptainR 3:dcfbceb81fef 306 command[j] = (vy[i] >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 307 j++;
CaptainR 3:dcfbceb81fef 308 command[j] = (vy[i] >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 309 j++;
CaptainR 3:dcfbceb81fef 310 }
CaptainR 3:dcfbceb81fef 311 command[j] = (color >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 312 command[j+1] = (color >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 313
CaptainR 3:dcfbceb81fef 314 writeCOMMAND(command, size);
CaptainR 5:890ddd974624 315 getResponse(1);
CaptainR 3:dcfbceb81fef 316 }
CaptainR 3:dcfbceb81fef 317 }
CaptainR 3:dcfbceb81fef 318
CaptainR 3:dcfbceb81fef 319 //**************************************************************************
CaptainR 3:dcfbceb81fef 320 // The Draw Triangle command draws a triangle outline between vertices
CaptainR 3:dcfbceb81fef 321 // x1,y1 , x2,y2 and x3,y3 using the specified color.
CaptainR 3:dcfbceb81fef 322 // The line may be tessellated with the “Line Pattern” command.
CaptainR 3:dcfbceb81fef 323 //**************************************************************************
CaptainR 3:dcfbceb81fef 324 void PICASO_4DGL :: drawTriangle(short x1, short y1, short x2, short y2, short x3, short y3, short color) {
CaptainR 3:dcfbceb81fef 325
CaptainR 3:dcfbceb81fef 326 char command[16] = "";
CaptainR 3:dcfbceb81fef 327
CaptainR 3:dcfbceb81fef 328 command[0] = (DRAW_TRIANGLE >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 329 command[1] = (DRAW_TRIANGLE >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 330 command[2] = (x1 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 331 command[3] = (x1 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 332 command[4] = (y1 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 333 command[5] = (y1 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 334 command[6] = (x2 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 335 command[7] = (x2 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 336 command[8] = (y2 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 337 command[9] = (y2 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 338 command[10] = (x3 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 339 command[11] = (x3 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 340 command[12] = (y3 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 341 command[13] = (y3 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 342 command[14] = (color >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 343 command[15] = (color >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 344
CaptainR 3:dcfbceb81fef 345 writeCOMMAND(command, 16);
CaptainR 5:890ddd974624 346 getResponse(1);
CaptainR 3:dcfbceb81fef 347 }
CaptainR 3:dcfbceb81fef 348
CaptainR 3:dcfbceb81fef 349 //**************************************************************************
CaptainR 3:dcfbceb81fef 350 // The Draw Filled Triangle command draws a solid triangle between vertices
CaptainR 3:dcfbceb81fef 351 // x1, y1, x2, y2 and x3, y3 using the specified color.
CaptainR 3:dcfbceb81fef 352 //**************************************************************************
CaptainR 3:dcfbceb81fef 353 void PICASO_4DGL :: drawFilledTriangle(short x1, short y1, short x2, short y2, short x3, short y3, short color) {
CaptainR 3:dcfbceb81fef 354
CaptainR 3:dcfbceb81fef 355 char command[16] = "";
CaptainR 3:dcfbceb81fef 356
CaptainR 3:dcfbceb81fef 357 command[0] = (TRIANGLE_FILLED >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 358 command[1] = (TRIANGLE_FILLED >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 359 command[2] = (x1 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 360 command[3] = (x1 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 361 command[4] = (y1 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 362 command[5] = (y1 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 363 command[6] = (x2 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 364 command[7] = (x2 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 365 command[8] = (y2 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 366 command[9] = (y2 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 367 command[10] = (x3 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 368 command[11] = (x3 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 369 command[12] = (y3 >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 370 command[13] = (y3 >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 371 command[14] = (color >> (8*1)) & 0xff;
CaptainR 3:dcfbceb81fef 372 command[15] = (color >> (8*0)) & 0xff;
CaptainR 3:dcfbceb81fef 373
CaptainR 3:dcfbceb81fef 374 writeCOMMAND(command, 16);
CaptainR 5:890ddd974624 375 getResponse(1);
CaptainR 3:dcfbceb81fef 376 }
CaptainR 0:a5ef6bc3c2e8 377
CaptainR 4:50511ed54ab4 378 //**************************************************************************
CaptainR 4:50511ed54ab4 379 // The Calculate Orbit command calculates the x, y coordinates of a distant point relative
CaptainR 4:50511ed54ab4 380 // to the current origin, where the only known parameters are the angle and the distance
CaptainR 4:50511ed54ab4 381 // from the current origin. The new coordinates are calculated and then placed in the
CaptainR 4:50511ed54ab4 382 // destination variables Xdest and Ydest.
CaptainR 4:50511ed54ab4 383 //**************************************************************************
CaptainR 4:50511ed54ab4 384 void PICASO_4DGL :: calculateOrbit(short angle, short distance) {
CaptainR 4:50511ed54ab4 385
CaptainR 4:50511ed54ab4 386 char command[6] = "";
CaptainR 4:50511ed54ab4 387
CaptainR 4:50511ed54ab4 388 command[0] = (CALCULATE_ORBIT >> (8*1)) & 0xff;
CaptainR 4:50511ed54ab4 389 command[1] = (CALCULATE_ORBIT >> (8*0)) & 0xff;
CaptainR 4:50511ed54ab4 390 command[2] = (angle >> (8*1)) & 0xff;
CaptainR 4:50511ed54ab4 391 command[3] = (angle >> (8*0)) & 0xff;
CaptainR 4:50511ed54ab4 392 command[4] = (distance >> (8*1)) & 0xff;
CaptainR 4:50511ed54ab4 393 command[5] = (distance >> (8*0)) & 0xff;
CaptainR 4:50511ed54ab4 394
CaptainR 4:50511ed54ab4 395 writeCOMMAND(command, 6);
CaptainR 6:a1a85f2bc04b 396 calculateOrbitResponse();
CaptainR 6:a1a85f2bc04b 397 }
CaptainR 6:a1a85f2bc04b 398
CaptainR 6:a1a85f2bc04b 399 //**************************************************************************
CaptainR 6:a1a85f2bc04b 400 // The Put Pixel command draws a pixel at position x, y using the specified color.
CaptainR 6:a1a85f2bc04b 401 //**************************************************************************
CaptainR 6:a1a85f2bc04b 402 void PICASO_4DGL :: putPixel(short x, short y, short color) {
CaptainR 6:a1a85f2bc04b 403
CaptainR 6:a1a85f2bc04b 404 char command[8] = "";
CaptainR 6:a1a85f2bc04b 405
CaptainR 6:a1a85f2bc04b 406 command[0] = (PUT_PIXEL >> (8*1)) & 0xff;
CaptainR 6:a1a85f2bc04b 407 command[1] = (PUT_PIXEL >> (8*0)) & 0xff;
CaptainR 6:a1a85f2bc04b 408 command[2] = (x >> (8*1)) & 0xff;
CaptainR 6:a1a85f2bc04b 409 command[3] = (x >> (8*0)) & 0xff;
CaptainR 6:a1a85f2bc04b 410 command[4] = (y >> (8*1)) & 0xff;
CaptainR 6:a1a85f2bc04b 411 command[5] = (y >> (8*0)) & 0xff;
CaptainR 6:a1a85f2bc04b 412 command[6] = (color >> (8*1)) & 0xff;
CaptainR 6:a1a85f2bc04b 413 command[7] = (color >> (8*0)) & 0xff;
CaptainR 6:a1a85f2bc04b 414
CaptainR 6:a1a85f2bc04b 415 writeCOMMAND(command, 8);
CaptainR 6:a1a85f2bc04b 416 getResponse(1);
CaptainR 6:a1a85f2bc04b 417 }
CaptainR 6:a1a85f2bc04b 418
CaptainR 6:a1a85f2bc04b 419 //**************************************************************************
CaptainR 6:a1a85f2bc04b 420 // The Move Origin command moves the origin to a new position, which is suitable for
CaptainR 6:a1a85f2bc04b 421 // specifying the location for both graphics and text.
CaptainR 6:a1a85f2bc04b 422 //**************************************************************************
CaptainR 6:a1a85f2bc04b 423 void PICASO_4DGL :: moveOrigin(short x, short y) {
CaptainR 6:a1a85f2bc04b 424
CaptainR 6:a1a85f2bc04b 425 char command[6] = "";
CaptainR 6:a1a85f2bc04b 426
CaptainR 7:f064ae670553 427 command[0] = (MOVE_ORIGIN >> (8*1)) & 0xff;
CaptainR 7:f064ae670553 428 command[1] = (MOVE_ORIGIN >> (8*0)) & 0xff;
CaptainR 6:a1a85f2bc04b 429 command[2] = (x >> (8*1)) & 0xff;
CaptainR 6:a1a85f2bc04b 430 command[3] = (x >> (8*0)) & 0xff;
CaptainR 6:a1a85f2bc04b 431 command[4] = (y >> (8*1)) & 0xff;
CaptainR 6:a1a85f2bc04b 432 command[5] = (y >> (8*0)) & 0xff;
CaptainR 6:a1a85f2bc04b 433
CaptainR 8:b634ac9c92f8 434 writeCOMMAND(command, 6);
CaptainR 8:b634ac9c92f8 435 getResponse(1);
CaptainR 8:b634ac9c92f8 436 }
CaptainR 8:b634ac9c92f8 437
CaptainR 8:b634ac9c92f8 438 //**************************************************************************
CaptainR 8:b634ac9c92f8 439 // The Draw Line & Move Origin command draws a line from the current origin
CaptainR 8:b634ac9c92f8 440 // to a new position. The Origin is then set to the new position.
CaptainR 8:b634ac9c92f8 441 // The line is drawn using the current object colour, using the
CaptainR 8:b634ac9c92f8 442 // “Set Graphics Parameters” – “Object Colour” command. The line may be
CaptainR 8:b634ac9c92f8 443 // tessellated with the “Line Pattern” command.
CaptainR 8:b634ac9c92f8 444 //
CaptainR 8:b634ac9c92f8 445 // Note: this command is mostly useful with the “Calculate Orbit” command,
CaptainR 8:b634ac9c92f8 446 // and usually the “Draw Line” command would be used
CaptainR 8:b634ac9c92f8 447 //**************************************************************************
CaptainR 8:b634ac9c92f8 448 void PICASO_4DGL :: lineTo(short x, short y) {
CaptainR 8:b634ac9c92f8 449
CaptainR 8:b634ac9c92f8 450 char command[6] = "";
CaptainR 8:b634ac9c92f8 451
CaptainR 8:b634ac9c92f8 452 command[0] = (LINE_TO >> (8*1)) & 0xff;
CaptainR 8:b634ac9c92f8 453 command[1] = (LINE_TO >> (8*0)) & 0xff;
CaptainR 8:b634ac9c92f8 454 command[2] = (x >> (8*1)) & 0xff;
CaptainR 8:b634ac9c92f8 455 command[3] = (x >> (8*0)) & 0xff;
CaptainR 8:b634ac9c92f8 456 command[4] = (y >> (8*1)) & 0xff;
CaptainR 8:b634ac9c92f8 457 command[5] = (y >> (8*0)) & 0xff;
CaptainR 8:b634ac9c92f8 458
CaptainR 8:b634ac9c92f8 459 writeCOMMAND(command, 6);
CaptainR 6:a1a85f2bc04b 460 getResponse(1);
CaptainR 4:50511ed54ab4 461 }
CaptainR 4:50511ed54ab4 462
CaptainR 9:32eb75c01e9d 463 //**************************************************************************
CaptainR 9:32eb75c01e9d 464 // The Set Clip Window command specifies a clipping window region on the screen such
CaptainR 9:32eb75c01e9d 465 // that any objects and text placed onto the screen will be clipped and displayed only
CaptainR 9:32eb75c01e9d 466 // within that region. For the clipping window to take effect, the clipping setting must be
CaptainR 9:32eb75c01e9d 467 // enabled separately using the “Clipping” command
CaptainR 9:32eb75c01e9d 468 //**************************************************************************
CaptainR 9:32eb75c01e9d 469 void PICASO_4DGL :: setClipWindow(short x1, short y1, short x2, short y2) {
CaptainR 9:32eb75c01e9d 470
CaptainR 9:32eb75c01e9d 471 char command[10] = "";
CaptainR 9:32eb75c01e9d 472
CaptainR 9:32eb75c01e9d 473 command[0] = (SET_CLIP_WINDOW >> (8*1)) & 0xff;
CaptainR 9:32eb75c01e9d 474 command[1] = (SET_CLIP_WINDOW >> (8*0)) & 0xff;
CaptainR 9:32eb75c01e9d 475 command[2] = (x1 >> (8*1)) & 0xff;
CaptainR 9:32eb75c01e9d 476 command[3] = (x1 >> (8*0)) & 0xff;
CaptainR 9:32eb75c01e9d 477 command[4] = (y1 >> (8*1)) & 0xff;
CaptainR 9:32eb75c01e9d 478 command[5] = (y1 >> (8*0)) & 0xff;
CaptainR 9:32eb75c01e9d 479 command[6] = (x2 >> (8*1)) & 0xff;
CaptainR 9:32eb75c01e9d 480 command[7] = (x2 >> (8*0)) & 0xff;
CaptainR 9:32eb75c01e9d 481 command[8] = (y2 >> (8*1)) & 0xff;
CaptainR 9:32eb75c01e9d 482 command[9] = (y2 >> (8*0)) & 0xff;
CaptainR 9:32eb75c01e9d 483
CaptainR 9:32eb75c01e9d 484 writeCOMMAND(command, 10);
CaptainR 9:32eb75c01e9d 485 getResponse(1);
CaptainR 9:32eb75c01e9d 486 }
CaptainR 4:50511ed54ab4 487
CaptainR 9:32eb75c01e9d 488 //**************************************************************************
CaptainR 9:32eb75c01e9d 489 // The Clipping command Enables or Disables the ability for Clipping to be used.
CaptainR 9:32eb75c01e9d 490 // The clipping points are set with “Set Clip Window” and must be set first.
CaptainR 9:32eb75c01e9d 491 //**************************************************************************
CaptainR 9:32eb75c01e9d 492 void PICASO_4DGL :: clipping(short value) {
CaptainR 9:32eb75c01e9d 493
CaptainR 9:32eb75c01e9d 494 char command[4] = "";
CaptainR 9:32eb75c01e9d 495
CaptainR 9:32eb75c01e9d 496 command[0] = (CLIPPING >> (8*1)) & 0xff;
CaptainR 9:32eb75c01e9d 497 command[1] = (CLIPPING >> (8*0)) & 0xff;
CaptainR 9:32eb75c01e9d 498 command[2] = (value >> (8*1)) & 0xff;
CaptainR 9:32eb75c01e9d 499 command[3] = (value >> (8*0)) & 0xff;
CaptainR 9:32eb75c01e9d 500
CaptainR 9:32eb75c01e9d 501 writeCOMMAND(command, 4);
CaptainR 9:32eb75c01e9d 502 getResponse(1);
CaptainR 9:32eb75c01e9d 503 }
CaptainR 4:50511ed54ab4 504
CaptainR 9:32eb75c01e9d 505 //**************************************************************************
CaptainR 9:32eb75c01e9d 506 // The Extend Clip Region command forces the clip region to the extent
CaptainR 9:32eb75c01e9d 507 // of the last text that was printed, or the last image that was shown.
CaptainR 9:32eb75c01e9d 508 //**************************************************************************
CaptainR 9:32eb75c01e9d 509 void PICASO_4DGL :: extendClipRegion() {
CaptainR 9:32eb75c01e9d 510
CaptainR 9:32eb75c01e9d 511 char command[2] = "";
CaptainR 9:32eb75c01e9d 512
CaptainR 9:32eb75c01e9d 513 command[0] = (EXTEND_CLIP >> (8*1)) & 0xff;
CaptainR 9:32eb75c01e9d 514 command[1] = (EXTEND_CLIP >> (8*0)) & 0xff;
CaptainR 9:32eb75c01e9d 515
CaptainR 9:32eb75c01e9d 516 writeCOMMAND(command, 2);
CaptainR 9:32eb75c01e9d 517 getResponse(1);
CaptainR 9:32eb75c01e9d 518 }
CaptainR 9:32eb75c01e9d 519
CaptainR 10:b959bb206e6b 520 //**************************************************************************
CaptainR 10:b959bb206e6b 521 // The Draw Ellipse command plots a colored Ellipse on the screen at centre
CaptainR 10:b959bb206e6b 522 // x, y with x-radius = xrad and y-radius = yrad.
CaptainR 10:b959bb206e6b 523 //**************************************************************************
CaptainR 10:b959bb206e6b 524 void PICASO_4DGL :: drawElipse(short x, short y, short xRad, short yRad, short color) {
CaptainR 10:b959bb206e6b 525
CaptainR 10:b959bb206e6b 526 char command[12] = "";
CaptainR 10:b959bb206e6b 527
CaptainR 10:b959bb206e6b 528 command[0] = (DRAW_ELIPSE >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 529 command[1] = (DRAW_ELIPSE >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 530 command[2] = (x >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 531 command[3] = (x >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 532 command[4] = (y >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 533 command[5] = (y >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 534 command[6] = (xRad >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 535 command[7] = (xRad >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 536 command[8] = (yRad >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 537 command[9] = (yRad >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 538 command[10] = (color >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 539 command[11] = (color >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 540
CaptainR 10:b959bb206e6b 541 writeCOMMAND(command, 12);
CaptainR 10:b959bb206e6b 542 getResponse(1);
CaptainR 10:b959bb206e6b 543 }
CaptainR 10:b959bb206e6b 544
CaptainR 10:b959bb206e6b 545 //**************************************************************************
CaptainR 10:b959bb206e6b 546 // The Draw Filled Ellipse command plots a solid colored Ellipse on the screen at centre
CaptainR 10:b959bb206e6b 547 // x, y with x-radius = xrad and y-radius = yrad.
CaptainR 10:b959bb206e6b 548 //**************************************************************************
CaptainR 10:b959bb206e6b 549 void PICASO_4DGL :: drawFilledElipse(short x, short y, short xRad, short yRad, short color) {
CaptainR 10:b959bb206e6b 550
CaptainR 10:b959bb206e6b 551 char command[12] = "";
CaptainR 10:b959bb206e6b 552
CaptainR 10:b959bb206e6b 553 command[0] = (ELIPSE_FILLED >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 554 command[1] = (ELIPSE_FILLED >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 555 command[2] = (x >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 556 command[3] = (x >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 557 command[4] = (y >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 558 command[5] = (y >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 559 command[6] = (xRad >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 560 command[7] = (xRad >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 561 command[8] = (yRad >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 562 command[9] = (yRad >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 563 command[10] = (color >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 564 command[11] = (color >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 565
CaptainR 10:b959bb206e6b 566 writeCOMMAND(command, 12);
CaptainR 10:b959bb206e6b 567 getResponse(1);
CaptainR 10:b959bb206e6b 568 }
CaptainR 10:b959bb206e6b 569
CaptainR 10:b959bb206e6b 570 //**************************************************************************
CaptainR 10:b959bb206e6b 571 // The Draw Button command draws a 3 dimensional Text Button at screen location
CaptainR 10:b959bb206e6b 572 // defined by x, y parameters (top left corner). The size of the button depends
CaptainR 10:b959bb206e6b 573 // on the font, width, height and length of the text. The button can contain
CaptainR 10:b959bb206e6b 574 // multiple lines of text by having the \n character embedded in the string
CaptainR 10:b959bb206e6b 575 // for the end of line marker. In this case, the widest text in the string sets
CaptainR 10:b959bb206e6b 576 // the overall width, and the height of the button is set by the number of
CaptainR 10:b959bb206e6b 577 // text lines. In the case of multiple lines, each line is left justified.
CaptainR 10:b959bb206e6b 578 // If you wish to centre or right justify the text, you will need to prepare
CaptainR 10:b959bb206e6b 579 // the text string according to your requirements.
CaptainR 10:b959bb206e6b 580 //
CaptainR 10:b959bb206e6b 581 // state - Appearance of button, 0 = Button depressed; 1 = Button raised.
CaptainR 10:b959bb206e6b 582 // x, y - Specifies the top left corner position of the button on the screen.
CaptainR 10:b959bb206e6b 583 //**************************************************************************
CaptainR 10:b959bb206e6b 584 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 585
CaptainR 10:b959bb206e6b 586 int size = 19 + (strlen(txt));
CaptainR 10:b959bb206e6b 587 int i, j = 18;
CaptainR 10:b959bb206e6b 588 char command[size];
CaptainR 10:b959bb206e6b 589 for(i = 0; i < size; i++) command[i] = 0;
CaptainR 10:b959bb206e6b 590
CaptainR 10:b959bb206e6b 591 command[0] = (DRAW_BUTTON >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 592 command[1] = (DRAW_BUTTON >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 593 command[2] = (state >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 594 command[3] = (state >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 595 command[4] = (x >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 596 command[5] = (x >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 597 command[6] = (y >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 598 command[7] = (y >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 599 command[8] = (btnColor >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 600 command[9] = (btnColor >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 601 command[10] = (txtColor >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 602 command[11] = (txtColor >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 603 command[12] = (font >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 604 command[13] = (font >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 605 command[14] = (txtW >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 606 command[15] = (txtW >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 607 command[16] = (txtH >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 608 command[17] = (txtH >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 609 for (i = 0; i < strlen(txt); i++) {
CaptainR 10:b959bb206e6b 610 command[j] = txt[i];
CaptainR 10:b959bb206e6b 611 j++;
CaptainR 10:b959bb206e6b 612 }
CaptainR 10:b959bb206e6b 613 command[j] = 0;
CaptainR 10:b959bb206e6b 614
CaptainR 10:b959bb206e6b 615 writeCOMMAND(command, size);
CaptainR 10:b959bb206e6b 616 getResponse(1);
CaptainR 10:b959bb206e6b 617 }
CaptainR 10:b959bb206e6b 618
CaptainR 10:b959bb206e6b 619 //**************************************************************************
CaptainR 10:b959bb206e6b 620 // The Draw Panel command draws a 3 dimensional rectangular panel at a screen
CaptainR 10:b959bb206e6b 621 // location defined by x, y parameters (top left corner). The size of the panel
CaptainR 10:b959bb206e6b 622 // is set with the width and height parameters. The colour is defined by colour.
CaptainR 10:b959bb206e6b 623 // The state parameter determines the appearance of the panel, 0 = recessed, 1 = raised.
CaptainR 10:b959bb206e6b 624 //**************************************************************************
CaptainR 10:b959bb206e6b 625 void PICASO_4DGL :: drawPanel(short state, short x, short y, short width, short height, short color) {
CaptainR 10:b959bb206e6b 626
CaptainR 10:b959bb206e6b 627 char command[14] = "";
CaptainR 10:b959bb206e6b 628
CaptainR 10:b959bb206e6b 629 command[0] = (DRAW_PANEL >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 630 command[1] = (DRAW_PANEL >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 631 command[2] = (state >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 632 command[3] = (state >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 633 command[4] = (x >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 634 command[5] = (x >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 635 command[6] = (y >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 636 command[7] = (y >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 637 command[8] = (width >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 638 command[9] = (width >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 639 command[10] = (height >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 640 command[11] = (height >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 641 command[12] = (color >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 642 command[13] = (color >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 643
CaptainR 10:b959bb206e6b 644 writeCOMMAND(command, 14);
CaptainR 10:b959bb206e6b 645 getResponse(1);
CaptainR 10:b959bb206e6b 646 }
CaptainR 10:b959bb206e6b 647
CaptainR 10:b959bb206e6b 648 //**************************************************************************
CaptainR 10:b959bb206e6b 649 // The Draw Slider command draws a vertical or horizontal slider bar on the screen.
CaptainR 10:b959bb206e6b 650 // The Draw Slider command has several different modes of operation.
CaptainR 10:b959bb206e6b 651 // In order to minimise the amount of graphics functions we need, all modes of operation
CaptainR 10:b959bb206e6b 652 // are selected naturally depending on the parameter values.
CaptainR 10:b959bb206e6b 653 // Selection rules:
CaptainR 10:b959bb206e6b 654 // 1a) if x2-x1 > y2-y1 slider is assumed to be horizontal
CaptainR 10:b959bb206e6b 655 // (ie: if width > height, slider is horizontal)
CaptainR 10:b959bb206e6b 656 // 1b) if x2-x1 <= y2-y1 slider is assumed to be vertical
CaptainR 10:b959bb206e6b 657 // (ie: if height <= width, slider is horizontal)
CaptainR 10:b959bb206e6b 658 // 2a) If value is positive, thumb is set to the position that is the proportion
CaptainR 10:b959bb206e6b 659 // of value to the scale parameter.(used to set the control to the actual value of a variable)
CaptainR 10:b959bb206e6b 660 // 2b) If value is negative, thumb is driven to the graphics position set by the
CaptainR 10:b959bb206e6b 661 // ABSolute of value. (used to set thumb to its actual graphical position (usually by touch screen)
CaptainR 10:b959bb206e6b 662 // 3) The thumb colour is determine by the “Set Graphics Parameters” –
CaptainR 10:b959bb206e6b 663 // “Object Colour” command, however, if the current object colour is BLACK,
CaptainR 10:b959bb206e6b 664 // a darkened shade of the colour parameter is used for the thumb .
CaptainR 10:b959bb206e6b 665 //
CaptainR 10:b959bb206e6b 666 // mode - mode = 0 : Slider Indented, mode = 1 : Slider Raised, mode 2, Slider Hidden (background colour).
CaptainR 10:b959bb206e6b 667 // Scale - scale = n : sets the full scale range of the slider for the thumb from 0 to n.
CaptainR 10:b959bb206e6b 668 // 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 669 //**************************************************************************
CaptainR 10:b959bb206e6b 670 void PICASO_4DGL :: drawSlider(short state, short x1, short y1, short x2, short y2, short color, short scale, short value) {
CaptainR 10:b959bb206e6b 671
CaptainR 10:b959bb206e6b 672 char command[18] = "";
CaptainR 10:b959bb206e6b 673
CaptainR 10:b959bb206e6b 674 command[0] = (DRAW_SLIDER >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 675 command[1] = (DRAW_SLIDER >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 676 command[2] = (state >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 677 command[3] = (state >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 678 command[4] = (x1 >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 679 command[5] = (x1 >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 680 command[6] = (y1 >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 681 command[7] = (y1 >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 682 command[8] = (x2 >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 683 command[9] = (x2 >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 684 command[10] = (y2 >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 685 command[11] = (y2 >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 686 command[12] = (color >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 687 command[13] = (color >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 688 command[14] = (scale >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 689 command[15] = (scale >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 690 command[16] = (value >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 691 command[17] = (value >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 692
CaptainR 10:b959bb206e6b 693 writeCOMMAND(command, 18);
CaptainR 10:b959bb206e6b 694 getResponse(1);
CaptainR 10:b959bb206e6b 695 }
CaptainR 10:b959bb206e6b 696
CaptainR 10:b959bb206e6b 697 //**************************************************************************
CaptainR 10:b959bb206e6b 698 // The Screen Copy Paste command copies an area of a screen from xs, ys of size given
CaptainR 10:b959bb206e6b 699 // by width and height parameters and pastes it to another location determined by xd, yd.
CaptainR 10:b959bb206e6b 700 //**************************************************************************
CaptainR 10:b959bb206e6b 701 void PICASO_4DGL :: screenCopyPaste(short xs, short ys, short xd, short yd, short width, short height) {
CaptainR 10:b959bb206e6b 702
CaptainR 10:b959bb206e6b 703 char command[14] = "";
CaptainR 10:b959bb206e6b 704
CaptainR 10:b959bb206e6b 705 command[0] = (SCREEN_CP >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 706 command[1] = (SCREEN_CP >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 707 command[2] = (xs >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 708 command[3] = (xs >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 709 command[4] = (ys >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 710 command[5] = (ys >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 711 command[6] = (xd >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 712 command[7] = (xd >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 713 command[8] = (yd >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 714 command[9] = (yd >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 715 command[10] = (width >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 716 command[11] = (width >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 717 command[12] = (height >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 718 command[13] = (height >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 719
CaptainR 10:b959bb206e6b 720 writeCOMMAND(command, 14);
CaptainR 10:b959bb206e6b 721 getResponse(1);
CaptainR 10:b959bb206e6b 722 }
CaptainR 10:b959bb206e6b 723
CaptainR 10:b959bb206e6b 724 //**************************************************************************
CaptainR 10:b959bb206e6b 725 // The Bevel Shadow command changes the graphics “Draw Button” commands bevel shadow depth
CaptainR 10:b959bb206e6b 726 // value - 0 = No Bevel Shadow 1-4 = Number of Pixels Deep (Default = 3)
CaptainR 10:b959bb206e6b 727 //**************************************************************************
CaptainR 10:b959bb206e6b 728 void PICASO_4DGL :: bevelShadow(short value) {
CaptainR 10:b959bb206e6b 729
CaptainR 10:b959bb206e6b 730 char command[4] = "";
CaptainR 10:b959bb206e6b 731
CaptainR 10:b959bb206e6b 732 command[0] = (BEVEL_SHADOW >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 733 command[1] = (BEVEL_SHADOW >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 734 command[2] = (value >> (8*1)) & 0xff;
CaptainR 10:b959bb206e6b 735 command[3] = (value >> (8*0)) & 0xff;
CaptainR 10:b959bb206e6b 736
CaptainR 10:b959bb206e6b 737 writeCOMMAND(command, 4);
CaptainR 10:b959bb206e6b 738 getResponse(3);
CaptainR 10:b959bb206e6b 739 }
CaptainR 10:b959bb206e6b 740
CaptainR 10:b959bb206e6b 741
CaptainR 10:b959bb206e6b 742
CaptainR 10:b959bb206e6b 743
CaptainR 10:b959bb206e6b 744
CaptainR 10:b959bb206e6b 745
CaptainR 10:b959bb206e6b 746