Mini SmartGPU Intelligent Graphics Processor. Mbed library Rev1.0 Vizic Technologies 2012 http://vizictechnologies.com/#/mini-smart-gpu/4566376187

Dependents:   BounceBallMSG BouncingBallsMSG HouseMSG NiceClockMSG ... more

Committer:
emmanuelchio
Date:
Wed Aug 29 22:31:40 2012 +0000
Revision:
1:83a75a056cfa
Parent:
0:1c3989d263f4
MiniSMARTGPU Mbed Library R2 - Vizic Technologies

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emmanuelchio 0:1c3989d263f4 1 /*********************************************************
emmanuelchio 0:1c3989d263f4 2 VIZIC TECHNOLOGIES. COPYRIGHT 2012.
emmanuelchio 0:1c3989d263f4 3 THE DATASHEETS, SOFTWARE AND LIBRARIES ARE PROVIDED "AS IS."
emmanuelchio 0:1c3989d263f4 4 VIZIC EXPRESSLY DISCLAIM ANY WARRANTY OF ANY KIND, WHETHER
emmanuelchio 0:1c3989d263f4 5 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED
emmanuelchio 0:1c3989d263f4 6 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
emmanuelchio 0:1c3989d263f4 7 OR NONINFRINGEMENT. IN NO EVENT SHALL VIZIC BE LIABLE FOR
emmanuelchio 0:1c3989d263f4 8 ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES,
emmanuelchio 0:1c3989d263f4 9 LOST PROFITS OR LOST DATA, HARM TO YOUR EQUIPMENT, COST OF
emmanuelchio 0:1c3989d263f4 10 PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES,
emmanuelchio 0:1c3989d263f4 11 ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO
emmanuelchio 0:1c3989d263f4 12 ANY DEFENCE THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION,
emmanuelchio 0:1c3989d263f4 13 OR OTHER SIMILAR COSTS.
emmanuelchio 0:1c3989d263f4 14 *********************************************************/
emmanuelchio 0:1c3989d263f4 15
emmanuelchio 0:1c3989d263f4 16 #include "mbed.h"
emmanuelchio 0:1c3989d263f4 17 #include "MINISMARTGPU.h"
emmanuelchio 0:1c3989d263f4 18
emmanuelchio 0:1c3989d263f4 19 // MINI SMART GPU DEFAULT BAUD RATE: 9600bps
emmanuelchio 0:1c3989d263f4 20 //It shoud be used like this : MINISMARTGPU lcd(p13,p14,p15); for serial communication with MINISMARTGPU
emmanuelchio 0:1c3989d263f4 21 MINISMARTGPU::MINISMARTGPU(PinName TXPin, PinName RXPin, PinName resetPin): _serialMINISMARTGPU(TXPin,RXPin), _resetPin(resetPin){
emmanuelchio 0:1c3989d263f4 22 init();
emmanuelchio 0:1c3989d263f4 23 }
emmanuelchio 0:1c3989d263f4 24
emmanuelchio 0:1c3989d263f4 25 /********** high level commands, for the user! */
emmanuelchio 0:1c3989d263f4 26 void MINISMARTGPU::init(){ //configure the mbed for MINISMARTGPU board
emmanuelchio 0:1c3989d263f4 27 _serialMINISMARTGPU.baud(9600);
emmanuelchio 0:1c3989d263f4 28 _resetPin=1; //set the pin to 3.3v to avoid reset
emmanuelchio 0:1c3989d263f4 29 }
emmanuelchio 0:1c3989d263f4 30
emmanuelchio 0:1c3989d263f4 31 void MINISMARTGPU::reset(){ //Reset the MINISMARTGPU board
emmanuelchio 0:1c3989d263f4 32 _resetPin=0; //set the pin to GND to reset
emmanuelchio 0:1c3989d263f4 33 wait_ms(500);
emmanuelchio 0:1c3989d263f4 34 _resetPin=1; //set the pin to 3.3v to end reset
emmanuelchio 0:1c3989d263f4 35 wait_ms(500);
emmanuelchio 0:1c3989d263f4 36
emmanuelchio 0:1c3989d263f4 37 }
emmanuelchio 0:1c3989d263f4 38
emmanuelchio 0:1c3989d263f4 39 unsigned char MINISMARTGPU::start(){ //Init the MINISMARTGPU
emmanuelchio 0:1c3989d263f4 40 wait_ms(500);
emmanuelchio 0:1c3989d263f4 41 _serialMINISMARTGPU.putc('U');
emmanuelchio 0:1c3989d263f4 42 wait_ms(1500);
emmanuelchio 0:1c3989d263f4 43 return _serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 44
emmanuelchio 0:1c3989d263f4 45 }
emmanuelchio 0:1c3989d263f4 46
emmanuelchio 0:1c3989d263f4 47 unsigned char MINISMARTGPU::erase(){ //Erase the MINISMARTGPU screen
emmanuelchio 0:1c3989d263f4 48 _serialMINISMARTGPU.putc('E');
emmanuelchio 0:1c3989d263f4 49 return _serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 50
emmanuelchio 0:1c3989d263f4 51 }
emmanuelchio 0:1c3989d263f4 52
emmanuelchio 0:1c3989d263f4 53 unsigned char MINISMARTGPU::sleep(unsigned char mode){ //Send MINISMARTGPU to sleep mode
emmanuelchio 0:1c3989d263f4 54 _serialMINISMARTGPU.putc('Z');
emmanuelchio 0:1c3989d263f4 55 _serialMINISMARTGPU.putc(mode);
emmanuelchio 0:1c3989d263f4 56 return _serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 57
emmanuelchio 0:1c3989d263f4 58 }
emmanuelchio 0:1c3989d263f4 59
emmanuelchio 0:1c3989d263f4 60 unsigned char MINISMARTGPU::orientation(unsigned char side){ //Change display orientation
emmanuelchio 0:1c3989d263f4 61 _serialMINISMARTGPU.putc('O');
emmanuelchio 0:1c3989d263f4 62 _serialMINISMARTGPU.putc(side);
emmanuelchio 0:1c3989d263f4 63 return _serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 64
emmanuelchio 0:1c3989d263f4 65 }
emmanuelchio 0:1c3989d263f4 66
emmanuelchio 0:1c3989d263f4 67 unsigned char MINISMARTGPU::bright(unsigned char val){ //Change display brightness
emmanuelchio 0:1c3989d263f4 68 _serialMINISMARTGPU.putc('V');
emmanuelchio 0:1c3989d263f4 69 _serialMINISMARTGPU.putc(val);
emmanuelchio 0:1c3989d263f4 70 return _serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 71
emmanuelchio 0:1c3989d263f4 72 }
emmanuelchio 0:1c3989d263f4 73
emmanuelchio 0:1c3989d263f4 74 unsigned char MINISMARTGPU::baudChange(unsigned long val){ //Change baud rate of mbed and SMARTGPU board
emmanuelchio 0:1c3989d263f4 75 unsigned char aux;
emmanuelchio 0:1c3989d263f4 76
emmanuelchio 0:1c3989d263f4 77 switch(val){
emmanuelchio 0:1c3989d263f4 78 case 9600:
emmanuelchio 0:1c3989d263f4 79 aux=0;
emmanuelchio 0:1c3989d263f4 80 break;
emmanuelchio 0:1c3989d263f4 81 case 19200:
emmanuelchio 0:1c3989d263f4 82 aux=1;
emmanuelchio 0:1c3989d263f4 83 break;
emmanuelchio 0:1c3989d263f4 84 case 57600:
emmanuelchio 0:1c3989d263f4 85 aux=2;
emmanuelchio 0:1c3989d263f4 86 break;
emmanuelchio 0:1c3989d263f4 87 case 115200:
emmanuelchio 0:1c3989d263f4 88 aux=3;
emmanuelchio 0:1c3989d263f4 89 break;
emmanuelchio 0:1c3989d263f4 90 case 256000:
emmanuelchio 0:1c3989d263f4 91 aux=4;
emmanuelchio 0:1c3989d263f4 92 break;
emmanuelchio 0:1c3989d263f4 93 case 500000:
emmanuelchio 0:1c3989d263f4 94 aux=5;
emmanuelchio 0:1c3989d263f4 95 break;
emmanuelchio 0:1c3989d263f4 96 case 1000000:
emmanuelchio 0:1c3989d263f4 97 aux=6;
emmanuelchio 0:1c3989d263f4 98 break;
emmanuelchio 0:1c3989d263f4 99 case 2000000:
emmanuelchio 0:1c3989d263f4 100 aux=7;
emmanuelchio 0:1c3989d263f4 101 break;
emmanuelchio 0:1c3989d263f4 102 default:
emmanuelchio 0:1c3989d263f4 103 return 'F';
emmanuelchio 0:1c3989d263f4 104
emmanuelchio 0:1c3989d263f4 105 }
emmanuelchio 0:1c3989d263f4 106 _serialMINISMARTGPU.putc('X');
emmanuelchio 0:1c3989d263f4 107 _serialMINISMARTGPU.putc(aux);
emmanuelchio 0:1c3989d263f4 108 aux=_serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 109
emmanuelchio 0:1c3989d263f4 110 if(aux=='O'){
emmanuelchio 0:1c3989d263f4 111 wait_ms(150);
emmanuelchio 0:1c3989d263f4 112 _serialMINISMARTGPU.baud(val);
emmanuelchio 0:1c3989d263f4 113 wait_ms(200);
emmanuelchio 0:1c3989d263f4 114 return _serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 115 }else{
emmanuelchio 0:1c3989d263f4 116 return aux;
emmanuelchio 0:1c3989d263f4 117 }
emmanuelchio 0:1c3989d263f4 118 }
emmanuelchio 0:1c3989d263f4 119
emmanuelchio 0:1c3989d263f4 120 unsigned char MINISMARTGPU::setScreenBackground(int colour){ //Change the default screen background colour for erase function
emmanuelchio 0:1c3989d263f4 121 _serialMINISMARTGPU.putc('B');
emmanuelchio 0:1c3989d263f4 122 _serialMINISMARTGPU.putc(colour>>8);
emmanuelchio 0:1c3989d263f4 123 _serialMINISMARTGPU.putc(colour);
emmanuelchio 0:1c3989d263f4 124 return _serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 125
emmanuelchio 0:1c3989d263f4 126 }
emmanuelchio 0:1c3989d263f4 127
emmanuelchio 0:1c3989d263f4 128 unsigned char MINISMARTGPU::setTextBackground(int colour){ //Set the default text background colour for letters and strings
emmanuelchio 0:1c3989d263f4 129 _serialMINISMARTGPU.putc('A');
emmanuelchio 0:1c3989d263f4 130 _serialMINISMARTGPU.putc(colour>>8);
emmanuelchio 0:1c3989d263f4 131 _serialMINISMARTGPU.putc(colour);
emmanuelchio 0:1c3989d263f4 132 return _serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 133
emmanuelchio 0:1c3989d263f4 134 }
emmanuelchio 0:1c3989d263f4 135
emmanuelchio 0:1c3989d263f4 136 unsigned char MINISMARTGPU::memoryRead(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, char buffer[]){ //Read the internal memory of the MINISMARTGPU, This command returns 24bit pixels (3 bytes)
emmanuelchio 0:1c3989d263f4 137 unsigned int i,j,k=0;
emmanuelchio 0:1c3989d263f4 138
emmanuelchio 0:1c3989d263f4 139 _serialMINISMARTGPU.putc('M');
emmanuelchio 0:1c3989d263f4 140 _serialMINISMARTGPU.putc(x1);
emmanuelchio 0:1c3989d263f4 141 _serialMINISMARTGPU.putc(y1);
emmanuelchio 0:1c3989d263f4 142 _serialMINISMARTGPU.putc(x2);
emmanuelchio 0:1c3989d263f4 143 _serialMINISMARTGPU.putc(y2);
emmanuelchio 0:1c3989d263f4 144
emmanuelchio 0:1c3989d263f4 145 //receive all the pixels
emmanuelchio 0:1c3989d263f4 146 for(j=0;j<=(y2-y1);j++){
emmanuelchio 0:1c3989d263f4 147 for(i=0;i<=(x2-x1);i++){
emmanuelchio 0:1c3989d263f4 148 buffer[k]=_serialMINISMARTGPU.getc(); //Red
emmanuelchio 0:1c3989d263f4 149 k++;
emmanuelchio 0:1c3989d263f4 150 buffer[k]=_serialMINISMARTGPU.getc(); //Green
emmanuelchio 0:1c3989d263f4 151 k++;
emmanuelchio 0:1c3989d263f4 152 buffer[k]=_serialMINISMARTGPU.getc(); //Blue
emmanuelchio 0:1c3989d263f4 153 k++;
emmanuelchio 0:1c3989d263f4 154 }
emmanuelchio 0:1c3989d263f4 155 }
emmanuelchio 0:1c3989d263f4 156 return _serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 157
emmanuelchio 0:1c3989d263f4 158 }
emmanuelchio 0:1c3989d263f4 159
emmanuelchio 0:1c3989d263f4 160 unsigned char MINISMARTGPU::putPixel(unsigned char x, unsigned char y, int colour){ //Draw a pixel on the screen
emmanuelchio 0:1c3989d263f4 161 _serialMINISMARTGPU.putc('P');
emmanuelchio 0:1c3989d263f4 162 _serialMINISMARTGPU.putc(x);
emmanuelchio 0:1c3989d263f4 163 _serialMINISMARTGPU.putc(y);
emmanuelchio 0:1c3989d263f4 164 _serialMINISMARTGPU.putc(colour>>8);
emmanuelchio 0:1c3989d263f4 165 _serialMINISMARTGPU.putc(colour);
emmanuelchio 0:1c3989d263f4 166 return _serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 167
emmanuelchio 0:1c3989d263f4 168 }
emmanuelchio 0:1c3989d263f4 169
emmanuelchio 0:1c3989d263f4 170 unsigned char MINISMARTGPU::drawLine(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, int colour){ //Draw a line on the screen
emmanuelchio 0:1c3989d263f4 171 _serialMINISMARTGPU.putc('L');
emmanuelchio 0:1c3989d263f4 172 _serialMINISMARTGPU.putc(x1);
emmanuelchio 0:1c3989d263f4 173 _serialMINISMARTGPU.putc(y1);
emmanuelchio 0:1c3989d263f4 174 _serialMINISMARTGPU.putc(x2);
emmanuelchio 0:1c3989d263f4 175 _serialMINISMARTGPU.putc(y2);
emmanuelchio 0:1c3989d263f4 176 _serialMINISMARTGPU.putc(colour>>8);
emmanuelchio 0:1c3989d263f4 177 _serialMINISMARTGPU.putc(colour);
emmanuelchio 0:1c3989d263f4 178 return _serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 179
emmanuelchio 0:1c3989d263f4 180 }
emmanuelchio 0:1c3989d263f4 181
emmanuelchio 0:1c3989d263f4 182 unsigned char MINISMARTGPU::drawRectangle(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, int colour, unsigned char fill){ //Draw a rectangle on the screen
emmanuelchio 0:1c3989d263f4 183 _serialMINISMARTGPU.putc('R');
emmanuelchio 0:1c3989d263f4 184 _serialMINISMARTGPU.putc(x1);
emmanuelchio 0:1c3989d263f4 185 _serialMINISMARTGPU.putc(y1);
emmanuelchio 0:1c3989d263f4 186 _serialMINISMARTGPU.putc(x2);
emmanuelchio 0:1c3989d263f4 187 _serialMINISMARTGPU.putc(y2);
emmanuelchio 0:1c3989d263f4 188 _serialMINISMARTGPU.putc(colour>>8);
emmanuelchio 0:1c3989d263f4 189 _serialMINISMARTGPU.putc(colour);
emmanuelchio 0:1c3989d263f4 190 _serialMINISMARTGPU.putc(fill);
emmanuelchio 0:1c3989d263f4 191 return _serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 192
emmanuelchio 0:1c3989d263f4 193 }
emmanuelchio 0:1c3989d263f4 194
emmanuelchio 0:1c3989d263f4 195 unsigned char MINISMARTGPU::drawTriangle(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, unsigned char x3, unsigned char y3, int colour, unsigned char fill){ //Draw a triangle on the screen
emmanuelchio 0:1c3989d263f4 196 _serialMINISMARTGPU.putc('T');
emmanuelchio 0:1c3989d263f4 197 _serialMINISMARTGPU.putc(x1);
emmanuelchio 0:1c3989d263f4 198 _serialMINISMARTGPU.putc(y1);
emmanuelchio 0:1c3989d263f4 199 _serialMINISMARTGPU.putc(x2);
emmanuelchio 0:1c3989d263f4 200 _serialMINISMARTGPU.putc(y2);
emmanuelchio 0:1c3989d263f4 201 _serialMINISMARTGPU.putc(x3);
emmanuelchio 0:1c3989d263f4 202 _serialMINISMARTGPU.putc(y3);
emmanuelchio 0:1c3989d263f4 203 _serialMINISMARTGPU.putc(colour>>8);
emmanuelchio 0:1c3989d263f4 204 _serialMINISMARTGPU.putc(colour);
emmanuelchio 0:1c3989d263f4 205 _serialMINISMARTGPU.putc(fill);
emmanuelchio 0:1c3989d263f4 206 return _serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 207
emmanuelchio 0:1c3989d263f4 208 }
emmanuelchio 0:1c3989d263f4 209
emmanuelchio 0:1c3989d263f4 210 unsigned char MINISMARTGPU::drawCircle(unsigned char x, unsigned char y, unsigned char radius, int colour, unsigned char fill){ //Draw a circle on the screen
emmanuelchio 0:1c3989d263f4 211 _serialMINISMARTGPU.putc('C');
emmanuelchio 0:1c3989d263f4 212 _serialMINISMARTGPU.putc(x);
emmanuelchio 0:1c3989d263f4 213 _serialMINISMARTGPU.putc(y);
emmanuelchio 0:1c3989d263f4 214 _serialMINISMARTGPU.putc(radius);
emmanuelchio 0:1c3989d263f4 215 _serialMINISMARTGPU.putc(colour>>8);
emmanuelchio 0:1c3989d263f4 216 _serialMINISMARTGPU.putc(colour);
emmanuelchio 0:1c3989d263f4 217 _serialMINISMARTGPU.putc(fill);
emmanuelchio 0:1c3989d263f4 218 return _serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 219
emmanuelchio 0:1c3989d263f4 220 }
emmanuelchio 0:1c3989d263f4 221
emmanuelchio 0:1c3989d263f4 222 unsigned char MINISMARTGPU::putLetter(unsigned char x, unsigned char y, int colour, unsigned char font, unsigned char fill, unsigned char letter){ //Draw a letter on the screen
emmanuelchio 0:1c3989d263f4 223 _serialMINISMARTGPU.putc('W');
emmanuelchio 0:1c3989d263f4 224 _serialMINISMARTGPU.putc(x);
emmanuelchio 0:1c3989d263f4 225 _serialMINISMARTGPU.putc(y);
emmanuelchio 0:1c3989d263f4 226 _serialMINISMARTGPU.putc(colour>>8);
emmanuelchio 0:1c3989d263f4 227 _serialMINISMARTGPU.putc(colour);
emmanuelchio 0:1c3989d263f4 228 _serialMINISMARTGPU.putc(font);
emmanuelchio 0:1c3989d263f4 229 _serialMINISMARTGPU.putc(fill);
emmanuelchio 0:1c3989d263f4 230 _serialMINISMARTGPU.putc(letter);
emmanuelchio 0:1c3989d263f4 231 return _serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 232
emmanuelchio 0:1c3989d263f4 233 }
emmanuelchio 0:1c3989d263f4 234
emmanuelchio 0:1c3989d263f4 235 unsigned char MINISMARTGPU::string(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, int colour, unsigned char font, unsigned char fill, char text[]){ //Draw a string on the screen
emmanuelchio 0:1c3989d263f4 236 int counter=0;
emmanuelchio 0:1c3989d263f4 237
emmanuelchio 0:1c3989d263f4 238 _serialMINISMARTGPU.putc('S');
emmanuelchio 0:1c3989d263f4 239 _serialMINISMARTGPU.putc('N'); //not SD
emmanuelchio 0:1c3989d263f4 240 _serialMINISMARTGPU.putc(x1);
emmanuelchio 0:1c3989d263f4 241 _serialMINISMARTGPU.putc(y1);
emmanuelchio 0:1c3989d263f4 242 _serialMINISMARTGPU.putc(x2);
emmanuelchio 0:1c3989d263f4 243 _serialMINISMARTGPU.putc(y2);
emmanuelchio 0:1c3989d263f4 244 _serialMINISMARTGPU.putc(colour>>8);
emmanuelchio 0:1c3989d263f4 245 _serialMINISMARTGPU.putc(colour);
emmanuelchio 0:1c3989d263f4 246 _serialMINISMARTGPU.putc(font);
emmanuelchio 0:1c3989d263f4 247 _serialMINISMARTGPU.putc(fill);
emmanuelchio 0:1c3989d263f4 248 while(1){
emmanuelchio 0:1c3989d263f4 249 _serialMINISMARTGPU.putc(text[counter]);
emmanuelchio 0:1c3989d263f4 250 if(text[counter]==0x00){
emmanuelchio 0:1c3989d263f4 251 break;
emmanuelchio 0:1c3989d263f4 252 }
emmanuelchio 0:1c3989d263f4 253 counter++;
emmanuelchio 0:1c3989d263f4 254 }
emmanuelchio 0:1c3989d263f4 255 return _serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 256
emmanuelchio 0:1c3989d263f4 257 }
emmanuelchio 0:1c3989d263f4 258
emmanuelchio 0:1c3989d263f4 259 unsigned char MINISMARTGPU::stringSD(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, int colour, unsigned char font, unsigned char fill, int BS, int BR, char name[]){ //Draw a String from a text file contained on the micro SD card on the screen
emmanuelchio 0:1c3989d263f4 260 unsigned char counter=0;
emmanuelchio 0:1c3989d263f4 261
emmanuelchio 0:1c3989d263f4 262 _serialMINISMARTGPU.putc('S');
emmanuelchio 0:1c3989d263f4 263 _serialMINISMARTGPU.putc('S'); //from SD
emmanuelchio 0:1c3989d263f4 264 _serialMINISMARTGPU.putc(x1);
emmanuelchio 0:1c3989d263f4 265 _serialMINISMARTGPU.putc(y1);
emmanuelchio 0:1c3989d263f4 266 _serialMINISMARTGPU.putc(x2);
emmanuelchio 0:1c3989d263f4 267 _serialMINISMARTGPU.putc(y2);
emmanuelchio 0:1c3989d263f4 268 _serialMINISMARTGPU.putc(colour>>8);
emmanuelchio 0:1c3989d263f4 269 _serialMINISMARTGPU.putc(colour);
emmanuelchio 0:1c3989d263f4 270 _serialMINISMARTGPU.putc(font);
emmanuelchio 0:1c3989d263f4 271 _serialMINISMARTGPU.putc(fill);
emmanuelchio 0:1c3989d263f4 272 _serialMINISMARTGPU.putc(BS>>8);
emmanuelchio 0:1c3989d263f4 273 _serialMINISMARTGPU.putc(BS);
emmanuelchio 0:1c3989d263f4 274 _serialMINISMARTGPU.putc(BR>>8);
emmanuelchio 0:1c3989d263f4 275 _serialMINISMARTGPU.putc(BR);
emmanuelchio 0:1c3989d263f4 276 while(1){
emmanuelchio 0:1c3989d263f4 277 _serialMINISMARTGPU.putc(name[counter]);
emmanuelchio 0:1c3989d263f4 278 if(name[counter]==0x00){
emmanuelchio 0:1c3989d263f4 279 break;
emmanuelchio 0:1c3989d263f4 280 }
emmanuelchio 0:1c3989d263f4 281 counter++;
emmanuelchio 0:1c3989d263f4 282 }
emmanuelchio 0:1c3989d263f4 283 return _serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 284
emmanuelchio 0:1c3989d263f4 285 }
emmanuelchio 0:1c3989d263f4 286
emmanuelchio 0:1c3989d263f4 287 unsigned char MINISMARTGPU::icon(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, char icon[]){ //Send and image or icon pixel by pixel to MINISMARTGPU, 16bit(2 bytes) each pixel RGB565
emmanuelchio 0:1c3989d263f4 288 unsigned int i,j,k=0;
emmanuelchio 0:1c3989d263f4 289
emmanuelchio 0:1c3989d263f4 290 _serialMINISMARTGPU.putc('I');
emmanuelchio 0:1c3989d263f4 291 _serialMINISMARTGPU.putc('N'); //not SD
emmanuelchio 0:1c3989d263f4 292 _serialMINISMARTGPU.putc(x1);
emmanuelchio 0:1c3989d263f4 293 _serialMINISMARTGPU.putc(y1);
emmanuelchio 0:1c3989d263f4 294 _serialMINISMARTGPU.putc(x2);
emmanuelchio 0:1c3989d263f4 295 _serialMINISMARTGPU.putc(y2);
emmanuelchio 0:1c3989d263f4 296
emmanuelchio 0:1c3989d263f4 297 //Send icon buffer pixel by pixel
emmanuelchio 0:1c3989d263f4 298 for(j=0;j<=(y2-y1);j++){
emmanuelchio 0:1c3989d263f4 299 for(i=0;i<=(x2-x1);i++){
emmanuelchio 0:1c3989d263f4 300 _serialMINISMARTGPU.putc(icon[k]);
emmanuelchio 0:1c3989d263f4 301 k++;
emmanuelchio 0:1c3989d263f4 302 }
emmanuelchio 0:1c3989d263f4 303 }
emmanuelchio 0:1c3989d263f4 304 return _serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 305
emmanuelchio 0:1c3989d263f4 306 }
emmanuelchio 0:1c3989d263f4 307
emmanuelchio 0:1c3989d263f4 308 unsigned char MINISMARTGPU::imageSD(unsigned char x, unsigned char y, char name[]){ //Draw an Image contained on the micro SD card on the screen, top left corner coordinates
emmanuelchio 0:1c3989d263f4 309 unsigned char counter=0;
emmanuelchio 0:1c3989d263f4 310
emmanuelchio 0:1c3989d263f4 311 _serialMINISMARTGPU.putc('I');
emmanuelchio 0:1c3989d263f4 312 _serialMINISMARTGPU.putc('S'); //from SD
emmanuelchio 0:1c3989d263f4 313 _serialMINISMARTGPU.putc(x);
emmanuelchio 0:1c3989d263f4 314 _serialMINISMARTGPU.putc(y);
emmanuelchio 0:1c3989d263f4 315
emmanuelchio 0:1c3989d263f4 316 while(1){
emmanuelchio 0:1c3989d263f4 317 _serialMINISMARTGPU.putc(name[counter]);
emmanuelchio 0:1c3989d263f4 318 if(name[counter]==0x00){
emmanuelchio 0:1c3989d263f4 319 break;
emmanuelchio 0:1c3989d263f4 320 }
emmanuelchio 0:1c3989d263f4 321 counter++;
emmanuelchio 0:1c3989d263f4 322 }
emmanuelchio 0:1c3989d263f4 323 return _serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 324
emmanuelchio 0:1c3989d263f4 325 }
emmanuelchio 0:1c3989d263f4 326
emmanuelchio 0:1c3989d263f4 327 /****************************************************************/
emmanuelchio 0:1c3989d263f4 328 //Those next functions return file execution status instead of ACK 'O' or NAK 'F'
emmanuelchio 0:1c3989d263f4 329 /****************************************************************/
emmanuelchio 0:1c3989d263f4 330
emmanuelchio 0:1c3989d263f4 331 unsigned char MINISMARTGPU::SDfopen(unsigned char mode, char name[]){
emmanuelchio 0:1c3989d263f4 332 unsigned char counter=0;
emmanuelchio 0:1c3989d263f4 333 unsigned char aux = 0;
emmanuelchio 0:1c3989d263f4 334
emmanuelchio 0:1c3989d263f4 335 wait_ms(1);
emmanuelchio 0:1c3989d263f4 336 _serialMINISMARTGPU.putc('F'); //memory card file management
emmanuelchio 0:1c3989d263f4 337 _serialMINISMARTGPU.putc('O'); //file open
emmanuelchio 0:1c3989d263f4 338 _serialMINISMARTGPU.putc(mode);
emmanuelchio 0:1c3989d263f4 339 while(1){
emmanuelchio 1:83a75a056cfa 340 _serialMINISMARTGPU.putc(name[counter]);
emmanuelchio 0:1c3989d263f4 341 if(name[counter]==0x00){
emmanuelchio 0:1c3989d263f4 342 break;
emmanuelchio 1:83a75a056cfa 343 }
emmanuelchio 1:83a75a056cfa 344 counter++;
emmanuelchio 0:1c3989d263f4 345 }
emmanuelchio 0:1c3989d263f4 346 aux= _serialMINISMARTGPU.getc(); //Get FAT result
emmanuelchio 0:1c3989d263f4 347 _serialMINISMARTGPU.getc(); //Discard 'O' or 'F'
emmanuelchio 0:1c3989d263f4 348 return aux; //Return FAT result
emmanuelchio 0:1c3989d263f4 349 }
emmanuelchio 0:1c3989d263f4 350
emmanuelchio 0:1c3989d263f4 351 unsigned char MINISMARTGPU::SDfclose(){
emmanuelchio 0:1c3989d263f4 352 unsigned char aux = 0;
emmanuelchio 0:1c3989d263f4 353
emmanuelchio 0:1c3989d263f4 354 wait_ms(5);
emmanuelchio 0:1c3989d263f4 355 _serialMINISMARTGPU.putc('F'); //memory card file management
emmanuelchio 0:1c3989d263f4 356 _serialMINISMARTGPU.putc('C'); //file close
emmanuelchio 0:1c3989d263f4 357
emmanuelchio 0:1c3989d263f4 358 aux= _serialMINISMARTGPU.getc(); //Get FAT result
emmanuelchio 0:1c3989d263f4 359 _serialMINISMARTGPU.getc(); //Discard 'O' or 'F'
emmanuelchio 0:1c3989d263f4 360 return aux; //Return FAT result
emmanuelchio 0:1c3989d263f4 361 }
emmanuelchio 0:1c3989d263f4 362
emmanuelchio 0:1c3989d263f4 363 unsigned char MINISMARTGPU::SDfsync(){
emmanuelchio 0:1c3989d263f4 364 unsigned char aux = 0;
emmanuelchio 0:1c3989d263f4 365
emmanuelchio 0:1c3989d263f4 366 _serialMINISMARTGPU.putc('F'); //memory card file management
emmanuelchio 0:1c3989d263f4 367 _serialMINISMARTGPU.putc('S'); //file sync
emmanuelchio 0:1c3989d263f4 368
emmanuelchio 0:1c3989d263f4 369 aux= _serialMINISMARTGPU.getc(); //Get FAT result
emmanuelchio 0:1c3989d263f4 370 _serialMINISMARTGPU.getc(); //Discard 'O' or 'F'
emmanuelchio 0:1c3989d263f4 371 return aux; //Return FAT result
emmanuelchio 0:1c3989d263f4 372 }
emmanuelchio 0:1c3989d263f4 373
emmanuelchio 0:1c3989d263f4 374 unsigned char MINISMARTGPU::SDfpointer(unsigned long position){
emmanuelchio 0:1c3989d263f4 375 unsigned char aux = 0;
emmanuelchio 0:1c3989d263f4 376
emmanuelchio 0:1c3989d263f4 377 _serialMINISMARTGPU.putc('F'); //memory card file management
emmanuelchio 0:1c3989d263f4 378 _serialMINISMARTGPU.putc('P'); //file sync
emmanuelchio 0:1c3989d263f4 379 _serialMINISMARTGPU.putc(position>>24);
emmanuelchio 0:1c3989d263f4 380 _serialMINISMARTGPU.putc(position>>16);
emmanuelchio 0:1c3989d263f4 381 _serialMINISMARTGPU.putc(position>>8);
emmanuelchio 0:1c3989d263f4 382 _serialMINISMARTGPU.putc(position);
emmanuelchio 0:1c3989d263f4 383
emmanuelchio 0:1c3989d263f4 384 aux= _serialMINISMARTGPU.getc(); //Get FAT result
emmanuelchio 0:1c3989d263f4 385 _serialMINISMARTGPU.getc(); //Discard 'O' or 'F'
emmanuelchio 0:1c3989d263f4 386 return aux; //Return FAT result
emmanuelchio 1:83a75a056cfa 387 }
emmanuelchio 0:1c3989d263f4 388
emmanuelchio 0:1c3989d263f4 389 unsigned char MINISMARTGPU::SDfread(unsigned int BTR, char buffer[], unsigned int *SRB){ //Bytes to Read, Read Buffer, Succesfully Readed Bytes
emmanuelchio 0:1c3989d263f4 390 unsigned char aux = 0;
emmanuelchio 0:1c3989d263f4 391 unsigned int x=0, sr=0;
emmanuelchio 0:1c3989d263f4 392
emmanuelchio 0:1c3989d263f4 393 _serialMINISMARTGPU.putc('F'); //memory card file management
emmanuelchio 0:1c3989d263f4 394 _serialMINISMARTGPU.putc('R'); //file read
emmanuelchio 0:1c3989d263f4 395 _serialMINISMARTGPU.putc(BTR>>8);
emmanuelchio 0:1c3989d263f4 396 _serialMINISMARTGPU.putc(BTR);
emmanuelchio 0:1c3989d263f4 397 for(x=0;x<BTR;x++){
emmanuelchio 1:83a75a056cfa 398 buffer[x]=_serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 399 }
emmanuelchio 0:1c3989d263f4 400 sr=_serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 401 sr=sr<<8;
emmanuelchio 0:1c3989d263f4 402 sr|=_serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 403
emmanuelchio 0:1c3989d263f4 404 aux= _serialMINISMARTGPU.getc(); //Get FAT result
emmanuelchio 0:1c3989d263f4 405 _serialMINISMARTGPU.getc(); //Discard 'O' or 'F'
emmanuelchio 0:1c3989d263f4 406 *SRB = sr;
emmanuelchio 0:1c3989d263f4 407 return aux; //Return FAT result
emmanuelchio 1:83a75a056cfa 408 }
emmanuelchio 0:1c3989d263f4 409
emmanuelchio 0:1c3989d263f4 410 unsigned char MINISMARTGPU::SDfwrite(unsigned int BTW, char buffer[], unsigned int *SWB){ //Bytes to Write, Write Buffer, Succesfully Written Bytes
emmanuelchio 0:1c3989d263f4 411 unsigned char aux = 0;
emmanuelchio 0:1c3989d263f4 412 unsigned int x=0, sw=0;
emmanuelchio 0:1c3989d263f4 413
emmanuelchio 0:1c3989d263f4 414 wait_ms(1);
emmanuelchio 0:1c3989d263f4 415 if(BTW>512){ //Mini SmartGPU accept to write more than 512 bytes, however this is not recommended, remove this IF for fully write support
emmanuelchio 1:83a75a056cfa 416 aux = 19; //Invalid Parameter == 19
emmanuelchio 0:1c3989d263f4 417 }else{
emmanuelchio 1:83a75a056cfa 418 _serialMINISMARTGPU.putc('F'); //memory card file management
emmanuelchio 1:83a75a056cfa 419 _serialMINISMARTGPU.putc('W'); //file write
emmanuelchio 1:83a75a056cfa 420 _serialMINISMARTGPU.putc(BTW>>8);
emmanuelchio 1:83a75a056cfa 421 _serialMINISMARTGPU.putc(BTW);
emmanuelchio 1:83a75a056cfa 422 for(x=0;x<BTW;x++){
emmanuelchio 1:83a75a056cfa 423 _serialMINISMARTGPU.putc(buffer[x]);
emmanuelchio 1:83a75a056cfa 424 }
emmanuelchio 1:83a75a056cfa 425 sw=_serialMINISMARTGPU.getc();
emmanuelchio 1:83a75a056cfa 426 sw=sw<<8;
emmanuelchio 1:83a75a056cfa 427 sw|=_serialMINISMARTGPU.getc();
emmanuelchio 0:1c3989d263f4 428
emmanuelchio 1:83a75a056cfa 429 aux= _serialMINISMARTGPU.getc(); //Get FAT result
emmanuelchio 1:83a75a056cfa 430 _serialMINISMARTGPU.getc(); //Discard 'O' or 'F'
emmanuelchio 1:83a75a056cfa 431 *SWB = sw;
emmanuelchio 0:1c3989d263f4 432 }
emmanuelchio 0:1c3989d263f4 433 return aux; //Return FAT result
emmanuelchio 0:1c3989d263f4 434 }