This is the Official SmartGPU 2 processor board library to use with MBED boards!!!

Dependents:   BounceBall_SG2 BounceBalls_SG2 EEPROM_SG2 Ellipses_SG2 ... more

Committer:
emmanuelchio
Date:
Tue Jul 09 08:18:07 2013 +0000
Revision:
0:210b5ba62803
Child:
1:0bf6fac21233
Official SmartGPU 2 processor board - MBED library!!!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emmanuelchio 0:210b5ba62803 1 /*********************************************************
emmanuelchio 0:210b5ba62803 2 VIZIC TECHNOLOGIES. COPYRIGHT 2013.
emmanuelchio 0:210b5ba62803 3 THE DATASHEETS, SOFTWARE AND LIBRARIES ARE PROVIDED "AS IS."
emmanuelchio 0:210b5ba62803 4 VIZIC EXPRESSLY DISCLAIM ANY WARRANTY OF ANY KIND, WHETHER
emmanuelchio 0:210b5ba62803 5 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED
emmanuelchio 0:210b5ba62803 6 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
emmanuelchio 0:210b5ba62803 7 OR NONINFRINGEMENT. IN NO EVENT SHALL VIZIC BE LIABLE FOR
emmanuelchio 0:210b5ba62803 8 ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES,
emmanuelchio 0:210b5ba62803 9 LOST PROFITS OR LOST DATA, HARM TO YOUR EQUIPMENT, COST OF
emmanuelchio 0:210b5ba62803 10 PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES,
emmanuelchio 0:210b5ba62803 11 ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO
emmanuelchio 0:210b5ba62803 12 ANY DEFENCE THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION,
emmanuelchio 0:210b5ba62803 13 OR OTHER SIMILAR COSTS.
emmanuelchio 0:210b5ba62803 14 *********************************************************/
emmanuelchio 0:210b5ba62803 15
emmanuelchio 0:210b5ba62803 16 /********************************************************
emmanuelchio 0:210b5ba62803 17 MBED SMARTGPU2 LIBRARY VERSION V1.0
emmanuelchio 0:210b5ba62803 18 IMPORTANT : This library is created for the MBED Software IDE
emmanuelchio 0:210b5ba62803 19 ********************************************************/
emmanuelchio 0:210b5ba62803 20
emmanuelchio 0:210b5ba62803 21 #include "mbed.h"
emmanuelchio 0:210b5ba62803 22 #include "SMARTGPU2.h"
emmanuelchio 0:210b5ba62803 23
emmanuelchio 0:210b5ba62803 24 /****************************************************************/
emmanuelchio 0:210b5ba62803 25 //Communication Functions(PLATFORM DEPENDENT) - MODIFY TO FIT YOUR PLATFORM IF DIFFERENT THAN MBED
emmanuelchio 0:210b5ba62803 26 /****************************************************************/
emmanuelchio 0:210b5ba62803 27 //Sends a single character through the serial port(USART)
emmanuelchio 0:210b5ba62803 28 #define putcharTX(data) _serialSMARTGPU2.putc(data)
emmanuelchio 0:210b5ba62803 29
emmanuelchio 0:210b5ba62803 30 //Returns a single character obtained from the serial port(USART)
emmanuelchio 0:210b5ba62803 31 #define getcharRX() _serialSMARTGPU2.getc()
emmanuelchio 0:210b5ba62803 32
emmanuelchio 0:210b5ba62803 33 //Changes/Sets a new baudrate of the Host
emmanuelchio 0:210b5ba62803 34 #define setBaud(newBaud) _serialSMARTGPU2.baud(newBaud)
emmanuelchio 0:210b5ba62803 35
emmanuelchio 0:210b5ba62803 36 //Performs a Hardware Reset on smartGPU2 RESETPIN
emmanuelchio 0:210b5ba62803 37 SMARTGPUREPLY SMARTGPU2::reset(){ //Physically Reset the SMARTGPU2 board
emmanuelchio 0:210b5ba62803 38 _resetPin=GND; // set the pin to GND to reset
emmanuelchio 0:210b5ba62803 39 wait_ms(500);
emmanuelchio 0:210b5ba62803 40 _resetPin=VCC; // set the pin to 5v to end reset
emmanuelchio 0:210b5ba62803 41 wait_ms(500);
emmanuelchio 0:210b5ba62803 42 return OK;
emmanuelchio 0:210b5ba62803 43 }
emmanuelchio 0:210b5ba62803 44
emmanuelchio 0:210b5ba62803 45 //MBED Exclusive - Hardware Configuration
emmanuelchio 0:210b5ba62803 46 void SMARTGPU2::init(){ //configure the MBED board for SMARTGPU2 board
emmanuelchio 0:210b5ba62803 47 setBaud(9600);
emmanuelchio 0:210b5ba62803 48 _resetPin=VCC; // set the pin to 5v to end reset
emmanuelchio 0:210b5ba62803 49 }
emmanuelchio 0:210b5ba62803 50
emmanuelchio 0:210b5ba62803 51 /****************************************************************/
emmanuelchio 0:210b5ba62803 52 /****************************************************************/
emmanuelchio 0:210b5ba62803 53 /****************************************************************/
emmanuelchio 0:210b5ba62803 54 //SmartGPU2 Library exclusive Functions - DO NOT MODIFY DOWN FROM HERE
emmanuelchio 0:210b5ba62803 55 /****************************************************************/
emmanuelchio 0:210b5ba62803 56 /****************************************************************/
emmanuelchio 0:210b5ba62803 57 /****************************************************************/
emmanuelchio 0:210b5ba62803 58 // SMART GPU2 DEFAULT BAUD RATE: 9600bps
emmanuelchio 0:210b5ba62803 59 //It shoud be used like this : SMARTGPU2 lcd(TXPIN,RXPIN,RESET); for serial communication with SMARTGPU2
emmanuelchio 0:210b5ba62803 60 SMARTGPU2::SMARTGPU2(PinName TXPin, PinName RXPin, PinName resetPin): _serialSMARTGPU2(TXPin,RXPin), _resetPin(resetPin){
emmanuelchio 0:210b5ba62803 61 init();
emmanuelchio 0:210b5ba62803 62 }
emmanuelchio 0:210b5ba62803 63
emmanuelchio 0:210b5ba62803 64 SMARTGPUREPLY SMARTGPU2::start(){ //Init the SMARTGPU2
emmanuelchio 0:210b5ba62803 65 wait_ms(500);
emmanuelchio 0:210b5ba62803 66 putcharTX('U');
emmanuelchio 0:210b5ba62803 67 wait_ms(500);
emmanuelchio 0:210b5ba62803 68 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 69 }
emmanuelchio 0:210b5ba62803 70
emmanuelchio 0:210b5ba62803 71
emmanuelchio 0:210b5ba62803 72 /****************************************************************/
emmanuelchio 0:210b5ba62803 73 //Master Functions
emmanuelchio 0:210b5ba62803 74 /****************************************************************/
emmanuelchio 0:210b5ba62803 75 SMARTGPUREPLY SMARTGPU2::erase(){ //Erase the SMARTGPU2 screen
emmanuelchio 0:210b5ba62803 76 putcharTX('M'); //Master function
emmanuelchio 0:210b5ba62803 77 putcharTX('E');
emmanuelchio 0:210b5ba62803 78 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 79 }
emmanuelchio 0:210b5ba62803 80
emmanuelchio 0:210b5ba62803 81 SMARTGPUREPLY SMARTGPU2::sleep(STATE state){ //Send SMARTGPU2 to sleep mode
emmanuelchio 0:210b5ba62803 82 putcharTX('M'); //Master function
emmanuelchio 0:210b5ba62803 83 putcharTX('Z');
emmanuelchio 0:210b5ba62803 84 putcharTX(state);
emmanuelchio 0:210b5ba62803 85 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 86 }
emmanuelchio 0:210b5ba62803 87
emmanuelchio 0:210b5ba62803 88 SMARTGPUREPLY SMARTGPU2::orientation(LCDORIENTATIONS side){ //Change display orientation
emmanuelchio 0:210b5ba62803 89 putcharTX('M'); //Master function
emmanuelchio 0:210b5ba62803 90 putcharTX('O');
emmanuelchio 0:210b5ba62803 91 putcharTX(side);
emmanuelchio 0:210b5ba62803 92 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 93 }
emmanuelchio 0:210b5ba62803 94
emmanuelchio 0:210b5ba62803 95 SMARTGPUREPLY SMARTGPU2::bright(unsigned char val){ //Change display brightness
emmanuelchio 0:210b5ba62803 96 putcharTX('M'); //Master function
emmanuelchio 0:210b5ba62803 97 putcharTX('B');
emmanuelchio 0:210b5ba62803 98 putcharTX(val);
emmanuelchio 0:210b5ba62803 99 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 100 }
emmanuelchio 0:210b5ba62803 101
emmanuelchio 0:210b5ba62803 102 // SMART GPU 2 DEFAULT/INITIAL BAUD RATE: 9600bps
emmanuelchio 0:210b5ba62803 103 SMARTGPUREPLY SMARTGPU2::baudChange(unsigned long baud){ //Change baud rate of MBED and SMARTGPU2 board
emmanuelchio 0:210b5ba62803 104 unsigned char aux;
emmanuelchio 0:210b5ba62803 105
emmanuelchio 0:210b5ba62803 106 putcharTX('M'); //Master function
emmanuelchio 0:210b5ba62803 107 putcharTX('X');
emmanuelchio 0:210b5ba62803 108 putcharTX(baud>>24);
emmanuelchio 0:210b5ba62803 109 putcharTX(baud>>16);
emmanuelchio 0:210b5ba62803 110 putcharTX(baud>>8);
emmanuelchio 0:210b5ba62803 111 putcharTX(baud);
emmanuelchio 0:210b5ba62803 112 aux=getcharRX();
emmanuelchio 0:210b5ba62803 113 if(aux=='O'){ //if command is successfull, change baudrate, if not just leave and return 'F'
emmanuelchio 0:210b5ba62803 114 wait_ms(150);
emmanuelchio 0:210b5ba62803 115 setBaud(baud);
emmanuelchio 0:210b5ba62803 116 wait_ms(200);
emmanuelchio 0:210b5ba62803 117 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 118 }else{
emmanuelchio 0:210b5ba62803 119 return (SMARTGPUREPLY)aux;
emmanuelchio 0:210b5ba62803 120 }
emmanuelchio 0:210b5ba62803 121 }
emmanuelchio 0:210b5ba62803 122
emmanuelchio 0:210b5ba62803 123 SMARTGPUREPLY SMARTGPU2::setEraseBackColour(COLOUR colour){ //Change the default screen background colour for erase function
emmanuelchio 0:210b5ba62803 124 putcharTX('M'); //Master function
emmanuelchio 0:210b5ba62803 125 putcharTX('C'); //Background Colour
emmanuelchio 0:210b5ba62803 126 putcharTX(colour>>8);
emmanuelchio 0:210b5ba62803 127 putcharTX(colour);
emmanuelchio 0:210b5ba62803 128 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 129 }
emmanuelchio 0:210b5ba62803 130
emmanuelchio 0:210b5ba62803 131
emmanuelchio 0:210b5ba62803 132 /****************************************************************/
emmanuelchio 0:210b5ba62803 133 //Geometric Functions
emmanuelchio 0:210b5ba62803 134 /****************************************************************/
emmanuelchio 0:210b5ba62803 135 SMARTGPUREPLY SMARTGPU2::putPixel(AXIS x, AXIS y, COLOUR colour){ //Draw a pixel on the screen
emmanuelchio 0:210b5ba62803 136 putcharTX('G'); //Geometric function
emmanuelchio 0:210b5ba62803 137 putcharTX('P');
emmanuelchio 0:210b5ba62803 138 putcharTX(x>>8);
emmanuelchio 0:210b5ba62803 139 putcharTX(x);
emmanuelchio 0:210b5ba62803 140 putcharTX(y>>8);
emmanuelchio 0:210b5ba62803 141 putcharTX(y);
emmanuelchio 0:210b5ba62803 142 putcharTX(colour>>8);
emmanuelchio 0:210b5ba62803 143 putcharTX(colour);
emmanuelchio 0:210b5ba62803 144 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 145 }
emmanuelchio 0:210b5ba62803 146
emmanuelchio 0:210b5ba62803 147 SMARTGPUREPLY SMARTGPU2::drawLine(AXIS x1, AXIS y1, AXIS x2, AXIS y2, COLOUR colour){ //Draw a line on the screen
emmanuelchio 0:210b5ba62803 148 putcharTX('G'); //Geometric function
emmanuelchio 0:210b5ba62803 149 putcharTX('L');
emmanuelchio 0:210b5ba62803 150 putcharTX(x1>>8);
emmanuelchio 0:210b5ba62803 151 putcharTX(x1);
emmanuelchio 0:210b5ba62803 152 putcharTX(y1>>8);
emmanuelchio 0:210b5ba62803 153 putcharTX(y1);
emmanuelchio 0:210b5ba62803 154 putcharTX(x2>>8);
emmanuelchio 0:210b5ba62803 155 putcharTX(x2);
emmanuelchio 0:210b5ba62803 156 putcharTX(y2>>8);
emmanuelchio 0:210b5ba62803 157 putcharTX(y2);
emmanuelchio 0:210b5ba62803 158 putcharTX(colour>>8);
emmanuelchio 0:210b5ba62803 159 putcharTX(colour);
emmanuelchio 0:210b5ba62803 160 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 161 }
emmanuelchio 0:210b5ba62803 162
emmanuelchio 0:210b5ba62803 163 SMARTGPUREPLY SMARTGPU2::drawRectangle(AXIS x1, AXIS y1, AXIS x2, AXIS y2, COLOUR colour, FILLGEOM fill){ //Draw a rectangle on the screen
emmanuelchio 0:210b5ba62803 164 putcharTX('G'); //Geometric function
emmanuelchio 0:210b5ba62803 165 putcharTX('R'); //Rectangle
emmanuelchio 0:210b5ba62803 166 putcharTX(x1>>8);
emmanuelchio 0:210b5ba62803 167 putcharTX(x1);
emmanuelchio 0:210b5ba62803 168 putcharTX(y1>>8);
emmanuelchio 0:210b5ba62803 169 putcharTX(y1);
emmanuelchio 0:210b5ba62803 170 putcharTX(x2>>8);
emmanuelchio 0:210b5ba62803 171 putcharTX(x2);
emmanuelchio 0:210b5ba62803 172 putcharTX(y2>>8);
emmanuelchio 0:210b5ba62803 173 putcharTX(y2);
emmanuelchio 0:210b5ba62803 174 putcharTX(colour>>8);
emmanuelchio 0:210b5ba62803 175 putcharTX(colour);
emmanuelchio 0:210b5ba62803 176 putcharTX(fill);
emmanuelchio 0:210b5ba62803 177 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 178 }
emmanuelchio 0:210b5ba62803 179
emmanuelchio 0:210b5ba62803 180 SMARTGPUREPLY SMARTGPU2::drawRoundRect(AXIS x1, AXIS y1, AXIS x2, AXIS y2, RADIUS radius, COLOUR colour, FILLGEOM fill){ //Draw a rounded rectangle on the screen
emmanuelchio 0:210b5ba62803 181 putcharTX('G'); //Geometric function
emmanuelchio 0:210b5ba62803 182 putcharTX('O'); //Rounded Rectangle
emmanuelchio 0:210b5ba62803 183 putcharTX(x1>>8);
emmanuelchio 0:210b5ba62803 184 putcharTX(x1);
emmanuelchio 0:210b5ba62803 185 putcharTX(y1>>8);
emmanuelchio 0:210b5ba62803 186 putcharTX(y1);
emmanuelchio 0:210b5ba62803 187 putcharTX(x2>>8);
emmanuelchio 0:210b5ba62803 188 putcharTX(x2);
emmanuelchio 0:210b5ba62803 189 putcharTX(y2>>8);
emmanuelchio 0:210b5ba62803 190 putcharTX(y2);
emmanuelchio 0:210b5ba62803 191 putcharTX(radius>>8);
emmanuelchio 0:210b5ba62803 192 putcharTX(radius);
emmanuelchio 0:210b5ba62803 193 putcharTX(colour>>8);
emmanuelchio 0:210b5ba62803 194 putcharTX(colour);
emmanuelchio 0:210b5ba62803 195 putcharTX(fill);
emmanuelchio 0:210b5ba62803 196 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 197 }
emmanuelchio 0:210b5ba62803 198
emmanuelchio 0:210b5ba62803 199 SMARTGPUREPLY SMARTGPU2::drawGradientRect(AXIS x1, AXIS y1, AXIS x2, AXIS y2, COLOUR firstColour, COLOUR lastColour, ORIENTATIONPARAMETER direction){
emmanuelchio 0:210b5ba62803 200 putcharTX('G'); //Geometric function
emmanuelchio 0:210b5ba62803 201 putcharTX('G'); //Gradient rectangle function
emmanuelchio 0:210b5ba62803 202 putcharTX(x1>>8);
emmanuelchio 0:210b5ba62803 203 putcharTX(x1);
emmanuelchio 0:210b5ba62803 204 putcharTX(y1>>8);
emmanuelchio 0:210b5ba62803 205 putcharTX(y1);
emmanuelchio 0:210b5ba62803 206 putcharTX(x2>>8);
emmanuelchio 0:210b5ba62803 207 putcharTX(x2);
emmanuelchio 0:210b5ba62803 208 putcharTX(y2>>8);
emmanuelchio 0:210b5ba62803 209 putcharTX(y2);
emmanuelchio 0:210b5ba62803 210 putcharTX(firstColour>>8);
emmanuelchio 0:210b5ba62803 211 putcharTX(firstColour);
emmanuelchio 0:210b5ba62803 212 putcharTX(lastColour>>8);
emmanuelchio 0:210b5ba62803 213 putcharTX(lastColour);
emmanuelchio 0:210b5ba62803 214 putcharTX(direction);
emmanuelchio 0:210b5ba62803 215 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 216 }
emmanuelchio 0:210b5ba62803 217
emmanuelchio 0:210b5ba62803 218 SMARTGPUREPLY SMARTGPU2::drawTriangle(AXIS x1, AXIS y1, AXIS x2, AXIS y2, AXIS x3, AXIS y3, COLOUR colour, FILLGEOM fill){ //Draw a triangle on the screen
emmanuelchio 0:210b5ba62803 219 putcharTX('G'); //Geometric function
emmanuelchio 0:210b5ba62803 220 putcharTX('T');
emmanuelchio 0:210b5ba62803 221 putcharTX(x1>>8);
emmanuelchio 0:210b5ba62803 222 putcharTX(x1);
emmanuelchio 0:210b5ba62803 223 putcharTX(y1>>8);
emmanuelchio 0:210b5ba62803 224 putcharTX(y1);
emmanuelchio 0:210b5ba62803 225 putcharTX(x2>>8);
emmanuelchio 0:210b5ba62803 226 putcharTX(x2);
emmanuelchio 0:210b5ba62803 227 putcharTX(y2>>8);
emmanuelchio 0:210b5ba62803 228 putcharTX(y2);
emmanuelchio 0:210b5ba62803 229 putcharTX(x3>>8);
emmanuelchio 0:210b5ba62803 230 putcharTX(x3);
emmanuelchio 0:210b5ba62803 231 putcharTX(y3>>8);
emmanuelchio 0:210b5ba62803 232 putcharTX(y3);
emmanuelchio 0:210b5ba62803 233 putcharTX(colour>>8);
emmanuelchio 0:210b5ba62803 234 putcharTX(colour);
emmanuelchio 0:210b5ba62803 235 putcharTX(fill);
emmanuelchio 0:210b5ba62803 236 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 237 }
emmanuelchio 0:210b5ba62803 238
emmanuelchio 0:210b5ba62803 239 SMARTGPUREPLY SMARTGPU2::drawArc(AXIS x, AXIS y, RADIUS radiusx, RADIUS radiusy, ARCQUADRANT quadrant, COLOUR colour, FILLGEOM fill){ //Draw an Arc on the screen
emmanuelchio 0:210b5ba62803 240 putcharTX('G'); //Geometric function
emmanuelchio 0:210b5ba62803 241 putcharTX('A'); //Arc
emmanuelchio 0:210b5ba62803 242 putcharTX(x>>8);
emmanuelchio 0:210b5ba62803 243 putcharTX(x);
emmanuelchio 0:210b5ba62803 244 putcharTX(y>>8);
emmanuelchio 0:210b5ba62803 245 putcharTX(y);
emmanuelchio 0:210b5ba62803 246 putcharTX(radiusx>>8);
emmanuelchio 0:210b5ba62803 247 putcharTX(radiusx);
emmanuelchio 0:210b5ba62803 248 putcharTX(radiusy>>8);
emmanuelchio 0:210b5ba62803 249 putcharTX(radiusy);
emmanuelchio 0:210b5ba62803 250 putcharTX(quadrant);
emmanuelchio 0:210b5ba62803 251 putcharTX(colour>>8);
emmanuelchio 0:210b5ba62803 252 putcharTX(colour);
emmanuelchio 0:210b5ba62803 253 putcharTX(fill);
emmanuelchio 0:210b5ba62803 254 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 255 }
emmanuelchio 0:210b5ba62803 256
emmanuelchio 0:210b5ba62803 257 SMARTGPUREPLY SMARTGPU2::drawCircle(AXIS x, AXIS y, RADIUS radius, COLOUR colour, FILLGEOM fill){ //Draw a circle on the screen
emmanuelchio 0:210b5ba62803 258 putcharTX('G'); //Geometric function
emmanuelchio 0:210b5ba62803 259 putcharTX('C'); //Circle
emmanuelchio 0:210b5ba62803 260 putcharTX(x>>8);
emmanuelchio 0:210b5ba62803 261 putcharTX(x);
emmanuelchio 0:210b5ba62803 262 putcharTX(y>>8);
emmanuelchio 0:210b5ba62803 263 putcharTX(y);
emmanuelchio 0:210b5ba62803 264 putcharTX(radius>>8);
emmanuelchio 0:210b5ba62803 265 putcharTX(radius);
emmanuelchio 0:210b5ba62803 266 putcharTX(colour>>8);
emmanuelchio 0:210b5ba62803 267 putcharTX(colour);
emmanuelchio 0:210b5ba62803 268 putcharTX(fill);
emmanuelchio 0:210b5ba62803 269 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 270 }
emmanuelchio 0:210b5ba62803 271
emmanuelchio 0:210b5ba62803 272 SMARTGPUREPLY SMARTGPU2::drawEllipse(AXIS x, AXIS y, RADIUS radiusx, RADIUS radiusy, COLOUR colour, FILLGEOM fill){ //Draw an Ellipse on the screen
emmanuelchio 0:210b5ba62803 273 putcharTX('G'); //Geometric function
emmanuelchio 0:210b5ba62803 274 putcharTX('E'); //Ellipse
emmanuelchio 0:210b5ba62803 275 putcharTX(x>>8);
emmanuelchio 0:210b5ba62803 276 putcharTX(x);
emmanuelchio 0:210b5ba62803 277 putcharTX(y>>8);
emmanuelchio 0:210b5ba62803 278 putcharTX(y);
emmanuelchio 0:210b5ba62803 279 putcharTX(radiusx>>8);
emmanuelchio 0:210b5ba62803 280 putcharTX(radiusx);
emmanuelchio 0:210b5ba62803 281 putcharTX(radiusy>>8);
emmanuelchio 0:210b5ba62803 282 putcharTX(radiusy);
emmanuelchio 0:210b5ba62803 283 putcharTX(colour>>8);
emmanuelchio 0:210b5ba62803 284 putcharTX(colour);
emmanuelchio 0:210b5ba62803 285 putcharTX(fill);
emmanuelchio 0:210b5ba62803 286 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 287 }
emmanuelchio 0:210b5ba62803 288
emmanuelchio 0:210b5ba62803 289
emmanuelchio 0:210b5ba62803 290 /****************************************************************/
emmanuelchio 0:210b5ba62803 291 //String Functions
emmanuelchio 0:210b5ba62803 292 /****************************************************************/
emmanuelchio 0:210b5ba62803 293 SMARTGPUREPLY SMARTGPU2::putLetter(AXIS x, AXIS y, char letter, AXIS *xUpdated){ //Draw a letter on the screen on X,Y coords, returns updated value of X axis in xUpdated variable
emmanuelchio 0:210b5ba62803 294 unsigned int xUp = 0; //variable to store the updated position of X axis after command is called/char is printed
emmanuelchio 0:210b5ba62803 295
emmanuelchio 0:210b5ba62803 296 putcharTX('S'); //String Function
emmanuelchio 0:210b5ba62803 297 putcharTX('L'); //Letter - a simple letter
emmanuelchio 0:210b5ba62803 298 putcharTX(x>>8);
emmanuelchio 0:210b5ba62803 299 putcharTX(x);
emmanuelchio 0:210b5ba62803 300 putcharTX(y>>8);
emmanuelchio 0:210b5ba62803 301 putcharTX(y);
emmanuelchio 0:210b5ba62803 302 putcharTX(letter);
emmanuelchio 0:210b5ba62803 303
emmanuelchio 0:210b5ba62803 304 xUp=getcharRX();
emmanuelchio 0:210b5ba62803 305 xUp=xUp<<8;
emmanuelchio 0:210b5ba62803 306 xUp|=getcharRX();
emmanuelchio 0:210b5ba62803 307 *xUpdated = xUp;
emmanuelchio 0:210b5ba62803 308 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 309 }
emmanuelchio 0:210b5ba62803 310
emmanuelchio 0:210b5ba62803 311 SMARTGPUREPLY SMARTGPU2::printNumber(AXIS x, AXIS y, float number){ //Prints a float number on screen
emmanuelchio 0:210b5ba62803 312 putcharTX('S'); //String Function
emmanuelchio 0:210b5ba62803 313 putcharTX('N'); //Number
emmanuelchio 0:210b5ba62803 314 putcharTX(x>>8);
emmanuelchio 0:210b5ba62803 315 putcharTX(x);
emmanuelchio 0:210b5ba62803 316 putcharTX(y>>8);
emmanuelchio 0:210b5ba62803 317 putcharTX(y);
emmanuelchio 0:210b5ba62803 318 putcharTX(((char *)&number)[3]);
emmanuelchio 0:210b5ba62803 319 putcharTX(((char *)&number)[2]);
emmanuelchio 0:210b5ba62803 320 putcharTX(((char *)&number)[1]);
emmanuelchio 0:210b5ba62803 321 putcharTX(((char *)&number)[0]);
emmanuelchio 0:210b5ba62803 322 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 323 }
emmanuelchio 0:210b5ba62803 324
emmanuelchio 0:210b5ba62803 325 SMARTGPUREPLY SMARTGPU2::string(AXIS x1, AXIS y1, AXIS x2, AXIS y2, char text[], NUMBEROFBYTES *SPB){ //Draw a string on the screen on defined Text Box coords, and stores the successfully printed bytes on SPB
emmanuelchio 0:210b5ba62803 326 unsigned int counter=0, sp=0;
emmanuelchio 0:210b5ba62803 327
emmanuelchio 0:210b5ba62803 328 putcharTX('S'); //String Function
emmanuelchio 0:210b5ba62803 329 putcharTX('S'); //String
emmanuelchio 0:210b5ba62803 330 putcharTX(x1>>8);
emmanuelchio 0:210b5ba62803 331 putcharTX(x1);
emmanuelchio 0:210b5ba62803 332 putcharTX(y1>>8);
emmanuelchio 0:210b5ba62803 333 putcharTX(y1);
emmanuelchio 0:210b5ba62803 334 putcharTX(x2>>8);
emmanuelchio 0:210b5ba62803 335 putcharTX(x2);
emmanuelchio 0:210b5ba62803 336 putcharTX(y2>>8);
emmanuelchio 0:210b5ba62803 337 putcharTX(y2);
emmanuelchio 0:210b5ba62803 338 while(1){
emmanuelchio 0:210b5ba62803 339 putcharTX(text[counter]);
emmanuelchio 0:210b5ba62803 340 if(text[counter]==0x00){
emmanuelchio 0:210b5ba62803 341 break;
emmanuelchio 0:210b5ba62803 342 }
emmanuelchio 0:210b5ba62803 343 counter++;
emmanuelchio 0:210b5ba62803 344 }
emmanuelchio 0:210b5ba62803 345
emmanuelchio 0:210b5ba62803 346 sp=getcharRX();
emmanuelchio 0:210b5ba62803 347 sp=sp<<8;
emmanuelchio 0:210b5ba62803 348 sp|=getcharRX();
emmanuelchio 0:210b5ba62803 349 *SPB = sp;
emmanuelchio 0:210b5ba62803 350 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 351 }
emmanuelchio 0:210b5ba62803 352
emmanuelchio 0:210b5ba62803 353 SMARTGPUREPLY SMARTGPU2::stringSD(AXIS x1, AXIS y1, AXIS x2, AXIS y2, NUMBEROFBYTES BS, NUMBEROFBYTES BR, FILENAME name, NUMBEROFBYTES *SPB){ //Draw a String from a text file stored on the micro SD card
emmanuelchio 0:210b5ba62803 354 unsigned char counter=0, sp=0;
emmanuelchio 0:210b5ba62803 355
emmanuelchio 0:210b5ba62803 356 putcharTX('S'); //String function
emmanuelchio 0:210b5ba62803 357 putcharTX('F'); //text File from SD
emmanuelchio 0:210b5ba62803 358 putcharTX(x1>>8);
emmanuelchio 0:210b5ba62803 359 putcharTX(x1);
emmanuelchio 0:210b5ba62803 360 putcharTX(y1>>8);
emmanuelchio 0:210b5ba62803 361 putcharTX(y1);
emmanuelchio 0:210b5ba62803 362 putcharTX(x2>>8);
emmanuelchio 0:210b5ba62803 363 putcharTX(x2);
emmanuelchio 0:210b5ba62803 364 putcharTX(y2>>8);
emmanuelchio 0:210b5ba62803 365 putcharTX(y2);
emmanuelchio 0:210b5ba62803 366 putcharTX(BS>>8);
emmanuelchio 0:210b5ba62803 367 putcharTX(BS);
emmanuelchio 0:210b5ba62803 368 putcharTX(BR>>8);
emmanuelchio 0:210b5ba62803 369 putcharTX(BR);
emmanuelchio 0:210b5ba62803 370 while(1){
emmanuelchio 0:210b5ba62803 371 putcharTX(name[counter]);
emmanuelchio 0:210b5ba62803 372 if(name[counter]==0x00){
emmanuelchio 0:210b5ba62803 373 break;
emmanuelchio 0:210b5ba62803 374 }
emmanuelchio 0:210b5ba62803 375 counter++;
emmanuelchio 0:210b5ba62803 376 }
emmanuelchio 0:210b5ba62803 377
emmanuelchio 0:210b5ba62803 378 sp=getcharRX();
emmanuelchio 0:210b5ba62803 379 sp=sp<<8;
emmanuelchio 0:210b5ba62803 380 sp|=getcharRX();
emmanuelchio 0:210b5ba62803 381 *SPB = sp;
emmanuelchio 0:210b5ba62803 382 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 383 }
emmanuelchio 0:210b5ba62803 384
emmanuelchio 0:210b5ba62803 385 SMARTGPUREPLY SMARTGPU2::setTextColour(COLOUR colour){ //Set the default text colour for letters and strings
emmanuelchio 0:210b5ba62803 386 putcharTX('S'); //String Function
emmanuelchio 0:210b5ba62803 387 putcharTX('C'); //Config
emmanuelchio 0:210b5ba62803 388 putcharTX('T'); //Text
emmanuelchio 0:210b5ba62803 389 putcharTX(colour>>8);
emmanuelchio 0:210b5ba62803 390 putcharTX(colour);
emmanuelchio 0:210b5ba62803 391 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 392 }
emmanuelchio 0:210b5ba62803 393
emmanuelchio 0:210b5ba62803 394 SMARTGPUREPLY SMARTGPU2::setTextBackColour(COLOUR colour){ //Set the default text background colour for letters and strings
emmanuelchio 0:210b5ba62803 395 putcharTX('S'); //String Function
emmanuelchio 0:210b5ba62803 396 putcharTX('C'); //Config
emmanuelchio 0:210b5ba62803 397 putcharTX('B'); //Background
emmanuelchio 0:210b5ba62803 398 putcharTX(colour>>8);
emmanuelchio 0:210b5ba62803 399 putcharTX(colour);
emmanuelchio 0:210b5ba62803 400 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 401 }
emmanuelchio 0:210b5ba62803 402
emmanuelchio 0:210b5ba62803 403 SMARTGPUREPLY SMARTGPU2::setTextSize(FONTSIZE size){ //Set the default text size for letters and strings
emmanuelchio 0:210b5ba62803 404 putcharTX('S'); //String Function
emmanuelchio 0:210b5ba62803 405 putcharTX('C'); //Config
emmanuelchio 0:210b5ba62803 406 putcharTX('S'); //Size
emmanuelchio 0:210b5ba62803 407 putcharTX(size);
emmanuelchio 0:210b5ba62803 408 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 409 }
emmanuelchio 0:210b5ba62803 410
emmanuelchio 0:210b5ba62803 411 SMARTGPUREPLY SMARTGPU2::setTextBackFill(TEXTBACKGROUNDCOLOURFILLUNFILL fillState){ //Set the default text FILL or UNFILL background letters and strings
emmanuelchio 0:210b5ba62803 412 putcharTX('S'); //String Function
emmanuelchio 0:210b5ba62803 413 putcharTX('C'); //Config
emmanuelchio 0:210b5ba62803 414 putcharTX('F'); //Fill
emmanuelchio 0:210b5ba62803 415 putcharTX(fillState);
emmanuelchio 0:210b5ba62803 416 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 417 }
emmanuelchio 0:210b5ba62803 418
emmanuelchio 0:210b5ba62803 419
emmanuelchio 0:210b5ba62803 420 /****************************************************************/
emmanuelchio 0:210b5ba62803 421 //Image Functions
emmanuelchio 0:210b5ba62803 422 /****************************************************************/
emmanuelchio 0:210b5ba62803 423 SMARTGPUREPLY SMARTGPU2::drawIcon(AXIS x1, AXIS y1, AXIS x2, AXIS y2, char icon[]){ //Send and image or icon pixel by pixel to SMARTGPU2, 16bit(2 bytes) each pixel RGB565
emmanuelchio 0:210b5ba62803 424 unsigned int i,j,k=0;
emmanuelchio 0:210b5ba62803 425
emmanuelchio 0:210b5ba62803 426 putcharTX('I'); //Image function
emmanuelchio 0:210b5ba62803 427 putcharTX('I'); //Icon image received pixel by pixel
emmanuelchio 0:210b5ba62803 428 putcharTX(x1>>8);
emmanuelchio 0:210b5ba62803 429 putcharTX(x1);
emmanuelchio 0:210b5ba62803 430 putcharTX(y1>>8);
emmanuelchio 0:210b5ba62803 431 putcharTX(y1);
emmanuelchio 0:210b5ba62803 432 putcharTX(x2>>8);
emmanuelchio 0:210b5ba62803 433 putcharTX(x2);
emmanuelchio 0:210b5ba62803 434 putcharTX(y2>>8);
emmanuelchio 0:210b5ba62803 435 putcharTX(y2);
emmanuelchio 0:210b5ba62803 436 //Send icon buffer pixel by pixel
emmanuelchio 0:210b5ba62803 437 for(j=0;j<=(y2-y1);j++){
emmanuelchio 0:210b5ba62803 438 for(i=0;i<=(x2-x1);i++){
emmanuelchio 0:210b5ba62803 439 putcharTX(icon[k++]); //16bit per pixel - Upper 8bits part
emmanuelchio 0:210b5ba62803 440 putcharTX(icon[k++]); //16bit per pixel - Lower 8bits part
emmanuelchio 0:210b5ba62803 441 }
emmanuelchio 0:210b5ba62803 442 }
emmanuelchio 0:210b5ba62803 443
emmanuelchio 0:210b5ba62803 444 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 445 }
emmanuelchio 0:210b5ba62803 446
emmanuelchio 0:210b5ba62803 447 SMARTGPUREPLY SMARTGPU2::imageBMPSD(AXIS x, AXIS y, FILENAME name){ //Draw an Image stored on the micro SD card on the screen, at X,Y top right corner coordinates
emmanuelchio 0:210b5ba62803 448 unsigned char counter=0;
emmanuelchio 0:210b5ba62803 449
emmanuelchio 0:210b5ba62803 450 putcharTX('I'); //Image function
emmanuelchio 0:210b5ba62803 451 putcharTX('B'); //BMP from SD card
emmanuelchio 0:210b5ba62803 452 putcharTX(x>>8);
emmanuelchio 0:210b5ba62803 453 putcharTX(x);
emmanuelchio 0:210b5ba62803 454 putcharTX(y>>8);
emmanuelchio 0:210b5ba62803 455 putcharTX(y);
emmanuelchio 0:210b5ba62803 456 while(1){
emmanuelchio 0:210b5ba62803 457 putcharTX(name[counter]);
emmanuelchio 0:210b5ba62803 458 if(name[counter]==0x00){
emmanuelchio 0:210b5ba62803 459 break;
emmanuelchio 0:210b5ba62803 460 }
emmanuelchio 0:210b5ba62803 461 counter++;
emmanuelchio 0:210b5ba62803 462 }
emmanuelchio 0:210b5ba62803 463 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 464 }
emmanuelchio 0:210b5ba62803 465
emmanuelchio 0:210b5ba62803 466 SMARTGPUREPLY SMARTGPU2::imageJPGSD(AXIS x, AXIS y, JPGSCALEFACTOR scaleFactor, FILENAME name){ //Draw an Image stored on the micro SD card on the screen, at X,Y top right corner coordinates
emmanuelchio 0:210b5ba62803 467 unsigned char counter=0;
emmanuelchio 0:210b5ba62803 468
emmanuelchio 0:210b5ba62803 469 putcharTX('I'); //Image function
emmanuelchio 0:210b5ba62803 470 putcharTX('J'); //JPG from SD card
emmanuelchio 0:210b5ba62803 471 putcharTX(x>>8);
emmanuelchio 0:210b5ba62803 472 putcharTX(x);
emmanuelchio 0:210b5ba62803 473 putcharTX(y>>8);
emmanuelchio 0:210b5ba62803 474 putcharTX(y);
emmanuelchio 0:210b5ba62803 475 putcharTX(scaleFactor);
emmanuelchio 0:210b5ba62803 476 while(1){
emmanuelchio 0:210b5ba62803 477 putcharTX(name[counter]);
emmanuelchio 0:210b5ba62803 478 if(name[counter]==0x00){
emmanuelchio 0:210b5ba62803 479 break;
emmanuelchio 0:210b5ba62803 480 }
emmanuelchio 0:210b5ba62803 481 counter++;
emmanuelchio 0:210b5ba62803 482 }
emmanuelchio 0:210b5ba62803 483 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 484 }
emmanuelchio 0:210b5ba62803 485
emmanuelchio 0:210b5ba62803 486 //Reads a defined x1,x1,x2,y2 box of the SmartGPU display, and returns it pixel by pixel in RGB 888 format, 1 byte per colour, 3 bytes per pixel
emmanuelchio 0:210b5ba62803 487 SMARTGPUREPLY SMARTGPU2::getImageFromMemory(AXIS x1, AXIS y1, AXIS x2, AXIS y2, char buffer[]){ //Read the internal memory of the SMARTGPU2, This command returns 24bit pixels (3 bytes)
emmanuelchio 0:210b5ba62803 488 unsigned int i,j,k=0;
emmanuelchio 0:210b5ba62803 489
emmanuelchio 0:210b5ba62803 490 putcharTX('I'); //Image function
emmanuelchio 0:210b5ba62803 491 putcharTX('M'); //from SmartGPU internal Display Memory
emmanuelchio 0:210b5ba62803 492 putcharTX(x1>>8);
emmanuelchio 0:210b5ba62803 493 putcharTX(x1);
emmanuelchio 0:210b5ba62803 494 putcharTX(y1>>8);
emmanuelchio 0:210b5ba62803 495 putcharTX(y1);
emmanuelchio 0:210b5ba62803 496 putcharTX(x2>>8);
emmanuelchio 0:210b5ba62803 497 putcharTX(x2);
emmanuelchio 0:210b5ba62803 498 putcharTX(y2>>8);
emmanuelchio 0:210b5ba62803 499 putcharTX(y2);
emmanuelchio 0:210b5ba62803 500 //receive all the pixels
emmanuelchio 0:210b5ba62803 501 for(j=0;j<=(y2-y1);j++){
emmanuelchio 0:210b5ba62803 502 for(i=0;i<=(x2-x1);i++){
emmanuelchio 0:210b5ba62803 503 buffer[k++]=getcharRX(); //Red
emmanuelchio 0:210b5ba62803 504 buffer[k++]=getcharRX(); //Green
emmanuelchio 0:210b5ba62803 505 buffer[k++]=getcharRX(); //Blue
emmanuelchio 0:210b5ba62803 506 }
emmanuelchio 0:210b5ba62803 507 }
emmanuelchio 0:210b5ba62803 508 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 509 }
emmanuelchio 0:210b5ba62803 510
emmanuelchio 0:210b5ba62803 511 //takes a screenshot of SmartGPU2 display and stores it in the microSD card with consecutive names Screenshot000.bmp, Screenshot001.bmp, etc
emmanuelchio 0:210b5ba62803 512 SMARTGPUREPLY SMARTGPU2::screenshot(){
emmanuelchio 0:210b5ba62803 513 putcharTX('I'); //Image function
emmanuelchio 0:210b5ba62803 514 putcharTX('S'); //Screenshot
emmanuelchio 0:210b5ba62803 515 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 516 }
emmanuelchio 0:210b5ba62803 517
emmanuelchio 0:210b5ba62803 518
emmanuelchio 0:210b5ba62803 519 /****************************************************************/
emmanuelchio 0:210b5ba62803 520 //Video Functions
emmanuelchio 0:210b5ba62803 521 /****************************************************************/
emmanuelchio 0:210b5ba62803 522 //Allocates a ".vid" video stored on the micro SD card with the given filename name
emmanuelchio 0:210b5ba62803 523 SMARTGPUREPLY SMARTGPU2::allocateVideoSD(FILENAME name, VIDDATA *videoData){
emmanuelchio 0:210b5ba62803 524 unsigned int wid=0, hei=0, fra=0, tot=0;
emmanuelchio 0:210b5ba62803 525 unsigned char counter=0;
emmanuelchio 0:210b5ba62803 526
emmanuelchio 0:210b5ba62803 527 putcharTX('V'); //Video function
emmanuelchio 0:210b5ba62803 528 putcharTX('A'); //Allocate
emmanuelchio 0:210b5ba62803 529 while(1){ //Send Video Name
emmanuelchio 0:210b5ba62803 530 putcharTX(name[counter]);
emmanuelchio 0:210b5ba62803 531 if(name[counter]==0x00){
emmanuelchio 0:210b5ba62803 532 break;
emmanuelchio 0:210b5ba62803 533 }
emmanuelchio 0:210b5ba62803 534 counter++;
emmanuelchio 0:210b5ba62803 535 }
emmanuelchio 0:210b5ba62803 536
emmanuelchio 0:210b5ba62803 537 ((unsigned char *) &wid)[1]=getcharRX(); //get video width
emmanuelchio 0:210b5ba62803 538 ((unsigned char *) &wid)[0]=getcharRX();
emmanuelchio 0:210b5ba62803 539 ((unsigned char *) &hei)[1]=getcharRX(); //get video height
emmanuelchio 0:210b5ba62803 540 ((unsigned char *) &hei)[0]=getcharRX();
emmanuelchio 0:210b5ba62803 541 ((unsigned char *) &fra)[1]=getcharRX(); //get video frames per second
emmanuelchio 0:210b5ba62803 542 ((unsigned char *) &fra)[0]=getcharRX();
emmanuelchio 0:210b5ba62803 543 ((unsigned char *) &tot)[1]=getcharRX(); //get video total frames
emmanuelchio 0:210b5ba62803 544 ((unsigned char *) &tot)[0]=getcharRX();
emmanuelchio 0:210b5ba62803 545 videoData->width = wid;
emmanuelchio 0:210b5ba62803 546 videoData->height = hei;
emmanuelchio 0:210b5ba62803 547 videoData->framesPerSec = fra;
emmanuelchio 0:210b5ba62803 548 videoData->totalFrames = tot;
emmanuelchio 0:210b5ba62803 549 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 550 }
emmanuelchio 0:210b5ba62803 551
emmanuelchio 0:210b5ba62803 552 //deAllocates a ".vid" video previously allocated, must be called when no more calls to video will be done
emmanuelchio 0:210b5ba62803 553 SMARTGPUREPLY SMARTGPU2::freeVideoSD(){
emmanuelchio 0:210b5ba62803 554 putcharTX('V'); //Video function
emmanuelchio 0:210b5ba62803 555 putcharTX('D'); //DeAllocate
emmanuelchio 0:210b5ba62803 556 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 557 }
emmanuelchio 0:210b5ba62803 558
emmanuelchio 0:210b5ba62803 559 //Sets a video start Frame position, this function can be used to FastForward video or Rewing, returns 'F' if invalid position
emmanuelchio 0:210b5ba62803 560 SMARTGPUREPLY SMARTGPU2::setFrameVideoSD(unsigned int startFrame){
emmanuelchio 0:210b5ba62803 561 putcharTX('V'); //Video function
emmanuelchio 0:210b5ba62803 562 putcharTX('F'); //set Video Frame
emmanuelchio 0:210b5ba62803 563 putcharTX(startFrame>>8);
emmanuelchio 0:210b5ba62803 564 putcharTX(startFrame);
emmanuelchio 0:210b5ba62803 565 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 566 }
emmanuelchio 0:210b5ba62803 567
emmanuelchio 0:210b5ba62803 568 //Plays a previously allocated ".vid" video stored on mSD card on X,Y top right corner coordinates, starting from current Video Frame and plays framesToPlay
emmanuelchio 0:210b5ba62803 569 SMARTGPUREPLY SMARTGPU2::playVideoSD(AXIS x, AXIS y, unsigned int framesToPlay){ //frames to play from current video Frame
emmanuelchio 0:210b5ba62803 570 putcharTX('V'); //Video function
emmanuelchio 0:210b5ba62803 571 putcharTX('P'); //Play
emmanuelchio 0:210b5ba62803 572 putcharTX(x>>8);
emmanuelchio 0:210b5ba62803 573 putcharTX(x);
emmanuelchio 0:210b5ba62803 574 putcharTX(y>>8);
emmanuelchio 0:210b5ba62803 575 putcharTX(y);
emmanuelchio 0:210b5ba62803 576 putcharTX(framesToPlay>>8);
emmanuelchio 0:210b5ba62803 577 putcharTX(framesToPlay);
emmanuelchio 0:210b5ba62803 578 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 579 }
emmanuelchio 0:210b5ba62803 580
emmanuelchio 0:210b5ba62803 581
emmanuelchio 0:210b5ba62803 582 /****************************************************************/
emmanuelchio 0:210b5ba62803 583 //Audio Functions
emmanuelchio 0:210b5ba62803 584 /****************************************************************/
emmanuelchio 0:210b5ba62803 585 SMARTGPUREPLY SMARTGPU2::initDACAudio(STATE state){
emmanuelchio 0:210b5ba62803 586 putcharTX('A'); //Audio Function
emmanuelchio 0:210b5ba62803 587 putcharTX('I'); //Init - Deinit DACs
emmanuelchio 0:210b5ba62803 588 putcharTX(state); //Enable/Disable
emmanuelchio 0:210b5ba62803 589 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 590 }
emmanuelchio 0:210b5ba62803 591
emmanuelchio 0:210b5ba62803 592 SMARTGPUREPLY SMARTGPU2::audioBoost(STATE state){
emmanuelchio 0:210b5ba62803 593 putcharTX('A'); //Audio Function
emmanuelchio 0:210b5ba62803 594 putcharTX('B'); //Boost
emmanuelchio 0:210b5ba62803 595 putcharTX(state); //Enable/Disable
emmanuelchio 0:210b5ba62803 596 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 597 }
emmanuelchio 0:210b5ba62803 598
emmanuelchio 0:210b5ba62803 599 SMARTGPUREPLY SMARTGPU2::getWAVPlayState(STATE* state){ //returns ENABLE or DISABLE if any file is playing
emmanuelchio 0:210b5ba62803 600 putcharTX('A'); //Audio Function
emmanuelchio 0:210b5ba62803 601 putcharTX('G'); //Get playing File status
emmanuelchio 0:210b5ba62803 602 *state = (STATE)getcharRX(); //Get state
emmanuelchio 0:210b5ba62803 603 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 604 }
emmanuelchio 0:210b5ba62803 605
emmanuelchio 0:210b5ba62803 606 SMARTGPUREPLY SMARTGPU2::playWAVFile(FILENAME name, unsigned int* seconds){ //returns in "seconds" variable the song duration in seconds
emmanuelchio 0:210b5ba62803 607 unsigned int counter=0;
emmanuelchio 0:210b5ba62803 608 unsigned int secs=0;
emmanuelchio 0:210b5ba62803 609
emmanuelchio 0:210b5ba62803 610 putcharTX('A'); //Audio Function
emmanuelchio 0:210b5ba62803 611 putcharTX('P'); //Play WAV file
emmanuelchio 0:210b5ba62803 612 while(1){ //Send file name
emmanuelchio 0:210b5ba62803 613 putcharTX(name[counter]);
emmanuelchio 0:210b5ba62803 614 if(name[counter]==0x00){
emmanuelchio 0:210b5ba62803 615 break;
emmanuelchio 0:210b5ba62803 616 }
emmanuelchio 0:210b5ba62803 617 counter++;
emmanuelchio 0:210b5ba62803 618 }
emmanuelchio 0:210b5ba62803 619
emmanuelchio 0:210b5ba62803 620 ((unsigned char *) &secs)[1]=getcharRX();
emmanuelchio 0:210b5ba62803 621 ((unsigned char *) &secs)[0]=getcharRX();
emmanuelchio 0:210b5ba62803 622 *seconds = secs;
emmanuelchio 0:210b5ba62803 623 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 624 }
emmanuelchio 0:210b5ba62803 625
emmanuelchio 0:210b5ba62803 626 SMARTGPUREPLY SMARTGPU2::pauseWAVFile(){ //pauses a playing file, returns 'F' if no file is playing
emmanuelchio 0:210b5ba62803 627 putcharTX('A'); //Audio Function
emmanuelchio 0:210b5ba62803 628 putcharTX('W'); //Pause file
emmanuelchio 0:210b5ba62803 629 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 630 }
emmanuelchio 0:210b5ba62803 631
emmanuelchio 0:210b5ba62803 632 SMARTGPUREPLY SMARTGPU2::stopWAVFile(){
emmanuelchio 0:210b5ba62803 633 putcharTX('A'); //Audio Function
emmanuelchio 0:210b5ba62803 634 putcharTX('S'); //Stop playing file
emmanuelchio 0:210b5ba62803 635 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 636 }
emmanuelchio 0:210b5ba62803 637
emmanuelchio 0:210b5ba62803 638 SMARTGPUREPLY SMARTGPU2::advanceWAVFile(unsigned int seconds){ //advance to the file to the given seconds parameter
emmanuelchio 0:210b5ba62803 639 putcharTX('A'); //Audio Function
emmanuelchio 0:210b5ba62803 640 putcharTX('A'); //Advance file
emmanuelchio 0:210b5ba62803 641 putcharTX(seconds>>8);
emmanuelchio 0:210b5ba62803 642 putcharTX(seconds);
emmanuelchio 0:210b5ba62803 643 return (SMARTGPUREPLY)getcharRX(); //returns 'F' if no file is playing or if no seconds position exists, in this case file will stop playing
emmanuelchio 0:210b5ba62803 644 }
emmanuelchio 0:210b5ba62803 645
emmanuelchio 0:210b5ba62803 646 SMARTGPUREPLY SMARTGPU2::setVolumeWAV(unsigned char volume){
emmanuelchio 0:210b5ba62803 647 putcharTX('A'); //Audio Function
emmanuelchio 0:210b5ba62803 648 putcharTX('V'); //Volume
emmanuelchio 0:210b5ba62803 649 putcharTX(volume);
emmanuelchio 0:210b5ba62803 650 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 651 }
emmanuelchio 0:210b5ba62803 652
emmanuelchio 0:210b5ba62803 653
emmanuelchio 0:210b5ba62803 654 /****************************************************************/
emmanuelchio 0:210b5ba62803 655 //Real Time Clock Functions
emmanuelchio 0:210b5ba62803 656 /****************************************************************/
emmanuelchio 0:210b5ba62803 657 SMARTGPUREPLY SMARTGPU2::setupRTC(STATE *state){
emmanuelchio 0:210b5ba62803 658 putcharTX('R'); //RTC function - Real Time Clock
emmanuelchio 0:210b5ba62803 659 putcharTX('S'); //Setup RTC
emmanuelchio 0:210b5ba62803 660 *state = (STATE)getcharRX(); //Get state
emmanuelchio 0:210b5ba62803 661 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 662 }
emmanuelchio 0:210b5ba62803 663
emmanuelchio 0:210b5ba62803 664 SMARTGPUREPLY SMARTGPU2::getRTCTimeDate(TIME *timeDate){
emmanuelchio 0:210b5ba62803 665 unsigned int counter=0;
emmanuelchio 0:210b5ba62803 666
emmanuelchio 0:210b5ba62803 667 putcharTX('R'); //RTC function - Real Time Clock
emmanuelchio 0:210b5ba62803 668 putcharTX('P'); //Parameters
emmanuelchio 0:210b5ba62803 669 putcharTX('G'); //Get
emmanuelchio 0:210b5ba62803 670 timeDate->hour = getcharRX(); //hour
emmanuelchio 0:210b5ba62803 671 timeDate->minute = getcharRX(); //min
emmanuelchio 0:210b5ba62803 672 timeDate->second = getcharRX(); //sec
emmanuelchio 0:210b5ba62803 673 timeDate->day = getcharRX(); //day
emmanuelchio 0:210b5ba62803 674 timeDate->month = getcharRX(); //month
emmanuelchio 0:210b5ba62803 675 ((unsigned char*)&counter)[1] = getcharRX(); //year upper
emmanuelchio 0:210b5ba62803 676 ((unsigned char*)&counter)[0] = getcharRX(); //year lower
emmanuelchio 0:210b5ba62803 677 timeDate->year = counter; //year
emmanuelchio 0:210b5ba62803 678 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 679 }
emmanuelchio 0:210b5ba62803 680
emmanuelchio 0:210b5ba62803 681 SMARTGPUREPLY SMARTGPU2::setRTCTimeDate(TIME *timeDate){
emmanuelchio 0:210b5ba62803 682 putcharTX('R'); //RTC function - Real Time Clock
emmanuelchio 0:210b5ba62803 683 putcharTX('P'); //Parameters
emmanuelchio 0:210b5ba62803 684 putcharTX('S'); //Set
emmanuelchio 0:210b5ba62803 685 putcharTX(timeDate->hour); //hour
emmanuelchio 0:210b5ba62803 686 putcharTX(timeDate->minute); //min
emmanuelchio 0:210b5ba62803 687 putcharTX(timeDate->second); //sec
emmanuelchio 0:210b5ba62803 688 putcharTX(timeDate->day); //day
emmanuelchio 0:210b5ba62803 689 putcharTX(timeDate->month); //month
emmanuelchio 0:210b5ba62803 690 putcharTX(timeDate->year>>8);//year upper
emmanuelchio 0:210b5ba62803 691 putcharTX(timeDate->year); //year lower
emmanuelchio 0:210b5ba62803 692 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 693 }
emmanuelchio 0:210b5ba62803 694
emmanuelchio 0:210b5ba62803 695
emmanuelchio 0:210b5ba62803 696 /****************************************************************/
emmanuelchio 0:210b5ba62803 697 //Objects Functions
emmanuelchio 0:210b5ba62803 698 /****************************************************************/
emmanuelchio 0:210b5ba62803 699 SMARTGPUREPLY SMARTGPU2::objButton(AXIS x1, AXIS y1, AXIS x2, AXIS y2, ACTIVE activeState, char text[]){
emmanuelchio 0:210b5ba62803 700 unsigned int counter=0;
emmanuelchio 0:210b5ba62803 701
emmanuelchio 0:210b5ba62803 702 putcharTX('O'); //Object function
emmanuelchio 0:210b5ba62803 703 putcharTX('B'); //Button
emmanuelchio 0:210b5ba62803 704 putcharTX(x1>>8);
emmanuelchio 0:210b5ba62803 705 putcharTX(x1);
emmanuelchio 0:210b5ba62803 706 putcharTX(y1>>8);
emmanuelchio 0:210b5ba62803 707 putcharTX(y1);
emmanuelchio 0:210b5ba62803 708 putcharTX(x2>>8);
emmanuelchio 0:210b5ba62803 709 putcharTX(x2);
emmanuelchio 0:210b5ba62803 710 putcharTX(y2>>8);
emmanuelchio 0:210b5ba62803 711 putcharTX(y2);
emmanuelchio 0:210b5ba62803 712 putcharTX(activeState);
emmanuelchio 0:210b5ba62803 713 while(1){ //Send button text
emmanuelchio 0:210b5ba62803 714 putcharTX(text[counter]);
emmanuelchio 0:210b5ba62803 715 if(text[counter]==0x00){
emmanuelchio 0:210b5ba62803 716 break;
emmanuelchio 0:210b5ba62803 717 }
emmanuelchio 0:210b5ba62803 718 counter++;
emmanuelchio 0:210b5ba62803 719 }
emmanuelchio 0:210b5ba62803 720 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 721 }
emmanuelchio 0:210b5ba62803 722
emmanuelchio 0:210b5ba62803 723 SMARTGPUREPLY SMARTGPU2::objSwitch(AXIS x, AXIS y, unsigned int switchSize, ACTIVE activeState){
emmanuelchio 0:210b5ba62803 724 putcharTX('O'); //Object function
emmanuelchio 0:210b5ba62803 725 putcharTX('T'); //Switch
emmanuelchio 0:210b5ba62803 726 putcharTX(x>>8);
emmanuelchio 0:210b5ba62803 727 putcharTX(x);
emmanuelchio 0:210b5ba62803 728 putcharTX(y>>8);
emmanuelchio 0:210b5ba62803 729 putcharTX(y);
emmanuelchio 0:210b5ba62803 730 putcharTX(switchSize>>8);
emmanuelchio 0:210b5ba62803 731 putcharTX(switchSize);
emmanuelchio 0:210b5ba62803 732 putcharTX(activeState);
emmanuelchio 0:210b5ba62803 733 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 734 }
emmanuelchio 0:210b5ba62803 735
emmanuelchio 0:210b5ba62803 736 SMARTGPUREPLY SMARTGPU2::objCheckbox(AXIS x, AXIS y, unsigned int checkboxSize, ACTIVE activeState){
emmanuelchio 0:210b5ba62803 737 putcharTX('O'); //Object function
emmanuelchio 0:210b5ba62803 738 putcharTX('C'); //Checkbox
emmanuelchio 0:210b5ba62803 739 putcharTX(x>>8);
emmanuelchio 0:210b5ba62803 740 putcharTX(x);
emmanuelchio 0:210b5ba62803 741 putcharTX(y>>8);
emmanuelchio 0:210b5ba62803 742 putcharTX(y);
emmanuelchio 0:210b5ba62803 743 putcharTX(checkboxSize>>8);
emmanuelchio 0:210b5ba62803 744 putcharTX(checkboxSize);
emmanuelchio 0:210b5ba62803 745 putcharTX(activeState);
emmanuelchio 0:210b5ba62803 746 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 747 }
emmanuelchio 0:210b5ba62803 748
emmanuelchio 0:210b5ba62803 749 SMARTGPUREPLY SMARTGPU2::objProgressBar(AXIS x1, AXIS y1, AXIS x2, AXIS y2, unsigned char progress){
emmanuelchio 0:210b5ba62803 750 putcharTX('O'); //Object function
emmanuelchio 0:210b5ba62803 751 putcharTX('P'); //Progress Bar
emmanuelchio 0:210b5ba62803 752 putcharTX(x1>>8);
emmanuelchio 0:210b5ba62803 753 putcharTX(x1);
emmanuelchio 0:210b5ba62803 754 putcharTX(y1>>8);
emmanuelchio 0:210b5ba62803 755 putcharTX(y1);
emmanuelchio 0:210b5ba62803 756 putcharTX(x2>>8);
emmanuelchio 0:210b5ba62803 757 putcharTX(x2);
emmanuelchio 0:210b5ba62803 758 putcharTX(y2>>8);
emmanuelchio 0:210b5ba62803 759 putcharTX(y2);
emmanuelchio 0:210b5ba62803 760 putcharTX(progress);
emmanuelchio 0:210b5ba62803 761 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 762 }
emmanuelchio 0:210b5ba62803 763
emmanuelchio 0:210b5ba62803 764 SMARTGPUREPLY SMARTGPU2::objSlider(AXIS x1, AXIS y1, AXIS x2, AXIS y2, unsigned char position, unsigned char divisions, ORIENTATIONPARAMETER sliderOrientation){
emmanuelchio 0:210b5ba62803 765 putcharTX('O'); //Object function
emmanuelchio 0:210b5ba62803 766 putcharTX('L'); //Slider
emmanuelchio 0:210b5ba62803 767 putcharTX(x1>>8);
emmanuelchio 0:210b5ba62803 768 putcharTX(x1);
emmanuelchio 0:210b5ba62803 769 putcharTX(y1>>8);
emmanuelchio 0:210b5ba62803 770 putcharTX(y1);
emmanuelchio 0:210b5ba62803 771 putcharTX(x2>>8);
emmanuelchio 0:210b5ba62803 772 putcharTX(x2);
emmanuelchio 0:210b5ba62803 773 putcharTX(y2>>8);
emmanuelchio 0:210b5ba62803 774 putcharTX(y2);
emmanuelchio 0:210b5ba62803 775 putcharTX(position);
emmanuelchio 0:210b5ba62803 776 putcharTX(divisions);
emmanuelchio 0:210b5ba62803 777 putcharTX(sliderOrientation);
emmanuelchio 0:210b5ba62803 778 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 779 }
emmanuelchio 0:210b5ba62803 780
emmanuelchio 0:210b5ba62803 781 SMARTGPUREPLY SMARTGPU2::objScrollBar(AXIS x1, AXIS y1, AXIS x2, AXIS y2, unsigned char position, unsigned char divisions, ORIENTATIONPARAMETER scrollBarOrientation, ACTIVE activeState){
emmanuelchio 0:210b5ba62803 782 putcharTX('O'); //Object function
emmanuelchio 0:210b5ba62803 783 putcharTX('S'); //Scroll bar
emmanuelchio 0:210b5ba62803 784 putcharTX(x1>>8);
emmanuelchio 0:210b5ba62803 785 putcharTX(x1);
emmanuelchio 0:210b5ba62803 786 putcharTX(y1>>8);
emmanuelchio 0:210b5ba62803 787 putcharTX(y1);
emmanuelchio 0:210b5ba62803 788 putcharTX(x2>>8);
emmanuelchio 0:210b5ba62803 789 putcharTX(x2);
emmanuelchio 0:210b5ba62803 790 putcharTX(y2>>8);
emmanuelchio 0:210b5ba62803 791 putcharTX(y2);
emmanuelchio 0:210b5ba62803 792 putcharTX(position);
emmanuelchio 0:210b5ba62803 793 putcharTX(divisions);
emmanuelchio 0:210b5ba62803 794 putcharTX(scrollBarOrientation);
emmanuelchio 0:210b5ba62803 795 putcharTX(activeState);
emmanuelchio 0:210b5ba62803 796 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 797 }
emmanuelchio 0:210b5ba62803 798
emmanuelchio 0:210b5ba62803 799 SMARTGPUREPLY SMARTGPU2::objWindow(AXIS x1, AXIS y1, AXIS x2, AXIS y2, FONTSIZE textSize, WINDOWTYPE winType, char text[]){
emmanuelchio 0:210b5ba62803 800 unsigned int counter=0;
emmanuelchio 0:210b5ba62803 801
emmanuelchio 0:210b5ba62803 802 putcharTX('O'); //Object function
emmanuelchio 0:210b5ba62803 803 putcharTX('W'); //Window
emmanuelchio 0:210b5ba62803 804 putcharTX(x1>>8);
emmanuelchio 0:210b5ba62803 805 putcharTX(x1);
emmanuelchio 0:210b5ba62803 806 putcharTX(y1>>8);
emmanuelchio 0:210b5ba62803 807 putcharTX(y1);
emmanuelchio 0:210b5ba62803 808 putcharTX(x2>>8);
emmanuelchio 0:210b5ba62803 809 putcharTX(x2);
emmanuelchio 0:210b5ba62803 810 putcharTX(y2>>8);
emmanuelchio 0:210b5ba62803 811 putcharTX(y2);
emmanuelchio 0:210b5ba62803 812 putcharTX(textSize);
emmanuelchio 0:210b5ba62803 813 putcharTX(winType);
emmanuelchio 0:210b5ba62803 814 while(1){ //Send button text
emmanuelchio 0:210b5ba62803 815 putcharTX(text[counter]);
emmanuelchio 0:210b5ba62803 816 if(text[counter]==0x00){
emmanuelchio 0:210b5ba62803 817 break;
emmanuelchio 0:210b5ba62803 818 }
emmanuelchio 0:210b5ba62803 819 counter++;
emmanuelchio 0:210b5ba62803 820 }
emmanuelchio 0:210b5ba62803 821 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 822 }
emmanuelchio 0:210b5ba62803 823
emmanuelchio 0:210b5ba62803 824
emmanuelchio 0:210b5ba62803 825 /****************************************************************/
emmanuelchio 0:210b5ba62803 826 //EEPROM-FLASH Functions - Refer to "smartGPU2 Command Set" to learn about READ-WRITE procedure.
emmanuelchio 0:210b5ba62803 827 /****************************************************************/
emmanuelchio 0:210b5ba62803 828 SMARTGPUREPLY SMARTGPU2::initClearEEPROMBuff(){
emmanuelchio 0:210b5ba62803 829 putcharTX('E'); //EEPROM function
emmanuelchio 0:210b5ba62803 830 putcharTX('I'); //Init/Clear EEPROM Buffer
emmanuelchio 0:210b5ba62803 831 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 832 }
emmanuelchio 0:210b5ba62803 833
emmanuelchio 0:210b5ba62803 834 SMARTGPUREPLY SMARTGPU2::readEEPROMBuff(char buffer[], ADDRESS EEPROMbufferAddress, NUMBEROFBYTES bytesToRead, NUMBEROFBYTES *SRB){
emmanuelchio 0:210b5ba62803 835 unsigned int x=0, sr=0;
emmanuelchio 0:210b5ba62803 836
emmanuelchio 0:210b5ba62803 837 putcharTX('E'); //EEPROM function
emmanuelchio 0:210b5ba62803 838 putcharTX('R'); //Read N bytes from EEPROM buffer to received buffer[]
emmanuelchio 0:210b5ba62803 839 putcharTX(EEPROMbufferAddress>>8); //address to start reading from EEPROM buffer
emmanuelchio 0:210b5ba62803 840 putcharTX(EEPROMbufferAddress);
emmanuelchio 0:210b5ba62803 841 putcharTX(bytesToRead>>8);
emmanuelchio 0:210b5ba62803 842 putcharTX(bytesToRead);
emmanuelchio 0:210b5ba62803 843
emmanuelchio 0:210b5ba62803 844 for(x=0; x<bytesToRead; x++){
emmanuelchio 0:210b5ba62803 845 buffer[x]=getcharRX();
emmanuelchio 0:210b5ba62803 846 }
emmanuelchio 0:210b5ba62803 847 sr=getcharRX();
emmanuelchio 0:210b5ba62803 848 sr=sr<<8;
emmanuelchio 0:210b5ba62803 849 sr|=getcharRX();
emmanuelchio 0:210b5ba62803 850 *SRB = sr; //store succesfully read bytes
emmanuelchio 0:210b5ba62803 851 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 852 }
emmanuelchio 0:210b5ba62803 853
emmanuelchio 0:210b5ba62803 854 SMARTGPUREPLY SMARTGPU2::writeEEPROMBuff(char buffer[], ADDRESS EEPROMbufferAddress, NUMBEROFBYTES bytesToWrite, NUMBEROFBYTES *SWB){
emmanuelchio 0:210b5ba62803 855 unsigned int x=0, sw=0;
emmanuelchio 0:210b5ba62803 856
emmanuelchio 0:210b5ba62803 857 putcharTX('E'); //EEPROM function
emmanuelchio 0:210b5ba62803 858 putcharTX('W'); //Write N bytes to EEPROM buffer from received buffer[]
emmanuelchio 0:210b5ba62803 859 putcharTX(EEPROMbufferAddress>>8); //address to start writting to EEPROM buffer
emmanuelchio 0:210b5ba62803 860 putcharTX(EEPROMbufferAddress);
emmanuelchio 0:210b5ba62803 861 putcharTX(bytesToWrite>>8);
emmanuelchio 0:210b5ba62803 862 putcharTX(bytesToWrite);
emmanuelchio 0:210b5ba62803 863 for(x=0; x<bytesToWrite; x++){
emmanuelchio 0:210b5ba62803 864 putcharTX(buffer[x]);
emmanuelchio 0:210b5ba62803 865 }
emmanuelchio 0:210b5ba62803 866
emmanuelchio 0:210b5ba62803 867 sw=getcharRX();
emmanuelchio 0:210b5ba62803 868 sw=sw<<8;
emmanuelchio 0:210b5ba62803 869 sw|=getcharRX();
emmanuelchio 0:210b5ba62803 870 *SWB = sw; //store succesfully written bytes
emmanuelchio 0:210b5ba62803 871 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 872 }
emmanuelchio 0:210b5ba62803 873
emmanuelchio 0:210b5ba62803 874 SMARTGPUREPLY SMARTGPU2::saveBuffToEEPROMPage(EEPROMPAGE page){
emmanuelchio 0:210b5ba62803 875 putcharTX('E'); //EEPROM function
emmanuelchio 0:210b5ba62803 876 putcharTX('S'); //Save EEPROM buffer contents to received EEPROM page#
emmanuelchio 0:210b5ba62803 877 putcharTX(page);
emmanuelchio 0:210b5ba62803 878 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 879 }
emmanuelchio 0:210b5ba62803 880
emmanuelchio 0:210b5ba62803 881 SMARTGPUREPLY SMARTGPU2::fillBuffFromEEPROMPage(EEPROMPAGE page){
emmanuelchio 0:210b5ba62803 882 putcharTX('E'); //EEPROM function
emmanuelchio 0:210b5ba62803 883 putcharTX('F'); //Fill(copy) EEPROM buffer with received EEPROM page# contents
emmanuelchio 0:210b5ba62803 884 putcharTX(page);
emmanuelchio 0:210b5ba62803 885 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 886 }
emmanuelchio 0:210b5ba62803 887
emmanuelchio 0:210b5ba62803 888 SMARTGPUREPLY SMARTGPU2::compBuffToEEPROMPage(EEPROMPAGE page, unsigned char *result){
emmanuelchio 0:210b5ba62803 889 putcharTX('E'); //EEPROM function
emmanuelchio 0:210b5ba62803 890 putcharTX('C'); //Compare EEPROM buffer contents with received EEPROM page#
emmanuelchio 0:210b5ba62803 891 putcharTX(page);
emmanuelchio 0:210b5ba62803 892 *result = getcharRX();
emmanuelchio 0:210b5ba62803 893 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 894 }
emmanuelchio 0:210b5ba62803 895
emmanuelchio 0:210b5ba62803 896 SMARTGPUREPLY SMARTGPU2::eraseEEPROMPage(EEPROMPAGE page){
emmanuelchio 0:210b5ba62803 897 putcharTX('E'); //EEPROM function
emmanuelchio 0:210b5ba62803 898 putcharTX('E'); //Erase received EEPROM page#
emmanuelchio 0:210b5ba62803 899 putcharTX(page);
emmanuelchio 0:210b5ba62803 900 return (SMARTGPUREPLY)getcharRX();
emmanuelchio 0:210b5ba62803 901 }
emmanuelchio 0:210b5ba62803 902
emmanuelchio 0:210b5ba62803 903
emmanuelchio 0:210b5ba62803 904 /****************************************************************/
emmanuelchio 0:210b5ba62803 905 //Touch Functions
emmanuelchio 0:210b5ba62803 906 //Those next Touch Functions return valid or invalid touch coordinates status(TOUCHREPLY) instead of ACK 'O' or NAK 'F'(SMARTGPUREPLY)
emmanuelchio 0:210b5ba62803 907 /****************************************************************/
emmanuelchio 0:210b5ba62803 908 TOUCHREPLY SMARTGPU2::touchScreen(POINT *point){ //Ask for a touch on the screen, if return==VALID, touch coords are valid and stored on xAxis and yAxis
emmanuelchio 0:210b5ba62803 909 unsigned int x=0,y=0;
emmanuelchio 0:210b5ba62803 910 putcharTX('T'); //Touch Function
emmanuelchio 0:210b5ba62803 911 putcharTX('S'); //Screen touch
emmanuelchio 0:210b5ba62803 912 ((unsigned char *) &x)[1]=getcharRX();
emmanuelchio 0:210b5ba62803 913 ((unsigned char *) &x)[0]=getcharRX();
emmanuelchio 0:210b5ba62803 914 ((unsigned char *) &y)[1]=getcharRX();
emmanuelchio 0:210b5ba62803 915 ((unsigned char *) &y)[0]=getcharRX();
emmanuelchio 0:210b5ba62803 916 if(getcharRX()=='O'){ //if touch coordinates are valid, assign values
emmanuelchio 0:210b5ba62803 917 point->x=x;
emmanuelchio 0:210b5ba62803 918 point->y=y;
emmanuelchio 0:210b5ba62803 919 return (TOUCHREPLY)VALID;
emmanuelchio 0:210b5ba62803 920 }
emmanuelchio 0:210b5ba62803 921 return (TOUCHREPLY)INVALID;
emmanuelchio 0:210b5ba62803 922 }
emmanuelchio 0:210b5ba62803 923
emmanuelchio 0:210b5ba62803 924 TOUCHREPLY SMARTGPU2::touchIcon(ICON *icon){ //Ask for a touch on the icons of the screen, if return==VALID, icon first letter is stored on icon
emmanuelchio 0:210b5ba62803 925 putcharTX('T'); //Touch Function
emmanuelchio 0:210b5ba62803 926 putcharTX('I'); //Icons touch
emmanuelchio 0:210b5ba62803 927 *icon = (ICON)getcharRX();
emmanuelchio 0:210b5ba62803 928 if(getcharRX()=='O'){ //if touch coordinates are valid
emmanuelchio 0:210b5ba62803 929 return (TOUCHREPLY)VALID;
emmanuelchio 0:210b5ba62803 930 }
emmanuelchio 0:210b5ba62803 931 return (TOUCHREPLY)INVALID;
emmanuelchio 0:210b5ba62803 932 }
emmanuelchio 0:210b5ba62803 933
emmanuelchio 0:210b5ba62803 934
emmanuelchio 0:210b5ba62803 935 /****************************************************************/
emmanuelchio 0:210b5ba62803 936 //SD FAT management Functions
emmanuelchio 0:210b5ba62803 937 //Those next SDF - SD Functions return file execution status(FILERESULT) instead of ACK 'O' or NAK 'F'(SMARTGPUREPLY)
emmanuelchio 0:210b5ba62803 938 /****************************************************************/
emmanuelchio 0:210b5ba62803 939 FILERESULT SMARTGPU2::SDFgetList(unsigned int *numOfDirs, unsigned int *numOfFiles){ //get number of dirs and files
emmanuelchio 0:210b5ba62803 940 FILERESULT res;
emmanuelchio 0:210b5ba62803 941 unsigned int dirs=0, files=0;
emmanuelchio 0:210b5ba62803 942
emmanuelchio 0:210b5ba62803 943 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 944 putcharTX('L'); //List/count dirs and files
emmanuelchio 0:210b5ba62803 945
emmanuelchio 0:210b5ba62803 946 ((unsigned char *) &dirs)[1]= getcharRX(); //Get Upper part
emmanuelchio 0:210b5ba62803 947 ((unsigned char *) &dirs)[0]= getcharRX(); //Get Lower part
emmanuelchio 0:210b5ba62803 948 ((unsigned char *) &files)[1]= getcharRX(); //Get Upper part
emmanuelchio 0:210b5ba62803 949 ((unsigned char *) &files)[0]= getcharRX(); //Get Lower part
emmanuelchio 0:210b5ba62803 950 *numOfDirs=dirs;
emmanuelchio 0:210b5ba62803 951 *numOfFiles=files;
emmanuelchio 0:210b5ba62803 952 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 953 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 954 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 955 }
emmanuelchio 0:210b5ba62803 956
emmanuelchio 0:210b5ba62803 957 FILERESULT SMARTGPU2::SDFgetDirName(ITEMNUMBER itemNumber, FILENAME name){ //searches for the "itemNumber" on the SD current folder and updates the buffer with the Dir name ended with NULL character
emmanuelchio 0:210b5ba62803 958 FILERESULT res;
emmanuelchio 0:210b5ba62803 959 unsigned int i=0;
emmanuelchio 0:210b5ba62803 960
emmanuelchio 0:210b5ba62803 961 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 962 putcharTX('G'); //Get name of given item file number
emmanuelchio 0:210b5ba62803 963 putcharTX('D'); //Directory
emmanuelchio 0:210b5ba62803 964 putcharTX(itemNumber>>8); //Send Upper part of itemNumber
emmanuelchio 0:210b5ba62803 965 putcharTX(itemNumber); //Send Lower part of itemNumber
emmanuelchio 0:210b5ba62803 966
emmanuelchio 0:210b5ba62803 967 while(1){
emmanuelchio 0:210b5ba62803 968 name[i]=getcharRX();
emmanuelchio 0:210b5ba62803 969 if(name[i]==0x00){ //if we find NULL character, means end of name
emmanuelchio 0:210b5ba62803 970 break;
emmanuelchio 0:210b5ba62803 971 }
emmanuelchio 0:210b5ba62803 972 i++;
emmanuelchio 0:210b5ba62803 973 }
emmanuelchio 0:210b5ba62803 974 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 975 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 976 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 977 }
emmanuelchio 0:210b5ba62803 978
emmanuelchio 0:210b5ba62803 979 FILERESULT SMARTGPU2::SDFgetFileName(ITEMNUMBER itemNumber, FILENAME name){ //searches for the "itemNumber" on the SD current folder and updates the buffer with the File name ended with NULL character
emmanuelchio 0:210b5ba62803 980 FILERESULT res;
emmanuelchio 0:210b5ba62803 981 unsigned int i=0;
emmanuelchio 0:210b5ba62803 982
emmanuelchio 0:210b5ba62803 983 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 984 putcharTX('G'); //Get name of given item file number
emmanuelchio 0:210b5ba62803 985 putcharTX('F'); //File
emmanuelchio 0:210b5ba62803 986 putcharTX(itemNumber>>8); //Send Upper part of itemNumber
emmanuelchio 0:210b5ba62803 987 putcharTX(itemNumber); //Send Lower part of itemNumber
emmanuelchio 0:210b5ba62803 988
emmanuelchio 0:210b5ba62803 989 while(1){
emmanuelchio 0:210b5ba62803 990 name[i]=getcharRX();
emmanuelchio 0:210b5ba62803 991 if(name[i]==0x00){ //if we find NULL character, means end of name
emmanuelchio 0:210b5ba62803 992 break;
emmanuelchio 0:210b5ba62803 993 }
emmanuelchio 0:210b5ba62803 994 i++;
emmanuelchio 0:210b5ba62803 995 }
emmanuelchio 0:210b5ba62803 996 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 997 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 998 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 999 }
emmanuelchio 0:210b5ba62803 1000
emmanuelchio 0:210b5ba62803 1001 FILERESULT SMARTGPU2::SDFgetDirPath(char path[]){ //obtains current dir path and stores on path[] buffer
emmanuelchio 0:210b5ba62803 1002 FILERESULT res;
emmanuelchio 0:210b5ba62803 1003 unsigned int i=0;
emmanuelchio 0:210b5ba62803 1004 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 1005 putcharTX('H'); //Get current Dir Path
emmanuelchio 0:210b5ba62803 1006
emmanuelchio 0:210b5ba62803 1007 while(1){
emmanuelchio 0:210b5ba62803 1008 path[i]=getcharRX();
emmanuelchio 0:210b5ba62803 1009 if(path[i]==0x00){ //if we find NULL character, means end of path
emmanuelchio 0:210b5ba62803 1010 break;
emmanuelchio 0:210b5ba62803 1011 }
emmanuelchio 0:210b5ba62803 1012 i++;
emmanuelchio 0:210b5ba62803 1013 }
emmanuelchio 0:210b5ba62803 1014 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 1015 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 1016 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 1017 }
emmanuelchio 0:210b5ba62803 1018
emmanuelchio 0:210b5ba62803 1019 FILERESULT SMARTGPU2::SDFnewDir(FILENAME name){ //create a new Directory, fails if already exist
emmanuelchio 0:210b5ba62803 1020 FILERESULT res;
emmanuelchio 0:210b5ba62803 1021 unsigned int counter=0;
emmanuelchio 0:210b5ba62803 1022
emmanuelchio 0:210b5ba62803 1023 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 1024 putcharTX('N'); //New
emmanuelchio 0:210b5ba62803 1025 putcharTX('D'); //Directory/Folder
emmanuelchio 0:210b5ba62803 1026 while(1){
emmanuelchio 0:210b5ba62803 1027 putcharTX(name[counter]);
emmanuelchio 0:210b5ba62803 1028 if(name[counter]==0x00){
emmanuelchio 0:210b5ba62803 1029 break;
emmanuelchio 0:210b5ba62803 1030 }
emmanuelchio 0:210b5ba62803 1031 counter++;
emmanuelchio 0:210b5ba62803 1032 }
emmanuelchio 0:210b5ba62803 1033
emmanuelchio 0:210b5ba62803 1034 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 1035 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 1036 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 1037 }
emmanuelchio 0:210b5ba62803 1038
emmanuelchio 0:210b5ba62803 1039 FILERESULT SMARTGPU2::SDFnewFile(FILENAME name){ //create a new File, fails if already exist
emmanuelchio 0:210b5ba62803 1040 FILERESULT res;
emmanuelchio 0:210b5ba62803 1041 unsigned int counter=0;
emmanuelchio 0:210b5ba62803 1042
emmanuelchio 0:210b5ba62803 1043 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 1044 putcharTX('N'); //New
emmanuelchio 0:210b5ba62803 1045 putcharTX('F'); //File
emmanuelchio 0:210b5ba62803 1046 while(1){
emmanuelchio 0:210b5ba62803 1047 putcharTX(name[counter]);
emmanuelchio 0:210b5ba62803 1048 if(name[counter]==0x00){
emmanuelchio 0:210b5ba62803 1049 break;
emmanuelchio 0:210b5ba62803 1050 }
emmanuelchio 0:210b5ba62803 1051 counter++;
emmanuelchio 0:210b5ba62803 1052 }
emmanuelchio 0:210b5ba62803 1053
emmanuelchio 0:210b5ba62803 1054 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 1055 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 1056 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 1057 }
emmanuelchio 0:210b5ba62803 1058
emmanuelchio 0:210b5ba62803 1059 FILERESULT SMARTGPU2::SDFopenDir(FILENAME name){ //opens an existing Dir
emmanuelchio 0:210b5ba62803 1060 FILERESULT res;
emmanuelchio 0:210b5ba62803 1061 unsigned int counter=0;
emmanuelchio 0:210b5ba62803 1062
emmanuelchio 0:210b5ba62803 1063 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 1064 putcharTX('D'); //Open Dir
emmanuelchio 0:210b5ba62803 1065 while(1){
emmanuelchio 0:210b5ba62803 1066 putcharTX(name[counter]);
emmanuelchio 0:210b5ba62803 1067 if(name[counter]==0x00){
emmanuelchio 0:210b5ba62803 1068 break;
emmanuelchio 0:210b5ba62803 1069 }
emmanuelchio 0:210b5ba62803 1070 counter++;
emmanuelchio 0:210b5ba62803 1071 }
emmanuelchio 0:210b5ba62803 1072
emmanuelchio 0:210b5ba62803 1073 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 1074 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 1075 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 1076 }
emmanuelchio 0:210b5ba62803 1077
emmanuelchio 0:210b5ba62803 1078 FILERESULT SMARTGPU2::SDFopenFile(FILENAME name, OPENMODE mode, WORKSPACEBLOCK objectWorkspaceNo){ //opens an existing file in READONLY, WRITEONLY or READWRITE mode on the received object # workspace
emmanuelchio 0:210b5ba62803 1079 FILERESULT res;
emmanuelchio 0:210b5ba62803 1080 unsigned int counter=0;
emmanuelchio 0:210b5ba62803 1081
emmanuelchio 0:210b5ba62803 1082 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 1083 putcharTX('O'); //Open file
emmanuelchio 0:210b5ba62803 1084 putcharTX(objectWorkspaceNo); //object workspace number to allocate open file 0-4
emmanuelchio 0:210b5ba62803 1085 putcharTX(mode); //Mode - READONLY,WRITEONLY,READWRITE
emmanuelchio 0:210b5ba62803 1086 while(1){
emmanuelchio 0:210b5ba62803 1087 putcharTX(name[counter]);
emmanuelchio 0:210b5ba62803 1088 if(name[counter]==0x00){
emmanuelchio 0:210b5ba62803 1089 break;
emmanuelchio 0:210b5ba62803 1090 }
emmanuelchio 0:210b5ba62803 1091 counter++;
emmanuelchio 0:210b5ba62803 1092 }
emmanuelchio 0:210b5ba62803 1093
emmanuelchio 0:210b5ba62803 1094 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 1095 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 1096 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 1097 }
emmanuelchio 0:210b5ba62803 1098
emmanuelchio 0:210b5ba62803 1099 FILERESULT SMARTGPU2::SDFcloseFile(WORKSPACEBLOCK objectWorkspaceNo){ //close and save file object # workspace
emmanuelchio 0:210b5ba62803 1100 FILERESULT res;
emmanuelchio 0:210b5ba62803 1101
emmanuelchio 0:210b5ba62803 1102 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 1103 putcharTX('C'); //Close File
emmanuelchio 0:210b5ba62803 1104 putcharTX(objectWorkspaceNo); //object workspace number to close 0-4
emmanuelchio 0:210b5ba62803 1105
emmanuelchio 0:210b5ba62803 1106 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 1107 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 1108 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 1109 }
emmanuelchio 0:210b5ba62803 1110
emmanuelchio 0:210b5ba62803 1111 FILERESULT SMARTGPU2::SDFsaveFile(WORKSPACEBLOCK objectWorkspaceNo){ //sync/save file object # workspace
emmanuelchio 0:210b5ba62803 1112 FILERESULT res;
emmanuelchio 0:210b5ba62803 1113
emmanuelchio 0:210b5ba62803 1114 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 1115 putcharTX('S'); //Save/Sync file - Save changes on file
emmanuelchio 0:210b5ba62803 1116 putcharTX(objectWorkspaceNo); //object workspace number to save changes 0-4
emmanuelchio 0:210b5ba62803 1117
emmanuelchio 0:210b5ba62803 1118 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 1119 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 1120 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 1121 }
emmanuelchio 0:210b5ba62803 1122
emmanuelchio 0:210b5ba62803 1123 FILERESULT SMARTGPU2::SDFsetFilePointer(POINTERPOSITION pointerPosition, WORKSPACEBLOCK objectWorkspaceNo){ // set/move file pointer of file object # workspace
emmanuelchio 0:210b5ba62803 1124 FILERESULT res;
emmanuelchio 0:210b5ba62803 1125
emmanuelchio 0:210b5ba62803 1126 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 1127 putcharTX('P'); //Pointer position
emmanuelchio 0:210b5ba62803 1128 putcharTX(objectWorkspaceNo); //object workspace number to move pointer 0-4
emmanuelchio 0:210b5ba62803 1129 putcharTX('S'); //Set
emmanuelchio 0:210b5ba62803 1130 putcharTX(pointerPosition>>24);
emmanuelchio 0:210b5ba62803 1131 putcharTX(pointerPosition>>16);
emmanuelchio 0:210b5ba62803 1132 putcharTX(pointerPosition>>8);
emmanuelchio 0:210b5ba62803 1133 putcharTX(pointerPosition);
emmanuelchio 0:210b5ba62803 1134
emmanuelchio 0:210b5ba62803 1135 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 1136 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 1137 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 1138 }
emmanuelchio 0:210b5ba62803 1139
emmanuelchio 0:210b5ba62803 1140 FILERESULT SMARTGPU2::SDFgetFilePointer(POINTERPOSITION *pointerPosition, WORKSPACEBLOCK objectWorkspaceNo){ // get file pointer of file object # workspace
emmanuelchio 0:210b5ba62803 1141 FILERESULT res;
emmanuelchio 0:210b5ba62803 1142 unsigned long pos = 0;
emmanuelchio 0:210b5ba62803 1143
emmanuelchio 0:210b5ba62803 1144 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 1145 putcharTX('P'); //Pointer position
emmanuelchio 0:210b5ba62803 1146 putcharTX(objectWorkspaceNo); //object workspace number to get pointer 0-4
emmanuelchio 0:210b5ba62803 1147 putcharTX('G'); //Get
emmanuelchio 0:210b5ba62803 1148
emmanuelchio 0:210b5ba62803 1149 ((unsigned char *) &pos)[3]=getcharRX();
emmanuelchio 0:210b5ba62803 1150 ((unsigned char *) &pos)[2]=getcharRX();
emmanuelchio 0:210b5ba62803 1151 ((unsigned char *) &pos)[1]=getcharRX();
emmanuelchio 0:210b5ba62803 1152 ((unsigned char *) &pos)[0]=getcharRX();
emmanuelchio 0:210b5ba62803 1153 *pointerPosition =pos;
emmanuelchio 0:210b5ba62803 1154 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 1155 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 1156 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 1157 }
emmanuelchio 0:210b5ba62803 1158
emmanuelchio 0:210b5ba62803 1159 FILERESULT SMARTGPU2::SDFreadFile(char buffer[], NUMBEROFBYTES BTR, NUMBEROFBYTES *SRB, WORKSPACEBLOCK objectWorkspaceNo){ //Bytes to Read, Succesfully Read Bytes, file object # to read bytes from
emmanuelchio 0:210b5ba62803 1160 FILERESULT res;
emmanuelchio 0:210b5ba62803 1161 unsigned int x=0, sr=0;
emmanuelchio 0:210b5ba62803 1162
emmanuelchio 0:210b5ba62803 1163 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 1164 putcharTX('R'); //Read file
emmanuelchio 0:210b5ba62803 1165 putcharTX(objectWorkspaceNo); //object workspace number to read 0-4
emmanuelchio 0:210b5ba62803 1166 putcharTX(BTR>>8);
emmanuelchio 0:210b5ba62803 1167 putcharTX(BTR);
emmanuelchio 0:210b5ba62803 1168
emmanuelchio 0:210b5ba62803 1169 for(x=0;x<BTR;x++){
emmanuelchio 0:210b5ba62803 1170 buffer[x]=getcharRX();
emmanuelchio 0:210b5ba62803 1171 }
emmanuelchio 0:210b5ba62803 1172 sr=getcharRX();
emmanuelchio 0:210b5ba62803 1173 sr=sr<<8;
emmanuelchio 0:210b5ba62803 1174 sr|=getcharRX();
emmanuelchio 0:210b5ba62803 1175 *SRB = sr; //store succesfully read bytes
emmanuelchio 0:210b5ba62803 1176 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 1177 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 1178 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 1179 }
emmanuelchio 0:210b5ba62803 1180
emmanuelchio 0:210b5ba62803 1181 FILERESULT SMARTGPU2::SDFwriteFile(char buffer[], NUMBEROFBYTES BTW, NUMBEROFBYTES *SWB, WORKSPACEBLOCK objectWorkspaceNo){ //Bytes to Write, Succesfully Written Bytes, file object # to write bytes
emmanuelchio 0:210b5ba62803 1182 FILERESULT res;
emmanuelchio 0:210b5ba62803 1183 unsigned int x=0, sw=0;
emmanuelchio 0:210b5ba62803 1184
emmanuelchio 0:210b5ba62803 1185 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 1186 putcharTX('W'); //Write file
emmanuelchio 0:210b5ba62803 1187 putcharTX(objectWorkspaceNo); //object workspace number to write bytes 0-4
emmanuelchio 0:210b5ba62803 1188 putcharTX(BTW>>8);
emmanuelchio 0:210b5ba62803 1189 putcharTX(BTW);
emmanuelchio 0:210b5ba62803 1190 for(x=0;x<BTW;x++){
emmanuelchio 0:210b5ba62803 1191 putcharTX(buffer[x]);
emmanuelchio 0:210b5ba62803 1192 }
emmanuelchio 0:210b5ba62803 1193
emmanuelchio 0:210b5ba62803 1194 sw=getcharRX();
emmanuelchio 0:210b5ba62803 1195 sw=sw<<8;
emmanuelchio 0:210b5ba62803 1196 sw|=getcharRX();
emmanuelchio 0:210b5ba62803 1197 *SWB = sw; //store succesfully written bytes
emmanuelchio 0:210b5ba62803 1198 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 1199 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 1200 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 1201 }
emmanuelchio 0:210b5ba62803 1202
emmanuelchio 0:210b5ba62803 1203 FILERESULT SMARTGPU2::SDFtestFileError(WORKSPACEBLOCK objectWorkspaceNo){ //test for an error on file # workspace
emmanuelchio 0:210b5ba62803 1204 FILERESULT res;
emmanuelchio 0:210b5ba62803 1205
emmanuelchio 0:210b5ba62803 1206 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 1207 putcharTX('Q'); //Test
emmanuelchio 0:210b5ba62803 1208 putcharTX(objectWorkspaceNo); //object workspace number to write bytes 0-4
emmanuelchio 0:210b5ba62803 1209 putcharTX('R'); //Test Error
emmanuelchio 0:210b5ba62803 1210
emmanuelchio 0:210b5ba62803 1211 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 1212 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 1213 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 1214 }
emmanuelchio 0:210b5ba62803 1215
emmanuelchio 0:210b5ba62803 1216 FILERESULT SMARTGPU2::SDFtestFileEnd(WORKSPACEBLOCK objectWorkspaceNo){ //test for an error on file # workspace
emmanuelchio 0:210b5ba62803 1217 FILERESULT res;
emmanuelchio 0:210b5ba62803 1218
emmanuelchio 0:210b5ba62803 1219 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 1220 putcharTX('Q'); //Test
emmanuelchio 0:210b5ba62803 1221 putcharTX(objectWorkspaceNo); //object workspace number to write bytes 0-4
emmanuelchio 0:210b5ba62803 1222 putcharTX('E'); //Test End of File
emmanuelchio 0:210b5ba62803 1223
emmanuelchio 0:210b5ba62803 1224 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 1225 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 1226 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 1227 }
emmanuelchio 0:210b5ba62803 1228
emmanuelchio 0:210b5ba62803 1229 FILERESULT SMARTGPU2::SDFtruncateFile(WORKSPACEBLOCK objectWorkspaceNo){ //truncates the file size to the current file read/write pointer of the file # workspace
emmanuelchio 0:210b5ba62803 1230 FILERESULT res;
emmanuelchio 0:210b5ba62803 1231
emmanuelchio 0:210b5ba62803 1232 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 1233 putcharTX('V'); //Truncate
emmanuelchio 0:210b5ba62803 1234 putcharTX(objectWorkspaceNo); //object workspace number 0-4 to truncate on current pointerPosition
emmanuelchio 0:210b5ba62803 1235
emmanuelchio 0:210b5ba62803 1236 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 1237 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 1238 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 1239 }
emmanuelchio 0:210b5ba62803 1240
emmanuelchio 0:210b5ba62803 1241 FILERESULT SMARTGPU2::SDFeraseDirFile(FILENAME name){ //Erases an existing Dir or File
emmanuelchio 0:210b5ba62803 1242 FILERESULT res;
emmanuelchio 0:210b5ba62803 1243 unsigned int counter=0;
emmanuelchio 0:210b5ba62803 1244
emmanuelchio 0:210b5ba62803 1245 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 1246 putcharTX('E'); //Erase Dir File
emmanuelchio 0:210b5ba62803 1247 putcharTX('O'); //Unlock Erase Protection
emmanuelchio 0:210b5ba62803 1248 while(1){
emmanuelchio 0:210b5ba62803 1249 putcharTX(name[counter]);
emmanuelchio 0:210b5ba62803 1250 if(name[counter]==0x00){
emmanuelchio 0:210b5ba62803 1251 break;
emmanuelchio 0:210b5ba62803 1252 }
emmanuelchio 0:210b5ba62803 1253 counter++;
emmanuelchio 0:210b5ba62803 1254 }
emmanuelchio 0:210b5ba62803 1255
emmanuelchio 0:210b5ba62803 1256 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 1257 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 1258 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 1259 }
emmanuelchio 0:210b5ba62803 1260
emmanuelchio 0:210b5ba62803 1261 FILERESULT SMARTGPU2::SDFsetFileTimeDate(TIME *timeDate, FILENAME name){ //Set Time and Date to an existing File
emmanuelchio 0:210b5ba62803 1262 FILERESULT res;
emmanuelchio 0:210b5ba62803 1263 unsigned int counter=0;
emmanuelchio 0:210b5ba62803 1264
emmanuelchio 0:210b5ba62803 1265 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 1266 putcharTX('T'); //Time/Date
emmanuelchio 0:210b5ba62803 1267 putcharTX('S'); //Set
emmanuelchio 0:210b5ba62803 1268 putcharTX(timeDate->hour); //hour
emmanuelchio 0:210b5ba62803 1269 putcharTX(timeDate->minute); //min
emmanuelchio 0:210b5ba62803 1270 putcharTX(timeDate->second); //sec
emmanuelchio 0:210b5ba62803 1271 putcharTX(timeDate->day); //day
emmanuelchio 0:210b5ba62803 1272 putcharTX(timeDate->month); //month
emmanuelchio 0:210b5ba62803 1273 putcharTX(timeDate->year>>8);//year upper
emmanuelchio 0:210b5ba62803 1274 putcharTX(timeDate->year); //year lower
emmanuelchio 0:210b5ba62803 1275 while(1){
emmanuelchio 0:210b5ba62803 1276 putcharTX(name[counter]);
emmanuelchio 0:210b5ba62803 1277 if(name[counter]==0x00){
emmanuelchio 0:210b5ba62803 1278 break;
emmanuelchio 0:210b5ba62803 1279 }
emmanuelchio 0:210b5ba62803 1280 counter++;
emmanuelchio 0:210b5ba62803 1281 }
emmanuelchio 0:210b5ba62803 1282
emmanuelchio 0:210b5ba62803 1283 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 1284 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 1285 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 1286 }
emmanuelchio 0:210b5ba62803 1287
emmanuelchio 0:210b5ba62803 1288 FILERESULT SMARTGPU2::SDFgetFileTimeDate(TIME *timeDate, FILENAME name){ //Get Time and Date to an existing File
emmanuelchio 0:210b5ba62803 1289 FILERESULT res;
emmanuelchio 0:210b5ba62803 1290 unsigned int counter=0;
emmanuelchio 0:210b5ba62803 1291
emmanuelchio 0:210b5ba62803 1292 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 1293 putcharTX('T'); //Time/Date
emmanuelchio 0:210b5ba62803 1294 putcharTX('G'); //Get
emmanuelchio 0:210b5ba62803 1295 while(1){
emmanuelchio 0:210b5ba62803 1296 putcharTX(name[counter]);
emmanuelchio 0:210b5ba62803 1297 if(name[counter]==0x00){
emmanuelchio 0:210b5ba62803 1298 break;
emmanuelchio 0:210b5ba62803 1299 }
emmanuelchio 0:210b5ba62803 1300 counter++;
emmanuelchio 0:210b5ba62803 1301 }
emmanuelchio 0:210b5ba62803 1302
emmanuelchio 0:210b5ba62803 1303 timeDate->hour = getcharRX(); //hour
emmanuelchio 0:210b5ba62803 1304 timeDate->minute = getcharRX(); //min
emmanuelchio 0:210b5ba62803 1305 timeDate->second = getcharRX(); //sec
emmanuelchio 0:210b5ba62803 1306 timeDate->day = getcharRX(); //day
emmanuelchio 0:210b5ba62803 1307 timeDate->month = getcharRX(); //month
emmanuelchio 0:210b5ba62803 1308 ((unsigned char*)&counter)[1] = getcharRX(); //year upper
emmanuelchio 0:210b5ba62803 1309 ((unsigned char*)&counter)[0] = getcharRX(); //year lower
emmanuelchio 0:210b5ba62803 1310 timeDate->year = counter; //year
emmanuelchio 0:210b5ba62803 1311 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 1312 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 1313 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 1314 }
emmanuelchio 0:210b5ba62803 1315
emmanuelchio 0:210b5ba62803 1316 FILERESULT SMARTGPU2::SDFgetFileSize(FILENAME name, unsigned long *fileSize){ //Get Size of an existing File
emmanuelchio 0:210b5ba62803 1317 FILERESULT res;
emmanuelchio 0:210b5ba62803 1318 unsigned int counter=0;
emmanuelchio 0:210b5ba62803 1319 unsigned long size=0;
emmanuelchio 0:210b5ba62803 1320
emmanuelchio 0:210b5ba62803 1321 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 1322 putcharTX('I'); //Info
emmanuelchio 0:210b5ba62803 1323 putcharTX('S'); //Size
emmanuelchio 0:210b5ba62803 1324 while(1){
emmanuelchio 0:210b5ba62803 1325 putcharTX(name[counter]);
emmanuelchio 0:210b5ba62803 1326 if(name[counter]==0x00){
emmanuelchio 0:210b5ba62803 1327 break;
emmanuelchio 0:210b5ba62803 1328 }
emmanuelchio 0:210b5ba62803 1329 counter++;
emmanuelchio 0:210b5ba62803 1330 }
emmanuelchio 0:210b5ba62803 1331
emmanuelchio 0:210b5ba62803 1332 ((unsigned char *) &size)[3]=getcharRX();
emmanuelchio 0:210b5ba62803 1333 ((unsigned char *) &size)[2]=getcharRX();
emmanuelchio 0:210b5ba62803 1334 ((unsigned char *) &size)[1]=getcharRX();
emmanuelchio 0:210b5ba62803 1335 ((unsigned char *) &size)[0]=getcharRX();
emmanuelchio 0:210b5ba62803 1336 *fileSize=size;
emmanuelchio 0:210b5ba62803 1337 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 1338 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 1339 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 1340 }
emmanuelchio 0:210b5ba62803 1341
emmanuelchio 0:210b5ba62803 1342 FILERESULT SMARTGPU2::SDFrenameMoveDirFile(FILENAME oldName, FILENAME newName){ //renames or moves an existing Dir or File
emmanuelchio 0:210b5ba62803 1343 FILERESULT res;
emmanuelchio 0:210b5ba62803 1344 unsigned int counter=0;
emmanuelchio 0:210b5ba62803 1345
emmanuelchio 0:210b5ba62803 1346 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 1347 putcharTX('M'); //Rename / Move
emmanuelchio 0:210b5ba62803 1348 while(1){
emmanuelchio 0:210b5ba62803 1349 putcharTX(oldName[counter]);
emmanuelchio 0:210b5ba62803 1350 if(oldName[counter]==0x00){
emmanuelchio 0:210b5ba62803 1351 break;
emmanuelchio 0:210b5ba62803 1352 }
emmanuelchio 0:210b5ba62803 1353 counter++;
emmanuelchio 0:210b5ba62803 1354 }
emmanuelchio 0:210b5ba62803 1355 counter=0;
emmanuelchio 0:210b5ba62803 1356 while(1){
emmanuelchio 0:210b5ba62803 1357 putcharTX(newName[counter]);
emmanuelchio 0:210b5ba62803 1358 if(newName[counter]==0x00){
emmanuelchio 0:210b5ba62803 1359 break;
emmanuelchio 0:210b5ba62803 1360 }
emmanuelchio 0:210b5ba62803 1361 counter++;
emmanuelchio 0:210b5ba62803 1362 }
emmanuelchio 0:210b5ba62803 1363
emmanuelchio 0:210b5ba62803 1364 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 1365 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 1366 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 1367 }
emmanuelchio 0:210b5ba62803 1368
emmanuelchio 0:210b5ba62803 1369 FILERESULT SMARTGPU2::SDFgetFreeTotalSpace(unsigned long *freeSpace,unsigned long *totalSpace){ //Get free and total space in bytes of the microSD card
emmanuelchio 0:210b5ba62803 1370 FILERESULT res;
emmanuelchio 0:210b5ba62803 1371 unsigned long fSpace=0, tSpace=0;
emmanuelchio 0:210b5ba62803 1372
emmanuelchio 0:210b5ba62803 1373 putcharTX('F'); //File function - memory card file management
emmanuelchio 0:210b5ba62803 1374 putcharTX('F'); //Free/Total space
emmanuelchio 0:210b5ba62803 1375
emmanuelchio 0:210b5ba62803 1376 ((unsigned char *) &fSpace)[3]=getcharRX();
emmanuelchio 0:210b5ba62803 1377 ((unsigned char *) &fSpace)[2]=getcharRX();
emmanuelchio 0:210b5ba62803 1378 ((unsigned char *) &fSpace)[1]=getcharRX();
emmanuelchio 0:210b5ba62803 1379 ((unsigned char *) &fSpace)[0]=getcharRX();
emmanuelchio 0:210b5ba62803 1380 ((unsigned char *) &tSpace)[3]=getcharRX();
emmanuelchio 0:210b5ba62803 1381 ((unsigned char *) &tSpace)[2]=getcharRX();
emmanuelchio 0:210b5ba62803 1382 ((unsigned char *) &tSpace)[1]=getcharRX();
emmanuelchio 0:210b5ba62803 1383 ((unsigned char *) &tSpace)[0]=getcharRX();
emmanuelchio 0:210b5ba62803 1384 *freeSpace=fSpace;
emmanuelchio 0:210b5ba62803 1385 *totalSpace=tSpace;
emmanuelchio 0:210b5ba62803 1386 res = (FILERESULT)getcharRX(); //Get SD file execution status
emmanuelchio 0:210b5ba62803 1387 getcharRX(); //Discard 'O' or 'F'
emmanuelchio 0:210b5ba62803 1388 return res; //Return SD file execution status
emmanuelchio 0:210b5ba62803 1389 }