Library for uVGAIII

Dependents:   uVGAIII_demo

Committer:
ivygatech
Date:
Mon Mar 24 19:54:56 2014 +0000
Revision:
5:8acc50389659
Parent:
4:672a6d537dce
update library

Who changed what in which revision?

UserRevisionLine numberNew 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 // @author Stephane Rochon
ivygatech 0:de1ab53f3480 20
ivygatech 0:de1ab53f3480 21 #include "mbed.h"
ivygatech 0:de1ab53f3480 22
ivygatech 0:de1ab53f3480 23 // Debug Verbose on terminal enabled
ivygatech 0:de1ab53f3480 24 #ifndef DEBUGMODE
ivygatech 0:de1ab53f3480 25 #define DEBUGMODE 1
ivygatech 0:de1ab53f3480 26 #endif
ivygatech 0:de1ab53f3480 27
ivygatech 0:de1ab53f3480 28 // Common WAIT value in millisecond
ivygatech 0:de1ab53f3480 29 #define TEMPO 5
ivygatech 0:de1ab53f3480 30
ivygatech 0:de1ab53f3480 31 // 4DGL Functions values
ivygatech 0:de1ab53f3480 32 // Graphic Commands values
ivygatech 0:de1ab53f3480 33 #define CLS 0xFFCD
ivygatech 0:de1ab53f3480 34 #define BCKGDCOLOR 0xFFA4
ivygatech 0:de1ab53f3480 35 #define SCREENMODE 0xFF9E
ivygatech 0:de1ab53f3480 36 #define CIRCLE 0xFFC3
ivygatech 0:de1ab53f3480 37 #define CIRCLE_F 0xFFC2
ivygatech 0:de1ab53f3480 38 #define TRIANGLE 0xFFBF
ivygatech 0:de1ab53f3480 39 #define TRIANGLE_F 0xFFA9
ivygatech 0:de1ab53f3480 40 #define LINE 0xFFC8
ivygatech 0:de1ab53f3480 41 #define RECTANGLE 0xFFC5
ivygatech 0:de1ab53f3480 42 #define RECTANGLE_F 0xFFC4
ivygatech 0:de1ab53f3480 43 #define ELLIPSE 0xFFB2
ivygatech 0:de1ab53f3480 44 #define ELLIPSE_F 0xFFB1
ivygatech 0:de1ab53f3480 45 #define PUTPIXEL 0xFFC1
ivygatech 0:de1ab53f3480 46 #define READPIXEL 0xFFC0
ivygatech 0:de1ab53f3480 47 #define SCREENCOPY 0xFFAD
ivygatech 0:de1ab53f3480 48 #define CLIPPING 0xFFA2
ivygatech 0:de1ab53f3480 49 #define SETCLIPWIN 0xFFB5
ivygatech 0:de1ab53f3480 50 #define EXTCLIPREG 0xFFB3
ivygatech 0:de1ab53f3480 51 #define BUTTON 0x0011
ivygatech 0:de1ab53f3480 52 #define PANEL 0xFFAF
ivygatech 0:de1ab53f3480 53 #define SLIDER 0xFFAE
ivygatech 0:de1ab53f3480 54 #define CHANGECOLOR 0xFFB4
ivygatech 0:de1ab53f3480 55 #define MOVEORIGIN 0xFFCC
ivygatech 0:de1ab53f3480 56 #define LINEPATTERN 0xFF9B
ivygatech 0:de1ab53f3480 57 #define OUTLINECOLOR 0xFF9D
ivygatech 0:de1ab53f3480 58 #define TRANSPARENCY 0xFFA0
ivygatech 0:de1ab53f3480 59 #define TRANSPCOLOR 0xFFA1
ivygatech 0:de1ab53f3480 60 #define PARAMETERS 0xFFCE
ivygatech 0:de1ab53f3480 61
ivygatech 0:de1ab53f3480 62 // System Commands
ivygatech 0:de1ab53f3480 63 #define BAUDRATE 0x0026
ivygatech 0:de1ab53f3480 64 #define SPEVERSION 0x001B
ivygatech 0:de1ab53f3480 65 #define PMMCVERSION 0x001C
ivygatech 0:de1ab53f3480 66 #define SETVOLUME 0xFF00
ivygatech 0:de1ab53f3480 67
ivygatech 0:de1ab53f3480 68 // Text and String Commands
ivygatech 0:de1ab53f3480 69 #define MOVECURSOR 0xFFE9
ivygatech 0:de1ab53f3480 70 #define PUTCHAR 0xFFFE
ivygatech 0:de1ab53f3480 71 #define SETFONT 0xFFE5
ivygatech 0:de1ab53f3480 72 #define TEXTOPACITY 0xFFDF
ivygatech 0:de1ab53f3480 73 #define TEXTFGCOLOR 0xFFE7
ivygatech 0:de1ab53f3480 74 #define TEXTBGCOLOR 0xFFE6
ivygatech 0:de1ab53f3480 75 #define TEXTWIDTH 0xFFE4
ivygatech 0:de1ab53f3480 76 #define TEXTHEIGHT 0xFFE3
ivygatech 0:de1ab53f3480 77 #define TEXTXGAP 0xFFE2
ivygatech 0:de1ab53f3480 78 #define TEXTYGAP 0xFFE1
ivygatech 0:de1ab53f3480 79 #define TEXTBOLD 0xFFDE
ivygatech 0:de1ab53f3480 80 #define TEXTINVERSE 0xFFDC
ivygatech 0:de1ab53f3480 81 #define TEXTITALIC 0xFFDD
ivygatech 0:de1ab53f3480 82 #define TEXTUNDLINE 0xFFDB
ivygatech 0:de1ab53f3480 83 #define TEXTATTRIBU 0xFFDA
ivygatech 0:de1ab53f3480 84 #define PUTSTRING 0x0018
ivygatech 0:de1ab53f3480 85 #define CHARWIDTH 0x001E
ivygatech 0:de1ab53f3480 86 #define CHARHEIGHT 0x001D
ivygatech 0:de1ab53f3480 87 #define GETTOUCH '\x6F'
ivygatech 0:de1ab53f3480 88 #define WAITTOUCH '\x77'
ivygatech 0:de1ab53f3480 89 #define SETTOUCH '\x75'
ivygatech 0:de1ab53f3480 90
ivygatech 0:de1ab53f3480 91 // Touch Screen Commands
ivygatech 0:de1ab53f3480 92 #define TOUCHSET 0xFF38
ivygatech 0:de1ab53f3480 93 #define TOUCHGET 0xFF37
ivygatech 0:de1ab53f3480 94 #define TOUCHDETECT 0xFF39
ivygatech 0:de1ab53f3480 95
ivygatech 0:de1ab53f3480 96 // Slider
ivygatech 0:de1ab53f3480 97 #define INTENDED '\x00'
ivygatech 0:de1ab53f3480 98 #define S_RAISED '\x01'
ivygatech 0:de1ab53f3480 99 #define HIDDEN '\x02'
ivygatech 0:de1ab53f3480 100
ivygatech 0:de1ab53f3480 101 // Button
ivygatech 0:de1ab53f3480 102 #define DEPRESSED '\x00'
ivygatech 0:de1ab53f3480 103 #define B_RAISED '\x01'
ivygatech 0:de1ab53f3480 104
ivygatech 0:de1ab53f3480 105 // Panel
ivygatech 0:de1ab53f3480 106 #define RECESSED '\x00'
ivygatech 0:de1ab53f3480 107 #define P_RAISED '\x01'
ivygatech 0:de1ab53f3480 108
ivygatech 0:de1ab53f3480 109 // Screen answers
ivygatech 0:de1ab53f3480 110 #define ACK '\x06'
ivygatech 0:de1ab53f3480 111 #define NAK '\x15'
ivygatech 0:de1ab53f3480 112
ivygatech 0:de1ab53f3480 113 // Screen states
ivygatech 0:de1ab53f3480 114 #define OFF '\x00'
ivygatech 0:de1ab53f3480 115 #define ON '\x01'
ivygatech 0:de1ab53f3480 116
ivygatech 0:de1ab53f3480 117 // Graphics parameters
ivygatech 0:de1ab53f3480 118 #define OBJECTCOLOR 18
ivygatech 0:de1ab53f3480 119 #define RESOLUTION 32
ivygatech 0:de1ab53f3480 120 #define PGDISPLAY 33
ivygatech 0:de1ab53f3480 121 #define PGREAD 34
ivygatech 0:de1ab53f3480 122 #define PGWRITE 35
ivygatech 0:de1ab53f3480 123
ivygatech 0:de1ab53f3480 124 // Graphics modes
ivygatech 0:de1ab53f3480 125 #define SOLID '\x00'
ivygatech 0:de1ab53f3480 126 #define WIREFRAME '\x01'
ivygatech 0:de1ab53f3480 127
ivygatech 0:de1ab53f3480 128 // Text modes
ivygatech 0:de1ab53f3480 129 #define TRANSPARENT '\x00'
ivygatech 0:de1ab53f3480 130 #define OPAQUE '\x01'
ivygatech 0:de1ab53f3480 131
ivygatech 0:de1ab53f3480 132 // Fonts Sizes
ivygatech 0:de1ab53f3480 133 #define FONT1 '\x00' // 7X8
ivygatech 0:de1ab53f3480 134 #define FONT2 '\x01' // 8X8
ivygatech 0:de1ab53f3480 135 #define FONT3 '\x02' // 8X12
ivygatech 0:de1ab53f3480 136
ivygatech 0:de1ab53f3480 137 // Touch Values
ivygatech 0:de1ab53f3480 138 #define MOVE '\x03'
ivygatech 0:de1ab53f3480 139 #define STATUS '\x00'
ivygatech 0:de1ab53f3480 140 #define GETXPOSITION '\x01'
ivygatech 0:de1ab53f3480 141 #define GETYPOSITION '\x02'
ivygatech 0:de1ab53f3480 142
ivygatech 0:de1ab53f3480 143 // Data speed
ivygatech 0:de1ab53f3480 144 #define BAUD_110 0x0000
ivygatech 0:de1ab53f3480 145 #define BAUD_300 0x0001
ivygatech 0:de1ab53f3480 146 #define BAUD_600 0x0002
ivygatech 0:de1ab53f3480 147 #define BAUD_1200 0x0003
ivygatech 0:de1ab53f3480 148 #define BAUD_2400 0x0004
ivygatech 0:de1ab53f3480 149 #define BAUD_4800 0x0005
ivygatech 0:de1ab53f3480 150 #define BAUD_9600 0x0006
ivygatech 0:de1ab53f3480 151 #define BAUD_14400 0x0007
ivygatech 0:de1ab53f3480 152 #define BAUD_19200 0x0008
ivygatech 0:de1ab53f3480 153 #define BAUD_31250 0x0009
ivygatech 0:de1ab53f3480 154 #define BAUD_38400 0x000A
ivygatech 0:de1ab53f3480 155 #define BAUD_56000 0x000B
ivygatech 0:de1ab53f3480 156 #define BAUD_57600 0x000C
ivygatech 0:de1ab53f3480 157 #define BAUD_115200 0x000D
ivygatech 0:de1ab53f3480 158 #define BAUD_128000 0x000E
ivygatech 0:de1ab53f3480 159 #define BAUD_256000 0x000F
ivygatech 0:de1ab53f3480 160
ivygatech 0:de1ab53f3480 161 // Defined Colors
ivygatech 0:de1ab53f3480 162 #define BLACK 0x000000
ivygatech 0:de1ab53f3480 163 #define WHITE 0xFFFFFF
ivygatech 0:de1ab53f3480 164 #define LGREY 0xBFBFBF
ivygatech 0:de1ab53f3480 165 #define DGREY 0x5F5F5F
ivygatech 0:de1ab53f3480 166 #define RED 0xFF0000
ivygatech 0:de1ab53f3480 167 #define LIME 0x00FF00
ivygatech 0:de1ab53f3480 168 #define BLUE 0x0000FF
ivygatech 0:de1ab53f3480 169 #define YELLOW 0xFFFF00
ivygatech 0:de1ab53f3480 170 #define CYAN 0x00FFFF
ivygatech 0:de1ab53f3480 171 #define MAGENTA 0xFF00FF
ivygatech 0:de1ab53f3480 172 #define SILVER 0xC0C0C0
ivygatech 0:de1ab53f3480 173 #define GRAY 0x808080
ivygatech 0:de1ab53f3480 174 #define MAROON 0x800000
ivygatech 0:de1ab53f3480 175 #define OLIVE 0x808000
ivygatech 0:de1ab53f3480 176 #define GREEN 0x008000
ivygatech 0:de1ab53f3480 177 #define PURPLE 0x800080
ivygatech 0:de1ab53f3480 178 #define TEAL 0x008080
ivygatech 0:de1ab53f3480 179 #define NAVY 0x000080
ivygatech 0:de1ab53f3480 180
ivygatech 0:de1ab53f3480 181 // Mode data
ivygatech 0:de1ab53f3480 182 #define BACKLIGHT '\x00'
ivygatech 0:de1ab53f3480 183 #define DISPLAY '\x01'
ivygatech 0:de1ab53f3480 184 #define CONTRAST '\x02'
ivygatech 0:de1ab53f3480 185 #define POWER '\x03'
ivygatech 0:de1ab53f3480 186 #define ORIENTATION '\x04'
ivygatech 0:de1ab53f3480 187 #define TOUCH_CTRL '\x05'
ivygatech 0:de1ab53f3480 188 #define IMAGE_FORMAT '\x06'
ivygatech 0:de1ab53f3480 189 #define PROTECT_FAT '\x08'
ivygatech 0:de1ab53f3480 190
ivygatech 0:de1ab53f3480 191 // change this to your specific screen (newer versions) if needed
ivygatech 0:de1ab53f3480 192 // Startup orientation is PORTRAIT so SIZE_X must be lesser than SIZE_Y
ivygatech 0:de1ab53f3480 193 #define SIZE_X 480
ivygatech 0:de1ab53f3480 194 #define SIZE_Y 800
ivygatech 0:de1ab53f3480 195
ivygatech 0:de1ab53f3480 196 #define IS_LANDSCAPE 0
ivygatech 0:de1ab53f3480 197 #define IS_PORTRAIT 1
ivygatech 0:de1ab53f3480 198
ivygatech 0:de1ab53f3480 199 // Screen orientation
ivygatech 0:de1ab53f3480 200 #define LANDSCAPE '\x00'
ivygatech 0:de1ab53f3480 201 #define LANDSCAPE_R '\x01'
ivygatech 0:de1ab53f3480 202 #define PORTRAIT '\x02'
ivygatech 0:de1ab53f3480 203 #define PORTRAIT_R '\x03'
ivygatech 0:de1ab53f3480 204
ivygatech 1:cd4cc4298b2a 205 /**
ivygatech 1:cd4cc4298b2a 206 * This is a class for uVGAIII
ivygatech 1:cd4cc4298b2a 207 */
ivygatech 0:de1ab53f3480 208 class uVGAIII : public Stream
ivygatech 0:de1ab53f3480 209 {
ivygatech 0:de1ab53f3480 210
ivygatech 0:de1ab53f3480 211 public :
ivygatech 0:de1ab53f3480 212
ivygatech 0:de1ab53f3480 213 uVGAIII(PinName tx, PinName rx, PinName rst);
ivygatech 0:de1ab53f3480 214
ivygatech 0:de1ab53f3480 215 // General Commands *******************************************************************************
ivygatech 0:de1ab53f3480 216
ivygatech 0:de1ab53f3480 217 /** Clear the entire screen using the current background colour */
ivygatech 0:de1ab53f3480 218 void cls();
ivygatech 0:de1ab53f3480 219
ivygatech 0:de1ab53f3480 220 /** Reset screen */
ivygatech 0:de1ab53f3480 221 void reset();
ivygatech 0:de1ab53f3480 222
ivygatech 0:de1ab53f3480 223 /** Set serial Baud rate (both sides : screen and mbed)
ivygatech 0:de1ab53f3480 224 * @param Speed Correct BAUD value (see uVGAIII.h)
ivygatech 0:de1ab53f3480 225 */
ivygatech 0:de1ab53f3480 226 void baudrate(int speed);
ivygatech 0:de1ab53f3480 227
ivygatech 0:de1ab53f3480 228 /** Set internal speaker to specified value
ivygatech 0:de1ab53f3480 229 * @param value Correct range is 8 - 127
ivygatech 0:de1ab53f3480 230 */
ivygatech 0:de1ab53f3480 231 void set_volume(char value);
ivygatech 0:de1ab53f3480 232
ivygatech 0:de1ab53f3480 233 // Graphics Commands
ivygatech 2:60f6946df58c 234 /** Set the graphics orientation
ivygatech 2:60f6946df58c 235 * @param mode LANDSCAPE, LANDSCAPE_R, PORTRAIT, PORTRAIT_R
ivygatech 2:60f6946df58c 236 */
ivygatech 0:de1ab53f3480 237 void screen_mode(char mode);
ivygatech 2:60f6946df58c 238
ivygatech 2:60f6946df58c 239 /**
ivygatech 2:60f6946df58c 240 * Set background color of the screen
ivygatech 2:60f6946df58c 241 * @param color 24 bits in total with the most significant byte representing the red part and the middle byte representing the green part and the least significant byte representing the blue part
ivygatech 2:60f6946df58c 242 */
ivygatech 0:de1ab53f3480 243 void background_color(int color);
ivygatech 2:60f6946df58c 244 /**
ivygatech 2:60f6946df58c 245 * Draw a circle
ivygatech 2:60f6946df58c 246 * @param x x-coordinate of the center
ivygatech 2:60f6946df58c 247 * @param y y-coordinate of the center
ivygatech 2:60f6946df58c 248 * @param radius radius of the circle
ivygatech 2:60f6946df58c 249 * @param color color of the outline of the circle
ivygatech 2:60f6946df58c 250 */
ivygatech 0:de1ab53f3480 251 void circle(int x , int y , int radius, int color);
ivygatech 2:60f6946df58c 252 /**
ivygatech 2:60f6946df58c 253 * Draw a filled circle
ivygatech 2:60f6946df58c 254 * @param x x-coordinate of the center
ivygatech 2:60f6946df58c 255 * @param y y-coordinate of the center
ivygatech 2:60f6946df58c 256 * @param radius radius of the circle
ivygatech 2:60f6946df58c 257 * @param color color of the circle
ivygatech 2:60f6946df58c 258 */
ivygatech 0:de1ab53f3480 259 void filled_circle(int x, int y, int radius, int color);
ivygatech 2:60f6946df58c 260 /**
ivygatech 2:60f6946df58c 261 * Draw a triangle
ivygatech 2:60f6946df58c 262 * @param x1 x-coordinate of the first vertice
ivygatech 2:60f6946df58c 263 * @param y1 y-coordinate of the first vertice
ivygatech 2:60f6946df58c 264 * @param x2 x-coordinate of the second vertice
ivygatech 2:60f6946df58c 265 * @param y2 y-coordinate of the second vertice
ivygatech 2:60f6946df58c 266 * @param x3 x-coordinate of the third vertice
ivygatech 2:60f6946df58c 267 * @param y3 y-coordinate of the third vertice
ivygatech 2:60f6946df58c 268 * @param color color of the outline of the triangle
ivygatech 2:60f6946df58c 269 */
ivygatech 2:60f6946df58c 270 void triangle(int x1, int y1, int x2, int y2, int x3, int y3, int color);
ivygatech 2:60f6946df58c 271 /**
ivygatech 2:60f6946df58c 272 * Draw a filled triangle
ivygatech 2:60f6946df58c 273 * @param x1 x-coordinate of the first vertice
ivygatech 2:60f6946df58c 274 * @param y1 y-coordinate of the first vertice
ivygatech 2:60f6946df58c 275 * @param x2 x-coordinate of the second vertice
ivygatech 2:60f6946df58c 276 * @param y2 y-coordinate of the second vertice
ivygatech 2:60f6946df58c 277 * @param x3 x-coordinate of the third vertice
ivygatech 2:60f6946df58c 278 * @param y3 y-coordinate of the third vertice
ivygatech 2:60f6946df58c 279 * @param color color of the triangle
ivygatech 2:60f6946df58c 280 */
ivygatech 2:60f6946df58c 281 void filled_triangle(int x1, int y1, int x2, int y2, int x3, int y3, int color);
ivygatech 2:60f6946df58c 282 /**
ivygatech 2:60f6946df58c 283 * Draw a line
ivygatech 2:60f6946df58c 284 * @param x1 x-coordinate of the first vertice
ivygatech 2:60f6946df58c 285 * @param y1 y-coordinate of the first vertice
ivygatech 2:60f6946df58c 286 * @param x2 x-coordinate of the second vertice
ivygatech 2:60f6946df58c 287 * @param y2 y-coordinate of the second vertice
ivygatech 2:60f6946df58c 288 * @param color color of the line
ivygatech 2:60f6946df58c 289 */
ivygatech 2:60f6946df58c 290 void line(int x1, int y1 , int x2, int y2, int color);
ivygatech 2:60f6946df58c 291 /**
ivygatech 2:60f6946df58c 292 * Draw a rectangle
ivygatech 2:60f6946df58c 293 * @param x1 x-coordinate of the first vertice
ivygatech 2:60f6946df58c 294 * @param y1 y-coordinate of the first vertice
ivygatech 2:60f6946df58c 295 * @param x2 x-coordinate of the second vertice
ivygatech 2:60f6946df58c 296 * @param y2 y-coordinate of the second vertice
ivygatech 2:60f6946df58c 297 * @param color color of the outline of the rectangle
ivygatech 2:60f6946df58c 298 */
ivygatech 2:60f6946df58c 299 void rectangle(int x1, int y1 , int x2, int y2, int color);
ivygatech 2:60f6946df58c 300 /**
ivygatech 2:60f6946df58c 301 * Draw a filled rectangle
ivygatech 2:60f6946df58c 302 * @param x1 x-coordinate of the first vertice
ivygatech 2:60f6946df58c 303 * @param y1 y-coordinate of the first vertice
ivygatech 2:60f6946df58c 304 * @param x2 x-coordinate of the second vertice
ivygatech 2:60f6946df58c 305 * @param y2 y-coordinate of the second vertice
ivygatech 2:60f6946df58c 306 * @param color color of the rectangle
ivygatech 2:60f6946df58c 307 */
ivygatech 0:de1ab53f3480 308 void filled_rectangle(int, int, int, int, int);
ivygatech 2:60f6946df58c 309 /**
ivygatech 2:60f6946df58c 310 * Draw a ellipse
ivygatech 2:60f6946df58c 311 * @param x x-coordinate of the center
ivygatech 2:60f6946df58c 312 * @param y y-coordinate of the center
ivygatech 2:60f6946df58c 313 * @param radius_x x-radius of the ellipse
ivygatech 2:60f6946df58c 314 * @param redius_y y-radius of the ellipse
ivygatech 2:60f6946df58c 315 * @param color color of the outline of the rectangle
ivygatech 2:60f6946df58c 316 */
ivygatech 2:60f6946df58c 317 void ellipse(int x, int y , int radius_x, int radius_y, int color);
ivygatech 2:60f6946df58c 318 /**
ivygatech 2:60f6946df58c 319 * Draw a filled ellipse
ivygatech 2:60f6946df58c 320 * @param x x-coordinate of the center
ivygatech 2:60f6946df58c 321 * @param y y-coordinate of the center
ivygatech 2:60f6946df58c 322 * @param radius_x x-radius of the ellipse
ivygatech 2:60f6946df58c 323 * @param redius_y y-radius of the ellipse
ivygatech 2:60f6946df58c 324 * @param color color of the rectangle
ivygatech 2:60f6946df58c 325 */
ivygatech 2:60f6946df58c 326 void filled_ellipse(int x, int y , int radius_x, int radius_y, int color);
ivygatech 2:60f6946df58c 327 /**
ivygatech 2:60f6946df58c 328 * Draw a button
ivygatech 2:60f6946df58c 329 * @param state appearance of button, 0 = Button depressed; 1 = Button raised
ivygatech 2:60f6946df58c 330 * @param x x-coordinate of the top left corner of the button
ivygatech 2:60f6946df58c 331 * @param y y-coordinate of the top left corner of the button
ivygatech 2:60f6946df58c 332 * @param buttoncolor color of the button
ivygatech 2:60f6946df58c 333 * @param txtcolor color of the text
ivygatech 2:60f6946df58c 334 * @param font Specifies the Font ID
ivygatech 2:60f6946df58c 335 * @param txtWidth Set the width of the text
ivygatech 2:60f6946df58c 336 * @param txtHeight Set the height of the text
ivygatech 2:60f6946df58c 337 * @param text Specifies the text string
ivygatech 2:60f6946df58c 338 */
ivygatech 2:60f6946df58c 339 void button(int state, int x, int y, int buttoncolor, int txtcolor, int font, int txtWidth, int txtHeight, char * text);
ivygatech 2:60f6946df58c 340 /**
ivygatech 2:60f6946df58c 341 * Draw a panel
ivygatech 2:60f6946df58c 342 * @param state appearance of panel, 0 = recessed; 1 = raised
ivygatech 2:60f6946df58c 343 * @param x x-coordinate of the top left corner of the button
ivygatech 2:60f6946df58c 344 * @param y y-coordinate of the top left corner of the button
ivygatech 2:60f6946df58c 345 * @param Width Set the width of the panel
ivygatech 2:60f6946df58c 346 * @param Height Set the height of the panel
ivygatech 2:60f6946df58c 347 * @param color Set the color of the panel
ivygatech 2:60f6946df58c 348 */
ivygatech 2:60f6946df58c 349 void panel(int state, int x, int y, int Width, int Height, int color);
ivygatech 2:60f6946df58c 350 /**
ivygatech 2:60f6946df58c 351 * Draw a slider
ivygatech 2:60f6946df58c 352 * @param mode Mode = 0: Slider indented, mode = 1: Slider raised, mode 2: Slider hidden
ivygatech 2:60f6946df58c 353 * @param x1 x-coordinate of the top left position of the slider
ivygatech 2:60f6946df58c 354 * @param y1 y-coordinate of the top left position of the slider
ivygatech 2:60f6946df58c 355 * @param x2 x-coordinate of the bottom right position of the slider
ivygatech 2:60f6946df58c 356 * @param y2 y-coordinate of the bottom right position of the slider
ivygatech 2:60f6946df58c 357 * @param color Set the color of slider
ivygatech 2:60f6946df58c 358 * @param scale Set the full scale range of the slider for the thumb from 0 to n
ivygatech 2:60f6946df58c 359 * @param 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
ivygatech 2:60f6946df58c 360 */
ivygatech 2:60f6946df58c 361 void slider(char mode, int x1, int y1, int x2, int y2, int color, int scale, int value);
ivygatech 2:60f6946df58c 362 /**
ivygatech 2:60f6946df58c 363 * Draw a pixel
ivygatech 2:60f6946df58c 364 * @param x x-coordinate of the pixel
ivygatech 2:60f6946df58c 365 * @param y y-coordinate of the pixel
ivygatech 2:60f6946df58c 366 * @param color Set the color of pixel
ivygatech 2:60f6946df58c 367 */
ivygatech 2:60f6946df58c 368 void put_pixel(int x, int y, int color);
ivygatech 2:60f6946df58c 369 /**
ivygatech 2:60f6946df58c 370 * Read the color value of the pixel
ivygatech 2:60f6946df58c 371 * @param x x-coordinate of the pixel
ivygatech 2:60f6946df58c 372 * @param y y-coordinate of the pixel
ivygatech 2:60f6946df58c 373 * @return the color value of the pixel
ivygatech 2:60f6946df58c 374 */
ivygatech 2:60f6946df58c 375 int read_pixel(int x, int y);
ivygatech 2:60f6946df58c 376 /**
ivygatech 2:60f6946df58c 377 * Copy an area of a screen
ivygatech 2:60f6946df58c 378 * @param xs x-coordinate of the top left corner of the area to be copied
ivygatech 2:60f6946df58c 379 * @param ys y-coordinate of the top left corner of the area to be copied
ivygatech 2:60f6946df58c 380 * @param xd x-coordinate of the top left corner of the area to be pasted
ivygatech 2:60f6946df58c 381 * @param yd y-coordinate of the top left corner of the area to be pasted
ivygatech 2:60f6946df58c 382 * @param width Set the width of the copied area
ivygatech 2:60f6946df58c 383 * @param width Set the height of the copied area
ivygatech 2:60f6946df58c 384 */
ivygatech 2:60f6946df58c 385 void screen_copy(int xs, int ys , int xd, int yd , int width, int height);
ivygatech 3:908810caba2e 386 /**
ivygatech 3:908810caba2e 387 * Enable or disable the ability for Clipping to be used
ivygatech 3:908810caba2e 388 * @param value 0 = Clipping Disabled, 1 = Clipping Enabled
ivygatech 3:908810caba2e 389 */
ivygatech 3:908810caba2e 390 void clipping(char value);
ivygatech 3:908810caba2e 391 /**
ivygatech 3:908810caba2e 392 * Specifiy the clipping window region on the screen
ivygatech 3:908810caba2e 393 * @param x1 x-coordinate of the top left corner of the clipping window
ivygatech 3:908810caba2e 394 * @param y1 y-coordinate of the top left corner of the clipping window
ivygatech 3:908810caba2e 395 * @param x2 x-coordinate of the bottom right corner of the clipping window
ivygatech 3:908810caba2e 396 * @param y2 y-coordinate of the bottom right corner of the clipping window
ivygatech 3:908810caba2e 397 */
ivygatech 3:908810caba2e 398 void set_clipping_win(int x1, int y1, int x2, int y2);
ivygatech 3:908810caba2e 399 /**
ivygatech 3:908810caba2e 400 * Force the clip region to the extent of the last text
ivygatech 3:908810caba2e 401 *
ivygatech 3:908810caba2e 402 */
ivygatech 0:de1ab53f3480 403 void extend_clip_region();
ivygatech 3:908810caba2e 404 /**
ivygatech 3:908810caba2e 405 * Change all old color pixels to new color within the clipping window area
ivygatech 3:908810caba2e 406 * @param oldColor Sample color to be changed within the clipping window
ivygatech 3:908810caba2e 407 * @param newColor New color to change all occurrences of old color within the clipping window
ivygatech 3:908810caba2e 408 */
ivygatech 3:908810caba2e 409 void change_color(int oldColor, int newColor);
ivygatech 3:908810caba2e 410 /**
ivygatech 3:908810caba2e 411 * Move the origin to a new position
ivygatech 3:908810caba2e 412 * @param xpos x-coordinate of the new origin
ivygatech 3:908810caba2e 413 * @param ypos y-coordinate of the new origin
ivygatech 3:908810caba2e 414 */
ivygatech 3:908810caba2e 415 void move_origin(int xpos, int ypos);
ivygatech 3:908810caba2e 416 /**
ivygatech 3:908810caba2e 417 * Set the line pattern
ivygatech 3:908810caba2e 418 * @param pattern Correct value 0 to 65535 = number of bits in the line are turned off to form a pattern
ivygatech 3:908810caba2e 419 */
ivygatech 3:908810caba2e 420 void line_pattern(int pattern);
ivygatech 3:908810caba2e 421 /**
ivygatech 3:908810caba2e 422 * Set the outline color for rectangles and circles
ivygatech 3:908810caba2e 423 * @param color 24 bits in total of the color value
ivygatech 3:908810caba2e 424 */
ivygatech 3:908810caba2e 425 void outline_color(int color);
ivygatech 3:908810caba2e 426 /**
ivygatech 3:908810caba2e 427 * Set whether to enable the transparency
ivygatech 3:908810caba2e 428 * @param mode 0 = Transparency OFF, 1 = Transparency ON
ivygatech 3:908810caba2e 429 */
ivygatech 3:908810caba2e 430 void transparency(char mode);
ivygatech 3:908810caba2e 431 /**
ivygatech 3:908810caba2e 432 * Set the color to be transparent
ivygatech 3:908810caba2e 433 * @param color Color to be set to be transparent
ivygatech 3:908810caba2e 434 */
ivygatech 3:908810caba2e 435 void transparent_color(int color);
ivygatech 3:908810caba2e 436 /**
ivygatech 3:908810caba2e 437 * Set graphics parameters
ivygatech 3:908810caba2e 438 * @param function 18 = Object Color, 32 = Screen Resolution, 33 = Page Display, 34 = Page Read, 35 = Page Write
ivygatech 3:908810caba2e 439 * @param value different values to be applied according to different functions
ivygatech 3:908810caba2e 440 */
ivygatech 3:908810caba2e 441 void graphics_parameters(int function, int value);
ivygatech 0:de1ab53f3480 442
ivygatech 0:de1ab53f3480 443 // Texts Commands
ivygatech 4:672a6d537dce 444 /**
ivygatech 4:672a6d537dce 445 * Set font mode
ivygatech 4:672a6d537dce 446 * @param mode 0 for FONT1 = system font; 1 for FONT2; 2 for FONT3 = Default font
ivygatech 4:672a6d537dce 447 */
ivygatech 4:672a6d537dce 448 void set_font(char mode);
ivygatech 4:672a6d537dce 449 /**
ivygatech 4:672a6d537dce 450 * Move teh text cursor to a screen postion
ivygatech 4:672a6d537dce 451 * @param line Line position
ivygatech 4:672a6d537dce 452 * @param column Column position
ivygatech 4:672a6d537dce 453 */
ivygatech 4:672a6d537dce 454 void move_cursor(int line, int column);
ivygatech 4:672a6d537dce 455 /**
ivygatech 4:672a6d537dce 456 * Set whether or not the 'background' pixels are drawn
ivygatech 4:672a6d537dce 457 * @param mode 1 for ON(opaque), 0 for OFF(transparent)
ivygatech 4:672a6d537dce 458 */
ivygatech 4:672a6d537dce 459 void text_opacity(char mode);
ivygatech 4:672a6d537dce 460 /**
ivygatech 4:672a6d537dce 461 * Set the text width multiplier between 1 and 16
ivygatech 4:672a6d537dce 462 * @param multiplier Width multiplier 1 to 16
ivygatech 4:672a6d537dce 463 */
ivygatech 4:672a6d537dce 464 void text_width(int multiplier);
ivygatech 4:672a6d537dce 465 /**
ivygatech 4:672a6d537dce 466 * Set the text height multiplier between 1 and 16
ivygatech 4:672a6d537dce 467 * @param multiplier Height multiplier 1 to 16
ivygatech 4:672a6d537dce 468 */
ivygatech 4:672a6d537dce 469 void text_height(int multiplier);
ivygatech 4:672a6d537dce 470 /**
ivygatech 4:672a6d537dce 471 * Set the pixel gap between characters(x-axis)
ivygatech 4:672a6d537dce 472 * @param pixelcount 0 to 32
ivygatech 4:672a6d537dce 473 */
ivygatech 4:672a6d537dce 474 void text_x_gap(int pixelcount);
ivygatech 4:672a6d537dce 475 /**
ivygatech 4:672a6d537dce 476 * Set the pixel gap between characters(y-axis)
ivygatech 4:672a6d537dce 477 * @param pixelcount 0 to 32
ivygatech 4:672a6d537dce 478 */
ivygatech 4:672a6d537dce 479 void text_y_gap(int pixelcount);
ivygatech 4:672a6d537dce 480 /**
ivygatech 4:672a6d537dce 481 * Set the bold attribute for the text
ivygatech 4:672a6d537dce 482 * @param mode 1 for ON, 0 for OFF
ivygatech 4:672a6d537dce 483 */
ivygatech 4:672a6d537dce 484 void text_bold(char mode);
ivygatech 4:672a6d537dce 485 /**
ivygatech 4:672a6d537dce 486 * Inverse the background and foreground color of the text
ivygatech 4:672a6d537dce 487 * @param mode 1 for ON, 0 for OFF
ivygatech 4:672a6d537dce 488 */
ivygatech 4:672a6d537dce 489 void text_inverse(char mode);
ivygatech 4:672a6d537dce 490 /**
ivygatech 4:672a6d537dce 491 * Set the text to italic
ivygatech 4:672a6d537dce 492 * @param mode 1 for ON, 0 for OFF
ivygatech 4:672a6d537dce 493 */
ivygatech 4:672a6d537dce 494 void text_italic(char mode);
ivygatech 4:672a6d537dce 495 /**
ivygatech 4:672a6d537dce 496 * Set the text to underlined
ivygatech 4:672a6d537dce 497 * @param mode 1 for ON, 0 for OFF
ivygatech 4:672a6d537dce 498 */
ivygatech 4:672a6d537dce 499 void text_underline(char mode);
ivygatech 4:672a6d537dce 500 /**
ivygatech 4:672a6d537dce 501 * Control several functions grouped, Text Bold, Text Italic, Text Inverse, Text Underlined
ivygatech 4:672a6d537dce 502 * @param value DEC 16 for BOLD, DEC 32 for ITALIC, DEC 64 for INVERSE, DEC 128 for UNDERLINED
ivygatech 4:672a6d537dce 503 */
ivygatech 4:672a6d537dce 504 void text_attributes(int value);
ivygatech 4:672a6d537dce 505 /**
ivygatech 4:672a6d537dce 506 * Print a single character on the display
ivygatech 4:672a6d537dce 507 * @param c Character to be print on the screen
ivygatech 4:672a6d537dce 508 */
ivygatech 4:672a6d537dce 509 void put_char(char c);
ivygatech 4:672a6d537dce 510 /**
ivygatech 4:672a6d537dce 511 * Print a string on the display
ivygatech 4:672a6d537dce 512 * @param s A Null terminated string
ivygatech 4:672a6d537dce 513 */
ivygatech 4:672a6d537dce 514 void put_string(char *s);
ivygatech 4:672a6d537dce 515 /**
ivygatech 4:672a6d537dce 516 * Set the text foreground color
ivygatech 4:672a6d537dce 517 * @param color Specify the color to be set
ivygatech 4:672a6d537dce 518 */
ivygatech 4:672a6d537dce 519 void text_fgd_color(int color);
ivygatech 4:672a6d537dce 520 /**
ivygatech 4:672a6d537dce 521 * Set the text background color
ivygatech 4:672a6d537dce 522 * @param color Specify the color to be set
ivygatech 4:672a6d537dce 523 */
ivygatech 4:672a6d537dce 524 void text_bgd_color(int color);
ivygatech 4:672a6d537dce 525 /**
ivygatech 4:672a6d537dce 526 * calculate the width in pixel units for a character
ivygatech 4:672a6d537dce 527 * @param c Character for the width calculation
ivygatech 4:672a6d537dce 528 */
ivygatech 4:672a6d537dce 529 void char_width(char c);
ivygatech 4:672a6d537dce 530 /**
ivygatech 4:672a6d537dce 531 * calculate the height in pixel units for a character
ivygatech 4:672a6d537dce 532 * @param c Character for the height calculation
ivygatech 4:672a6d537dce 533 */
ivygatech 4:672a6d537dce 534 void char_height(char c);
ivygatech 4:672a6d537dce 535 /** place char at current cursor position
ivygatech 4:672a6d537dce 536 * used by virtual printf function _putc
ivygatech 4:672a6d537dce 537 * @param c Character to be printed out
ivygatech 4:672a6d537dce 538 */
ivygatech 4:672a6d537dce 539 void putc(char c);
ivygatech 4:672a6d537dce 540 /** place string at current cursor position
ivygatech 4:672a6d537dce 541 * @param s String to be printed out
ivygatech 4:672a6d537dce 542 */
ivygatech 4:672a6d537dce 543 void puts(char *s);
ivygatech 0:de1ab53f3480 544
ivygatech 0:de1ab53f3480 545 // Touch Command
ivygatech 5:8acc50389659 546 /** Specify a new touch detect region on the screen
ivygatech 5:8acc50389659 547 * @param x1 x-coordinate of the top left corner of the region
ivygatech 5:8acc50389659 548 * @param y1 y-coordinate of the top left corner of the region
ivygatech 5:8acc50389659 549 * @param x2 x-coordinate of the bottom right corner of the region
ivygatech 5:8acc50389659 550 * @param y2 y-coordinate of the bottom rigth corner of the region
ivygatech 5:8acc50389659 551 */
ivygatech 5:8acc50389659 552 void detect_touch_region(int x1, int y1, int x2, int y2);
ivygatech 5:8acc50389659 553 /** Get X coordinates of the touch
ivygatech 5:8acc50389659 554 * @param x X coordinate of the touch
ivygatech 5:8acc50389659 555 */
ivygatech 5:8acc50389659 556 void touch_get_x(int *x);
ivygatech 5:8acc50389659 557 /** Get Y coordinates of the touch
ivygatech 5:8acc50389659 558 * @param y Y coordinate of the touch
ivygatech 5:8acc50389659 559 */
ivygatech 5:8acc50389659 560 void touch_get_y(int *y);
ivygatech 5:8acc50389659 561 /** Set various touch screen related parameters
ivygatech 5:8acc50389659 562 * @param mode Mode = 0: enable and initialise touch screen hardware; mode = 1: disable the touch screen; mode = 2: reset the current active region to default which is the full screen area
ivygatech 5:8acc50389659 563 */
ivygatech 5:8acc50389659 564 void touch_set(char mode);
ivygatech 5:8acc50389659 565 /** Get the status of the screen
ivygatech 5:8acc50389659 566 * @return Status of the screen: 0 = INVALID/NOTOUCH, 1 = PRESS, 2 = RELEASE, 3 = MOVING
ivygatech 5:8acc50389659 567 */
ivygatech 0:de1ab53f3480 568 int touch_status(void);
ivygatech 0:de1ab53f3480 569
ivygatech 0:de1ab53f3480 570 // Screen Version Data
ivygatech 0:de1ab53f3480 571 int version;
ivygatech 0:de1ab53f3480 572 int SPEversion;
ivygatech 0:de1ab53f3480 573 int PmmCversion;
ivygatech 0:de1ab53f3480 574
ivygatech 0:de1ab53f3480 575 // Text data
ivygatech 0:de1ab53f3480 576 char current_col;
ivygatech 0:de1ab53f3480 577 char current_row;
ivygatech 0:de1ab53f3480 578 int current_color;
ivygatech 0:de1ab53f3480 579 char current_font;
ivygatech 0:de1ab53f3480 580 char current_orientation;
ivygatech 0:de1ab53f3480 581 char max_col;
ivygatech 0:de1ab53f3480 582 char max_row;
ivygatech 0:de1ab53f3480 583 int current_w, current_h;
ivygatech 0:de1ab53f3480 584 int current_fx, current_fy;
ivygatech 0:de1ab53f3480 585
ivygatech 0:de1ab53f3480 586 protected :
ivygatech 0:de1ab53f3480 587
ivygatech 0:de1ab53f3480 588 Serial _cmd;
ivygatech 0:de1ab53f3480 589 DigitalOut _rst;
ivygatech 0:de1ab53f3480 590
ivygatech 0:de1ab53f3480 591 //used by printf
ivygatech 0:de1ab53f3480 592 virtual int _putc(int c) {
ivygatech 0:de1ab53f3480 593 putc(c);
ivygatech 0:de1ab53f3480 594 return 0;
ivygatech 0:de1ab53f3480 595 };
ivygatech 0:de1ab53f3480 596 virtual int _getc() {
ivygatech 0:de1ab53f3480 597 return -1;
ivygatech 0:de1ab53f3480 598 }
ivygatech 0:de1ab53f3480 599
ivygatech 0:de1ab53f3480 600 void freeBUFFER (void);
ivygatech 0:de1ab53f3480 601 void writeBYTE (char);
ivygatech 0:de1ab53f3480 602 int writeCOMMAND(char *, int, int);
ivygatech 0:de1ab53f3480 603 int readVERSION (char *, int);
ivygatech 0:de1ab53f3480 604 void getTOUCH (char *, int, int *);
ivygatech 0:de1ab53f3480 605 int getSTATUS (char *, int);
ivygatech 0:de1ab53f3480 606 void speversion (void);
ivygatech 0:de1ab53f3480 607 void pmmcversion (void);
ivygatech 0:de1ab53f3480 608 #if DEBUGMODE
ivygatech 0:de1ab53f3480 609 Serial pc;
ivygatech 0:de1ab53f3480 610 #endif // DEBUGMODE
ivygatech 0:de1ab53f3480 611 };
ivygatech 0:de1ab53f3480 612
ivygatech 2:60f6946df58c 613 typedef unsigned char BYTE;
ivygatech 2:60f6946df58c 614