Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Picaso_4DGL-32PTU_graphics.cpp@12:29f5ad896382, 2016-09-14 (annotated)
- Committer:
- CaptainR
- Date:
- Wed Sep 14 13:27:37 2016 +0000
- Revision:
- 12:29f5ad896382
- Parent:
- 11:3ebd2263f3e9
- Child:
- 15:86bdf382e6f7
a little cleanup, media init and address pointer set working; started on read and write block
Who changed what in which revision?
| User | Revision | Line number | New 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 | 11:3ebd2263f3e9 | 317 | else pc.printf("\n\r ERROR_POLYGON_FILLED: There has to be at least 3 vertices!\n\r"); |
| CaptainR | 3:dcfbceb81fef | 318 | } |
| CaptainR | 3:dcfbceb81fef | 319 | |
| CaptainR | 3:dcfbceb81fef | 320 | //************************************************************************** |
| CaptainR | 3:dcfbceb81fef | 321 | // The Draw Triangle command draws a triangle outline between vertices |
| CaptainR | 3:dcfbceb81fef | 322 | // x1,y1 , x2,y2 and x3,y3 using the specified color. |
| CaptainR | 3:dcfbceb81fef | 323 | // The line may be tessellated with the “Line Pattern” command. |
| CaptainR | 3:dcfbceb81fef | 324 | //************************************************************************** |
| CaptainR | 3:dcfbceb81fef | 325 | void PICASO_4DGL :: drawTriangle(short x1, short y1, short x2, short y2, short x3, short y3, short color) { |
| CaptainR | 3:dcfbceb81fef | 326 | |
| CaptainR | 3:dcfbceb81fef | 327 | char command[16] = ""; |
| CaptainR | 3:dcfbceb81fef | 328 | |
| CaptainR | 3:dcfbceb81fef | 329 | command[0] = (DRAW_TRIANGLE >> (8*1)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 330 | command[1] = (DRAW_TRIANGLE >> (8*0)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 331 | command[2] = (x1 >> (8*1)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 332 | command[3] = (x1 >> (8*0)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 333 | command[4] = (y1 >> (8*1)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 334 | command[5] = (y1 >> (8*0)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 335 | command[6] = (x2 >> (8*1)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 336 | command[7] = (x2 >> (8*0)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 337 | command[8] = (y2 >> (8*1)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 338 | command[9] = (y2 >> (8*0)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 339 | command[10] = (x3 >> (8*1)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 340 | command[11] = (x3 >> (8*0)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 341 | command[12] = (y3 >> (8*1)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 342 | command[13] = (y3 >> (8*0)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 343 | command[14] = (color >> (8*1)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 344 | command[15] = (color >> (8*0)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 345 | |
| CaptainR | 3:dcfbceb81fef | 346 | writeCOMMAND(command, 16); |
| CaptainR | 5:890ddd974624 | 347 | getResponse(1); |
| CaptainR | 3:dcfbceb81fef | 348 | } |
| CaptainR | 3:dcfbceb81fef | 349 | |
| CaptainR | 3:dcfbceb81fef | 350 | //************************************************************************** |
| CaptainR | 3:dcfbceb81fef | 351 | // The Draw Filled Triangle command draws a solid triangle between vertices |
| CaptainR | 3:dcfbceb81fef | 352 | // x1, y1, x2, y2 and x3, y3 using the specified color. |
| CaptainR | 3:dcfbceb81fef | 353 | //************************************************************************** |
| CaptainR | 3:dcfbceb81fef | 354 | void PICASO_4DGL :: drawFilledTriangle(short x1, short y1, short x2, short y2, short x3, short y3, short color) { |
| CaptainR | 3:dcfbceb81fef | 355 | |
| CaptainR | 3:dcfbceb81fef | 356 | char command[16] = ""; |
| CaptainR | 3:dcfbceb81fef | 357 | |
| CaptainR | 3:dcfbceb81fef | 358 | command[0] = (TRIANGLE_FILLED >> (8*1)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 359 | command[1] = (TRIANGLE_FILLED >> (8*0)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 360 | command[2] = (x1 >> (8*1)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 361 | command[3] = (x1 >> (8*0)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 362 | command[4] = (y1 >> (8*1)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 363 | command[5] = (y1 >> (8*0)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 364 | command[6] = (x2 >> (8*1)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 365 | command[7] = (x2 >> (8*0)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 366 | command[8] = (y2 >> (8*1)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 367 | command[9] = (y2 >> (8*0)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 368 | command[10] = (x3 >> (8*1)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 369 | command[11] = (x3 >> (8*0)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 370 | command[12] = (y3 >> (8*1)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 371 | command[13] = (y3 >> (8*0)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 372 | command[14] = (color >> (8*1)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 373 | command[15] = (color >> (8*0)) & 0xff; |
| CaptainR | 3:dcfbceb81fef | 374 | |
| CaptainR | 3:dcfbceb81fef | 375 | writeCOMMAND(command, 16); |
| CaptainR | 5:890ddd974624 | 376 | getResponse(1); |
| CaptainR | 3:dcfbceb81fef | 377 | } |
| CaptainR | 0:a5ef6bc3c2e8 | 378 | |
| CaptainR | 4:50511ed54ab4 | 379 | //************************************************************************** |
| CaptainR | 4:50511ed54ab4 | 380 | // The Calculate Orbit command calculates the x, y coordinates of a distant point relative |
| CaptainR | 4:50511ed54ab4 | 381 | // to the current origin, where the only known parameters are the angle and the distance |
| CaptainR | 4:50511ed54ab4 | 382 | // from the current origin. The new coordinates are calculated and then placed in the |
| CaptainR | 4:50511ed54ab4 | 383 | // destination variables Xdest and Ydest. |
| CaptainR | 4:50511ed54ab4 | 384 | //************************************************************************** |
| CaptainR | 4:50511ed54ab4 | 385 | void PICASO_4DGL :: calculateOrbit(short angle, short distance) { |
| CaptainR | 4:50511ed54ab4 | 386 | |
| CaptainR | 4:50511ed54ab4 | 387 | char command[6] = ""; |
| CaptainR | 4:50511ed54ab4 | 388 | |
| CaptainR | 4:50511ed54ab4 | 389 | command[0] = (CALCULATE_ORBIT >> (8*1)) & 0xff; |
| CaptainR | 4:50511ed54ab4 | 390 | command[1] = (CALCULATE_ORBIT >> (8*0)) & 0xff; |
| CaptainR | 4:50511ed54ab4 | 391 | command[2] = (angle >> (8*1)) & 0xff; |
| CaptainR | 4:50511ed54ab4 | 392 | command[3] = (angle >> (8*0)) & 0xff; |
| CaptainR | 4:50511ed54ab4 | 393 | command[4] = (distance >> (8*1)) & 0xff; |
| CaptainR | 4:50511ed54ab4 | 394 | command[5] = (distance >> (8*0)) & 0xff; |
| CaptainR | 4:50511ed54ab4 | 395 | |
| CaptainR | 4:50511ed54ab4 | 396 | writeCOMMAND(command, 6); |
| CaptainR | 6:a1a85f2bc04b | 397 | calculateOrbitResponse(); |
| CaptainR | 6:a1a85f2bc04b | 398 | } |
| CaptainR | 6:a1a85f2bc04b | 399 | |
| CaptainR | 6:a1a85f2bc04b | 400 | //************************************************************************** |
| CaptainR | 6:a1a85f2bc04b | 401 | // The Put Pixel command draws a pixel at position x, y using the specified color. |
| CaptainR | 6:a1a85f2bc04b | 402 | //************************************************************************** |
| CaptainR | 6:a1a85f2bc04b | 403 | void PICASO_4DGL :: putPixel(short x, short y, short color) { |
| CaptainR | 6:a1a85f2bc04b | 404 | |
| CaptainR | 6:a1a85f2bc04b | 405 | char command[8] = ""; |
| CaptainR | 6:a1a85f2bc04b | 406 | |
| CaptainR | 6:a1a85f2bc04b | 407 | command[0] = (PUT_PIXEL >> (8*1)) & 0xff; |
| CaptainR | 6:a1a85f2bc04b | 408 | command[1] = (PUT_PIXEL >> (8*0)) & 0xff; |
| CaptainR | 6:a1a85f2bc04b | 409 | command[2] = (x >> (8*1)) & 0xff; |
| CaptainR | 6:a1a85f2bc04b | 410 | command[3] = (x >> (8*0)) & 0xff; |
| CaptainR | 6:a1a85f2bc04b | 411 | command[4] = (y >> (8*1)) & 0xff; |
| CaptainR | 6:a1a85f2bc04b | 412 | command[5] = (y >> (8*0)) & 0xff; |
| CaptainR | 6:a1a85f2bc04b | 413 | command[6] = (color >> (8*1)) & 0xff; |
| CaptainR | 6:a1a85f2bc04b | 414 | command[7] = (color >> (8*0)) & 0xff; |
| CaptainR | 6:a1a85f2bc04b | 415 | |
| CaptainR | 6:a1a85f2bc04b | 416 | writeCOMMAND(command, 8); |
| CaptainR | 6:a1a85f2bc04b | 417 | getResponse(1); |
| CaptainR | 6:a1a85f2bc04b | 418 | } |
| CaptainR | 6:a1a85f2bc04b | 419 | |
| CaptainR | 6:a1a85f2bc04b | 420 | //************************************************************************** |
| CaptainR | 6:a1a85f2bc04b | 421 | // The Move Origin command moves the origin to a new position, which is suitable for |
| CaptainR | 6:a1a85f2bc04b | 422 | // specifying the location for both graphics and text. |
| CaptainR | 6:a1a85f2bc04b | 423 | //************************************************************************** |
| CaptainR | 6:a1a85f2bc04b | 424 | void PICASO_4DGL :: moveOrigin(short x, short y) { |
| CaptainR | 6:a1a85f2bc04b | 425 | |
| CaptainR | 6:a1a85f2bc04b | 426 | char command[6] = ""; |
| CaptainR | 6:a1a85f2bc04b | 427 | |
| CaptainR | 7:f064ae670553 | 428 | command[0] = (MOVE_ORIGIN >> (8*1)) & 0xff; |
| CaptainR | 7:f064ae670553 | 429 | command[1] = (MOVE_ORIGIN >> (8*0)) & 0xff; |
| CaptainR | 6:a1a85f2bc04b | 430 | command[2] = (x >> (8*1)) & 0xff; |
| CaptainR | 6:a1a85f2bc04b | 431 | command[3] = (x >> (8*0)) & 0xff; |
| CaptainR | 6:a1a85f2bc04b | 432 | command[4] = (y >> (8*1)) & 0xff; |
| CaptainR | 6:a1a85f2bc04b | 433 | command[5] = (y >> (8*0)) & 0xff; |
| CaptainR | 6:a1a85f2bc04b | 434 | |
| CaptainR | 8:b634ac9c92f8 | 435 | writeCOMMAND(command, 6); |
| CaptainR | 8:b634ac9c92f8 | 436 | getResponse(1); |
| CaptainR | 8:b634ac9c92f8 | 437 | } |
| CaptainR | 8:b634ac9c92f8 | 438 | |
| CaptainR | 8:b634ac9c92f8 | 439 | //************************************************************************** |
| CaptainR | 8:b634ac9c92f8 | 440 | // The Draw Line & Move Origin command draws a line from the current origin |
| CaptainR | 8:b634ac9c92f8 | 441 | // to a new position. The Origin is then set to the new position. |
| CaptainR | 8:b634ac9c92f8 | 442 | // The line is drawn using the current object colour, using the |
| CaptainR | 8:b634ac9c92f8 | 443 | // “Set Graphics Parameters” – “Object Colour” command. The line may be |
| CaptainR | 8:b634ac9c92f8 | 444 | // tessellated with the “Line Pattern” command. |
| CaptainR | 8:b634ac9c92f8 | 445 | // |
| CaptainR | 8:b634ac9c92f8 | 446 | // Note: this command is mostly useful with the “Calculate Orbit” command, |
| CaptainR | 8:b634ac9c92f8 | 447 | // and usually the “Draw Line” command would be used |
| CaptainR | 8:b634ac9c92f8 | 448 | //************************************************************************** |
| CaptainR | 8:b634ac9c92f8 | 449 | void PICASO_4DGL :: lineTo(short x, short y) { |
| CaptainR | 8:b634ac9c92f8 | 450 | |
| CaptainR | 8:b634ac9c92f8 | 451 | char command[6] = ""; |
| CaptainR | 8:b634ac9c92f8 | 452 | |
| CaptainR | 8:b634ac9c92f8 | 453 | command[0] = (LINE_TO >> (8*1)) & 0xff; |
| CaptainR | 8:b634ac9c92f8 | 454 | command[1] = (LINE_TO >> (8*0)) & 0xff; |
| CaptainR | 8:b634ac9c92f8 | 455 | command[2] = (x >> (8*1)) & 0xff; |
| CaptainR | 8:b634ac9c92f8 | 456 | command[3] = (x >> (8*0)) & 0xff; |
| CaptainR | 8:b634ac9c92f8 | 457 | command[4] = (y >> (8*1)) & 0xff; |
| CaptainR | 8:b634ac9c92f8 | 458 | command[5] = (y >> (8*0)) & 0xff; |
| CaptainR | 8:b634ac9c92f8 | 459 | |
| CaptainR | 8:b634ac9c92f8 | 460 | writeCOMMAND(command, 6); |
| CaptainR | 6:a1a85f2bc04b | 461 | getResponse(1); |
| CaptainR | 4:50511ed54ab4 | 462 | } |
| CaptainR | 4:50511ed54ab4 | 463 | |
| CaptainR | 9:32eb75c01e9d | 464 | //************************************************************************** |
| CaptainR | 9:32eb75c01e9d | 465 | // The Set Clip Window command specifies a clipping window region on the screen such |
| CaptainR | 9:32eb75c01e9d | 466 | // that any objects and text placed onto the screen will be clipped and displayed only |
| CaptainR | 9:32eb75c01e9d | 467 | // within that region. For the clipping window to take effect, the clipping setting must be |
| CaptainR | 9:32eb75c01e9d | 468 | // enabled separately using the “Clipping” command |
| CaptainR | 9:32eb75c01e9d | 469 | //************************************************************************** |
| CaptainR | 9:32eb75c01e9d | 470 | void PICASO_4DGL :: setClipWindow(short x1, short y1, short x2, short y2) { |
| CaptainR | 9:32eb75c01e9d | 471 | |
| CaptainR | 9:32eb75c01e9d | 472 | char command[10] = ""; |
| CaptainR | 9:32eb75c01e9d | 473 | |
| CaptainR | 9:32eb75c01e9d | 474 | command[0] = (SET_CLIP_WINDOW >> (8*1)) & 0xff; |
| CaptainR | 9:32eb75c01e9d | 475 | command[1] = (SET_CLIP_WINDOW >> (8*0)) & 0xff; |
| CaptainR | 9:32eb75c01e9d | 476 | command[2] = (x1 >> (8*1)) & 0xff; |
| CaptainR | 9:32eb75c01e9d | 477 | command[3] = (x1 >> (8*0)) & 0xff; |
| CaptainR | 9:32eb75c01e9d | 478 | command[4] = (y1 >> (8*1)) & 0xff; |
| CaptainR | 9:32eb75c01e9d | 479 | command[5] = (y1 >> (8*0)) & 0xff; |
| CaptainR | 9:32eb75c01e9d | 480 | command[6] = (x2 >> (8*1)) & 0xff; |
| CaptainR | 9:32eb75c01e9d | 481 | command[7] = (x2 >> (8*0)) & 0xff; |
| CaptainR | 9:32eb75c01e9d | 482 | command[8] = (y2 >> (8*1)) & 0xff; |
| CaptainR | 9:32eb75c01e9d | 483 | command[9] = (y2 >> (8*0)) & 0xff; |
| CaptainR | 9:32eb75c01e9d | 484 | |
| CaptainR | 9:32eb75c01e9d | 485 | writeCOMMAND(command, 10); |
| CaptainR | 9:32eb75c01e9d | 486 | getResponse(1); |
| CaptainR | 9:32eb75c01e9d | 487 | } |
| CaptainR | 4:50511ed54ab4 | 488 | |
| CaptainR | 9:32eb75c01e9d | 489 | //************************************************************************** |
| CaptainR | 9:32eb75c01e9d | 490 | // The Clipping command Enables or Disables the ability for Clipping to be used. |
| CaptainR | 9:32eb75c01e9d | 491 | // The clipping points are set with “Set Clip Window” and must be set first. |
| CaptainR | 9:32eb75c01e9d | 492 | //************************************************************************** |
| CaptainR | 9:32eb75c01e9d | 493 | void PICASO_4DGL :: clipping(short value) { |
| CaptainR | 9:32eb75c01e9d | 494 | |
| CaptainR | 9:32eb75c01e9d | 495 | char command[4] = ""; |
| CaptainR | 9:32eb75c01e9d | 496 | |
| CaptainR | 9:32eb75c01e9d | 497 | command[0] = (CLIPPING >> (8*1)) & 0xff; |
| CaptainR | 9:32eb75c01e9d | 498 | command[1] = (CLIPPING >> (8*0)) & 0xff; |
| CaptainR | 9:32eb75c01e9d | 499 | command[2] = (value >> (8*1)) & 0xff; |
| CaptainR | 9:32eb75c01e9d | 500 | command[3] = (value >> (8*0)) & 0xff; |
| CaptainR | 9:32eb75c01e9d | 501 | |
| CaptainR | 9:32eb75c01e9d | 502 | writeCOMMAND(command, 4); |
| CaptainR | 9:32eb75c01e9d | 503 | getResponse(1); |
| CaptainR | 9:32eb75c01e9d | 504 | } |
| CaptainR | 4:50511ed54ab4 | 505 | |
| CaptainR | 9:32eb75c01e9d | 506 | //************************************************************************** |
| CaptainR | 9:32eb75c01e9d | 507 | // The Extend Clip Region command forces the clip region to the extent |
| CaptainR | 9:32eb75c01e9d | 508 | // of the last text that was printed, or the last image that was shown. |
| CaptainR | 9:32eb75c01e9d | 509 | //************************************************************************** |
| CaptainR | 9:32eb75c01e9d | 510 | void PICASO_4DGL :: extendClipRegion() { |
| CaptainR | 9:32eb75c01e9d | 511 | |
| CaptainR | 9:32eb75c01e9d | 512 | char command[2] = ""; |
| CaptainR | 9:32eb75c01e9d | 513 | |
| CaptainR | 9:32eb75c01e9d | 514 | command[0] = (EXTEND_CLIP >> (8*1)) & 0xff; |
| CaptainR | 9:32eb75c01e9d | 515 | command[1] = (EXTEND_CLIP >> (8*0)) & 0xff; |
| CaptainR | 9:32eb75c01e9d | 516 | |
| CaptainR | 9:32eb75c01e9d | 517 | writeCOMMAND(command, 2); |
| CaptainR | 9:32eb75c01e9d | 518 | getResponse(1); |
| CaptainR | 9:32eb75c01e9d | 519 | } |
| CaptainR | 9:32eb75c01e9d | 520 | |
| CaptainR | 10:b959bb206e6b | 521 | //************************************************************************** |
| CaptainR | 10:b959bb206e6b | 522 | // The Draw Ellipse command plots a colored Ellipse on the screen at centre |
| CaptainR | 10:b959bb206e6b | 523 | // x, y with x-radius = xrad and y-radius = yrad. |
| CaptainR | 10:b959bb206e6b | 524 | //************************************************************************** |
| CaptainR | 10:b959bb206e6b | 525 | void PICASO_4DGL :: drawElipse(short x, short y, short xRad, short yRad, short color) { |
| CaptainR | 10:b959bb206e6b | 526 | |
| CaptainR | 10:b959bb206e6b | 527 | char command[12] = ""; |
| CaptainR | 10:b959bb206e6b | 528 | |
| CaptainR | 10:b959bb206e6b | 529 | command[0] = (DRAW_ELIPSE >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 530 | command[1] = (DRAW_ELIPSE >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 531 | command[2] = (x >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 532 | command[3] = (x >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 533 | command[4] = (y >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 534 | command[5] = (y >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 535 | command[6] = (xRad >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 536 | command[7] = (xRad >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 537 | command[8] = (yRad >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 538 | command[9] = (yRad >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 539 | command[10] = (color >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 540 | command[11] = (color >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 541 | |
| CaptainR | 10:b959bb206e6b | 542 | writeCOMMAND(command, 12); |
| CaptainR | 10:b959bb206e6b | 543 | getResponse(1); |
| CaptainR | 10:b959bb206e6b | 544 | } |
| CaptainR | 10:b959bb206e6b | 545 | |
| CaptainR | 10:b959bb206e6b | 546 | //************************************************************************** |
| CaptainR | 10:b959bb206e6b | 547 | // The Draw Filled Ellipse command plots a solid colored Ellipse on the screen at centre |
| CaptainR | 10:b959bb206e6b | 548 | // x, y with x-radius = xrad and y-radius = yrad. |
| CaptainR | 10:b959bb206e6b | 549 | //************************************************************************** |
| CaptainR | 10:b959bb206e6b | 550 | void PICASO_4DGL :: drawFilledElipse(short x, short y, short xRad, short yRad, short color) { |
| CaptainR | 10:b959bb206e6b | 551 | |
| CaptainR | 10:b959bb206e6b | 552 | char command[12] = ""; |
| CaptainR | 10:b959bb206e6b | 553 | |
| CaptainR | 10:b959bb206e6b | 554 | command[0] = (ELIPSE_FILLED >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 555 | command[1] = (ELIPSE_FILLED >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 556 | command[2] = (x >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 557 | command[3] = (x >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 558 | command[4] = (y >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 559 | command[5] = (y >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 560 | command[6] = (xRad >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 561 | command[7] = (xRad >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 562 | command[8] = (yRad >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 563 | command[9] = (yRad >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 564 | command[10] = (color >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 565 | command[11] = (color >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 566 | |
| CaptainR | 10:b959bb206e6b | 567 | writeCOMMAND(command, 12); |
| CaptainR | 10:b959bb206e6b | 568 | getResponse(1); |
| CaptainR | 10:b959bb206e6b | 569 | } |
| CaptainR | 10:b959bb206e6b | 570 | |
| CaptainR | 10:b959bb206e6b | 571 | //************************************************************************** |
| CaptainR | 10:b959bb206e6b | 572 | // The Draw Button command draws a 3 dimensional Text Button at screen location |
| CaptainR | 10:b959bb206e6b | 573 | // defined by x, y parameters (top left corner). The size of the button depends |
| CaptainR | 10:b959bb206e6b | 574 | // on the font, width, height and length of the text. The button can contain |
| CaptainR | 10:b959bb206e6b | 575 | // multiple lines of text by having the \n character embedded in the string |
| CaptainR | 10:b959bb206e6b | 576 | // for the end of line marker. In this case, the widest text in the string sets |
| CaptainR | 10:b959bb206e6b | 577 | // the overall width, and the height of the button is set by the number of |
| CaptainR | 10:b959bb206e6b | 578 | // text lines. In the case of multiple lines, each line is left justified. |
| CaptainR | 10:b959bb206e6b | 579 | // If you wish to centre or right justify the text, you will need to prepare |
| CaptainR | 10:b959bb206e6b | 580 | // the text string according to your requirements. |
| CaptainR | 10:b959bb206e6b | 581 | // |
| CaptainR | 10:b959bb206e6b | 582 | // state - Appearance of button, 0 = Button depressed; 1 = Button raised. |
| CaptainR | 10:b959bb206e6b | 583 | // x, y - Specifies the top left corner position of the button on the screen. |
| CaptainR | 10:b959bb206e6b | 584 | //************************************************************************** |
| CaptainR | 10:b959bb206e6b | 585 | 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 | 586 | |
| CaptainR | 10:b959bb206e6b | 587 | int size = 19 + (strlen(txt)); |
| CaptainR | 10:b959bb206e6b | 588 | int i, j = 18; |
| CaptainR | 10:b959bb206e6b | 589 | char command[size]; |
| CaptainR | 10:b959bb206e6b | 590 | for(i = 0; i < size; i++) command[i] = 0; |
| CaptainR | 10:b959bb206e6b | 591 | |
| CaptainR | 10:b959bb206e6b | 592 | command[0] = (DRAW_BUTTON >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 593 | command[1] = (DRAW_BUTTON >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 594 | command[2] = (state >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 595 | command[3] = (state >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 596 | command[4] = (x >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 597 | command[5] = (x >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 598 | command[6] = (y >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 599 | command[7] = (y >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 600 | command[8] = (btnColor >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 601 | command[9] = (btnColor >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 602 | command[10] = (txtColor >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 603 | command[11] = (txtColor >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 604 | command[12] = (font >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 605 | command[13] = (font >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 606 | command[14] = (txtW >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 607 | command[15] = (txtW >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 608 | command[16] = (txtH >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 609 | command[17] = (txtH >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 610 | for (i = 0; i < strlen(txt); i++) { |
| CaptainR | 10:b959bb206e6b | 611 | command[j] = txt[i]; |
| CaptainR | 10:b959bb206e6b | 612 | j++; |
| CaptainR | 10:b959bb206e6b | 613 | } |
| CaptainR | 10:b959bb206e6b | 614 | command[j] = 0; |
| CaptainR | 10:b959bb206e6b | 615 | |
| CaptainR | 10:b959bb206e6b | 616 | writeCOMMAND(command, size); |
| CaptainR | 10:b959bb206e6b | 617 | getResponse(1); |
| CaptainR | 10:b959bb206e6b | 618 | } |
| CaptainR | 10:b959bb206e6b | 619 | |
| CaptainR | 10:b959bb206e6b | 620 | //************************************************************************** |
| CaptainR | 10:b959bb206e6b | 621 | // The Draw Panel command draws a 3 dimensional rectangular panel at a screen |
| CaptainR | 10:b959bb206e6b | 622 | // location defined by x, y parameters (top left corner). The size of the panel |
| CaptainR | 10:b959bb206e6b | 623 | // is set with the width and height parameters. The colour is defined by colour. |
| CaptainR | 10:b959bb206e6b | 624 | // The state parameter determines the appearance of the panel, 0 = recessed, 1 = raised. |
| CaptainR | 10:b959bb206e6b | 625 | //************************************************************************** |
| CaptainR | 10:b959bb206e6b | 626 | void PICASO_4DGL :: drawPanel(short state, short x, short y, short width, short height, short color) { |
| CaptainR | 10:b959bb206e6b | 627 | |
| CaptainR | 10:b959bb206e6b | 628 | char command[14] = ""; |
| CaptainR | 10:b959bb206e6b | 629 | |
| CaptainR | 10:b959bb206e6b | 630 | command[0] = (DRAW_PANEL >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 631 | command[1] = (DRAW_PANEL >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 632 | command[2] = (state >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 633 | command[3] = (state >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 634 | command[4] = (x >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 635 | command[5] = (x >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 636 | command[6] = (y >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 637 | command[7] = (y >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 638 | command[8] = (width >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 639 | command[9] = (width >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 640 | command[10] = (height >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 641 | command[11] = (height >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 642 | command[12] = (color >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 643 | command[13] = (color >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 644 | |
| CaptainR | 10:b959bb206e6b | 645 | writeCOMMAND(command, 14); |
| CaptainR | 10:b959bb206e6b | 646 | getResponse(1); |
| CaptainR | 10:b959bb206e6b | 647 | } |
| CaptainR | 10:b959bb206e6b | 648 | |
| CaptainR | 10:b959bb206e6b | 649 | //************************************************************************** |
| CaptainR | 10:b959bb206e6b | 650 | // The Draw Slider command draws a vertical or horizontal slider bar on the screen. |
| CaptainR | 10:b959bb206e6b | 651 | // The Draw Slider command has several different modes of operation. |
| CaptainR | 10:b959bb206e6b | 652 | // In order to minimise the amount of graphics functions we need, all modes of operation |
| CaptainR | 10:b959bb206e6b | 653 | // are selected naturally depending on the parameter values. |
| CaptainR | 10:b959bb206e6b | 654 | // Selection rules: |
| CaptainR | 10:b959bb206e6b | 655 | // 1a) if x2-x1 > y2-y1 slider is assumed to be horizontal |
| CaptainR | 10:b959bb206e6b | 656 | // (ie: if width > height, slider is horizontal) |
| CaptainR | 10:b959bb206e6b | 657 | // 1b) if x2-x1 <= y2-y1 slider is assumed to be vertical |
| CaptainR | 10:b959bb206e6b | 658 | // (ie: if height <= width, slider is horizontal) |
| CaptainR | 10:b959bb206e6b | 659 | // 2a) If value is positive, thumb is set to the position that is the proportion |
| CaptainR | 10:b959bb206e6b | 660 | // of value to the scale parameter.(used to set the control to the actual value of a variable) |
| CaptainR | 10:b959bb206e6b | 661 | // 2b) If value is negative, thumb is driven to the graphics position set by the |
| CaptainR | 10:b959bb206e6b | 662 | // ABSolute of value. (used to set thumb to its actual graphical position (usually by touch screen) |
| CaptainR | 10:b959bb206e6b | 663 | // 3) The thumb colour is determine by the “Set Graphics Parameters” – |
| CaptainR | 10:b959bb206e6b | 664 | // “Object Colour” command, however, if the current object colour is BLACK, |
| CaptainR | 10:b959bb206e6b | 665 | // a darkened shade of the colour parameter is used for the thumb . |
| CaptainR | 10:b959bb206e6b | 666 | // |
| CaptainR | 10:b959bb206e6b | 667 | // mode - mode = 0 : Slider Indented, mode = 1 : Slider Raised, mode 2, Slider Hidden (background colour). |
| CaptainR | 10:b959bb206e6b | 668 | // Scale - scale = n : sets the full scale range of the slider for the thumb from 0 to n. |
| CaptainR | 10:b959bb206e6b | 669 | // 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 | 670 | //************************************************************************** |
| CaptainR | 10:b959bb206e6b | 671 | void PICASO_4DGL :: drawSlider(short state, short x1, short y1, short x2, short y2, short color, short scale, short value) { |
| CaptainR | 10:b959bb206e6b | 672 | |
| CaptainR | 10:b959bb206e6b | 673 | char command[18] = ""; |
| CaptainR | 10:b959bb206e6b | 674 | |
| CaptainR | 10:b959bb206e6b | 675 | command[0] = (DRAW_SLIDER >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 676 | command[1] = (DRAW_SLIDER >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 677 | command[2] = (state >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 678 | command[3] = (state >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 679 | command[4] = (x1 >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 680 | command[5] = (x1 >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 681 | command[6] = (y1 >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 682 | command[7] = (y1 >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 683 | command[8] = (x2 >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 684 | command[9] = (x2 >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 685 | command[10] = (y2 >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 686 | command[11] = (y2 >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 687 | command[12] = (color >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 688 | command[13] = (color >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 689 | command[14] = (scale >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 690 | command[15] = (scale >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 691 | command[16] = (value >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 692 | command[17] = (value >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 693 | |
| CaptainR | 10:b959bb206e6b | 694 | writeCOMMAND(command, 18); |
| CaptainR | 10:b959bb206e6b | 695 | getResponse(1); |
| CaptainR | 10:b959bb206e6b | 696 | } |
| CaptainR | 10:b959bb206e6b | 697 | |
| CaptainR | 10:b959bb206e6b | 698 | //************************************************************************** |
| CaptainR | 10:b959bb206e6b | 699 | // The Screen Copy Paste command copies an area of a screen from xs, ys of size given |
| CaptainR | 10:b959bb206e6b | 700 | // by width and height parameters and pastes it to another location determined by xd, yd. |
| CaptainR | 10:b959bb206e6b | 701 | //************************************************************************** |
| CaptainR | 10:b959bb206e6b | 702 | void PICASO_4DGL :: screenCopyPaste(short xs, short ys, short xd, short yd, short width, short height) { |
| CaptainR | 10:b959bb206e6b | 703 | |
| CaptainR | 10:b959bb206e6b | 704 | char command[14] = ""; |
| CaptainR | 10:b959bb206e6b | 705 | |
| CaptainR | 10:b959bb206e6b | 706 | command[0] = (SCREEN_CP >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 707 | command[1] = (SCREEN_CP >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 708 | command[2] = (xs >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 709 | command[3] = (xs >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 710 | command[4] = (ys >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 711 | command[5] = (ys >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 712 | command[6] = (xd >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 713 | command[7] = (xd >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 714 | command[8] = (yd >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 715 | command[9] = (yd >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 716 | command[10] = (width >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 717 | command[11] = (width >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 718 | command[12] = (height >> (8*1)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 719 | command[13] = (height >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 720 | |
| CaptainR | 10:b959bb206e6b | 721 | writeCOMMAND(command, 14); |
| CaptainR | 10:b959bb206e6b | 722 | getResponse(1); |
| CaptainR | 10:b959bb206e6b | 723 | } |
| CaptainR | 10:b959bb206e6b | 724 | |
| CaptainR | 10:b959bb206e6b | 725 | //************************************************************************** |
| CaptainR | 10:b959bb206e6b | 726 | // The Bevel Shadow command changes the graphics “Draw Button” commands bevel shadow depth |
| CaptainR | 10:b959bb206e6b | 727 | // value - 0 = No Bevel Shadow 1-4 = Number of Pixels Deep (Default = 3) |
| CaptainR | 10:b959bb206e6b | 728 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 729 | bool PICASO_4DGL :: bevelShadow(short value) { |
| CaptainR | 11:3ebd2263f3e9 | 730 | |
| CaptainR | 11:3ebd2263f3e9 | 731 | if (value <= 4) { |
| CaptainR | 11:3ebd2263f3e9 | 732 | char command[4] = ""; |
| CaptainR | 11:3ebd2263f3e9 | 733 | |
| CaptainR | 11:3ebd2263f3e9 | 734 | command[0] = (BEVEL_SHADOW >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 735 | command[1] = (BEVEL_SHADOW >> (8*0)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 736 | command[2] = (value >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 737 | command[3] = (value >> (8*0)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 738 | |
| CaptainR | 11:3ebd2263f3e9 | 739 | writeCOMMAND(command, 4); |
| CaptainR | 11:3ebd2263f3e9 | 740 | getResponse(3); |
| CaptainR | 11:3ebd2263f3e9 | 741 | return true; |
| CaptainR | 11:3ebd2263f3e9 | 742 | } |
| CaptainR | 11:3ebd2263f3e9 | 743 | else { |
| CaptainR | 11:3ebd2263f3e9 | 744 | pc.printf("\n\r ERROR_BEVEL_SHADOW: Value has to be (0 - 4)\n\r"); |
| CaptainR | 11:3ebd2263f3e9 | 745 | return false; |
| CaptainR | 11:3ebd2263f3e9 | 746 | } |
| CaptainR | 11:3ebd2263f3e9 | 747 | } |
| CaptainR | 11:3ebd2263f3e9 | 748 | |
| CaptainR | 11:3ebd2263f3e9 | 749 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 750 | // The Bevel Width command changes the graphics “Draw Button” commands bevel width |
| CaptainR | 11:3ebd2263f3e9 | 751 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 752 | bool PICASO_4DGL :: bevelWidth(short value) { |
| CaptainR | 11:3ebd2263f3e9 | 753 | |
| CaptainR | 11:3ebd2263f3e9 | 754 | if (value <= 15) { |
| CaptainR | 11:3ebd2263f3e9 | 755 | char command[4] = ""; |
| CaptainR | 11:3ebd2263f3e9 | 756 | |
| CaptainR | 11:3ebd2263f3e9 | 757 | command[0] = (BEVEL_WIDTH >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 758 | command[1] = (BEVEL_WIDTH >> (8*0)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 759 | command[2] = (value >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 760 | command[3] = (value >> (8*0)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 761 | |
| CaptainR | 11:3ebd2263f3e9 | 762 | writeCOMMAND(command, 4); |
| CaptainR | 11:3ebd2263f3e9 | 763 | getResponse(3); |
| CaptainR | 11:3ebd2263f3e9 | 764 | return true; |
| CaptainR | 11:3ebd2263f3e9 | 765 | } |
| CaptainR | 11:3ebd2263f3e9 | 766 | else { |
| CaptainR | 11:3ebd2263f3e9 | 767 | pc.printf("\n\r ERROR_BEVEL_WIDTH: Value has to be (0 - 15)\n\r"); |
| CaptainR | 11:3ebd2263f3e9 | 768 | return false; |
| CaptainR | 11:3ebd2263f3e9 | 769 | } |
| CaptainR | 11:3ebd2263f3e9 | 770 | } |
| CaptainR | 11:3ebd2263f3e9 | 771 | |
| CaptainR | 11:3ebd2263f3e9 | 772 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 773 | // The Background Colour command sets the screen background colour |
| CaptainR | 11:3ebd2263f3e9 | 774 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 775 | void PICASO_4DGL :: bgColor(short color) { |
| CaptainR | 11:3ebd2263f3e9 | 776 | |
| CaptainR | 11:3ebd2263f3e9 | 777 | char command[4] = ""; |
| CaptainR | 11:3ebd2263f3e9 | 778 | |
| CaptainR | 11:3ebd2263f3e9 | 779 | command[0] = (BG_COLOR >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 780 | command[1] = (BG_COLOR >> (8*0)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 781 | command[2] = (color >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 782 | command[3] = (color >> (8*0)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 783 | |
| CaptainR | 11:3ebd2263f3e9 | 784 | writeCOMMAND(command, 4); |
| CaptainR | 11:3ebd2263f3e9 | 785 | getResponse(3); |
| CaptainR | 11:3ebd2263f3e9 | 786 | } |
| CaptainR | 11:3ebd2263f3e9 | 787 | |
| CaptainR | 11:3ebd2263f3e9 | 788 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 789 | // The Outline Colour command sets the outline colour for rectangles and circles. |
| CaptainR | 11:3ebd2263f3e9 | 790 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 791 | void PICASO_4DGL :: outlineColor(short color) { |
| CaptainR | 10:b959bb206e6b | 792 | |
| CaptainR | 10:b959bb206e6b | 793 | char command[4] = ""; |
| CaptainR | 10:b959bb206e6b | 794 | |
| CaptainR | 11:3ebd2263f3e9 | 795 | command[0] = (OUTLINE_COLOR >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 796 | command[1] = (OUTLINE_COLOR >> (8*0)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 797 | command[2] = (color >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 798 | command[3] = (color >> (8*0)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 799 | |
| CaptainR | 11:3ebd2263f3e9 | 800 | writeCOMMAND(command, 4); |
| CaptainR | 11:3ebd2263f3e9 | 801 | getResponse(3); |
| CaptainR | 11:3ebd2263f3e9 | 802 | } |
| CaptainR | 11:3ebd2263f3e9 | 803 | |
| CaptainR | 11:3ebd2263f3e9 | 804 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 805 | // The Contrast Command sets the contrast of the display, or turns it On/Off |
| CaptainR | 11:3ebd2263f3e9 | 806 | // depending on display model |
| CaptainR | 11:3ebd2263f3e9 | 807 | // Contrast 0 = display OFF, non-zero = display ON |
| CaptainR | 11:3ebd2263f3e9 | 808 | // EXCEPTION: |
| CaptainR | 11:3ebd2263f3e9 | 809 | // uLCD-43 supports Contrast values from 1-15 and 0 to turn the Display off. |
| CaptainR | 11:3ebd2263f3e9 | 810 | // 3202X-P1 supports Contrast values from 1 to 9 and 0 to turn the Display off. |
| CaptainR | 11:3ebd2263f3e9 | 811 | // Note: Does not apply to uVGA-II/III modules. |
| CaptainR | 11:3ebd2263f3e9 | 812 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 813 | void PICASO_4DGL :: contrast(short contrast) { |
| CaptainR | 11:3ebd2263f3e9 | 814 | |
| CaptainR | 11:3ebd2263f3e9 | 815 | char command[4] = ""; |
| CaptainR | 11:3ebd2263f3e9 | 816 | |
| CaptainR | 11:3ebd2263f3e9 | 817 | command[0] = (CONTRAST >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 818 | command[1] = (CONTRAST >> (8*0)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 819 | command[2] = (contrast >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 820 | command[3] = (contrast >> (8*0)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 821 | |
| CaptainR | 11:3ebd2263f3e9 | 822 | writeCOMMAND(command, 4); |
| CaptainR | 11:3ebd2263f3e9 | 823 | getResponse(3); |
| CaptainR | 11:3ebd2263f3e9 | 824 | } |
| CaptainR | 11:3ebd2263f3e9 | 825 | |
| CaptainR | 11:3ebd2263f3e9 | 826 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 827 | // The Frame Delay command sets the inter frame delay for the “Media Video” command |
| CaptainR | 11:3ebd2263f3e9 | 828 | // 0-255 milliseconds |
| CaptainR | 11:3ebd2263f3e9 | 829 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 830 | bool PICASO_4DGL :: frameDelay(short msec) { |
| CaptainR | 11:3ebd2263f3e9 | 831 | |
| CaptainR | 11:3ebd2263f3e9 | 832 | if (msec <= 255) { |
| CaptainR | 11:3ebd2263f3e9 | 833 | char command[4] = ""; |
| CaptainR | 11:3ebd2263f3e9 | 834 | |
| CaptainR | 11:3ebd2263f3e9 | 835 | command[0] = (FRAME_DELAY >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 836 | command[1] = (FRAME_DELAY >> (8*0)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 837 | command[2] = (msec >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 838 | command[3] = (msec >> (8*0)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 839 | |
| CaptainR | 11:3ebd2263f3e9 | 840 | writeCOMMAND(command, 4); |
| CaptainR | 11:3ebd2263f3e9 | 841 | getResponse(3); |
| CaptainR | 11:3ebd2263f3e9 | 842 | return true; |
| CaptainR | 11:3ebd2263f3e9 | 843 | } |
| CaptainR | 11:3ebd2263f3e9 | 844 | else { |
| CaptainR | 11:3ebd2263f3e9 | 845 | pc.printf("\n\r ERROR_FRAME_DELAY: Value has to be (0 - 255)\n\r"); |
| CaptainR | 11:3ebd2263f3e9 | 846 | return false; |
| CaptainR | 11:3ebd2263f3e9 | 847 | } |
| CaptainR | 11:3ebd2263f3e9 | 848 | } |
| CaptainR | 11:3ebd2263f3e9 | 849 | |
| CaptainR | 11:3ebd2263f3e9 | 850 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 851 | // The Line Pattern command sets the line draw pattern for line drawing. |
| CaptainR | 11:3ebd2263f3e9 | 852 | // If set to zero, lines are solid, else each '1' bit represents a pixel |
| CaptainR | 11:3ebd2263f3e9 | 853 | // that is turned off. |
| CaptainR | 11:3ebd2263f3e9 | 854 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 855 | void PICASO_4DGL :: linePatern(short patern) { |
| CaptainR | 11:3ebd2263f3e9 | 856 | |
| CaptainR | 11:3ebd2263f3e9 | 857 | char command[4] = ""; |
| CaptainR | 11:3ebd2263f3e9 | 858 | |
| CaptainR | 11:3ebd2263f3e9 | 859 | command[0] = (LINE_PATERN >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 860 | command[1] = (LINE_PATERN >> (8*0)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 861 | command[2] = (patern >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 862 | command[3] = (patern >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 863 | |
| CaptainR | 10:b959bb206e6b | 864 | writeCOMMAND(command, 4); |
| CaptainR | 10:b959bb206e6b | 865 | getResponse(3); |
| CaptainR | 10:b959bb206e6b | 866 | } |
| CaptainR | 11:3ebd2263f3e9 | 867 | |
| CaptainR | 11:3ebd2263f3e9 | 868 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 869 | // The Screen Mode command alters the graphics orientation LANDSCAPE, |
| CaptainR | 11:3ebd2263f3e9 | 870 | // LANDSCAPE_R, PORTRAIT, PORTRAIT_R |
| CaptainR | 11:3ebd2263f3e9 | 871 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 872 | void PICASO_4DGL :: screenMode(char c) { // select screen orientation |
| CaptainR | 11:3ebd2263f3e9 | 873 | char command[4] = ""; |
| CaptainR | 11:3ebd2263f3e9 | 874 | command[0] = (ORIENTATION >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 875 | command[1] = (ORIENTATION >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 876 | |
| CaptainR | 11:3ebd2263f3e9 | 877 | switch (c) { |
| CaptainR | 11:3ebd2263f3e9 | 878 | case 1 : |
| CaptainR | 11:3ebd2263f3e9 | 879 | command[2] = (LANDSCAPE >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 880 | command[3] = (LANDSCAPE >> (8*0)) & 0xff; |
| CaptainR | 12:29f5ad896382 | 881 | currentMode = 1; |
| CaptainR | 11:3ebd2263f3e9 | 882 | break; |
| CaptainR | 11:3ebd2263f3e9 | 883 | case 2 : |
| CaptainR | 11:3ebd2263f3e9 | 884 | command[2] = (LANDSCAPE_R >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 885 | command[3] = (LANDSCAPE_R >> (8*0)) & 0xff; |
| CaptainR | 12:29f5ad896382 | 886 | currentMode = 2; |
| CaptainR | 11:3ebd2263f3e9 | 887 | break; |
| CaptainR | 11:3ebd2263f3e9 | 888 | case 3 : |
| CaptainR | 11:3ebd2263f3e9 | 889 | command[2] = (PORTRAIT >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 890 | command[3] = (PORTRAIT >> (8*0)) & 0xff; |
| CaptainR | 12:29f5ad896382 | 891 | currentMode = 3; |
| CaptainR | 11:3ebd2263f3e9 | 892 | break; |
| CaptainR | 11:3ebd2263f3e9 | 893 | case 4 : |
| CaptainR | 11:3ebd2263f3e9 | 894 | command[2] = (PORTRAIT_R >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 895 | command[3] = (PORTRAIT_R >> (8*0)) & 0xff; |
| CaptainR | 12:29f5ad896382 | 896 | currentMode = 4; |
| CaptainR | 11:3ebd2263f3e9 | 897 | break; |
| CaptainR | 11:3ebd2263f3e9 | 898 | } |
| CaptainR | 10:b959bb206e6b | 899 | |
| CaptainR | 11:3ebd2263f3e9 | 900 | writeCOMMAND(command, 4); |
| CaptainR | 11:3ebd2263f3e9 | 901 | getResponse(3); |
| CaptainR | 11:3ebd2263f3e9 | 902 | } |
| CaptainR | 11:3ebd2263f3e9 | 903 | |
| CaptainR | 11:3ebd2263f3e9 | 904 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 905 | // The Transparency command turns the transparency ON or OFF. Transparency |
| CaptainR | 11:3ebd2263f3e9 | 906 | // is automatically turned OFF after the next image or video command. |
| CaptainR | 11:3ebd2263f3e9 | 907 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 908 | void PICASO_4DGL :: transparency(short mode) { |
| CaptainR | 10:b959bb206e6b | 909 | |
| CaptainR | 11:3ebd2263f3e9 | 910 | char command[4] = ""; |
| CaptainR | 11:3ebd2263f3e9 | 911 | |
| CaptainR | 11:3ebd2263f3e9 | 912 | command[0] = (TRANSPARENCY >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 913 | command[1] = (TRANSPARENCY >> (8*0)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 914 | command[2] = (mode >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 915 | command[3] = (mode >> (8*0)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 916 | |
| CaptainR | 11:3ebd2263f3e9 | 917 | writeCOMMAND(command, 4); |
| CaptainR | 11:3ebd2263f3e9 | 918 | getResponse(3); |
| CaptainR | 11:3ebd2263f3e9 | 919 | } |
| CaptainR | 11:3ebd2263f3e9 | 920 | |
| CaptainR | 11:3ebd2263f3e9 | 921 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 922 | // The Transparent Colour command alters the colour that needs to be made transparent. |
| CaptainR | 11:3ebd2263f3e9 | 923 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 924 | void PICASO_4DGL :: transparentColor(short color) { |
| CaptainR | 11:3ebd2263f3e9 | 925 | |
| CaptainR | 11:3ebd2263f3e9 | 926 | char command[4] = ""; |
| CaptainR | 11:3ebd2263f3e9 | 927 | |
| CaptainR | 11:3ebd2263f3e9 | 928 | command[0] = (TRANSPARENT_COLOR >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 929 | command[1] = (TRANSPARENT_COLOR >> (8*0)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 930 | command[2] = (color >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 931 | command[3] = (color >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 932 | |
| CaptainR | 11:3ebd2263f3e9 | 933 | writeCOMMAND(command, 4); |
| CaptainR | 11:3ebd2263f3e9 | 934 | getResponse(3); |
| CaptainR | 11:3ebd2263f3e9 | 935 | } |
| CaptainR | 11:3ebd2263f3e9 | 936 | |
| CaptainR | 11:3ebd2263f3e9 | 937 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 938 | // Sets various graphics parameters: |
| CaptainR | 11:3ebd2263f3e9 | 939 | // Function = 18 Object Colour - Sets the Object colour used in various functions |
| CaptainR | 11:3ebd2263f3e9 | 940 | // such as Draw Slider and Draw Line & Move Origin (0 – 65535 or 0 - 0xFFFF) |
| CaptainR | 11:3ebd2263f3e9 | 941 | // |
| CaptainR | 11:3ebd2263f3e9 | 942 | // Function = 32 Screen Resolution - Set VGA Screen resolution. Applies to uVGA-II and uVGA-III only |
| CaptainR | 11:3ebd2263f3e9 | 943 | // (0 for 320x240, 1 for 640 x 480, 2 for 800 x 480) |
| CaptainR | 11:3ebd2263f3e9 | 944 | // |
| CaptainR | 11:3ebd2263f3e9 | 945 | // Function = 33 Page Display - Choose Page to be displayed. Value depends on the resolution set. |
| CaptainR | 11:3ebd2263f3e9 | 946 | // Applies to uVGA-II, uVGA-III and uLCD-43 range only. |
| CaptainR | 11:3ebd2263f3e9 | 947 | // e.g. 0-4 for 320x240 resolution on a uVGA-II and uVGA-III |
| CaptainR | 11:3ebd2263f3e9 | 948 | // |
| CaptainR | 11:3ebd2263f3e9 | 949 | // Function = 34 Page Read - Choose the Page to be read. Value depends on the resolution set. |
| CaptainR | 11:3ebd2263f3e9 | 950 | // Applies to uVGA-II, uVGA-III and uLCD-43 range only.. |
| CaptainR | 11:3ebd2263f3e9 | 951 | // e.g. 0-4 for 320x240 resolution on a uVGA-II and uVGA-III |
| CaptainR | 11:3ebd2263f3e9 | 952 | // |
| CaptainR | 11:3ebd2263f3e9 | 953 | // Function = 35 Page Write - Choose the Page to be written. 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 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 958 | void PICASO_4DGL :: setGraphics(short function, short value) { // set graphics parameters |
| CaptainR | 11:3ebd2263f3e9 | 959 | |
| CaptainR | 11:3ebd2263f3e9 | 960 | char command[6] = ""; |
| CaptainR | 10:b959bb206e6b | 961 | |
| CaptainR | 11:3ebd2263f3e9 | 962 | command[0] = (SET_GRAPHICS >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 963 | command[1] = (SET_GRAPHICS >> (8*0)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 964 | command[2] = (function >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 965 | command[3] = (function >> (8*0)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 966 | command[4] = (value >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 967 | command[5] = (value >> (8*0)) & 0xff; |
| CaptainR | 10:b959bb206e6b | 968 | |
| CaptainR | 11:3ebd2263f3e9 | 969 | writeCOMMAND(command, 6); |
| CaptainR | 11:3ebd2263f3e9 | 970 | getResponse(1); |
| CaptainR | 11:3ebd2263f3e9 | 971 | } |
| CaptainR | 11:3ebd2263f3e9 | 972 | |
| CaptainR | 11:3ebd2263f3e9 | 973 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 974 | // Returns various graphics parameters to the caller. |
| CaptainR | 11:3ebd2263f3e9 | 975 | // mode = 0 : Current orientations maximum X value (X_MAX) |
| CaptainR | 11:3ebd2263f3e9 | 976 | // mode = 1 : Current orientations maximum Y value (Y_MAX) |
| CaptainR | 11:3ebd2263f3e9 | 977 | // mode = 2 : Left location of last Object |
| CaptainR | 11:3ebd2263f3e9 | 978 | // mode = 3 : Top location of Object |
| CaptainR | 11:3ebd2263f3e9 | 979 | // mode = 4 : Right location of last Object |
| CaptainR | 11:3ebd2263f3e9 | 980 | // mode = 5 : Bottom location of Object |
| CaptainR | 11:3ebd2263f3e9 | 981 | // |
| CaptainR | 11:3ebd2263f3e9 | 982 | //************************************************************************** |
| CaptainR | 11:3ebd2263f3e9 | 983 | short PICASO_4DGL :: getGraphics(short mode) { // set graphics parameters |
| CaptainR | 11:3ebd2263f3e9 | 984 | |
| CaptainR | 11:3ebd2263f3e9 | 985 | short answer = 0; |
| CaptainR | 11:3ebd2263f3e9 | 986 | char command[4] = ""; |
| CaptainR | 11:3ebd2263f3e9 | 987 | |
| CaptainR | 11:3ebd2263f3e9 | 988 | command[0] = (GET_GRAPHICS >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 989 | command[1] = (GET_GRAPHICS >> (8*0)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 990 | command[2] = (mode >> (8*1)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 991 | command[3] = (mode >> (8*0)) & 0xff; |
| CaptainR | 11:3ebd2263f3e9 | 992 | |
| CaptainR | 11:3ebd2263f3e9 | 993 | writeCOMMAND(command, 4); |
| CaptainR | 11:3ebd2263f3e9 | 994 | answer = getGraphicsResponse(); |
| CaptainR | 11:3ebd2263f3e9 | 995 | pc.printf("\n\ranswer = %i\n\r", answer); |
| CaptainR | 11:3ebd2263f3e9 | 996 | return answer; |
| CaptainR | 11:3ebd2263f3e9 | 997 | } |
| CaptainR | 11:3ebd2263f3e9 | 998 | |
| CaptainR | 11:3ebd2263f3e9 | 999 | |
| CaptainR | 11:3ebd2263f3e9 | 1000 | |
| CaptainR | 11:3ebd2263f3e9 | 1001 | |
| CaptainR | 11:3ebd2263f3e9 | 1002 | |
| CaptainR | 11:3ebd2263f3e9 | 1003 | |
| CaptainR | 11:3ebd2263f3e9 | 1004 | |
| 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 |