ECE 2035 uLCD library
Fork of 4DGL-uLCD-SE by
uLCD_4DGL_Graphics.cpp@7:e39a44de229a, 2013-11-30 (annotated)
- Committer:
- 4180_1
- Date:
- Sat Nov 30 02:05:15 2013 +0000
- Revision:
- 7:e39a44de229a
- Parent:
- 6:b759b69cbaf9
ver1.5
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
4180_1 | 1:8b656995301f | 1 | // |
4180_1 | 6:b759b69cbaf9 | 2 | // uLCD_4DGL is a class to drive 4D Systems LCD screens |
4180_1 | 1:8b656995301f | 3 | // |
4180_1 | 1:8b656995301f | 4 | // Copyright (C) <2010> Stephane ROCHON <stephane.rochon at free.fr> |
4180_1 | 7:e39a44de229a | 5 | // Modifed for Goldelox processor <2013> Jim Hamblen |
4180_1 | 1:8b656995301f | 6 | // |
4180_1 | 1:8b656995301f | 7 | // uLCD_4DGL is free software: you can redistribute it and/or modify |
4180_1 | 1:8b656995301f | 8 | // it under the terms of the GNU General Public License as published by |
4180_1 | 1:8b656995301f | 9 | // the Free Software Foundation, either version 3 of the License, or |
4180_1 | 1:8b656995301f | 10 | // (at your option) any later version. |
4180_1 | 1:8b656995301f | 11 | // |
4180_1 | 1:8b656995301f | 12 | // uLCD_4DGL is distributed in the hope that it will be useful, |
4180_1 | 1:8b656995301f | 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
4180_1 | 1:8b656995301f | 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4180_1 | 1:8b656995301f | 15 | // GNU General Public License for more details. |
4180_1 | 1:8b656995301f | 16 | // |
4180_1 | 1:8b656995301f | 17 | // You should have received a copy of the GNU General Public License |
4180_1 | 1:8b656995301f | 18 | // along with uLCD_4DGL. If not, see <http://www.gnu.org/licenses/>. |
4180_1 | 1:8b656995301f | 19 | |
4180_1 | 1:8b656995301f | 20 | #include "mbed.h" |
4180_1 | 1:8b656995301f | 21 | #include "uLCD_4DGL.h" |
4180_1 | 1:8b656995301f | 22 | |
4180_1 | 1:8b656995301f | 23 | #define ARRAY_SIZE(X) sizeof(X)/sizeof(X[0]) |
4180_1 | 1:8b656995301f | 24 | |
4180_1 | 1:8b656995301f | 25 | //**************************************************************************************************** |
4180_1 | 3:9ba47197d94f | 26 | void uLCD_4DGL :: circle(int x, int y , int radius, int color) // draw a circle in (x,y) |
4180_1 | 3:9ba47197d94f | 27 | { |
4180_1 | 1:8b656995301f | 28 | char command[9]= ""; |
4180_1 | 1:8b656995301f | 29 | |
4180_1 | 1:8b656995301f | 30 | command[0] = CIRCLE; |
4180_1 | 1:8b656995301f | 31 | |
4180_1 | 1:8b656995301f | 32 | command[1] = (x >> 8) & 0xFF; |
4180_1 | 1:8b656995301f | 33 | command[2] = x & 0xFF; |
4180_1 | 1:8b656995301f | 34 | |
4180_1 | 1:8b656995301f | 35 | command[3] = (y >> 8) & 0xFF; |
4180_1 | 1:8b656995301f | 36 | command[4] = y & 0xFF; |
4180_1 | 1:8b656995301f | 37 | |
4180_1 | 1:8b656995301f | 38 | command[5] = (radius >> 8) & 0xFF; |
4180_1 | 1:8b656995301f | 39 | command[6] = radius & 0xFF; |
4180_1 | 1:8b656995301f | 40 | |
4180_1 | 1:8b656995301f | 41 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
4180_1 | 1:8b656995301f | 42 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
4180_1 | 1:8b656995301f | 43 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
4180_1 | 1:8b656995301f | 44 | |
4180_1 | 1:8b656995301f | 45 | command[7] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
4180_1 | 1:8b656995301f | 46 | command[8] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
4180_1 | 1:8b656995301f | 47 | |
4180_1 | 1:8b656995301f | 48 | writeCOMMAND(command, 9); |
4180_1 | 1:8b656995301f | 49 | } |
4180_1 | 7:e39a44de229a | 50 | //**************************************************************************************************** |
4180_1 | 7:e39a44de229a | 51 | void uLCD_4DGL :: filled_circle(int x, int y , int radius, int color) // draw a circle in (x,y) |
4180_1 | 7:e39a44de229a | 52 | { |
4180_1 | 7:e39a44de229a | 53 | char command[9]= ""; |
4180_1 | 7:e39a44de229a | 54 | |
4180_1 | 7:e39a44de229a | 55 | command[0] = FCIRCLE; |
4180_1 | 7:e39a44de229a | 56 | |
4180_1 | 7:e39a44de229a | 57 | command[1] = (x >> 8) & 0xFF; |
4180_1 | 7:e39a44de229a | 58 | command[2] = x & 0xFF; |
4180_1 | 7:e39a44de229a | 59 | |
4180_1 | 7:e39a44de229a | 60 | command[3] = (y >> 8) & 0xFF; |
4180_1 | 7:e39a44de229a | 61 | command[4] = y & 0xFF; |
4180_1 | 7:e39a44de229a | 62 | |
4180_1 | 7:e39a44de229a | 63 | command[5] = (radius >> 8) & 0xFF; |
4180_1 | 7:e39a44de229a | 64 | command[6] = radius & 0xFF; |
4180_1 | 7:e39a44de229a | 65 | |
4180_1 | 7:e39a44de229a | 66 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
4180_1 | 7:e39a44de229a | 67 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
4180_1 | 7:e39a44de229a | 68 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
4180_1 | 7:e39a44de229a | 69 | |
4180_1 | 7:e39a44de229a | 70 | command[7] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
4180_1 | 7:e39a44de229a | 71 | command[8] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
4180_1 | 7:e39a44de229a | 72 | |
4180_1 | 7:e39a44de229a | 73 | writeCOMMAND(command, 9); |
4180_1 | 7:e39a44de229a | 74 | } |
4180_1 | 1:8b656995301f | 75 | |
4180_1 | 1:8b656995301f | 76 | //**************************************************************************************************** |
4180_1 | 3:9ba47197d94f | 77 | void uLCD_4DGL :: triangle(int x1, int y1 , int x2, int y2, int x3, int y3, int color) // draw a traingle |
4180_1 | 3:9ba47197d94f | 78 | { |
4180_1 | 1:8b656995301f | 79 | char command[15]= ""; |
4180_1 | 1:8b656995301f | 80 | |
4180_1 | 1:8b656995301f | 81 | command[0] = TRIANGLE; |
4180_1 | 1:8b656995301f | 82 | |
4180_1 | 1:8b656995301f | 83 | command[1] = (x1 >> 8) & 0xFF; |
4180_1 | 1:8b656995301f | 84 | command[2] = x1 & 0xFF; |
4180_1 | 1:8b656995301f | 85 | |
4180_1 | 1:8b656995301f | 86 | command[3] = (y1 >> 8) & 0xFF; |
4180_1 | 1:8b656995301f | 87 | command[4] = y1 & 0xFF; |
4180_1 | 1:8b656995301f | 88 | |
4180_1 | 1:8b656995301f | 89 | command[5] = (x2 >> 8) & 0xFF; |
4180_1 | 1:8b656995301f | 90 | command[6] = x2 & 0xFF; |
4180_1 | 1:8b656995301f | 91 | |
4180_1 | 1:8b656995301f | 92 | command[7] = (y2 >> 8) & 0xFF; |
4180_1 | 1:8b656995301f | 93 | command[8] = y2 & 0xFF; |
4180_1 | 1:8b656995301f | 94 | |
4180_1 | 1:8b656995301f | 95 | command[9] = (x3 >> 8) & 0xFF; |
4180_1 | 1:8b656995301f | 96 | command[10] = x3 & 0xFF; |
4180_1 | 1:8b656995301f | 97 | |
4180_1 | 1:8b656995301f | 98 | command[11] = (y3 >> 8) & 0xFF; |
4180_1 | 1:8b656995301f | 99 | command[12] = y3 & 0xFF; |
4180_1 | 1:8b656995301f | 100 | |
4180_1 | 1:8b656995301f | 101 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
4180_1 | 1:8b656995301f | 102 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
4180_1 | 1:8b656995301f | 103 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
4180_1 | 1:8b656995301f | 104 | |
4180_1 | 1:8b656995301f | 105 | command[13] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
4180_1 | 1:8b656995301f | 106 | command[14] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
4180_1 | 1:8b656995301f | 107 | |
4180_1 | 1:8b656995301f | 108 | writeCOMMAND(command, 15); |
4180_1 | 1:8b656995301f | 109 | } |
4180_1 | 1:8b656995301f | 110 | |
4180_1 | 1:8b656995301f | 111 | //**************************************************************************************************** |
4180_1 | 3:9ba47197d94f | 112 | void uLCD_4DGL :: line(int x1, int y1 , int x2, int y2, int color) // draw a line |
4180_1 | 3:9ba47197d94f | 113 | { |
4180_1 | 1:8b656995301f | 114 | char command[11]= ""; |
4180_1 | 1:8b656995301f | 115 | |
4180_1 | 1:8b656995301f | 116 | command[0] = LINE; |
4180_1 | 1:8b656995301f | 117 | |
4180_1 | 1:8b656995301f | 118 | command[1] = (x1 >> 8) & 0xFF; |
4180_1 | 1:8b656995301f | 119 | command[2] = x1 & 0xFF; |
4180_1 | 1:8b656995301f | 120 | |
4180_1 | 1:8b656995301f | 121 | command[3] = (y1 >> 8) & 0xFF; |
4180_1 | 1:8b656995301f | 122 | command[4] = y1 & 0xFF; |
4180_1 | 1:8b656995301f | 123 | |
4180_1 | 1:8b656995301f | 124 | command[5] = (x2 >> 8) & 0xFF; |
4180_1 | 1:8b656995301f | 125 | command[6] = x2 & 0xFF; |
4180_1 | 1:8b656995301f | 126 | |
4180_1 | 1:8b656995301f | 127 | command[7] = (y2 >> 8) & 0xFF; |
4180_1 | 1:8b656995301f | 128 | command[8] = y2 & 0xFF; |
4180_1 | 1:8b656995301f | 129 | |
4180_1 | 1:8b656995301f | 130 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
4180_1 | 1:8b656995301f | 131 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
4180_1 | 1:8b656995301f | 132 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
4180_1 | 1:8b656995301f | 133 | |
4180_1 | 1:8b656995301f | 134 | command[9] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
4180_1 | 1:8b656995301f | 135 | command[10] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
4180_1 | 1:8b656995301f | 136 | |
4180_1 | 1:8b656995301f | 137 | writeCOMMAND(command, 11); |
4180_1 | 1:8b656995301f | 138 | } |
4180_1 | 1:8b656995301f | 139 | |
4180_1 | 1:8b656995301f | 140 | //**************************************************************************************************** |
4180_1 | 3:9ba47197d94f | 141 | void uLCD_4DGL :: rectangle(int x1, int y1 , int x2, int y2, int color) // draw a rectangle |
4180_1 | 3:9ba47197d94f | 142 | { |
4180_1 | 1:8b656995301f | 143 | char command[11]= ""; |
4180_1 | 1:8b656995301f | 144 | |
4180_1 | 1:8b656995301f | 145 | command[0] = RECTANGLE; |
4180_1 | 1:8b656995301f | 146 | |
4180_1 | 1:8b656995301f | 147 | command[1] = (x1 >> 8) & 0xFF; |
4180_1 | 1:8b656995301f | 148 | command[2] = x1 & 0xFF; |
4180_1 | 1:8b656995301f | 149 | |
4180_1 | 1:8b656995301f | 150 | command[3] = (y1 >> 8) & 0xFF; |
4180_1 | 1:8b656995301f | 151 | command[4] = y1 & 0xFF; |
4180_1 | 1:8b656995301f | 152 | |
4180_1 | 1:8b656995301f | 153 | command[5] = (x2 >> 8) & 0xFF; |
4180_1 | 1:8b656995301f | 154 | command[6] = x2 & 0xFF; |
4180_1 | 1:8b656995301f | 155 | |
4180_1 | 1:8b656995301f | 156 | command[7] = (y2 >> 8) & 0xFF; |
4180_1 | 1:8b656995301f | 157 | command[8] = y2 & 0xFF; |
4180_1 | 1:8b656995301f | 158 | |
4180_1 | 1:8b656995301f | 159 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
4180_1 | 1:8b656995301f | 160 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
4180_1 | 1:8b656995301f | 161 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
4180_1 | 1:8b656995301f | 162 | |
4180_1 | 1:8b656995301f | 163 | command[9] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
4180_1 | 1:8b656995301f | 164 | command[10] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
4180_1 | 1:8b656995301f | 165 | |
4180_1 | 1:8b656995301f | 166 | writeCOMMAND(command, 11); |
4180_1 | 1:8b656995301f | 167 | } |
4180_1 | 1:8b656995301f | 168 | |
4180_1 | 1:8b656995301f | 169 | //**************************************************************************************************** |
4180_1 | 7:e39a44de229a | 170 | void uLCD_4DGL :: filled_rectangle(int x1, int y1 , int x2, int y2, int color) // draw a rectangle |
4180_1 | 3:9ba47197d94f | 171 | { |
4180_1 | 1:8b656995301f | 172 | char command[11]= ""; |
4180_1 | 1:8b656995301f | 173 | |
4180_1 | 7:e39a44de229a | 174 | command[0] = FRECTANGLE; |
4180_1 | 1:8b656995301f | 175 | |
4180_1 | 7:e39a44de229a | 176 | command[1] = (x1 >> 8) & 0xFF; |
4180_1 | 7:e39a44de229a | 177 | command[2] = x1 & 0xFF; |
4180_1 | 1:8b656995301f | 178 | |
4180_1 | 7:e39a44de229a | 179 | command[3] = (y1 >> 8) & 0xFF; |
4180_1 | 7:e39a44de229a | 180 | command[4] = y1 & 0xFF; |
4180_1 | 1:8b656995301f | 181 | |
4180_1 | 7:e39a44de229a | 182 | command[5] = (x2 >> 8) & 0xFF; |
4180_1 | 7:e39a44de229a | 183 | command[6] = x2 & 0xFF; |
4180_1 | 1:8b656995301f | 184 | |
4180_1 | 7:e39a44de229a | 185 | command[7] = (y2 >> 8) & 0xFF; |
4180_1 | 7:e39a44de229a | 186 | command[8] = y2 & 0xFF; |
4180_1 | 1:8b656995301f | 187 | |
4180_1 | 1:8b656995301f | 188 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
4180_1 | 1:8b656995301f | 189 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
4180_1 | 1:8b656995301f | 190 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
4180_1 | 1:8b656995301f | 191 | |
4180_1 | 1:8b656995301f | 192 | command[9] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
4180_1 | 1:8b656995301f | 193 | command[10] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
4180_1 | 1:8b656995301f | 194 | |
4180_1 | 1:8b656995301f | 195 | writeCOMMAND(command, 11); |
4180_1 | 1:8b656995301f | 196 | } |
4180_1 | 1:8b656995301f | 197 | |
4180_1 | 7:e39a44de229a | 198 | |
4180_1 | 7:e39a44de229a | 199 | |
4180_1 | 1:8b656995301f | 200 | //**************************************************************************************************** |
4180_1 | 3:9ba47197d94f | 201 | void uLCD_4DGL :: pixel(int x, int y, int color) // draw a pixel |
4180_1 | 3:9ba47197d94f | 202 | { |
4180_1 | 1:8b656995301f | 203 | char command[7]= ""; |
4180_1 | 1:8b656995301f | 204 | |
4180_1 | 1:8b656995301f | 205 | command[0] = PIXEL; |
4180_1 | 1:8b656995301f | 206 | |
4180_1 | 1:8b656995301f | 207 | command[1] = (x >> 8) & 0xFF; |
4180_1 | 1:8b656995301f | 208 | command[2] = x & 0xFF; |
4180_1 | 1:8b656995301f | 209 | |
4180_1 | 1:8b656995301f | 210 | command[3] = (y >> 8) & 0xFF; |
4180_1 | 1:8b656995301f | 211 | command[4] = y & 0xFF; |
4180_1 | 1:8b656995301f | 212 | |
4180_1 | 1:8b656995301f | 213 | int red5 = (color >> (16 + 3)) & 0x1F; // get red on 5 bits |
4180_1 | 1:8b656995301f | 214 | int green6 = (color >> (8 + 2)) & 0x3F; // get green on 6 bits |
4180_1 | 1:8b656995301f | 215 | int blue5 = (color >> (0 + 3)) & 0x1F; // get blue on 5 bits |
4180_1 | 1:8b656995301f | 216 | |
4180_1 | 1:8b656995301f | 217 | command[5] = ((red5 << 3) + (green6 >> 3)) & 0xFF; // first part of 16 bits color |
4180_1 | 1:8b656995301f | 218 | command[6] = ((green6 << 5) + (blue5 >> 0)) & 0xFF; // second part of 16 bits color |
4180_1 | 1:8b656995301f | 219 | |
4180_1 | 1:8b656995301f | 220 | writeCOMMAND(command, 7); |
4180_1 | 1:8b656995301f | 221 | } |
4180_1 | 3:9ba47197d94f | 222 | //**************************************************************************************************** |
4180_1 | 3:9ba47197d94f | 223 | void uLCD_4DGL :: BLIT(int x, int y, int w, int h, int *colors) // draw a block of pixels |
4180_1 | 3:9ba47197d94f | 224 | { |
4180_1 | 3:9ba47197d94f | 225 | int red5, green6, blue5; |
4180_1 | 7:e39a44de229a | 226 | writeBYTEfast('\x00'); |
4180_1 | 7:e39a44de229a | 227 | writeBYTEfast(BLITCOM); |
4180_1 | 7:e39a44de229a | 228 | writeBYTEfast((x >> 8) & 0xFF); |
4180_1 | 7:e39a44de229a | 229 | writeBYTEfast(x & 0xFF); |
4180_1 | 7:e39a44de229a | 230 | writeBYTEfast((y >> 8) & 0xFF); |
4180_1 | 7:e39a44de229a | 231 | writeBYTEfast(y & 0xFF); |
4180_1 | 7:e39a44de229a | 232 | writeBYTEfast((w >> 8) & 0xFF); |
4180_1 | 3:9ba47197d94f | 233 | writeBYTE(w & 0xFF); |
4180_1 | 3:9ba47197d94f | 234 | writeBYTE((h >> 8) & 0xFF); |
4180_1 | 3:9ba47197d94f | 235 | writeBYTE(h & 0xFF); |
4180_1 | 4:74df7fc26fef | 236 | wait_ms(1); |
4180_1 | 3:9ba47197d94f | 237 | for (int i=0; i<w*h; i++) { |
4180_1 | 3:9ba47197d94f | 238 | red5 = (colors[i] >> (16 + 3)) & 0x1F; // get red on 5 bits |
4180_1 | 3:9ba47197d94f | 239 | green6 = (colors[i] >> (8 + 2)) & 0x3F; // get green on 6 bits |
4180_1 | 3:9ba47197d94f | 240 | blue5 = (colors[i] >> (0 + 3)) & 0x1F; // get blue on 5 bits |
4180_1 | 4:74df7fc26fef | 241 | writeBYTEfast(((red5 << 3) + (green6 >> 3)) & 0xFF); // first part of 16 bits color |
4180_1 | 4:74df7fc26fef | 242 | writeBYTEfast(((green6 << 5) + (blue5 >> 0)) & 0xFF); // second part of 16 bits color |
4180_1 | 3:9ba47197d94f | 243 | } |
4180_1 | 3:9ba47197d94f | 244 | int resp=0; |
4180_1 | 3:9ba47197d94f | 245 | while (!_cmd.readable()) wait_ms(TEMPO); // wait for screen answer |
4180_1 | 3:9ba47197d94f | 246 | if (_cmd.readable()) resp = _cmd.getc(); // read response if any |
4180_1 | 3:9ba47197d94f | 247 | switch (resp) { |
4180_1 | 3:9ba47197d94f | 248 | case ACK : // if OK return 1 |
4180_1 | 3:9ba47197d94f | 249 | resp = 1; |
4180_1 | 3:9ba47197d94f | 250 | break; |
4180_1 | 3:9ba47197d94f | 251 | case NAK : // if NOK return -1 |
4180_1 | 3:9ba47197d94f | 252 | resp = -1; |
4180_1 | 3:9ba47197d94f | 253 | break; |
4180_1 | 3:9ba47197d94f | 254 | default : |
4180_1 | 3:9ba47197d94f | 255 | resp = 0; // else return 0 |
4180_1 | 3:9ba47197d94f | 256 | break; |
4180_1 | 3:9ba47197d94f | 257 | } |
4180_1 | 3:9ba47197d94f | 258 | #if DEBUGMODE |
4180_1 | 3:9ba47197d94f | 259 | pc.printf(" Answer received : %d\n",resp); |
4180_1 | 3:9ba47197d94f | 260 | #endif |
4180_1 | 1:8b656995301f | 261 | |
4180_1 | 3:9ba47197d94f | 262 | } |
4180_1 | 1:8b656995301f | 263 | //****************************************************************************************************** |
4180_1 | 3:9ba47197d94f | 264 | int uLCD_4DGL :: read_pixel(int x, int y) // read screen info and populate data |
4180_1 | 3:9ba47197d94f | 265 | { |
4180_1 | 1:8b656995301f | 266 | |
4180_1 | 1:8b656995301f | 267 | char command[6]= ""; |
4180_1 | 1:8b656995301f | 268 | command[0] = 0xFF; |
4180_1 | 1:8b656995301f | 269 | command[1] = READPIXEL; |
4180_1 | 1:8b656995301f | 270 | |
4180_1 | 1:8b656995301f | 271 | command[2] = (x >> 8) & 0xFF; |
4180_1 | 1:8b656995301f | 272 | command[3] = x & 0xFF; |
4180_1 | 1:8b656995301f | 273 | |
4180_1 | 1:8b656995301f | 274 | command[4] = (y >> 8) & 0xFF; |
4180_1 | 1:8b656995301f | 275 | command[5] = y & 0xFF; |
4180_1 | 1:8b656995301f | 276 | |
4180_1 | 1:8b656995301f | 277 | int i, temp = 0, color = 0, resp = 0; |
4180_1 | 1:8b656995301f | 278 | char response[2] = ""; |
4180_1 | 1:8b656995301f | 279 | |
4180_1 | 1:8b656995301f | 280 | freeBUFFER(); |
4180_1 | 1:8b656995301f | 281 | |
4180_1 | 1:8b656995301f | 282 | for (i = 0; i < 6; i++) { // send all chars to serial port |
4180_1 | 1:8b656995301f | 283 | writeBYTE(command[i]); |
4180_1 | 1:8b656995301f | 284 | } |
4180_1 | 1:8b656995301f | 285 | |
4180_1 | 1:8b656995301f | 286 | while (!_cmd.readable()) wait_ms(TEMPO); // wait for screen answer |
4180_1 | 1:8b656995301f | 287 | |
4180_1 | 1:8b656995301f | 288 | while (_cmd.readable() && resp < ARRAY_SIZE(response)) { |
4180_1 | 1:8b656995301f | 289 | temp = _cmd.getc(); |
4180_1 | 1:8b656995301f | 290 | response[resp++] = (char)temp; |
4180_1 | 1:8b656995301f | 291 | } |
4180_1 | 1:8b656995301f | 292 | |
4180_1 | 1:8b656995301f | 293 | color = ((response[0] << 8) + response[1]); |
4180_1 | 1:8b656995301f | 294 | |
4180_1 | 1:8b656995301f | 295 | return color; // WARNING : this is 16bits color, not 24bits... need to be fixed |
4180_1 | 1:8b656995301f | 296 | } |
4180_1 | 1:8b656995301f | 297 | |
4180_1 | 1:8b656995301f | 298 | |
4180_1 | 1:8b656995301f | 299 | //**************************************************************************************************** |
4180_1 | 3:9ba47197d94f | 300 | void uLCD_4DGL :: pen_size(char mode) // set pen to SOLID or WIREFRAME |
4180_1 | 3:9ba47197d94f | 301 | { |
4180_1 | 1:8b656995301f | 302 | char command[2]= ""; |
4180_1 | 1:8b656995301f | 303 | |
4180_1 | 1:8b656995301f | 304 | command[0] = PENSIZE; |
4180_1 | 1:8b656995301f | 305 | command[1] = mode; |
4180_1 | 1:8b656995301f | 306 | writeCOMMAND(command, 2); |
4180_1 | 1:8b656995301f | 307 | } |
4180_1 | 4:74df7fc26fef | 308 | |
4180_1 | 6:b759b69cbaf9 | 309 | |
4180_1 | 7:e39a44de229a | 310 |