Updated serial prints for debugging
Dependents: mbedica_on_yehowshua mbedica
uVGAIII_Graphics.cpp@6:58c02c38e75f, 2018-12-10 (annotated)
- Committer:
- zrussell3
- Date:
- Mon Dec 10 17:58:38 2018 +0000
- Revision:
- 6:58c02c38e75f
- Parent:
- 0:de1ab53f3480
Added checks for serial output
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ivygatech | 0:de1ab53f3480 | 1 | // |
ivygatech | 0:de1ab53f3480 | 2 | // uVGAIII is a class to drive 4D Systems TFT touch screens |
ivygatech | 0:de1ab53f3480 | 3 | // |
ivygatech | 0:de1ab53f3480 | 4 | // Copyright (C) <2010> Stephane ROCHON <stephane.rochon at free.fr> |
ivygatech | 0:de1ab53f3480 | 5 | // |
ivygatech | 0:de1ab53f3480 | 6 | // uVGAIII is free software: you can redistribute it and/or modify |
ivygatech | 0:de1ab53f3480 | 7 | // it under the terms of the GNU General Public License as published by |
ivygatech | 0:de1ab53f3480 | 8 | // the Free Software Foundation, either version 3 of the License, or |
ivygatech | 0:de1ab53f3480 | 9 | // (at your option) any later version. |
ivygatech | 0:de1ab53f3480 | 10 | // |
ivygatech | 0:de1ab53f3480 | 11 | // uVGAIII is distributed in the hope that it will be useful, |
ivygatech | 0:de1ab53f3480 | 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
ivygatech | 0:de1ab53f3480 | 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ivygatech | 0:de1ab53f3480 | 14 | // GNU General Public License for more details. |
ivygatech | 0:de1ab53f3480 | 15 | // |
ivygatech | 0:de1ab53f3480 | 16 | // You should have received a copy of the GNU General Public License |
ivygatech | 0:de1ab53f3480 | 17 | // along with uVGAIII. If not, see <http://www.gnu.org/licenses/>. |
ivygatech | 0:de1ab53f3480 | 18 | |
ivygatech | 0:de1ab53f3480 | 19 | #include "mbed.h" |
ivygatech | 0:de1ab53f3480 | 20 | #include "uVGAIII.h" |
ivygatech | 0:de1ab53f3480 | 21 | |
ivygatech | 0:de1ab53f3480 | 22 | #define ARRAY_SIZE(X) sizeof(X)/sizeof(X[0]) |
ivygatech | 0:de1ab53f3480 | 23 | |
ivygatech | 0:de1ab53f3480 | 24 | //************************************************************************** |
ivygatech | 0:de1ab53f3480 | 25 | void uVGAIII :: cls() { // clear screen |
zrussell3 | 6:58c02c38e75f | 26 | |
ivygatech | 0:de1ab53f3480 | 27 | char command[2] = ""; |
ivygatech | 0:de1ab53f3480 | 28 | command[0] = ( CLS >> 8 ) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 29 | command[1] = CLS & 0xFF; |
ivygatech | 0:de1ab53f3480 | 30 | writeCOMMAND(command, 2, 1); |
ivygatech | 0:de1ab53f3480 | 31 | |
ivygatech | 0:de1ab53f3480 | 32 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 33 | pc.printf("Clear screen completed.\n"); |
ivygatech | 0:de1ab53f3480 | 34 | #endif |
ivygatech | 0:de1ab53f3480 | 35 | } |
ivygatech | 0:de1ab53f3480 | 36 | |
ivygatech | 0:de1ab53f3480 | 37 | //**************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 38 | void uVGAIII :: change_color(int oldColor, int newColor) { // change all old color pixels to new color within the clipping window area |
ivygatech | 0:de1ab53f3480 | 39 | char command[6] = ""; |
ivygatech | 0:de1ab53f3480 | 40 | |
ivygatech | 0:de1ab53f3480 | 41 | command[0] = (CHANGECOLOR >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 42 | command[1] = CHANGECOLOR & 0xFF; |
ivygatech | 0:de1ab53f3480 | 43 | |
ivygatech | 0:de1ab53f3480 | 44 | int red5 = (oldColor >> (16 + 3)) & 0x1F; // get red on 5 bits |
ivygatech | 0:de1ab53f3480 | 45 | int green6 = (oldColor >> (8 + 2)) & 0x3F; // get green on 6 bits |
ivygatech | 0:de1ab53f3480 | 46 | int blue5 = (oldColor >> (0 + 3)) & 0x1F; // get blue on 5 bits |
ivygatech | 0:de1ab53f3480 | 47 | |
ivygatech | 0:de1ab53f3480 | 48 | command[2] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 49 | command[3] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 50 | |
ivygatech | 0:de1ab53f3480 | 51 | red5 = (newColor >> (16 + 3)) & 0x1F; // get red on 5 bits |
ivygatech | 0:de1ab53f3480 | 52 | green6 = (newColor >> (8 + 2)) & 0x3F; // get green on 6 bits |
ivygatech | 0:de1ab53f3480 | 53 | blue5 = (newColor >> (0 + 3)) & 0x1F; // get blue on 5 bits |
ivygatech | 0:de1ab53f3480 | 54 | |
ivygatech | 0:de1ab53f3480 | 55 | command[4] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 56 | command[5] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 57 | |
ivygatech | 0:de1ab53f3480 | 58 | writeCOMMAND(command, 6, 1); |
ivygatech | 0:de1ab53f3480 | 59 | |
ivygatech | 0:de1ab53f3480 | 60 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 61 | pc.printf("Change color completed.\n"); |
ivygatech | 0:de1ab53f3480 | 62 | #endif |
ivygatech | 0:de1ab53f3480 | 63 | } |
ivygatech | 0:de1ab53f3480 | 64 | |
ivygatech | 0:de1ab53f3480 | 65 | //**************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 66 | void uVGAIII :: background_color(int color) { // set screen background color |
ivygatech | 0:de1ab53f3480 | 67 | |
ivygatech | 0:de1ab53f3480 | 68 | char command[4]= ""; // input color is in 24bits like 0xRRGGBB |
ivygatech | 0:de1ab53f3480 | 69 | |
ivygatech | 0:de1ab53f3480 | 70 | command[0] = ( BCKGDCOLOR >> 8 ) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 71 | command[1] = BCKGDCOLOR & 0xFF; |
ivygatech | 0:de1ab53f3480 | 72 | |
ivygatech | 0:de1ab53f3480 | 73 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
ivygatech | 0:de1ab53f3480 | 74 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
ivygatech | 0:de1ab53f3480 | 75 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
ivygatech | 0:de1ab53f3480 | 76 | |
ivygatech | 0:de1ab53f3480 | 77 | command[2] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 78 | command[3] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 79 | |
ivygatech | 0:de1ab53f3480 | 80 | //command[2] = 0x00; |
ivygatech | 0:de1ab53f3480 | 81 | //command[3] = 0x10; |
ivygatech | 0:de1ab53f3480 | 82 | |
ivygatech | 0:de1ab53f3480 | 83 | writeCOMMAND(command, 4, 3); |
ivygatech | 0:de1ab53f3480 | 84 | |
ivygatech | 0:de1ab53f3480 | 85 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 86 | pc.printf("Set background color completed.\n"); |
ivygatech | 0:de1ab53f3480 | 87 | #endif |
ivygatech | 0:de1ab53f3480 | 88 | } |
ivygatech | 0:de1ab53f3480 | 89 | |
ivygatech | 0:de1ab53f3480 | 90 | //**************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 91 | void uVGAIII :: screen_mode(char mode) { // set the graphics orientation LANDSCAPE, LANDSCAPE_R, PORTRAIT, PORTRAIT_R |
ivygatech | 0:de1ab53f3480 | 92 | char command[4]= ""; |
ivygatech | 0:de1ab53f3480 | 93 | |
ivygatech | 0:de1ab53f3480 | 94 | command[0] = (SCREENMODE >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 95 | command[1] = SCREENMODE & 0xFF; |
ivygatech | 0:de1ab53f3480 | 96 | command[2] = 0x00; |
ivygatech | 0:de1ab53f3480 | 97 | command[3] = mode; |
ivygatech | 0:de1ab53f3480 | 98 | |
ivygatech | 0:de1ab53f3480 | 99 | switch (mode) { |
ivygatech | 0:de1ab53f3480 | 100 | case LANDSCAPE : |
ivygatech | 0:de1ab53f3480 | 101 | current_orientation = IS_LANDSCAPE; |
ivygatech | 0:de1ab53f3480 | 102 | break; |
ivygatech | 0:de1ab53f3480 | 103 | case LANDSCAPE_R : |
ivygatech | 0:de1ab53f3480 | 104 | current_orientation = IS_LANDSCAPE; |
ivygatech | 0:de1ab53f3480 | 105 | break; |
ivygatech | 0:de1ab53f3480 | 106 | case PORTRAIT : |
ivygatech | 0:de1ab53f3480 | 107 | current_orientation = IS_PORTRAIT; |
ivygatech | 0:de1ab53f3480 | 108 | break; |
ivygatech | 0:de1ab53f3480 | 109 | case PORTRAIT_R : |
ivygatech | 0:de1ab53f3480 | 110 | current_orientation = IS_PORTRAIT; |
ivygatech | 0:de1ab53f3480 | 111 | break; |
ivygatech | 0:de1ab53f3480 | 112 | } |
ivygatech | 0:de1ab53f3480 | 113 | |
ivygatech | 0:de1ab53f3480 | 114 | writeCOMMAND(command, 4, 3); |
ivygatech | 0:de1ab53f3480 | 115 | |
ivygatech | 0:de1ab53f3480 | 116 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 117 | pc.printf("Screen mode completed.\n"); |
ivygatech | 0:de1ab53f3480 | 118 | #endif |
ivygatech | 0:de1ab53f3480 | 119 | |
ivygatech | 0:de1ab53f3480 | 120 | set_font(current_font); |
ivygatech | 0:de1ab53f3480 | 121 | } |
ivygatech | 0:de1ab53f3480 | 122 | |
ivygatech | 0:de1ab53f3480 | 123 | //**************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 124 | void uVGAIII :: circle(int x, int y , int radius, int color) { // draw a circle in (x,y) |
ivygatech | 0:de1ab53f3480 | 125 | char command[10]= ""; |
ivygatech | 0:de1ab53f3480 | 126 | |
ivygatech | 0:de1ab53f3480 | 127 | command[0] = (CIRCLE >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 128 | command[1] = CIRCLE & 0xFF; |
ivygatech | 0:de1ab53f3480 | 129 | |
ivygatech | 0:de1ab53f3480 | 130 | command[2] = (x >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 131 | command[3] = x & 0xFF; |
ivygatech | 0:de1ab53f3480 | 132 | |
ivygatech | 0:de1ab53f3480 | 133 | command[4] = (y >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 134 | command[5] = y & 0xFF; |
ivygatech | 0:de1ab53f3480 | 135 | |
ivygatech | 0:de1ab53f3480 | 136 | command[6] = (radius >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 137 | command[7] = radius & 0xFF; |
ivygatech | 0:de1ab53f3480 | 138 | |
ivygatech | 0:de1ab53f3480 | 139 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
ivygatech | 0:de1ab53f3480 | 140 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
ivygatech | 0:de1ab53f3480 | 141 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
ivygatech | 0:de1ab53f3480 | 142 | |
ivygatech | 0:de1ab53f3480 | 143 | command[8] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 144 | command[9] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 145 | |
ivygatech | 0:de1ab53f3480 | 146 | writeCOMMAND(command, 10, 1); |
ivygatech | 0:de1ab53f3480 | 147 | |
ivygatech | 0:de1ab53f3480 | 148 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 149 | pc.printf("Draw circle completed.\n"); |
ivygatech | 0:de1ab53f3480 | 150 | #endif |
ivygatech | 0:de1ab53f3480 | 151 | } |
ivygatech | 0:de1ab53f3480 | 152 | |
ivygatech | 0:de1ab53f3480 | 153 | //**************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 154 | void uVGAIII :: filled_circle(int x, int y , int radius, int color) { // draw a filled circle in (x,y) |
ivygatech | 0:de1ab53f3480 | 155 | char command[10]= ""; |
ivygatech | 0:de1ab53f3480 | 156 | |
ivygatech | 0:de1ab53f3480 | 157 | command[0] = (CIRCLE_F >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 158 | command[1] = CIRCLE_F & 0xFF; |
ivygatech | 0:de1ab53f3480 | 159 | |
ivygatech | 0:de1ab53f3480 | 160 | command[2] = (x >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 161 | command[3] = x & 0xFF; |
ivygatech | 0:de1ab53f3480 | 162 | |
ivygatech | 0:de1ab53f3480 | 163 | command[4] = (y >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 164 | command[5] = y & 0xFF; |
ivygatech | 0:de1ab53f3480 | 165 | |
ivygatech | 0:de1ab53f3480 | 166 | command[6] = (radius >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 167 | command[7] = radius & 0xFF; |
ivygatech | 0:de1ab53f3480 | 168 | |
ivygatech | 0:de1ab53f3480 | 169 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
ivygatech | 0:de1ab53f3480 | 170 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
ivygatech | 0:de1ab53f3480 | 171 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
ivygatech | 0:de1ab53f3480 | 172 | |
ivygatech | 0:de1ab53f3480 | 173 | command[8] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 174 | command[9] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 175 | |
ivygatech | 0:de1ab53f3480 | 176 | writeCOMMAND(command, 10, 1); |
ivygatech | 0:de1ab53f3480 | 177 | |
ivygatech | 0:de1ab53f3480 | 178 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 179 | pc.printf("Draw filled circle completed.\n"); |
ivygatech | 0:de1ab53f3480 | 180 | #endif |
ivygatech | 0:de1ab53f3480 | 181 | } |
ivygatech | 0:de1ab53f3480 | 182 | |
ivygatech | 0:de1ab53f3480 | 183 | //**************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 184 | void uVGAIII :: triangle(int x1, int y1 , int x2, int y2, int x3, int y3, int color) { // draw a traingle |
ivygatech | 0:de1ab53f3480 | 185 | char command[16]= ""; |
ivygatech | 0:de1ab53f3480 | 186 | |
ivygatech | 0:de1ab53f3480 | 187 | command[0] = (TRIANGLE >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 188 | command[1] = TRIANGLE & 0xFF; |
ivygatech | 0:de1ab53f3480 | 189 | |
ivygatech | 0:de1ab53f3480 | 190 | command[2] = (x1 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 191 | command[3] = x1 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 192 | |
ivygatech | 0:de1ab53f3480 | 193 | command[4] = (y1 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 194 | command[5] = y1 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 195 | |
ivygatech | 0:de1ab53f3480 | 196 | command[6] = (x2 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 197 | command[7] = x2 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 198 | |
ivygatech | 0:de1ab53f3480 | 199 | command[8] = (y2 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 200 | command[9] = y2 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 201 | |
ivygatech | 0:de1ab53f3480 | 202 | command[10] = (x3 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 203 | command[11] = x3 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 204 | |
ivygatech | 0:de1ab53f3480 | 205 | command[12] = (y3 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 206 | command[13] = y3 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 207 | |
ivygatech | 0:de1ab53f3480 | 208 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
ivygatech | 0:de1ab53f3480 | 209 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
ivygatech | 0:de1ab53f3480 | 210 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
ivygatech | 0:de1ab53f3480 | 211 | |
ivygatech | 0:de1ab53f3480 | 212 | command[14] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 213 | command[15] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 214 | |
ivygatech | 0:de1ab53f3480 | 215 | writeCOMMAND(command, 16, 1); |
ivygatech | 0:de1ab53f3480 | 216 | |
ivygatech | 0:de1ab53f3480 | 217 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 218 | pc.printf("Draw triangle completed.\n"); |
ivygatech | 0:de1ab53f3480 | 219 | #endif |
ivygatech | 0:de1ab53f3480 | 220 | } |
ivygatech | 0:de1ab53f3480 | 221 | |
ivygatech | 0:de1ab53f3480 | 222 | //**************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 223 | void uVGAIII :: filled_triangle(int x1, int y1 , int x2, int y2, int x3, int y3, int color) { // draw a filled traingle |
ivygatech | 0:de1ab53f3480 | 224 | char command[16]= ""; |
ivygatech | 0:de1ab53f3480 | 225 | |
ivygatech | 0:de1ab53f3480 | 226 | command[0] = (TRIANGLE_F >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 227 | command[1] = TRIANGLE_F & 0xFF; |
ivygatech | 0:de1ab53f3480 | 228 | |
ivygatech | 0:de1ab53f3480 | 229 | command[2] = (x1 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 230 | command[3] = x1 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 231 | |
ivygatech | 0:de1ab53f3480 | 232 | command[4] = (y1 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 233 | command[5] = y1 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 234 | |
ivygatech | 0:de1ab53f3480 | 235 | command[6] = (x2 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 236 | command[7] = x2 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 237 | |
ivygatech | 0:de1ab53f3480 | 238 | command[8] = (y2 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 239 | command[9] = y2 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 240 | |
ivygatech | 0:de1ab53f3480 | 241 | command[10] = (x3 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 242 | command[11] = x3 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 243 | |
ivygatech | 0:de1ab53f3480 | 244 | command[12] = (y3 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 245 | command[13] = y3 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 246 | |
ivygatech | 0:de1ab53f3480 | 247 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
ivygatech | 0:de1ab53f3480 | 248 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
ivygatech | 0:de1ab53f3480 | 249 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
ivygatech | 0:de1ab53f3480 | 250 | |
ivygatech | 0:de1ab53f3480 | 251 | command[14] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 252 | command[15] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 253 | |
ivygatech | 0:de1ab53f3480 | 254 | writeCOMMAND(command, 16, 1); |
ivygatech | 0:de1ab53f3480 | 255 | |
ivygatech | 0:de1ab53f3480 | 256 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 257 | pc.printf("Draw filled triangle completed.\n"); |
ivygatech | 0:de1ab53f3480 | 258 | #endif |
ivygatech | 0:de1ab53f3480 | 259 | } |
ivygatech | 0:de1ab53f3480 | 260 | |
ivygatech | 0:de1ab53f3480 | 261 | //**************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 262 | void uVGAIII :: line(int x1, int y1 , int x2, int y2, int color) { // draw a line |
ivygatech | 0:de1ab53f3480 | 263 | char command[12]= ""; |
ivygatech | 0:de1ab53f3480 | 264 | |
ivygatech | 0:de1ab53f3480 | 265 | command[0] = (LINE >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 266 | command[1] = LINE & 0xFF; |
ivygatech | 0:de1ab53f3480 | 267 | |
ivygatech | 0:de1ab53f3480 | 268 | command[2] = (x1 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 269 | command[3] = x1 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 270 | |
ivygatech | 0:de1ab53f3480 | 271 | command[4] = (y1 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 272 | command[5] = y1 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 273 | |
ivygatech | 0:de1ab53f3480 | 274 | command[6] = (x2 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 275 | command[7] = x2 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 276 | |
ivygatech | 0:de1ab53f3480 | 277 | command[8] = (y2 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 278 | command[9] = y2 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 279 | |
ivygatech | 0:de1ab53f3480 | 280 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
ivygatech | 0:de1ab53f3480 | 281 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
ivygatech | 0:de1ab53f3480 | 282 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
ivygatech | 0:de1ab53f3480 | 283 | |
ivygatech | 0:de1ab53f3480 | 284 | command[10] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 285 | command[11] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 286 | |
ivygatech | 0:de1ab53f3480 | 287 | writeCOMMAND(command, 12, 1); |
ivygatech | 0:de1ab53f3480 | 288 | |
ivygatech | 0:de1ab53f3480 | 289 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 290 | pc.printf("Draw line completed.\n"); |
ivygatech | 0:de1ab53f3480 | 291 | #endif |
ivygatech | 0:de1ab53f3480 | 292 | } |
ivygatech | 0:de1ab53f3480 | 293 | |
ivygatech | 0:de1ab53f3480 | 294 | //**************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 295 | void uVGAIII :: rectangle(int x1, int y1 , int x2, int y2, int color) { // draw a rectangle |
ivygatech | 0:de1ab53f3480 | 296 | char command[12]= ""; |
ivygatech | 0:de1ab53f3480 | 297 | |
ivygatech | 0:de1ab53f3480 | 298 | command[0] = (RECTANGLE >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 299 | command[1] = RECTANGLE & 0xFF; |
ivygatech | 0:de1ab53f3480 | 300 | |
ivygatech | 0:de1ab53f3480 | 301 | command[2] = (x1 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 302 | command[3] = x1 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 303 | |
ivygatech | 0:de1ab53f3480 | 304 | command[4] = (y1 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 305 | command[5] = y1 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 306 | |
ivygatech | 0:de1ab53f3480 | 307 | command[6] = (x2 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 308 | command[7] = x2 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 309 | |
ivygatech | 0:de1ab53f3480 | 310 | command[8] = (y2 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 311 | command[9] = y2 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 312 | |
ivygatech | 0:de1ab53f3480 | 313 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
ivygatech | 0:de1ab53f3480 | 314 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
ivygatech | 0:de1ab53f3480 | 315 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
ivygatech | 0:de1ab53f3480 | 316 | |
ivygatech | 0:de1ab53f3480 | 317 | command[10] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 318 | command[11] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 319 | |
ivygatech | 0:de1ab53f3480 | 320 | writeCOMMAND(command, 12, 1); |
ivygatech | 0:de1ab53f3480 | 321 | |
ivygatech | 0:de1ab53f3480 | 322 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 323 | pc.printf("Draw rectangle completed.\n"); |
ivygatech | 0:de1ab53f3480 | 324 | #endif |
ivygatech | 0:de1ab53f3480 | 325 | } |
ivygatech | 0:de1ab53f3480 | 326 | |
ivygatech | 0:de1ab53f3480 | 327 | //**************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 328 | void uVGAIII :: filled_rectangle(int x1, int y1 , int x2, int y2, int color) { // draw a filled rectangle |
ivygatech | 0:de1ab53f3480 | 329 | char command[12]= ""; |
ivygatech | 0:de1ab53f3480 | 330 | |
ivygatech | 0:de1ab53f3480 | 331 | command[0] = (RECTANGLE_F >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 332 | command[1] = RECTANGLE_F & 0xFF; |
ivygatech | 0:de1ab53f3480 | 333 | |
ivygatech | 0:de1ab53f3480 | 334 | command[2] = (x1 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 335 | command[3] = x1 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 336 | |
ivygatech | 0:de1ab53f3480 | 337 | command[4] = (y1 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 338 | command[5] = y1 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 339 | |
ivygatech | 0:de1ab53f3480 | 340 | command[6] = (x2 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 341 | command[7] = x2 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 342 | |
ivygatech | 0:de1ab53f3480 | 343 | command[8] = (y2 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 344 | command[9] = y2 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 345 | |
ivygatech | 0:de1ab53f3480 | 346 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
ivygatech | 0:de1ab53f3480 | 347 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
ivygatech | 0:de1ab53f3480 | 348 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
ivygatech | 0:de1ab53f3480 | 349 | |
ivygatech | 0:de1ab53f3480 | 350 | command[10] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 351 | command[11] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 352 | |
ivygatech | 0:de1ab53f3480 | 353 | writeCOMMAND(command, 12, 1); |
ivygatech | 0:de1ab53f3480 | 354 | |
ivygatech | 0:de1ab53f3480 | 355 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 356 | pc.printf("Draw filled rectangle completed.\n"); |
ivygatech | 0:de1ab53f3480 | 357 | #endif |
ivygatech | 0:de1ab53f3480 | 358 | } |
ivygatech | 0:de1ab53f3480 | 359 | |
ivygatech | 0:de1ab53f3480 | 360 | //**************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 361 | void uVGAIII :: ellipse(int x, int y , int radius_x, int radius_y, int color) { // draw an ellipse |
ivygatech | 0:de1ab53f3480 | 362 | char command[12]= ""; |
ivygatech | 0:de1ab53f3480 | 363 | |
ivygatech | 0:de1ab53f3480 | 364 | command[0] = (ELLIPSE >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 365 | command[1] = ELLIPSE & 0xFF; |
ivygatech | 0:de1ab53f3480 | 366 | |
ivygatech | 0:de1ab53f3480 | 367 | command[2] = (x >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 368 | command[3] = x & 0xFF; |
ivygatech | 0:de1ab53f3480 | 369 | |
ivygatech | 0:de1ab53f3480 | 370 | command[4] = (y >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 371 | command[5] = y & 0xFF; |
ivygatech | 0:de1ab53f3480 | 372 | |
ivygatech | 0:de1ab53f3480 | 373 | command[6] = (radius_x >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 374 | command[7] = radius_x & 0xFF; |
ivygatech | 0:de1ab53f3480 | 375 | |
ivygatech | 0:de1ab53f3480 | 376 | command[8] = (radius_y >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 377 | command[9] = radius_y & 0xFF; |
ivygatech | 0:de1ab53f3480 | 378 | |
ivygatech | 0:de1ab53f3480 | 379 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
ivygatech | 0:de1ab53f3480 | 380 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
ivygatech | 0:de1ab53f3480 | 381 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
ivygatech | 0:de1ab53f3480 | 382 | |
ivygatech | 0:de1ab53f3480 | 383 | command[10] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 384 | command[11] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 385 | |
ivygatech | 0:de1ab53f3480 | 386 | writeCOMMAND(command, 12, 1); |
ivygatech | 0:de1ab53f3480 | 387 | |
ivygatech | 0:de1ab53f3480 | 388 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 389 | pc.printf("Draw ellipse completed.\n"); |
ivygatech | 0:de1ab53f3480 | 390 | #endif |
ivygatech | 0:de1ab53f3480 | 391 | } |
ivygatech | 0:de1ab53f3480 | 392 | |
ivygatech | 0:de1ab53f3480 | 393 | //**************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 394 | void uVGAIII :: filled_ellipse(int x, int y , int radius_x, int radius_y, int color) { // draw a filled ellipse |
ivygatech | 0:de1ab53f3480 | 395 | char command[12] = ""; |
ivygatech | 0:de1ab53f3480 | 396 | |
ivygatech | 0:de1ab53f3480 | 397 | command[0] = (ELLIPSE_F >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 398 | command[1] = ELLIPSE_F & 0xFF; |
ivygatech | 0:de1ab53f3480 | 399 | |
ivygatech | 0:de1ab53f3480 | 400 | command[2] = (x >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 401 | command[3] = x & 0xFF; |
ivygatech | 0:de1ab53f3480 | 402 | |
ivygatech | 0:de1ab53f3480 | 403 | command[4] = (y >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 404 | command[5] = y & 0xFF; |
ivygatech | 0:de1ab53f3480 | 405 | |
ivygatech | 0:de1ab53f3480 | 406 | command[6] = (radius_x >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 407 | command[7] = radius_x & 0xFF; |
ivygatech | 0:de1ab53f3480 | 408 | |
ivygatech | 0:de1ab53f3480 | 409 | command[8] = (radius_y >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 410 | command[9] = radius_y & 0xFF; |
ivygatech | 0:de1ab53f3480 | 411 | |
ivygatech | 0:de1ab53f3480 | 412 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
ivygatech | 0:de1ab53f3480 | 413 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
ivygatech | 0:de1ab53f3480 | 414 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
ivygatech | 0:de1ab53f3480 | 415 | |
ivygatech | 0:de1ab53f3480 | 416 | command[10] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 417 | command[11] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 418 | |
ivygatech | 0:de1ab53f3480 | 419 | writeCOMMAND(command, 12, 1); |
ivygatech | 0:de1ab53f3480 | 420 | |
ivygatech | 0:de1ab53f3480 | 421 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 422 | pc.printf("Draw filled ellipse completed.\n"); |
ivygatech | 0:de1ab53f3480 | 423 | #endif |
ivygatech | 0:de1ab53f3480 | 424 | } |
ivygatech | 0:de1ab53f3480 | 425 | |
ivygatech | 0:de1ab53f3480 | 426 | //**************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 427 | void uVGAIII :: button(int state, int x, int y, int buttoncolor, int txtcolor, int font, int txtWidth, int txtHeight, char * text) { // draw a button |
ivygatech | 0:de1ab53f3480 | 428 | char command[1000] = ""; |
ivygatech | 0:de1ab53f3480 | 429 | int size = strlen(text); |
ivygatech | 0:de1ab53f3480 | 430 | int i = 0; |
ivygatech | 0:de1ab53f3480 | 431 | |
ivygatech | 0:de1ab53f3480 | 432 | command[0] = (BUTTON >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 433 | command[1] = BUTTON & 0xFF; |
ivygatech | 0:de1ab53f3480 | 434 | |
ivygatech | 0:de1ab53f3480 | 435 | command[2] = (state >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 436 | command[3] = state & 0xFF; |
ivygatech | 0:de1ab53f3480 | 437 | |
ivygatech | 0:de1ab53f3480 | 438 | command[4] = (x >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 439 | command[5] = x & 0xFF; |
ivygatech | 0:de1ab53f3480 | 440 | |
ivygatech | 0:de1ab53f3480 | 441 | command[6] = (y >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 442 | command[7] = y & 0xFF; |
ivygatech | 0:de1ab53f3480 | 443 | |
ivygatech | 0:de1ab53f3480 | 444 | int red5 = (buttoncolor >> (16 + 3)) & 0x1F; // get red on 5 bits |
ivygatech | 0:de1ab53f3480 | 445 | int green6 = (buttoncolor >> (8 + 2)) & 0x3F; // get green on 6 bits |
ivygatech | 0:de1ab53f3480 | 446 | int blue5 = (buttoncolor >> (0 + 3)) & 0x1F; // get blue on 5 bits |
ivygatech | 0:de1ab53f3480 | 447 | |
ivygatech | 0:de1ab53f3480 | 448 | command[8] = ((red5 << 3) + (green6 >> 3)) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 449 | command[9] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 450 | |
ivygatech | 0:de1ab53f3480 | 451 | red5 = (txtcolor >> (16 + 3)) & 0x1F; // get red on 5 bits |
ivygatech | 0:de1ab53f3480 | 452 | green6 = (txtcolor >> (8 + 2)) & 0x3F; // get green on 6 bits |
ivygatech | 0:de1ab53f3480 | 453 | blue5 = (txtcolor >> (0 + 3)) & 0x1F; // get blue on 5 bits |
ivygatech | 0:de1ab53f3480 | 454 | |
ivygatech | 0:de1ab53f3480 | 455 | command[10] = ((red5 << 3) + (green6 >> 3)) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 456 | command[11] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 457 | |
ivygatech | 0:de1ab53f3480 | 458 | command[12] = (font >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 459 | command[13] = font & 0xFF; |
ivygatech | 0:de1ab53f3480 | 460 | |
ivygatech | 0:de1ab53f3480 | 461 | command[14] = (txtWidth >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 462 | command[15] = txtWidth & 0xFF; |
ivygatech | 0:de1ab53f3480 | 463 | |
ivygatech | 0:de1ab53f3480 | 464 | command[16] = (txtHeight >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 465 | command[17] = txtHeight & 0xFF; |
ivygatech | 0:de1ab53f3480 | 466 | |
ivygatech | 0:de1ab53f3480 | 467 | for (i=0; i<size; i++) command[18+i] = text[i]; |
ivygatech | 0:de1ab53f3480 | 468 | |
ivygatech | 0:de1ab53f3480 | 469 | command[18+size] = 0; |
ivygatech | 0:de1ab53f3480 | 470 | |
ivygatech | 0:de1ab53f3480 | 471 | writeCOMMAND(command, 19 + size, 1); |
ivygatech | 0:de1ab53f3480 | 472 | |
ivygatech | 0:de1ab53f3480 | 473 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 474 | pc.printf("Draw button completed.\n"); |
ivygatech | 0:de1ab53f3480 | 475 | #endif |
ivygatech | 0:de1ab53f3480 | 476 | } |
ivygatech | 0:de1ab53f3480 | 477 | |
ivygatech | 0:de1ab53f3480 | 478 | //**************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 479 | void uVGAIII :: panel(int state, int x, int y, int Width, int Height, int color) { // draw a panel |
ivygatech | 0:de1ab53f3480 | 480 | char command[14] = ""; |
ivygatech | 0:de1ab53f3480 | 481 | |
ivygatech | 0:de1ab53f3480 | 482 | command[0] = (PANEL >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 483 | command[1] = PANEL & 0xFF; |
ivygatech | 0:de1ab53f3480 | 484 | |
ivygatech | 0:de1ab53f3480 | 485 | command[2] = (state >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 486 | command[3] = state & 0xFF; |
ivygatech | 0:de1ab53f3480 | 487 | |
ivygatech | 0:de1ab53f3480 | 488 | command[4] = (x >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 489 | command[5] = x & 0xFF; |
ivygatech | 0:de1ab53f3480 | 490 | |
ivygatech | 0:de1ab53f3480 | 491 | command[6] = (y >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 492 | command[7] = y & 0xFF; |
ivygatech | 0:de1ab53f3480 | 493 | |
ivygatech | 0:de1ab53f3480 | 494 | command[8] = (Width >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 495 | command[9] = Width & 0xFF; |
ivygatech | 0:de1ab53f3480 | 496 | |
ivygatech | 0:de1ab53f3480 | 497 | command[10] = (Height >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 498 | command[11] = Height & 0xFF; |
ivygatech | 0:de1ab53f3480 | 499 | |
ivygatech | 0:de1ab53f3480 | 500 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
ivygatech | 0:de1ab53f3480 | 501 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
ivygatech | 0:de1ab53f3480 | 502 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
ivygatech | 0:de1ab53f3480 | 503 | |
ivygatech | 0:de1ab53f3480 | 504 | command[12] = ((red5 << 3) + (green6 >> 3)) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 505 | command[13] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 506 | |
ivygatech | 0:de1ab53f3480 | 507 | writeCOMMAND(command, 14, 1); |
ivygatech | 0:de1ab53f3480 | 508 | |
ivygatech | 0:de1ab53f3480 | 509 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 510 | pc.printf("Draw panel completed.\n"); |
ivygatech | 0:de1ab53f3480 | 511 | #endif |
ivygatech | 0:de1ab53f3480 | 512 | } |
ivygatech | 0:de1ab53f3480 | 513 | |
ivygatech | 0:de1ab53f3480 | 514 | //**************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 515 | void uVGAIII :: slider(char mode, int x1, int y1, int x2, int y2, int color, int scale, int value) { // draw a slider |
ivygatech | 0:de1ab53f3480 | 516 | char command[18] = ""; |
ivygatech | 0:de1ab53f3480 | 517 | |
ivygatech | 0:de1ab53f3480 | 518 | command[0] = (SLIDER >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 519 | command[1] = SLIDER & 0xFF; |
ivygatech | 0:de1ab53f3480 | 520 | |
ivygatech | 0:de1ab53f3480 | 521 | command[2] = 0x00; |
ivygatech | 0:de1ab53f3480 | 522 | command[3] = mode & 0xFF; |
ivygatech | 0:de1ab53f3480 | 523 | |
ivygatech | 0:de1ab53f3480 | 524 | command[4] = (x1 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 525 | command[5] = x1 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 526 | |
ivygatech | 0:de1ab53f3480 | 527 | command[6] = (y1 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 528 | command[7] = y1 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 529 | |
ivygatech | 0:de1ab53f3480 | 530 | command[8] = (x2 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 531 | command[9] = x2 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 532 | |
ivygatech | 0:de1ab53f3480 | 533 | command[10] = (y2 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 534 | command[11] = y2 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 535 | |
ivygatech | 0:de1ab53f3480 | 536 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
ivygatech | 0:de1ab53f3480 | 537 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
ivygatech | 0:de1ab53f3480 | 538 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
ivygatech | 0:de1ab53f3480 | 539 | |
ivygatech | 0:de1ab53f3480 | 540 | command[12] = ((red5 << 3) + (green6 >> 3)) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 541 | command[13] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 542 | |
ivygatech | 0:de1ab53f3480 | 543 | command[14] = (scale >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 544 | command[15] = scale & 0xFF; |
ivygatech | 0:de1ab53f3480 | 545 | |
ivygatech | 0:de1ab53f3480 | 546 | command[16] = (value) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 547 | command[17] = value & 0xFF; |
ivygatech | 0:de1ab53f3480 | 548 | |
ivygatech | 0:de1ab53f3480 | 549 | writeCOMMAND(command, 18, 1); |
ivygatech | 0:de1ab53f3480 | 550 | |
ivygatech | 0:de1ab53f3480 | 551 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 552 | pc.printf("Draw slider completed.\n"); |
ivygatech | 0:de1ab53f3480 | 553 | #endif |
ivygatech | 0:de1ab53f3480 | 554 | } |
ivygatech | 0:de1ab53f3480 | 555 | |
ivygatech | 0:de1ab53f3480 | 556 | //**************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 557 | void uVGAIII :: put_pixel(int x, int y, int color) { // draw a pixel |
ivygatech | 0:de1ab53f3480 | 558 | char command[8] = ""; |
ivygatech | 0:de1ab53f3480 | 559 | |
ivygatech | 0:de1ab53f3480 | 560 | command[0] = (PUTPIXEL >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 561 | command[1] = PUTPIXEL & 0xFF; |
ivygatech | 0:de1ab53f3480 | 562 | |
ivygatech | 0:de1ab53f3480 | 563 | command[2] = (x >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 564 | command[3] = x & 0xFF; |
ivygatech | 0:de1ab53f3480 | 565 | |
ivygatech | 0:de1ab53f3480 | 566 | command[4] = (y >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 567 | command[5] = y & 0xFF; |
ivygatech | 0:de1ab53f3480 | 568 | |
ivygatech | 0:de1ab53f3480 | 569 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
ivygatech | 0:de1ab53f3480 | 570 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
ivygatech | 0:de1ab53f3480 | 571 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
ivygatech | 0:de1ab53f3480 | 572 | |
ivygatech | 0:de1ab53f3480 | 573 | command[6] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 574 | command[7] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
ivygatech | 0:de1ab53f3480 | 575 | |
ivygatech | 0:de1ab53f3480 | 576 | writeCOMMAND(command, 8, 1); |
ivygatech | 0:de1ab53f3480 | 577 | |
ivygatech | 0:de1ab53f3480 | 578 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 579 | pc.printf("Put pixel completed.\n"); |
ivygatech | 0:de1ab53f3480 | 580 | #endif |
ivygatech | 0:de1ab53f3480 | 581 | } |
ivygatech | 0:de1ab53f3480 | 582 | |
ivygatech | 0:de1ab53f3480 | 583 | //****************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 584 | int uVGAIII :: read_pixel(int x, int y) { // read screen info and populate data |
ivygatech | 0:de1ab53f3480 | 585 | |
ivygatech | 0:de1ab53f3480 | 586 | char command[6]= ""; |
ivygatech | 0:de1ab53f3480 | 587 | |
ivygatech | 0:de1ab53f3480 | 588 | command[0] = (READPIXEL >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 589 | command[1] = READPIXEL & 0xFF; |
ivygatech | 0:de1ab53f3480 | 590 | |
ivygatech | 0:de1ab53f3480 | 591 | command[2] = (x >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 592 | command[3] = x & 0xFF; |
ivygatech | 0:de1ab53f3480 | 593 | |
ivygatech | 0:de1ab53f3480 | 594 | command[4] = (y >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 595 | command[5] = y & 0xFF; |
ivygatech | 0:de1ab53f3480 | 596 | |
ivygatech | 0:de1ab53f3480 | 597 | int i, temp = 0, color = 0, resp = 0; |
ivygatech | 0:de1ab53f3480 | 598 | char response[3] = ""; |
ivygatech | 0:de1ab53f3480 | 599 | |
ivygatech | 0:de1ab53f3480 | 600 | freeBUFFER(); |
ivygatech | 0:de1ab53f3480 | 601 | |
ivygatech | 0:de1ab53f3480 | 602 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 603 | pc.printf("\n"); |
ivygatech | 0:de1ab53f3480 | 604 | pc.printf("New COMMAND : 0x%02X%02X\n", command[0], command[1]); |
ivygatech | 0:de1ab53f3480 | 605 | #endif |
ivygatech | 0:de1ab53f3480 | 606 | |
ivygatech | 0:de1ab53f3480 | 607 | for (i = 0; i < 6; i++) { // send all chars to serial port |
ivygatech | 0:de1ab53f3480 | 608 | writeBYTE(command[i]); |
ivygatech | 0:de1ab53f3480 | 609 | } |
ivygatech | 0:de1ab53f3480 | 610 | |
ivygatech | 0:de1ab53f3480 | 611 | while (!_cmd.readable()) wait_ms(TEMPO); // wait for screen answer |
ivygatech | 0:de1ab53f3480 | 612 | |
ivygatech | 0:de1ab53f3480 | 613 | while (_cmd.readable() && resp < ARRAY_SIZE(response)) { |
ivygatech | 0:de1ab53f3480 | 614 | temp = _cmd.getc(); |
ivygatech | 0:de1ab53f3480 | 615 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 616 | pc.printf("Response = 0x%02X\n",int(temp)); |
ivygatech | 0:de1ab53f3480 | 617 | #endif |
ivygatech | 0:de1ab53f3480 | 618 | response[resp++] = (char)temp; |
ivygatech | 0:de1ab53f3480 | 619 | } |
ivygatech | 0:de1ab53f3480 | 620 | |
ivygatech | 0:de1ab53f3480 | 621 | color = ((response[1] << 8) + response[2]); |
ivygatech | 0:de1ab53f3480 | 622 | |
ivygatech | 0:de1ab53f3480 | 623 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 624 | pc.printf("Read pixel completed.\n"); |
ivygatech | 0:de1ab53f3480 | 625 | #endif |
ivygatech | 0:de1ab53f3480 | 626 | |
ivygatech | 0:de1ab53f3480 | 627 | return color; // WARNING : this is 16bits color, not 24bits... need to be fixed |
ivygatech | 0:de1ab53f3480 | 628 | } |
ivygatech | 0:de1ab53f3480 | 629 | |
ivygatech | 0:de1ab53f3480 | 630 | //****************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 631 | void uVGAIII :: screen_copy(int xs, int ys , int xd, int yd , int width, int height) { // copy an area of a screen from xs, ys of size given by width and height parameters and pastes it to another location determined by xd, yd |
ivygatech | 0:de1ab53f3480 | 632 | |
ivygatech | 0:de1ab53f3480 | 633 | char command[14]= ""; |
ivygatech | 0:de1ab53f3480 | 634 | |
ivygatech | 0:de1ab53f3480 | 635 | command[0] = (SCREENCOPY >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 636 | command[1] = SCREENCOPY & 0xFF; |
ivygatech | 0:de1ab53f3480 | 637 | |
ivygatech | 0:de1ab53f3480 | 638 | command[2] = (xs >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 639 | command[3] = xs & 0xFF; |
ivygatech | 0:de1ab53f3480 | 640 | |
ivygatech | 0:de1ab53f3480 | 641 | command[4] = (ys >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 642 | command[5] = ys & 0xFF; |
ivygatech | 0:de1ab53f3480 | 643 | |
ivygatech | 0:de1ab53f3480 | 644 | command[6] = (xd >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 645 | command[7] = xd & 0xFF; |
ivygatech | 0:de1ab53f3480 | 646 | |
ivygatech | 0:de1ab53f3480 | 647 | command[8] = (yd >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 648 | command[9] = yd & 0xFF; |
ivygatech | 0:de1ab53f3480 | 649 | |
ivygatech | 0:de1ab53f3480 | 650 | command[10] = (width >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 651 | command[11] = width & 0xFF; |
ivygatech | 0:de1ab53f3480 | 652 | |
ivygatech | 0:de1ab53f3480 | 653 | command[12] = (height >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 654 | command[13] = height & 0xFF; |
ivygatech | 0:de1ab53f3480 | 655 | |
ivygatech | 0:de1ab53f3480 | 656 | writeCOMMAND(command, 14, 1); |
ivygatech | 0:de1ab53f3480 | 657 | |
ivygatech | 0:de1ab53f3480 | 658 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 659 | pc.printf("Screen copy completed.\n"); |
ivygatech | 0:de1ab53f3480 | 660 | #endif |
ivygatech | 0:de1ab53f3480 | 661 | } |
ivygatech | 0:de1ab53f3480 | 662 | |
ivygatech | 0:de1ab53f3480 | 663 | //****************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 664 | void uVGAIII :: clipping(char value) { // To enable or disable the ability for Clippling to be used |
ivygatech | 0:de1ab53f3480 | 665 | char command[4] = ""; |
ivygatech | 0:de1ab53f3480 | 666 | |
ivygatech | 0:de1ab53f3480 | 667 | command[0] = (CLIPPING >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 668 | command[1] = CLIPPING & 0xFF; |
ivygatech | 0:de1ab53f3480 | 669 | |
ivygatech | 0:de1ab53f3480 | 670 | command[2] = 0x00; |
ivygatech | 0:de1ab53f3480 | 671 | command[3] = value & 0xFF; |
ivygatech | 0:de1ab53f3480 | 672 | |
ivygatech | 0:de1ab53f3480 | 673 | writeCOMMAND(command, 4, 1); |
ivygatech | 0:de1ab53f3480 | 674 | |
ivygatech | 0:de1ab53f3480 | 675 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 676 | pc.printf("Clipping completed.\n"); |
ivygatech | 0:de1ab53f3480 | 677 | #endif |
ivygatech | 0:de1ab53f3480 | 678 | } |
ivygatech | 0:de1ab53f3480 | 679 | |
ivygatech | 0:de1ab53f3480 | 680 | //****************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 681 | void uVGAIII :: set_clipping_win(int x1, int y1, int x2, int y2) { // Set the clipping window region |
ivygatech | 0:de1ab53f3480 | 682 | char command[10] = ""; |
ivygatech | 0:de1ab53f3480 | 683 | |
ivygatech | 0:de1ab53f3480 | 684 | command[0] = (SETCLIPWIN >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 685 | command[1] = SETCLIPWIN & 0xFF; |
ivygatech | 0:de1ab53f3480 | 686 | |
ivygatech | 0:de1ab53f3480 | 687 | command[2] = (x1 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 688 | command[3] = x1 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 689 | |
ivygatech | 0:de1ab53f3480 | 690 | command[4] = (y1 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 691 | command[5] = y1 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 692 | |
ivygatech | 0:de1ab53f3480 | 693 | command[6] = (x2 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 694 | command[7] = x2 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 695 | |
ivygatech | 0:de1ab53f3480 | 696 | command[8] = (y2 >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 697 | command[9] = y2 & 0xFF; |
ivygatech | 0:de1ab53f3480 | 698 | |
ivygatech | 0:de1ab53f3480 | 699 | writeCOMMAND(command, 10, 1); |
ivygatech | 0:de1ab53f3480 | 700 | |
ivygatech | 0:de1ab53f3480 | 701 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 702 | pc.printf("Set clipping window completed.\n"); |
ivygatech | 0:de1ab53f3480 | 703 | #endif |
ivygatech | 0:de1ab53f3480 | 704 | } |
ivygatech | 0:de1ab53f3480 | 705 | |
ivygatech | 0:de1ab53f3480 | 706 | //****************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 707 | void uVGAIII :: extend_clip_region() { // to force the clip region to the extent of the last text that was printed, or the last image that was shown |
ivygatech | 0:de1ab53f3480 | 708 | char command[2] = ""; |
ivygatech | 0:de1ab53f3480 | 709 | |
ivygatech | 0:de1ab53f3480 | 710 | command[0] = (EXTCLIPREG) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 711 | command[1] = EXTCLIPREG & 0xFF; |
ivygatech | 0:de1ab53f3480 | 712 | |
ivygatech | 0:de1ab53f3480 | 713 | writeCOMMAND(command, 2, 1); |
ivygatech | 0:de1ab53f3480 | 714 | |
ivygatech | 0:de1ab53f3480 | 715 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 716 | pc.printf("Extend clip region completed.\n"); |
ivygatech | 0:de1ab53f3480 | 717 | #endif |
ivygatech | 0:de1ab53f3480 | 718 | } |
ivygatech | 0:de1ab53f3480 | 719 | |
ivygatech | 0:de1ab53f3480 | 720 | //****************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 721 | void uVGAIII :: move_origin(int xpos, int ypos) { // Move the origin to a new position |
ivygatech | 0:de1ab53f3480 | 722 | char command[6] = ""; |
ivygatech | 0:de1ab53f3480 | 723 | |
ivygatech | 0:de1ab53f3480 | 724 | command[0] = (MOVEORIGIN) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 725 | command[1] = MOVEORIGIN & 0xFF; |
ivygatech | 0:de1ab53f3480 | 726 | |
ivygatech | 0:de1ab53f3480 | 727 | command[2] = (xpos >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 728 | command[3] = xpos & 0xFF; |
ivygatech | 0:de1ab53f3480 | 729 | |
ivygatech | 0:de1ab53f3480 | 730 | command[4] = (ypos >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 731 | command[5] = ypos & 0xFF; |
ivygatech | 0:de1ab53f3480 | 732 | |
ivygatech | 0:de1ab53f3480 | 733 | writeCOMMAND(command, 6, 1); |
ivygatech | 0:de1ab53f3480 | 734 | |
ivygatech | 0:de1ab53f3480 | 735 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 736 | pc.printf("Move origin completed.\n"); |
ivygatech | 0:de1ab53f3480 | 737 | #endif |
ivygatech | 0:de1ab53f3480 | 738 | } |
ivygatech | 0:de1ab53f3480 | 739 | |
ivygatech | 0:de1ab53f3480 | 740 | //****************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 741 | void uVGAIII :: line_pattern(int pattern) { // Set the line pattern |
ivygatech | 0:de1ab53f3480 | 742 | char command[4] = ""; // If set to zero means lines are solid, else each '1' bit represents a pixel that is turned off |
ivygatech | 0:de1ab53f3480 | 743 | |
ivygatech | 0:de1ab53f3480 | 744 | command[0] = (LINEPATTERN) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 745 | command[1] = LINEPATTERN & 0xFF; |
ivygatech | 0:de1ab53f3480 | 746 | |
ivygatech | 0:de1ab53f3480 | 747 | command[2] = (pattern >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 748 | command[3] = pattern & 0xFF; |
ivygatech | 0:de1ab53f3480 | 749 | |
ivygatech | 0:de1ab53f3480 | 750 | writeCOMMAND(command, 4, 3); |
ivygatech | 0:de1ab53f3480 | 751 | |
ivygatech | 0:de1ab53f3480 | 752 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 753 | pc.printf("Line pattern completed.\n"); |
ivygatech | 0:de1ab53f3480 | 754 | #endif |
ivygatech | 0:de1ab53f3480 | 755 | } |
ivygatech | 0:de1ab53f3480 | 756 | |
ivygatech | 0:de1ab53f3480 | 757 | //****************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 758 | void uVGAIII :: transparency(char mode) { // set whether to enable the transparency |
ivygatech | 0:de1ab53f3480 | 759 | char command[4] = ""; |
ivygatech | 0:de1ab53f3480 | 760 | |
ivygatech | 0:de1ab53f3480 | 761 | command[0] = (TRANSPARENCY) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 762 | command[1] = TRANSPARENCY & 0xFF; |
ivygatech | 0:de1ab53f3480 | 763 | |
ivygatech | 0:de1ab53f3480 | 764 | command[2] = 0x00; |
ivygatech | 0:de1ab53f3480 | 765 | command[3] = mode & 0xFF; |
ivygatech | 0:de1ab53f3480 | 766 | |
ivygatech | 0:de1ab53f3480 | 767 | writeCOMMAND(command, 4, 3); |
ivygatech | 0:de1ab53f3480 | 768 | |
ivygatech | 0:de1ab53f3480 | 769 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 770 | pc.printf("Transparency completed.\n"); |
ivygatech | 0:de1ab53f3480 | 771 | #endif |
ivygatech | 0:de1ab53f3480 | 772 | } |
ivygatech | 0:de1ab53f3480 | 773 | |
ivygatech | 0:de1ab53f3480 | 774 | //****************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 775 | void uVGAIII :: outline_color(int color) { // set the outline color for rectangles and circles |
ivygatech | 0:de1ab53f3480 | 776 | char command[4] = ""; |
ivygatech | 0:de1ab53f3480 | 777 | |
ivygatech | 0:de1ab53f3480 | 778 | command[0] = (OUTLINECOLOR) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 779 | command[1] = OUTLINECOLOR & 0xFF; |
ivygatech | 0:de1ab53f3480 | 780 | |
ivygatech | 0:de1ab53f3480 | 781 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
ivygatech | 0:de1ab53f3480 | 782 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
ivygatech | 0:de1ab53f3480 | 783 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
ivygatech | 0:de1ab53f3480 | 784 | |
ivygatech | 0:de1ab53f3480 | 785 | command[2] = ((red5 << 3) + (green6 >> 3)) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 786 | command[3] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 787 | |
ivygatech | 0:de1ab53f3480 | 788 | writeCOMMAND(command, 4, 3); |
ivygatech | 0:de1ab53f3480 | 789 | |
ivygatech | 0:de1ab53f3480 | 790 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 791 | pc.printf("Outline color completed.\n"); |
ivygatech | 0:de1ab53f3480 | 792 | #endif |
ivygatech | 0:de1ab53f3480 | 793 | } |
ivygatech | 0:de1ab53f3480 | 794 | |
ivygatech | 0:de1ab53f3480 | 795 | //****************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 796 | void uVGAIII :: transparent_color(int color) { // Set the color to be transparent |
ivygatech | 0:de1ab53f3480 | 797 | char command[4] = ""; |
ivygatech | 0:de1ab53f3480 | 798 | |
ivygatech | 0:de1ab53f3480 | 799 | command[0] = (TRANSPCOLOR) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 800 | command[1] = TRANSPCOLOR & 0xFF; |
ivygatech | 0:de1ab53f3480 | 801 | |
ivygatech | 0:de1ab53f3480 | 802 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
ivygatech | 0:de1ab53f3480 | 803 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
ivygatech | 0:de1ab53f3480 | 804 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
ivygatech | 0:de1ab53f3480 | 805 | |
ivygatech | 0:de1ab53f3480 | 806 | command[2] = ((red5 << 3) + (green6 >> 3)) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 807 | command[3] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 808 | |
ivygatech | 0:de1ab53f3480 | 809 | writeCOMMAND(command, 4, 3); |
ivygatech | 0:de1ab53f3480 | 810 | |
ivygatech | 0:de1ab53f3480 | 811 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 812 | pc.printf("Transparent color completed.\n"); |
ivygatech | 0:de1ab53f3480 | 813 | #endif |
ivygatech | 0:de1ab53f3480 | 814 | } |
ivygatech | 0:de1ab53f3480 | 815 | |
ivygatech | 0:de1ab53f3480 | 816 | //****************************************************************************************************** |
ivygatech | 0:de1ab53f3480 | 817 | void uVGAIII :: graphics_parameters(int function, int value) { //Set graphics parameters |
ivygatech | 0:de1ab53f3480 | 818 | char command[6] = ""; |
ivygatech | 0:de1ab53f3480 | 819 | |
ivygatech | 0:de1ab53f3480 | 820 | command[0] = (PARAMETERS >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 821 | command[1] = PARAMETERS & 0xFF; |
ivygatech | 0:de1ab53f3480 | 822 | |
ivygatech | 0:de1ab53f3480 | 823 | command[2] = (function >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 824 | command[3] = function & 0xFF; |
ivygatech | 0:de1ab53f3480 | 825 | |
ivygatech | 0:de1ab53f3480 | 826 | command[4] = (value >> 8) & 0xFF; |
ivygatech | 0:de1ab53f3480 | 827 | command[5] = value & 0xFF; |
ivygatech | 0:de1ab53f3480 | 828 | |
ivygatech | 0:de1ab53f3480 | 829 | writeCOMMAND(command, 6, 1); |
ivygatech | 0:de1ab53f3480 | 830 | |
ivygatech | 0:de1ab53f3480 | 831 | #if DEBUGMODE |
ivygatech | 0:de1ab53f3480 | 832 | pc.printf("Graphics parameters completed.\n"); |
ivygatech | 0:de1ab53f3480 | 833 | #endif |
ivygatech | 0:de1ab53f3480 | 834 | } |