Full IPOD Like GUI Demo - MBED + SmartGPU2 board

Dependencies:   SMARTGPU2 mbed

Committer:
emmanuelchio
Date:
Thu Apr 17 21:45:15 2014 +0000
Revision:
1:2845aaa91e22
Parent:
0:9ec50d21947d
SmartGPU2 FullGUI_SG2 demo- Please select(uncomment) your smartGPU2 board under SMARTGPU2.h file before compiling!!!

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emmanuelchio 1:2845aaa91e22 1 /**************************************************************************************/
emmanuelchio 0:9ec50d21947d 2 /**************************************************************************************/
emmanuelchio 0:9ec50d21947d 3 /*SMARTGPU2 intelligent embedded graphics processor unit
emmanuelchio 1:2845aaa91e22 4 those examples are for using the SMARTGPU2 with the mbed microcontoller, just connect tx,rx,and reset
emmanuelchio 0:9ec50d21947d 5 Board:
emmanuelchio 1:2845aaa91e22 6 http://www.vizictechnologies.com/
emmanuelchio 0:9ec50d21947d 7
emmanuelchio 0:9ec50d21947d 8 www.vizictechnologies.com
emmanuelchio 1:2845aaa91e22 9 Vizic Technologies copyright 2014 */
emmanuelchio 1:2845aaa91e22 10 /**************************************************************************************/
emmanuelchio 0:9ec50d21947d 11 /**************************************************************************************/
emmanuelchio 0:9ec50d21947d 12
emmanuelchio 0:9ec50d21947d 13 #include "mbed.h"
emmanuelchio 0:9ec50d21947d 14 #include "SMARTGPU2.h"
emmanuelchio 0:9ec50d21947d 15 #include "stdlib.h"
emmanuelchio 0:9ec50d21947d 16
emmanuelchio 0:9ec50d21947d 17 SMARTGPU2 lcd(TXPIN,RXPIN,RESETPIN); //create our object called "lcd"
emmanuelchio 0:9ec50d21947d 18
emmanuelchio 0:9ec50d21947d 19 //defines for GUI
emmanuelchio 0:9ec50d21947d 20 #define HALFX 240/2
emmanuelchio 0:9ec50d21947d 21 #define HALFY 320/2
emmanuelchio 0:9ec50d21947d 22
emmanuelchio 0:9ec50d21947d 23 //declare our structures POINT and ICON
emmanuelchio 0:9ec50d21947d 24 POINT point;
emmanuelchio 0:9ec50d21947d 25 ICON icon;
emmanuelchio 0:9ec50d21947d 26
emmanuelchio 0:9ec50d21947d 27 //array to store file names 25 characters max, also used as working file array
emmanuelchio 0:9ec50d21947d 28 char name[25];
emmanuelchio 0:9ec50d21947d 29
emmanuelchio 0:9ec50d21947d 30 //Array with the names of the icons under "FullGUI/Ics" folder, names of 25 characters max
emmanuelchio 0:9ec50d21947d 31 #define TOTALICONS 13 //number of available icons, current sketch supports 25 icons max
emmanuelchio 0:9ec50d21947d 32 const char iconNames[TOTALICONS][25]={"backlight","calculator","clock","games","maps","media","notes","photos","wifi","settings","calls","music","wall"};
emmanuelchio 0:9ec50d21947d 33
emmanuelchio 0:9ec50d21947d 34 //array used by games
emmanuelchio 0:9ec50d21947d 35 #define MOLEHOLE 3 //position of the array where mole hole image is contained
emmanuelchio 0:9ec50d21947d 36 #define HITMOLE 4 //position of the array where hit mole image is contained
emmanuelchio 0:9ec50d21947d 37 #define MISSMOLE 5 //position of the array where miss mole image is contained
emmanuelchio 0:9ec50d21947d 38 const char moleType[6][9]={"MoleHap","MoleSee","MoleBad","MoleHole","MolePun","MoleMiss"}; //array containing the names of the different called images
emmanuelchio 0:9ec50d21947d 39
emmanuelchio 0:9ec50d21947d 40 //General/Miscellaneous Functions
emmanuelchio 0:9ec50d21947d 41 /**************************************************/
emmanuelchio 0:9ec50d21947d 42 /**************************************************/
emmanuelchio 0:9ec50d21947d 43 /**************************************************/
emmanuelchio 0:9ec50d21947d 44 unsigned char getTouchIconMainMenu(void){
emmanuelchio 0:9ec50d21947d 45 unsigned int icPress;
emmanuelchio 0:9ec50d21947d 46
emmanuelchio 0:9ec50d21947d 47 while(lcd.touchScreen(&point)==INVALID); //wait for a touch
emmanuelchio 0:9ec50d21947d 48 //PROCEDURE TO DIVIDE THE TOUCHSCREEN AREA IN 4 x 5 EQUAL PARTS--------------------------------------------
emmanuelchio 0:9ec50d21947d 49 //Divide screen into 4 equal horizontal parts for icons
emmanuelchio 0:9ec50d21947d 50 icPress= (point.x/(LCD_HEIGHT/4)) + 1; //LCD_HEIGHT is 240
emmanuelchio 0:9ec50d21947d 51 //Divide Screen into 5 equal vertical parts for icons
emmanuelchio 0:9ec50d21947d 52 icPress = icPress + (((point.y)/(LCD_WIDTH/5)) * 4); //LCD_WIDTH is 320
emmanuelchio 0:9ec50d21947d 53 //-------------------------------------------------------------------------------------------------
emmanuelchio 0:9ec50d21947d 54 return icPress; //return decoded coordinate from 1 to 20
emmanuelchio 0:9ec50d21947d 55 }
emmanuelchio 0:9ec50d21947d 56
emmanuelchio 0:9ec50d21947d 57 //obtain from EEPROM FLASH memory the name of the current stored wallpaper on the "name" array
emmanuelchio 0:9ec50d21947d 58 void getCurrentWallFromEEPROM(void){
emmanuelchio 0:9ec50d21947d 59 NUMBEROFBYTES bytesRead;
emmanuelchio 0:9ec50d21947d 60 lcd.fillBuffFromEEPROMPage(PAGE0); //copy PAGE0 to EEPROM RAM buffer
emmanuelchio 0:9ec50d21947d 61 lcd.readEEPROMBuff(name,0,14,&bytesRead); //read 14 bytes of the EEPROM RAM buffer to name array, wallpapers must not exceed 14 chars in name lenght
emmanuelchio 0:9ec50d21947d 62 if(strstr(name, 0x00) != 0x00){ //find a null character in name, if not find, add the 0x00 NULL character
emmanuelchio 0:9ec50d21947d 63 name[0] = 0x00;
emmanuelchio 0:9ec50d21947d 64 }
emmanuelchio 0:9ec50d21947d 65 }
emmanuelchio 0:9ec50d21947d 66
emmanuelchio 0:9ec50d21947d 67 //save current contents of "name" array on EEPROM PAGE0 at address 0x0000
emmanuelchio 0:9ec50d21947d 68 void saveWallpaperToEEPROM(void){
emmanuelchio 0:9ec50d21947d 69 NUMBEROFBYTES bytesWritten;
emmanuelchio 0:9ec50d21947d 70 lcd.initClearEEPROMBuff(); //Initialize EEPROM RAM Buffer
emmanuelchio 0:9ec50d21947d 71 lcd.writeEEPROMBuff(name,0,sizeof(name),&bytesWritten); //write all the contents of "name" array to EEPROM RAM Buffer
emmanuelchio 0:9ec50d21947d 72 lcd.eraseEEPROMPage(PAGE0); //erase all contents on the PAGE0
emmanuelchio 0:9ec50d21947d 73 lcd.saveBuffToEEPROMPage(PAGE0); //now save to EEPROM PAGE0 the contents of the EEPROM RAM Buffer(the name array + 0xFFs)
emmanuelchio 0:9ec50d21947d 74 }
emmanuelchio 0:9ec50d21947d 75
emmanuelchio 0:9ec50d21947d 76 /**************************************************/
emmanuelchio 0:9ec50d21947d 77 void drawHeader(char *text){
emmanuelchio 0:9ec50d21947d 78 NUMBEROFBYTES charsPrinted;
emmanuelchio 0:9ec50d21947d 79 unsigned int batteryPercentage = 65;
emmanuelchio 0:9ec50d21947d 80 //draw header and text
emmanuelchio 0:9ec50d21947d 81 lcd.drawRectangle(0,0,MAX_X_PORTRAIT,13,BLACK,FILL); //draw upper bar
emmanuelchio 0:9ec50d21947d 82 lcd.setTextSize(FONT0);
emmanuelchio 0:9ec50d21947d 83 lcd.setTextColour(WHITE);
emmanuelchio 0:9ec50d21947d 84 lcd.setTextBackFill(TRANS);
emmanuelchio 0:9ec50d21947d 85 lcd.string(2,0,MAX_X_PORTRAIT,20,"Vizic",&charsPrinted); //draw Vizic string
emmanuelchio 0:9ec50d21947d 86 lcd.string(85,0,MAX_X_PORTRAIT,20,text,&charsPrinted); //draw string
emmanuelchio 0:9ec50d21947d 87 //draw battery icon according to the battery percentage variable
emmanuelchio 0:9ec50d21947d 88 lcd.drawRectangle(215,0,215+((batteryPercentage*15)/100),10,GREEN,FILL);
emmanuelchio 0:9ec50d21947d 89 lcd.drawRectangle(215,0,230,10,WHITE,UNFILL);
emmanuelchio 0:9ec50d21947d 90 lcd.drawRectangle(230,4,232,6,WHITE,FILL);
emmanuelchio 0:9ec50d21947d 91 }
emmanuelchio 0:9ec50d21947d 92
emmanuelchio 0:9ec50d21947d 93 //Cuts the .ext and updates the name
emmanuelchio 0:9ec50d21947d 94 void cutFileExtension(char *name, char *ext){
emmanuelchio 0:9ec50d21947d 95 char *pch;
emmanuelchio 0:9ec50d21947d 96 pch=strstr(name,ext); //find the .ext extension to the name
emmanuelchio 0:9ec50d21947d 97 strncpy(pch,0x00,1); //cut/replace the .ext extension for the NULL 0x00 character
emmanuelchio 0:9ec50d21947d 98 }
emmanuelchio 0:9ec50d21947d 99
emmanuelchio 0:9ec50d21947d 100 //This function call the desired image in the position of the desired hole - used by games()
emmanuelchio 0:9ec50d21947d 101 void showMole(char mole, char hole){
emmanuelchio 0:9ec50d21947d 102 switch(hole){
emmanuelchio 0:9ec50d21947d 103 case 1:
emmanuelchio 0:9ec50d21947d 104 lcd.imageBMPSD(38,70,(char*)moleType[mole]); // hole 1
emmanuelchio 0:9ec50d21947d 105 break;
emmanuelchio 0:9ec50d21947d 106 case 2:
emmanuelchio 0:9ec50d21947d 107 lcd.imageBMPSD(138,70,(char*)moleType[mole]); // hole 2
emmanuelchio 0:9ec50d21947d 108 break;
emmanuelchio 0:9ec50d21947d 109 case 3:
emmanuelchio 0:9ec50d21947d 110 lcd.imageBMPSD(240,70,(char*)moleType[mole]); // hole 3
emmanuelchio 0:9ec50d21947d 111 break;
emmanuelchio 0:9ec50d21947d 112 case 4:
emmanuelchio 0:9ec50d21947d 113 lcd.imageBMPSD(38,147,(char*)moleType[mole]); // hole 4
emmanuelchio 0:9ec50d21947d 114 break;
emmanuelchio 0:9ec50d21947d 115 case 5:
emmanuelchio 0:9ec50d21947d 116 lcd.imageBMPSD(138,147,(char*)moleType[mole]); // hole 5
emmanuelchio 0:9ec50d21947d 117 break;
emmanuelchio 0:9ec50d21947d 118 case 6:
emmanuelchio 0:9ec50d21947d 119 lcd.imageBMPSD(240,147,(char*)moleType[mole]); // hole 6
emmanuelchio 0:9ec50d21947d 120 break;
emmanuelchio 0:9ec50d21947d 121 default:
emmanuelchio 0:9ec50d21947d 122 break;
emmanuelchio 0:9ec50d21947d 123 }
emmanuelchio 0:9ec50d21947d 124 }
emmanuelchio 0:9ec50d21947d 125
emmanuelchio 0:9ec50d21947d 126 //This function returns 1 if a touch has been made in a specified hole -used by games
emmanuelchio 0:9ec50d21947d 127 char touchOnHole(char hole){
emmanuelchio 0:9ec50d21947d 128 char hit=0;
emmanuelchio 0:9ec50d21947d 129 switch(hole){
emmanuelchio 0:9ec50d21947d 130 case 1:
emmanuelchio 0:9ec50d21947d 131 if(point.x>0 && point.x<111 && point.y>65 && point.y<146) hit=1; //check if the last touch was inside this area
emmanuelchio 0:9ec50d21947d 132 break;
emmanuelchio 0:9ec50d21947d 133 case 2:
emmanuelchio 0:9ec50d21947d 134 if(point.x>110 && point.x<211 && point.y>65 && point.y<146) hit=1; //check if the last touch was inside this area
emmanuelchio 0:9ec50d21947d 135 break;
emmanuelchio 0:9ec50d21947d 136 case 3:
emmanuelchio 0:9ec50d21947d 137 if(point.x>210 && point.x<320 && point.y>65 && point.y<146) hit=1; //check if the last touch was inside this area
emmanuelchio 0:9ec50d21947d 138 break;
emmanuelchio 0:9ec50d21947d 139 case 4:
emmanuelchio 0:9ec50d21947d 140 if(point.x>0 && point.x<111 && point.y>145 && point.y<240) hit=1; //check if the last touch was inside this area
emmanuelchio 0:9ec50d21947d 141 break;
emmanuelchio 0:9ec50d21947d 142 case 5:
emmanuelchio 0:9ec50d21947d 143 if(point.x>110 && point.x<211 && point.y>145 && point.y<240) hit=1;//check if the last touch was inside this area
emmanuelchio 0:9ec50d21947d 144 break;
emmanuelchio 0:9ec50d21947d 145 case 6:
emmanuelchio 0:9ec50d21947d 146 if(point.x>210 && point.x<320 && point.y>145 && point.y<240) hit=1;//check if the last touch was inside this area
emmanuelchio 0:9ec50d21947d 147 break;
emmanuelchio 0:9ec50d21947d 148 default:
emmanuelchio 0:9ec50d21947d 149 break;
emmanuelchio 0:9ec50d21947d 150 }
emmanuelchio 0:9ec50d21947d 151 return hit;
emmanuelchio 0:9ec50d21947d 152 }
emmanuelchio 0:9ec50d21947d 153
emmanuelchio 0:9ec50d21947d 154 //function used by music
emmanuelchio 0:9ec50d21947d 155 void drawControlRR(ACTIVE state){
emmanuelchio 0:9ec50d21947d 156 //draw button
emmanuelchio 0:9ec50d21947d 157 lcd.objButton(0,265,79,315,state,"");
emmanuelchio 0:9ec50d21947d 158 //draw symbol
emmanuelchio 0:9ec50d21947d 159 lcd.drawTriangle(0+10,265+((315-265)/2),0+39,265+10,0+39,315-10,BLACK,FILL);
emmanuelchio 0:9ec50d21947d 160 lcd.drawTriangle(0+39,265+((315-265)/2),0+79-10,265+10,0+79-10,315-10,BLACK,FILL);
emmanuelchio 0:9ec50d21947d 161 }
emmanuelchio 0:9ec50d21947d 162
emmanuelchio 0:9ec50d21947d 163 //function used by music
emmanuelchio 0:9ec50d21947d 164 void drawControlFF(ACTIVE state){
emmanuelchio 0:9ec50d21947d 165 //draw button
emmanuelchio 0:9ec50d21947d 166 lcd.objButton(160,265,MAX_X_PORTRAIT,315,state,"");
emmanuelchio 0:9ec50d21947d 167 //draw symbol
emmanuelchio 0:9ec50d21947d 168 lcd.drawTriangle(160+10,265+10,160+10,315-10,160+39,265+((315-265)/2),BLACK,FILL);
emmanuelchio 0:9ec50d21947d 169 lcd.drawTriangle(160+39,265+10,160+39,315-10,239-10,265+((315-265)/2),BLACK,FILL);
emmanuelchio 0:9ec50d21947d 170 }
emmanuelchio 0:9ec50d21947d 171
emmanuelchio 0:9ec50d21947d 172 //function used by music
emmanuelchio 0:9ec50d21947d 173 void drawControlPLAY(char symbol){
emmanuelchio 0:9ec50d21947d 174 //draw button
emmanuelchio 0:9ec50d21947d 175 lcd.objButton(80,265,159,315,SELECTED,"");
emmanuelchio 0:9ec50d21947d 176 //draw symbol
emmanuelchio 0:9ec50d21947d 177 if(symbol){ //PLAY
emmanuelchio 0:9ec50d21947d 178 lcd.drawTriangle(80+10,265+10,80+10,315-10,159-10,265+((315-265)/2),BLACK,FILL);
emmanuelchio 0:9ec50d21947d 179 }else{ //PAUSE
emmanuelchio 0:9ec50d21947d 180 lcd.drawRectangle(80+10,265+10,80+10+25,315-10,BLACK,FILL);
emmanuelchio 0:9ec50d21947d 181 lcd.drawRectangle(159-10-25,265+10,159-10,315-10,BLACK,FILL);
emmanuelchio 0:9ec50d21947d 182 }
emmanuelchio 0:9ec50d21947d 183 }
emmanuelchio 0:9ec50d21947d 184
emmanuelchio 0:9ec50d21947d 185 //function that draws buttons and current progress bar - used by media
emmanuelchio 0:9ec50d21947d 186 void drawButtonsAndProgress(unsigned long currFrame, unsigned long totFrames){
emmanuelchio 0:9ec50d21947d 187 lcd.objButton(0,200,159,230,DESELECTED,"Continue");
emmanuelchio 0:9ec50d21947d 188 lcd.objButton(161,200,MAX_X_LANDSCAPE,230,DESELECTED,"Return...");
emmanuelchio 0:9ec50d21947d 189 lcd.drawRectangle(0,170,(currFrame*MAX_X_LANDSCAPE)/(totFrames),190,RED,FILL); //scale currentFrame value to 0-319 pixels
emmanuelchio 0:9ec50d21947d 190 lcd.drawRectangle((currFrame*MAX_X_LANDSCAPE)/(totFrames),170,MAX_X_LANDSCAPE,190,BLACK,FILL); //scale currentFrame value to 0-319 pixels
emmanuelchio 0:9ec50d21947d 191 }
emmanuelchio 0:9ec50d21947d 192
emmanuelchio 0:9ec50d21947d 193 //Main applications, the next applications are called by the main loop menu
emmanuelchio 0:9ec50d21947d 194 /**************************************************/
emmanuelchio 0:9ec50d21947d 195 /**************************************************/
emmanuelchio 0:9ec50d21947d 196 /**************************************************/
emmanuelchio 0:9ec50d21947d 197 //draws Main Menu
emmanuelchio 0:9ec50d21947d 198 void drawMainMenu(void){
emmanuelchio 0:9ec50d21947d 199 unsigned int i=0, x=8, y=20;
emmanuelchio 0:9ec50d21947d 200 SMARTGPUREPLY res;
emmanuelchio 0:9ec50d21947d 201 char aux[25];
emmanuelchio 0:9ec50d21947d 202
emmanuelchio 0:9ec50d21947d 203 strcpy(aux,"Wall/"); //copy to name the string "Wall/"
emmanuelchio 0:9ec50d21947d 204 getCurrentWallFromEEPROM(); //fill global "name" array with the current EEPROM Stored name
emmanuelchio 0:9ec50d21947d 205 strcat(aux,name); //concatenate the currentWall name to "Wall/"
emmanuelchio 0:9ec50d21947d 206 if(lcd.imageBMPSD(0,0,aux)!=OK) lcd.erase(); //try to draw WallPaper Image, if fail, just erase screen
emmanuelchio 0:9ec50d21947d 207 //now draw all top icons
emmanuelchio 0:9ec50d21947d 208 lcd.SDFopenDir("Ics"); //open the folder with the icons
emmanuelchio 0:9ec50d21947d 209 while(i<TOTALICONS){
emmanuelchio 0:9ec50d21947d 210 res=lcd.imageBMPSD(x,y,(char*)iconNames[i++]); //try to draw icon and advance i
emmanuelchio 0:9ec50d21947d 211 if(res == OK){ //draw icon file, only if command success then advance x and y position
emmanuelchio 0:9ec50d21947d 212 x+=50+8; //advance the icon size 50 + 8 the space between icons
emmanuelchio 0:9ec50d21947d 213 if(x>230){ //if x > 230, means we have reach the end of file and must advance 1 coloumn
emmanuelchio 0:9ec50d21947d 214 x=8; //reset x
emmanuelchio 0:9ec50d21947d 215 y+=50+10; //advance the icon size 50 + 10 the space between icons
emmanuelchio 0:9ec50d21947d 216 if(y>300) break; //if there are more than 20 icons, break and ignore, current sketch supports only 20 icons max
emmanuelchio 0:9ec50d21947d 217 }
emmanuelchio 0:9ec50d21947d 218 }
emmanuelchio 0:9ec50d21947d 219 }
emmanuelchio 0:9ec50d21947d 220 lcd.SDFopenDir(".."); //return/go up to parent dir one level
emmanuelchio 0:9ec50d21947d 221 drawHeader("Main Menu");
emmanuelchio 0:9ec50d21947d 222 wait_ms(350); //A little delay to avoid fast image changing
emmanuelchio 0:9ec50d21947d 223 }
emmanuelchio 0:9ec50d21947d 224
emmanuelchio 0:9ec50d21947d 225 /**************************************************/
emmanuelchio 0:9ec50d21947d 226 void backlight(void){
emmanuelchio 0:9ec50d21947d 227 static unsigned char currentBacklightValue=100; //0-100
emmanuelchio 0:9ec50d21947d 228 NUMBEROFBYTES charsPrinted;
emmanuelchio 0:9ec50d21947d 229
emmanuelchio 0:9ec50d21947d 230 lcd.drawGradientRect(0,0,MAX_X_PORTRAIT,MAX_Y_PORTRAIT,BLACK,MAGENTA,VERTICAL); //draw a fullscreen gradient rectangle
emmanuelchio 0:9ec50d21947d 231 lcd.setTextSize(FONT3);
emmanuelchio 0:9ec50d21947d 232 lcd.setTextColour(WHITE);
emmanuelchio 0:9ec50d21947d 233 lcd.setTextBackFill(TRANS);
emmanuelchio 0:9ec50d21947d 234 lcd.string(40,45,MAX_X_PORTRAIT,MAX_Y_PORTRAIT,"Brightness Bar",&charsPrinted);
emmanuelchio 0:9ec50d21947d 235 lcd.objSlider(10,80,MAX_X_PORTRAIT-10,150,currentBacklightValue,101,HORIZONTAL);
emmanuelchio 0:9ec50d21947d 236 lcd.objButton(10,280,MAX_X_PORTRAIT-10,310,DESELECTED,"Return");
emmanuelchio 0:9ec50d21947d 237 drawHeader("Adjustments:");
emmanuelchio 0:9ec50d21947d 238 while(1){
emmanuelchio 0:9ec50d21947d 239 while(lcd.touchScreen(&point)==INVALID);//wait for a touch on screen to do something
emmanuelchio 0:9ec50d21947d 240 if((point.x>10) && (point.x<MAX_X_PORTRAIT-10) && (point.y>80) && (point.y<150)){ //if touch inside brightness bar
emmanuelchio 0:9ec50d21947d 241 currentBacklightValue= ((point.x-10)*100)/(MAX_X_PORTRAIT-10-10); //scale obtained touch value to 0-100
emmanuelchio 0:9ec50d21947d 242 lcd.objSlider(10,80,MAX_X_PORTRAIT-10,150,currentBacklightValue,101,HORIZONTAL); //update slider
emmanuelchio 0:9ec50d21947d 243 lcd.bright(currentBacklightValue); //set new brightness value
emmanuelchio 0:9ec50d21947d 244 wait_ms(150);
emmanuelchio 0:9ec50d21947d 245 }
emmanuelchio 0:9ec50d21947d 246 if(point.y>280){ //if touch inside return button
emmanuelchio 0:9ec50d21947d 247 lcd.objButton(10,280,MAX_X_PORTRAIT-10,310,SELECTED,"Return");
emmanuelchio 0:9ec50d21947d 248 wait_ms(300);
emmanuelchio 0:9ec50d21947d 249 return; //exit function
emmanuelchio 0:9ec50d21947d 250 }
emmanuelchio 0:9ec50d21947d 251 }
emmanuelchio 0:9ec50d21947d 252 }
emmanuelchio 0:9ec50d21947d 253
emmanuelchio 0:9ec50d21947d 254 /**************************************************/
emmanuelchio 0:9ec50d21947d 255 void clocks(void){
emmanuelchio 0:9ec50d21947d 256 int hours=4,mins=48,secs=0,i=0;
emmanuelchio 0:9ec50d21947d 257 int xs,ys,xm,ym,xh,yh;
emmanuelchio 0:9ec50d21947d 258 int angleH,angleM,angleS;
emmanuelchio 0:9ec50d21947d 259 int handHour=55;//hand size
emmanuelchio 0:9ec50d21947d 260 int handMin=70; //hand size
emmanuelchio 0:9ec50d21947d 261 int handSec=75; //hand size
emmanuelchio 0:9ec50d21947d 262
emmanuelchio 0:9ec50d21947d 263 lcd.drawGradientRect(0,0,MAX_X_PORTRAIT,MAX_Y_PORTRAIT,BLACK,MAGENTA,VERTICAL); //draw a fullscreen gradient rectangle
emmanuelchio 0:9ec50d21947d 264 lcd.objButton(10,280,MAX_X_PORTRAIT-10,310,DESELECTED,"Return");
emmanuelchio 0:9ec50d21947d 265 drawHeader("Clocks:");
emmanuelchio 0:9ec50d21947d 266 //drawClock Body
emmanuelchio 0:9ec50d21947d 267 lcd.drawCircle(HALFX,HALFY,80,BLACK,FILL);
emmanuelchio 0:9ec50d21947d 268 lcd.drawCircle(HALFX,HALFY,80,WHITE,UNFILL);
emmanuelchio 0:9ec50d21947d 269
emmanuelchio 0:9ec50d21947d 270 while(1){
emmanuelchio 0:9ec50d21947d 271 //Do some Math to get the second point of the clock hands. (first point is always the center of the clock)
emmanuelchio 0:9ec50d21947d 272 angleS=secs*6; //get the current seconds in angle form, a circle have 360 degrees divided by 60 seconds = 6, then we multiply the 6 by the current seconds to get current angle
emmanuelchio 0:9ec50d21947d 273 xs=(sin((angleS*3.14)/180)) * handSec; //get X component of the second's hand
emmanuelchio 0:9ec50d21947d 274 ys=(cos((angleS*3.14)/180)) * handSec; //get Y component of the second's hand
emmanuelchio 0:9ec50d21947d 275 angleM=mins*6; //get the current minutes in angle form, a circle have 360 degrees divided by 60 minutes = 6, then we multiply the 6 by the current minutes to get current angle
emmanuelchio 0:9ec50d21947d 276 xm=(sin((angleM*3.14)/180)) * handMin; //get X component of the minutes's hand
emmanuelchio 0:9ec50d21947d 277 ym=(cos((angleM*3.14)/180)) * handMin; //get Y component of the minutes's hand
emmanuelchio 0:9ec50d21947d 278 angleH=hours*30; //get the current hours in angle form, a circle have 360 degrees divided by 12 hours = 30, then we multiply the 30 by the current hours to get current angle
emmanuelchio 0:9ec50d21947d 279 xh=(sin((angleH*3.14)/180)) * handHour; //get X component of the hours's hand
emmanuelchio 0:9ec50d21947d 280 yh=(cos((angleH*3.14)/180)) * handHour; //get Y component of the hours's hand
emmanuelchio 0:9ec50d21947d 281
emmanuelchio 0:9ec50d21947d 282 //Draw current time hands
emmanuelchio 0:9ec50d21947d 283 lcd.drawLine(HALFX,HALFY,HALFX+xm,HALFY-ym,WHITE); // Draw the minutes hand, first point is the center of the clock, and the second is the point obtained by doing math
emmanuelchio 0:9ec50d21947d 284 lcd.drawLine(HALFX,HALFY,HALFX+xh,HALFY-yh,WHITE); // Draw the hours hand, first point is the center of the clock, and the second is the point obtained by doing math
emmanuelchio 0:9ec50d21947d 285 lcd.drawLine(HALFX,HALFY,HALFX+xs,HALFY-ys,RED); // Draw the seconds hand, first point is the center of the clock, and the second is the point obtained by doing math
emmanuelchio 0:9ec50d21947d 286 lcd.drawCircle(HALFX,HALFY,3,RED,FILL); // Draw the center of the second's hand
emmanuelchio 0:9ec50d21947d 287
emmanuelchio 0:9ec50d21947d 288 for(i=0;i<10;i++){ //loop for 10 times a delay of 100ms asking for a touch - this gives a total delay of 1 second
emmanuelchio 0:9ec50d21947d 289 if(lcd.touchScreen(&point)==VALID){ //ask for a touch on screen to do something
emmanuelchio 0:9ec50d21947d 290 if(point.y>280){ //if touch inside return button
emmanuelchio 0:9ec50d21947d 291 lcd.objButton(10,280,MAX_X_PORTRAIT-10,310,SELECTED,"Return");
emmanuelchio 0:9ec50d21947d 292 wait_ms(300);
emmanuelchio 0:9ec50d21947d 293 return; //exit function
emmanuelchio 0:9ec50d21947d 294 }
emmanuelchio 0:9ec50d21947d 295 }
emmanuelchio 0:9ec50d21947d 296 wait_ms(100);
emmanuelchio 0:9ec50d21947d 297 }
emmanuelchio 0:9ec50d21947d 298
emmanuelchio 0:9ec50d21947d 299 //time managing
emmanuelchio 0:9ec50d21947d 300 secs++; // increase seconds
emmanuelchio 0:9ec50d21947d 301 if(secs==60){ // if we reach 60 seconds
emmanuelchio 0:9ec50d21947d 302 mins++; // increase the minutes
emmanuelchio 0:9ec50d21947d 303 if(mins==60){ // if we reach 60 minutes
emmanuelchio 0:9ec50d21947d 304 hours++; // increase the minutes
emmanuelchio 0:9ec50d21947d 305 if(hours==12){ // if we reach 12 hours
emmanuelchio 0:9ec50d21947d 306 hours=0; // clear hours
emmanuelchio 0:9ec50d21947d 307 }
emmanuelchio 0:9ec50d21947d 308 mins=0; // clear minutes
emmanuelchio 0:9ec50d21947d 309 }
emmanuelchio 0:9ec50d21947d 310 secs=0; // clear seconds
emmanuelchio 0:9ec50d21947d 311 }
emmanuelchio 0:9ec50d21947d 312 //Erase all hands
emmanuelchio 0:9ec50d21947d 313 lcd.drawLine(HALFX,HALFY,HALFX+xs,HALFY-ys,BLACK); // Erase Second's hand
emmanuelchio 0:9ec50d21947d 314 lcd.drawLine(HALFX,HALFY,HALFX+xm,HALFY-ym,BLACK); // Erase Minute's hand
emmanuelchio 0:9ec50d21947d 315 lcd.drawLine(HALFX,HALFY,HALFX+xh,HALFY-yh,BLACK); // Erase Hour's hand
emmanuelchio 0:9ec50d21947d 316 }
emmanuelchio 0:9ec50d21947d 317 }
emmanuelchio 0:9ec50d21947d 318
emmanuelchio 0:9ec50d21947d 319 /**************************************************/
emmanuelchio 0:9ec50d21947d 320 void photos(void){
emmanuelchio 0:9ec50d21947d 321 unsigned int dirs=0,pics=0;
emmanuelchio 0:9ec50d21947d 322 static unsigned int i=0; //static to save last image position even we exit function
emmanuelchio 0:9ec50d21947d 323 NUMBEROFBYTES charsPrinted;
emmanuelchio 0:9ec50d21947d 324
emmanuelchio 0:9ec50d21947d 325 lcd.orientation(LANDSCAPE_LEFT); //set orientation as landscape
emmanuelchio 0:9ec50d21947d 326 lcd.setTextColour(WHITE);
emmanuelchio 0:9ec50d21947d 327 lcd.setTextSize(FONT3);
emmanuelchio 0:9ec50d21947d 328 lcd.setTextBackFill(TRANS);
emmanuelchio 0:9ec50d21947d 329 lcd.drawGradientRect(0,0,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,BLACK,MAGENTA,VERTICAL);
emmanuelchio 0:9ec50d21947d 330 lcd.string(80,110,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"Photo Gallery",&charsPrinted);
emmanuelchio 0:9ec50d21947d 331 lcd.setTextSize(FONT2);
emmanuelchio 0:9ec50d21947d 332 wait_ms(1000);
emmanuelchio 0:9ec50d21947d 333 lcd.SDFopenDir("Photos"); //open the folder with the photos
emmanuelchio 0:9ec50d21947d 334 lcd.SDFgetList(&dirs,&pics); //get number of files/Pics under the current folder "Photos"
emmanuelchio 0:9ec50d21947d 335
emmanuelchio 0:9ec50d21947d 336 while(1){
emmanuelchio 0:9ec50d21947d 337 lcd.SDFgetFileName(i,name); //get the name of the pic file number i
emmanuelchio 0:9ec50d21947d 338 cutFileExtension(name,".bmp"); //cut to name the .bmp extension
emmanuelchio 0:9ec50d21947d 339 lcd.imageBMPSD(0,0,name); //Load image from SD card, all images are 320x240(full screen) so we load them from top left corner X:0,Y:0
emmanuelchio 0:9ec50d21947d 340 wait_ms(200); //A little delay to avoid fast image changing
emmanuelchio 0:9ec50d21947d 341 lcd.string(60,220,319,239,"<Tap center to Exit>",&charsPrinted); //Show text
emmanuelchio 0:9ec50d21947d 342 while(lcd.touchScreen(&point)==INVALID); //wait for a touch to do something
emmanuelchio 0:9ec50d21947d 343 //check if we go to the next image, or to the previous one
emmanuelchio 0:9ec50d21947d 344 if(point.x>219){ //if the received touch was on the right corner of the screen we advance the image, else we decrease and go to previous image
emmanuelchio 0:9ec50d21947d 345 i++; //decrease image selector
emmanuelchio 0:9ec50d21947d 346 if(i>=pics){ //if we reach the position of the last image, we restart to image 0
emmanuelchio 0:9ec50d21947d 347 i=0;
emmanuelchio 0:9ec50d21947d 348 }
emmanuelchio 0:9ec50d21947d 349 }
emmanuelchio 0:9ec50d21947d 350 else if(point.x<100){
emmanuelchio 0:9ec50d21947d 351 if(i>0){ //if we can decrease i
emmanuelchio 0:9ec50d21947d 352 i--;
emmanuelchio 0:9ec50d21947d 353 }else{ //if we decrease i will be less than zero, so we move to last image instead
emmanuelchio 0:9ec50d21947d 354 i=pics-1;
emmanuelchio 0:9ec50d21947d 355 }
emmanuelchio 0:9ec50d21947d 356 }
emmanuelchio 0:9ec50d21947d 357 else{ //touch on center, EXIT
emmanuelchio 0:9ec50d21947d 358 break;
emmanuelchio 0:9ec50d21947d 359 }
emmanuelchio 0:9ec50d21947d 360 }
emmanuelchio 0:9ec50d21947d 361 lcd.SDFopenDir(".."); //return/go up to parent dir one level
emmanuelchio 0:9ec50d21947d 362 lcd.orientation(PORTRAIT_LOW); //change to portrait mode
emmanuelchio 0:9ec50d21947d 363 wait_ms(300);
emmanuelchio 0:9ec50d21947d 364 }
emmanuelchio 0:9ec50d21947d 365
emmanuelchio 0:9ec50d21947d 366 /**************************************************/
emmanuelchio 0:9ec50d21947d 367 void media(){
emmanuelchio 0:9ec50d21947d 368 unsigned int i=0, row=0, vids=0;
emmanuelchio 0:9ec50d21947d 369 unsigned long currentFrame=0, currentSecond=0;
emmanuelchio 0:9ec50d21947d 370 VIDDATA videoData;
emmanuelchio 0:9ec50d21947d 371 NUMBEROFBYTES charsPrinted;
emmanuelchio 0:9ec50d21947d 372
emmanuelchio 0:9ec50d21947d 373 lcd.orientation(LANDSCAPE_LEFT); //set orientation as landscape
emmanuelchio 0:9ec50d21947d 374 lcd.setTextColour(WHITE);
emmanuelchio 0:9ec50d21947d 375 lcd.setTextSize(FONT3);
emmanuelchio 0:9ec50d21947d 376 lcd.setTextBackFill(TRANS);
emmanuelchio 0:9ec50d21947d 377 lcd.drawGradientRect(0,0,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,BLACK,MAGENTA,VERTICAL);
emmanuelchio 0:9ec50d21947d 378 lcd.string(80,110,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"Video Player",&charsPrinted);
emmanuelchio 0:9ec50d21947d 379 lcd.stopWAVFile(); //stop current playing song if any
emmanuelchio 0:9ec50d21947d 380 wait_ms(1000);
emmanuelchio 0:9ec50d21947d 381 lcd.SDFopenDir("Videos"); //open the folder with the videos
emmanuelchio 0:9ec50d21947d 382 lcd.setTextSize(FONT2);
emmanuelchio 0:9ec50d21947d 383
emmanuelchio 0:9ec50d21947d 384 while(1){
emmanuelchio 0:9ec50d21947d 385 lcd.drawGradientRect(0,0,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,BLACK,MAGENTA,VERTICAL);
emmanuelchio 0:9ec50d21947d 386 lcd.string(5,0,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"Available Videos: (EXIT)",&charsPrinted);
emmanuelchio 0:9ec50d21947d 387 i=0; row=1; vids=0;
emmanuelchio 0:9ec50d21947d 388 while(1){ //list names
emmanuelchio 0:9ec50d21947d 389 lcd.SDFgetFileName(i++,name); //get the name of the vid file number i
emmanuelchio 0:9ec50d21947d 390 if(name[0]==0x00) break; //if name is invalid, meand end of files
emmanuelchio 0:9ec50d21947d 391 if(strstr(name,".vid")!=0x00){ //if .vid extension is found in the file name: print
emmanuelchio 0:9ec50d21947d 392 lcd.objButton(15,(row*30),MAX_X_LANDSCAPE-15,30+(row*30),DESELECTED,name); row++;
emmanuelchio 0:9ec50d21947d 393 vids++;
emmanuelchio 0:9ec50d21947d 394 }//else ignore name/file
emmanuelchio 0:9ec50d21947d 395 }
emmanuelchio 0:9ec50d21947d 396
emmanuelchio 0:9ec50d21947d 397 while(lcd.touchScreen(&point)==INVALID); //wait for a touch to perform action
emmanuelchio 0:9ec50d21947d 398 row=point.y/30; //decode touch point by dividing it by 30 (240/8) which gives the 30 pixels spacing between buttons
emmanuelchio 0:9ec50d21947d 399 if(row==0){ //touch on header (EXIT);
emmanuelchio 0:9ec50d21947d 400 lcd.SDFopenDir(".."); //return/go up to parent dir one level
emmanuelchio 0:9ec50d21947d 401 lcd.orientation(PORTRAIT_LOW); //change to portrait mode
emmanuelchio 0:9ec50d21947d 402 wait_ms(300);
emmanuelchio 0:9ec50d21947d 403 return; //EXIT media()
emmanuelchio 0:9ec50d21947d 404 }else if(row > vids) continue; //if touch on invalid row, where no button is present, go to top while(1)
emmanuelchio 0:9ec50d21947d 405 i=0;
emmanuelchio 0:9ec50d21947d 406 while(row){ //get name of obtained row
emmanuelchio 0:9ec50d21947d 407 lcd.SDFgetFileName(i++,name); //get the name of the vid file number i
emmanuelchio 0:9ec50d21947d 408 if(strstr(name,".vid")!=0x00) row--; //if .vid extension is found in the file name: decrease row variable
emmanuelchio 0:9ec50d21947d 409 }
emmanuelchio 0:9ec50d21947d 410 //Try to play video
emmanuelchio 0:9ec50d21947d 411 cutFileExtension(name,".vid"); //cut to name the .vid extension
emmanuelchio 0:9ec50d21947d 412 if(lcd.allocateVideoSD(name,&videoData)!=OK) continue; //try to allocate video, if fail, continue to top while(1)
emmanuelchio 0:9ec50d21947d 413 //up to here video is successfully allocated..
emmanuelchio 0:9ec50d21947d 414 currentFrame=0; currentSecond=0; //reset variables
emmanuelchio 0:9ec50d21947d 415 lcd.playWAVFile(name,&charsPrinted); //open audio if any, must be named the same as the video expept for the .extension
emmanuelchio 0:9ec50d21947d 416 while(1){
emmanuelchio 0:9ec50d21947d 417 if(lcd.playVideoSD(0,0,videoData.framesPerSec)!=OK) break; //play video for 1 second(this equal the obtained frames per second parameter) break if error
emmanuelchio 0:9ec50d21947d 418 currentSecond++; currentFrame+=videoData.framesPerSec;
emmanuelchio 0:9ec50d21947d 419 if(lcd.touchScreen(&point)==VALID){ //check about each ~1 second for a touch, if Valid:
emmanuelchio 0:9ec50d21947d 420 lcd.pauseWAVFile(); //stop audio
emmanuelchio 0:9ec50d21947d 421 //draw buttons and progress bar
emmanuelchio 0:9ec50d21947d 422 drawButtonsAndProgress(currentFrame, videoData.totalFrames);
emmanuelchio 0:9ec50d21947d 423 wait_ms(300);
emmanuelchio 0:9ec50d21947d 424 while(1){
emmanuelchio 0:9ec50d21947d 425 while(lcd.touchScreen(&point)==INVALID || point.y<170); //while no valid touch or touch outside buttons
emmanuelchio 0:9ec50d21947d 426 if(point.y > 200) break; //if touch on buttons, break while(1) and go to next ifs
emmanuelchio 0:9ec50d21947d 427 //advance file to received touch in progress bar value...
emmanuelchio 0:9ec50d21947d 428 currentFrame=((unsigned long)point.x * (unsigned long)videoData.totalFrames) / MAX_X_LANDSCAPE; //obtain new current frame value 0-319
emmanuelchio 0:9ec50d21947d 429 currentFrame= (currentFrame/(unsigned long)videoData.framesPerSec)*((unsigned long)videoData.framesPerSec); //convert currentFrame to a factor of videoData.framesPerSecond
emmanuelchio 0:9ec50d21947d 430 currentSecond=(currentFrame/(unsigned long)videoData.framesPerSec);
emmanuelchio 0:9ec50d21947d 431 lcd.setFrameVideoSD(currentFrame); //set new obtained frame
emmanuelchio 0:9ec50d21947d 432 lcd.playVideoSD(0,0,1); //show new frame
emmanuelchio 0:9ec50d21947d 433 lcd.advanceWAVFile(currentSecond); //set new value to audio file
emmanuelchio 0:9ec50d21947d 434 //update buttons and progress bar
emmanuelchio 0:9ec50d21947d 435 drawButtonsAndProgress(currentFrame, videoData.totalFrames);
emmanuelchio 0:9ec50d21947d 436 wait_ms(50);
emmanuelchio 0:9ec50d21947d 437 }
emmanuelchio 0:9ec50d21947d 438 if(point.x < 160){ //touch on continue button
emmanuelchio 0:9ec50d21947d 439 lcd.objButton(0,200,159,230,SELECTED,"Continue");
emmanuelchio 0:9ec50d21947d 440 wait_ms(300);
emmanuelchio 0:9ec50d21947d 441 lcd.pauseWAVFile(); //resume audio
emmanuelchio 0:9ec50d21947d 442 }else{ //touch on return button
emmanuelchio 0:9ec50d21947d 443 lcd.objButton(161,200,319,230,SELECTED,"Return...");
emmanuelchio 0:9ec50d21947d 444 lcd.stopWAVFile();
emmanuelchio 0:9ec50d21947d 445 wait_ms(300);
emmanuelchio 0:9ec50d21947d 446 break; //exit playback
emmanuelchio 0:9ec50d21947d 447 }
emmanuelchio 0:9ec50d21947d 448 }
emmanuelchio 0:9ec50d21947d 449 }
emmanuelchio 0:9ec50d21947d 450 }
emmanuelchio 0:9ec50d21947d 451 }
emmanuelchio 0:9ec50d21947d 452
emmanuelchio 0:9ec50d21947d 453 /**************************************************/
emmanuelchio 0:9ec50d21947d 454 void notes(){
emmanuelchio 0:9ec50d21947d 455 lcd.imageBMPSD(0,0,"Misc/notes"); //load notes design
emmanuelchio 0:9ec50d21947d 456 lcd.objButton(10,280,MAX_X_PORTRAIT-10,310,DESELECTED,"Return");
emmanuelchio 0:9ec50d21947d 457 drawHeader("Adjustments:");
emmanuelchio 0:9ec50d21947d 458 wait_ms(200); //A little delay to avoid fast image changing
emmanuelchio 0:9ec50d21947d 459
emmanuelchio 0:9ec50d21947d 460 while(1){
emmanuelchio 0:9ec50d21947d 461 while(lcd.touchScreen(&point)==INVALID); //wait for a touch to do something
emmanuelchio 0:9ec50d21947d 462 if(point.y<65){ //Touch on upper Icons
emmanuelchio 0:9ec50d21947d 463 //clear note block
emmanuelchio 0:9ec50d21947d 464 lcd.imageBMPSD(0,0,"Misc/notes"); //load notes design
emmanuelchio 0:9ec50d21947d 465 lcd.objButton(10,280,MAX_X_PORTRAIT-10,310,DESELECTED,"Return");
emmanuelchio 0:9ec50d21947d 466 drawHeader("Note pad:");
emmanuelchio 0:9ec50d21947d 467 }else if(point.y<280){ //touch on notepad
emmanuelchio 0:9ec50d21947d 468 lcd.drawCircle(point.x,point.y,1,BLACK,FILL); //draw
emmanuelchio 0:9ec50d21947d 469 }else{ //touch on return button
emmanuelchio 0:9ec50d21947d 470 lcd.objButton(10,280,MAX_X_PORTRAIT-10,310,SELECTED,"Return");
emmanuelchio 0:9ec50d21947d 471 wait_ms(300);
emmanuelchio 0:9ec50d21947d 472 return; //exit
emmanuelchio 0:9ec50d21947d 473 }
emmanuelchio 0:9ec50d21947d 474 }
emmanuelchio 0:9ec50d21947d 475 }
emmanuelchio 0:9ec50d21947d 476
emmanuelchio 0:9ec50d21947d 477 /**************************************************/
emmanuelchio 0:9ec50d21947d 478 void games(){
emmanuelchio 0:9ec50d21947d 479 int x;
emmanuelchio 0:9ec50d21947d 480 char hitFlag=0,hole,mole,moleCounter=20,points=0,pointsTotal[4]="00 "; //array to store the points
emmanuelchio 0:9ec50d21947d 481 NUMBEROFBYTES charsPrinted;
emmanuelchio 0:9ec50d21947d 482
emmanuelchio 0:9ec50d21947d 483 lcd.orientation(LANDSCAPE_LEFT); //set orientation as landscape
emmanuelchio 0:9ec50d21947d 484 lcd.SDFopenDir("Games"); //Open the Games folder that contains the images of the Application
emmanuelchio 0:9ec50d21947d 485
emmanuelchio 0:9ec50d21947d 486 while(1){ //loop forever
emmanuelchio 0:9ec50d21947d 487 lcd.drawGradientRect(0,0,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,BLACK,MAGENTA,VERTICAL);
emmanuelchio 0:9ec50d21947d 488 lcd.setTextColour(WHITE);
emmanuelchio 0:9ec50d21947d 489 lcd.setTextSize(FONT5);
emmanuelchio 0:9ec50d21947d 490 lcd.setTextBackFill(TRANS);
emmanuelchio 0:9ec50d21947d 491 lcd.string(10,80,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"MOLE STOMP!!!",&charsPrinted); //show name string
emmanuelchio 0:9ec50d21947d 492 wait_ms(1000);
emmanuelchio 0:9ec50d21947d 493 lcd.string(22,130,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"GET READY!!!",&charsPrinted); //show ready string
emmanuelchio 0:9ec50d21947d 494 wait_ms(1500);
emmanuelchio 0:9ec50d21947d 495 lcd.imageBMPSD(0,0,"MoleArea"); //show area
emmanuelchio 0:9ec50d21947d 496 lcd.setTextSize(FONT2);
emmanuelchio 0:9ec50d21947d 497 lcd.setTextBackFill(FILLED);
emmanuelchio 0:9ec50d21947d 498 lcd.setTextBackColour(BLUE); //set the all text background to blue
emmanuelchio 0:9ec50d21947d 499
emmanuelchio 0:9ec50d21947d 500 //Start the game!
emmanuelchio 0:9ec50d21947d 501 while(moleCounter>0){ //loop the game while moleCounter reaches zero moles
emmanuelchio 0:9ec50d21947d 502 mole=rand()%3; //get a random mole 0-2
emmanuelchio 0:9ec50d21947d 503 hole=rand()%7; //get a random hole 0-6
emmanuelchio 0:9ec50d21947d 504 showMole(mole,hole); //show the random mole on the random hole
emmanuelchio 0:9ec50d21947d 505 for(x=0;x<3000;x++){ //wait some time for the player hit the mole(less time=more difficulty, more time=easy play)
emmanuelchio 0:9ec50d21947d 506 if(lcd.touchScreen(&point)==VALID){ //if we receive a touch on screen
emmanuelchio 0:9ec50d21947d 507 if(touchOnHole(hole)){ //if the touch is on the hole of the current mole
emmanuelchio 0:9ec50d21947d 508 hitFlag=1; //turn on the hit mole flag
emmanuelchio 0:9ec50d21947d 509 break; //end the waiting time
emmanuelchio 0:9ec50d21947d 510 }
emmanuelchio 0:9ec50d21947d 511 if(point.x > 270 && point.y < 50) moleCounter=0; //touch on X symbol, end game
emmanuelchio 0:9ec50d21947d 512 }
emmanuelchio 0:9ec50d21947d 513 }
emmanuelchio 0:9ec50d21947d 514 if(hitFlag==1){ //if the last mole was hit
emmanuelchio 0:9ec50d21947d 515 showMole(HITMOLE,hole); //we show the hit mole
emmanuelchio 0:9ec50d21947d 516 points++; //increase hit mole counter or points
emmanuelchio 0:9ec50d21947d 517 hitFlag=0; //clear the hit flag
emmanuelchio 0:9ec50d21947d 518 }else{ //if the last mole was missed
emmanuelchio 0:9ec50d21947d 519 showMole(MISSMOLE,hole); //show the mole hiding
emmanuelchio 0:9ec50d21947d 520 }
emmanuelchio 0:9ec50d21947d 521 pointsTotal[0]=(points/10)+0x30; //get the tens of the points and convert them to ascii
emmanuelchio 0:9ec50d21947d 522 pointsTotal[1]=(points%10)+0x30; //get the ones of the points and convert them to ascii
emmanuelchio 0:9ec50d21947d 523 lcd.string(33,27,100,100,pointsTotal,&charsPrinted); //draw the points
emmanuelchio 0:9ec50d21947d 524 wait_ms(350);
emmanuelchio 0:9ec50d21947d 525 showMole(MOLEHOLE,hole); //show the bare hole
emmanuelchio 0:9ec50d21947d 526 moleCounter--; //decrease the mole counter
emmanuelchio 0:9ec50d21947d 527 }
emmanuelchio 0:9ec50d21947d 528
emmanuelchio 0:9ec50d21947d 529 //Game over, display results
emmanuelchio 0:9ec50d21947d 530 lcd.setTextColour(YELLOW);
emmanuelchio 0:9ec50d21947d 531 lcd.setTextSize(FONT3);
emmanuelchio 0:9ec50d21947d 532 lcd.setTextBackFill(TRANS);
emmanuelchio 0:9ec50d21947d 533 lcd.string(80,50,300,220,"Whacked Moles:",&charsPrinted);
emmanuelchio 0:9ec50d21947d 534 lcd.setTextColour(BLUE);
emmanuelchio 0:9ec50d21947d 535 lcd.string(153,75,300,220,pointsTotal,&charsPrinted); //draw the converted to ascii points array
emmanuelchio 0:9ec50d21947d 536 lcd.setTextColour(RED);
emmanuelchio 0:9ec50d21947d 537 lcd.setTextSize(FONT2);
emmanuelchio 0:9ec50d21947d 538 lcd.string(50,140,319,239,"TOUCH TO RESTART",&charsPrinted);
emmanuelchio 0:9ec50d21947d 539 lcd.objButton(10,200,MAX_X_LANDSCAPE-10,230,DESELECTED,"Return");
emmanuelchio 0:9ec50d21947d 540 wait_ms(1000);
emmanuelchio 0:9ec50d21947d 541
emmanuelchio 0:9ec50d21947d 542 while(lcd.touchScreen(&point)==INVALID); //wait for a touch on screen to restart or exit
emmanuelchio 0:9ec50d21947d 543 if(point.y>200){ //touch on return button
emmanuelchio 0:9ec50d21947d 544 lcd.objButton(10,200,MAX_X_LANDSCAPE-10,230,SELECTED,"Return");
emmanuelchio 0:9ec50d21947d 545 break; //exit while(1) loop
emmanuelchio 0:9ec50d21947d 546 }//else re-start game
emmanuelchio 0:9ec50d21947d 547 moleCounter=20; //reset the moleCounter
emmanuelchio 0:9ec50d21947d 548 points=0; //reset points
emmanuelchio 0:9ec50d21947d 549 lcd.erase(); //erase screen and restart all
emmanuelchio 0:9ec50d21947d 550 }
emmanuelchio 0:9ec50d21947d 551 lcd.SDFopenDir(".."); //return/go up to parent dir one level
emmanuelchio 0:9ec50d21947d 552 lcd.orientation(PORTRAIT_LOW); //change to portrait mode
emmanuelchio 0:9ec50d21947d 553 wait_ms(300);
emmanuelchio 0:9ec50d21947d 554 }
emmanuelchio 0:9ec50d21947d 555
emmanuelchio 0:9ec50d21947d 556 /**************************************************/
emmanuelchio 0:9ec50d21947d 557 void music(){
emmanuelchio 0:9ec50d21947d 558 STATE state; static char pause=1;
emmanuelchio 0:9ec50d21947d 559 unsigned int dirs=0,songs=0;
emmanuelchio 0:9ec50d21947d 560 static unsigned int currentSong=0, volume=100;//static to save current song and volume even we exit function
emmanuelchio 0:9ec50d21947d 561 NUMBEROFBYTES charsPrinted;
emmanuelchio 0:9ec50d21947d 562
emmanuelchio 0:9ec50d21947d 563 lcd.SDFopenDir("Music"); //Open the folder that contains the songs in .wav format
emmanuelchio 0:9ec50d21947d 564 lcd.SDFgetList(&dirs,&songs); //get number of files/songs under the current folder "Music"
emmanuelchio 0:9ec50d21947d 565
emmanuelchio 0:9ec50d21947d 566 lcd.setTextColour(WHITE);
emmanuelchio 0:9ec50d21947d 567 lcd.setTextSize(FONT3);
emmanuelchio 0:9ec50d21947d 568 lcd.setTextBackFill(TRANS);
emmanuelchio 0:9ec50d21947d 569 lcd.drawGradientRect(0,0,MAX_X_PORTRAIT,MAX_Y_PORTRAIT,BLACK,MAGENTA,VERTICAL);
emmanuelchio 0:9ec50d21947d 570 lcd.string(50,140,MAX_X_PORTRAIT,MAX_Y_PORTRAIT,"Music Player",&charsPrinted);
emmanuelchio 0:9ec50d21947d 571 wait_ms(1000);
emmanuelchio 0:9ec50d21947d 572 lcd.erase();
emmanuelchio 0:9ec50d21947d 573 drawHeader("Music:");
emmanuelchio 0:9ec50d21947d 574 lcd.getWAVPlayState(&state); //get playing state
emmanuelchio 0:9ec50d21947d 575 if(state==DISABLE) pause=1; //if not playing, set pause to active
emmanuelchio 0:9ec50d21947d 576 drawControlPLAY(pause); //draw button according to pause
emmanuelchio 0:9ec50d21947d 577 drawControlRR(DESELECTED);
emmanuelchio 0:9ec50d21947d 578 drawControlFF(DESELECTED);
emmanuelchio 0:9ec50d21947d 579 //draw current volume bar
emmanuelchio 0:9ec50d21947d 580 lcd.drawRectangle(0,245,(volume*MAX_X_PORTRAIT)/(100),260,YELLOW,FILL); //scale volume value to 0-239 pixels
emmanuelchio 0:9ec50d21947d 581 lcd.drawRectangle((volume*MAX_X_PORTRAIT)/(100),245,319,260,BLACK,FILL); //scale volume value to 0-239 pixels
emmanuelchio 0:9ec50d21947d 582
emmanuelchio 0:9ec50d21947d 583 while(1){
emmanuelchio 0:9ec50d21947d 584 lcd.getWAVPlayState(&state); //get playing state
emmanuelchio 0:9ec50d21947d 585 if(state==DISABLE){pause=1; drawControlPLAY(pause);} //if not playing, set pause to active and update button
emmanuelchio 0:9ec50d21947d 586 if(pause==0) lcd.drawGradientRect(0,70,MAX_X_PORTRAIT,240,(rand()%0xFFFF),(rand()%0xFFFF),HORIZONTAL);
emmanuelchio 0:9ec50d21947d 587
emmanuelchio 0:9ec50d21947d 588 wait_ms(100);
emmanuelchio 0:9ec50d21947d 589 if(lcd.touchScreen(&point)==VALID){ //ask for touch and if valid..
emmanuelchio 0:9ec50d21947d 590 if(point.y>265){ //Touch on controls
emmanuelchio 0:9ec50d21947d 591 if(point.x<80){ //touch on << icon
emmanuelchio 0:9ec50d21947d 592 drawControlRR(SELECTED);
emmanuelchio 0:9ec50d21947d 593 lcd.advanceWAVFile(0); //rewind song to beginning
emmanuelchio 0:9ec50d21947d 594 wait_ms(300); //wait
emmanuelchio 0:9ec50d21947d 595 drawControlRR(DESELECTED);
emmanuelchio 0:9ec50d21947d 596 }else if(point.x<160){ //touch on Play/Pause icon
emmanuelchio 0:9ec50d21947d 597 if(state == ENABLE){ //if playing
emmanuelchio 0:9ec50d21947d 598 lcd.pauseWAVFile(); //pause playing
emmanuelchio 0:9ec50d21947d 599 pause=!pause;
emmanuelchio 0:9ec50d21947d 600 }else{ //begin to play any song
emmanuelchio 0:9ec50d21947d 601 lcd.SDFgetFileName(currentSong,name); //get the name of the song file number currentSong
emmanuelchio 0:9ec50d21947d 602 cutFileExtension(name,".wav"); //cut to name the .wav extension
emmanuelchio 0:9ec50d21947d 603 lcd.playWAVFile(name,&charsPrinted); //play file - returns the duration of the song in seconds
emmanuelchio 0:9ec50d21947d 604 lcd.drawRectangle(0,25,MAX_X_PORTRAIT,70,BLACK,FILL); //erase previous name
emmanuelchio 0:9ec50d21947d 605 lcd.string(10,30,MAX_X_PORTRAIT,MAX_Y_PORTRAIT,name,&charsPrinted); //print new name
emmanuelchio 0:9ec50d21947d 606 pause=0;
emmanuelchio 0:9ec50d21947d 607 }
emmanuelchio 0:9ec50d21947d 608 wait_ms(300);
emmanuelchio 0:9ec50d21947d 609 }else{ //point.x<240 //touch on >> icon
emmanuelchio 0:9ec50d21947d 610 drawControlFF(SELECTED);
emmanuelchio 0:9ec50d21947d 611 lcd.stopWAVFile(); //stop current playing song if any
emmanuelchio 0:9ec50d21947d 612 currentSong++; //advance current song
emmanuelchio 0:9ec50d21947d 613 if(currentSong>=songs) currentSong=0; //check
emmanuelchio 0:9ec50d21947d 614 lcd.SDFgetFileName(currentSong,name); //get the name of the song file number currentSong
emmanuelchio 0:9ec50d21947d 615 cutFileExtension(name,".wav"); //cut to name the .wav extension
emmanuelchio 0:9ec50d21947d 616 lcd.playWAVFile(name,&charsPrinted); //play file
emmanuelchio 0:9ec50d21947d 617 lcd.drawRectangle(0,25,MAX_X_PORTRAIT,70,BLACK,FILL); //erase previous name
emmanuelchio 0:9ec50d21947d 618 lcd.string(10,30,MAX_X_PORTRAIT,MAX_Y_PORTRAIT,name,&charsPrinted); //print new name
emmanuelchio 0:9ec50d21947d 619 pause=0;
emmanuelchio 0:9ec50d21947d 620 wait_ms(300); //wait
emmanuelchio 0:9ec50d21947d 621 drawControlFF(DESELECTED);
emmanuelchio 0:9ec50d21947d 622 }
emmanuelchio 0:9ec50d21947d 623 drawControlPLAY(pause); //update button
emmanuelchio 0:9ec50d21947d 624 }else if(point.y>240){ //Touch on volume bar
emmanuelchio 0:9ec50d21947d 625 volume=(point.x*100)/MAX_X_PORTRAIT; //obtain new volume parameter by scaling to 0-239 pixels
emmanuelchio 0:9ec50d21947d 626 lcd.setVolumeWAV(volume); //set new volume to SmartGPU Audio
emmanuelchio 0:9ec50d21947d 627 //update volume bar
emmanuelchio 0:9ec50d21947d 628 lcd.drawRectangle(0,245,(volume*MAX_X_PORTRAIT)/(100),260,YELLOW,FILL); //scale volume value to 0-239 pixels
emmanuelchio 0:9ec50d21947d 629 lcd.drawRectangle((volume*MAX_X_PORTRAIT)/(100),245,MAX_X_PORTRAIT,260,BLACK,FILL); //scale volume value to 0-239 pixels
emmanuelchio 0:9ec50d21947d 630 wait_ms(50);
emmanuelchio 0:9ec50d21947d 631 }else if(point.y<20){ //if touch on main header, go to main menu
emmanuelchio 0:9ec50d21947d 632 lcd.SDFopenDir(".."); //return/go up to parent dir one level
emmanuelchio 0:9ec50d21947d 633 wait_ms(300);
emmanuelchio 0:9ec50d21947d 634 return;
emmanuelchio 0:9ec50d21947d 635 }
emmanuelchio 0:9ec50d21947d 636 }
emmanuelchio 0:9ec50d21947d 637 }
emmanuelchio 0:9ec50d21947d 638 }
emmanuelchio 0:9ec50d21947d 639
emmanuelchio 0:9ec50d21947d 640 /**************************************************/
emmanuelchio 0:9ec50d21947d 641 void wallpaper(){
emmanuelchio 0:9ec50d21947d 642 unsigned int dirs=0,walls=0, i=0;
emmanuelchio 0:9ec50d21947d 643 NUMBEROFBYTES charsPrinted;
emmanuelchio 0:9ec50d21947d 644
emmanuelchio 0:9ec50d21947d 645 lcd.SDFopenDir("Wall") ; //Open the folder that contains the wallpaper images
emmanuelchio 0:9ec50d21947d 646 lcd.SDFgetList(&dirs,&walls); //get number of files/Pics under the current folder "Wall"
emmanuelchio 0:9ec50d21947d 647
emmanuelchio 0:9ec50d21947d 648 lcd.setTextColour(WHITE);
emmanuelchio 0:9ec50d21947d 649 lcd.setTextSize(FONT3);
emmanuelchio 0:9ec50d21947d 650 lcd.setTextBackFill(TRANS);
emmanuelchio 0:9ec50d21947d 651 lcd.drawGradientRect(0,0,MAX_X_PORTRAIT,MAX_Y_PORTRAIT,BLACK,MAGENTA,VERTICAL);
emmanuelchio 0:9ec50d21947d 652 lcd.string(55,140,MAX_X_PORTRAIT,MAX_Y_PORTRAIT,"Wallpapers",&charsPrinted);
emmanuelchio 0:9ec50d21947d 653 wait_ms(1000);
emmanuelchio 0:9ec50d21947d 654
emmanuelchio 0:9ec50d21947d 655 while(1){
emmanuelchio 0:9ec50d21947d 656 lcd.SDFgetFileName(i,name); //get the name of the wall file number i
emmanuelchio 0:9ec50d21947d 657 cutFileExtension(name,".bmp"); //cut to name the .bmp extension
emmanuelchio 0:9ec50d21947d 658 lcd.imageBMPSD(0,0,name); //Load image from SD card, all images are 240x320(full screen) so we load them from top left corner X:0,Y:0
emmanuelchio 0:9ec50d21947d 659 drawHeader("Wallpapers:");
emmanuelchio 0:9ec50d21947d 660 wait_ms(200); //A little delay to avoid fast image changing
emmanuelchio 0:9ec50d21947d 661 lcd.objButton(10,25,MAX_X_PORTRAIT-10,55,DESELECTED,"Set as Wall");
emmanuelchio 0:9ec50d21947d 662 lcd.objButton(10,280,MAX_X_PORTRAIT-10,310,DESELECTED,"Return");
emmanuelchio 0:9ec50d21947d 663
emmanuelchio 0:9ec50d21947d 664 while(lcd.touchScreen(&point)==INVALID); //wait for a touch to do something
emmanuelchio 0:9ec50d21947d 665
emmanuelchio 0:9ec50d21947d 666 if(point.y > 280){ //if touch on "return" button, break to exit while(1);
emmanuelchio 0:9ec50d21947d 667 lcd.objButton(10,280,MAX_X_PORTRAIT-10,310,SELECTED,"Return");
emmanuelchio 0:9ec50d21947d 668 lcd.SDFopenDir(".."); //return/go up to parent dir one level
emmanuelchio 0:9ec50d21947d 669 wait_ms(300);
emmanuelchio 0:9ec50d21947d 670 return; //EXIT
emmanuelchio 0:9ec50d21947d 671 }
emmanuelchio 0:9ec50d21947d 672 if(point.y < 60){ //if touch on "set as wall" button
emmanuelchio 0:9ec50d21947d 673 lcd.objButton(10,25,MAX_X_PORTRAIT-10,55,SELECTED,"Set as Wall");
emmanuelchio 0:9ec50d21947d 674 lcd.setTextSize(FONT2);
emmanuelchio 0:9ec50d21947d 675 lcd.string(22,140,MAX_X_PORTRAIT,MAX_Y_PORTRAIT,"Saved on EEPROM",&charsPrinted);
emmanuelchio 0:9ec50d21947d 676 saveWallpaperToEEPROM(); //Save the current contents of "name" array to EEPROM
emmanuelchio 0:9ec50d21947d 677 wait_ms(500);
emmanuelchio 0:9ec50d21947d 678 continue;
emmanuelchio 0:9ec50d21947d 679 }
emmanuelchio 0:9ec50d21947d 680 //check if we go to the next image, or to the previous one
emmanuelchio 0:9ec50d21947d 681 if(point.x>120){ //if the received touch was on the right side of the screen we advance the image, else we decrease and go to previous image
emmanuelchio 0:9ec50d21947d 682 i++; //decrease image selector
emmanuelchio 0:9ec50d21947d 683 if(i>=walls){ //if we reach the position of the last image, we restart to image 0
emmanuelchio 0:9ec50d21947d 684 i=0;
emmanuelchio 0:9ec50d21947d 685 }
emmanuelchio 0:9ec50d21947d 686 }else{ //touch on left side of screen
emmanuelchio 0:9ec50d21947d 687 if(i>0){ //if we can decrease i
emmanuelchio 0:9ec50d21947d 688 i--;
emmanuelchio 0:9ec50d21947d 689 }else{ //if we decrease i will be less than zero, so we move to last image instead
emmanuelchio 0:9ec50d21947d 690 i=walls-1;
emmanuelchio 0:9ec50d21947d 691 }
emmanuelchio 0:9ec50d21947d 692 }
emmanuelchio 0:9ec50d21947d 693 }
emmanuelchio 0:9ec50d21947d 694 }
emmanuelchio 0:9ec50d21947d 695
emmanuelchio 0:9ec50d21947d 696 /***************************************************/
emmanuelchio 0:9ec50d21947d 697 /***************************************************/
emmanuelchio 0:9ec50d21947d 698 void initializeSmartGPU2(void){ //Initialize SMARTGPU2 Board
emmanuelchio 0:9ec50d21947d 699 lcd.reset(); //physically reset SMARTGPU2
emmanuelchio 0:9ec50d21947d 700 lcd.start(); //initialize the SMARTGPU2 processor
emmanuelchio 0:9ec50d21947d 701 }
emmanuelchio 0:9ec50d21947d 702
emmanuelchio 0:9ec50d21947d 703 /***************************************************/
emmanuelchio 0:9ec50d21947d 704 /***************************************************/
emmanuelchio 0:9ec50d21947d 705 /***************************************************/
emmanuelchio 0:9ec50d21947d 706 /***************************************************/
emmanuelchio 0:9ec50d21947d 707 int main() {
emmanuelchio 0:9ec50d21947d 708 unsigned char icons;
emmanuelchio 0:9ec50d21947d 709
emmanuelchio 0:9ec50d21947d 710 initializeSmartGPU2(); //Init communication with SmartGPU2 board
emmanuelchio 0:9ec50d21947d 711
emmanuelchio 0:9ec50d21947d 712 lcd.baudChange(BAUD7); //set high baud for advanced applications
emmanuelchio 0:9ec50d21947d 713 lcd.orientation(PORTRAIT_LOW); //set orientation as portrait
emmanuelchio 0:9ec50d21947d 714 lcd.initDACAudio(ENABLE); //Turn on the Audio DACs
emmanuelchio 0:9ec50d21947d 715 lcd.audioBoost(ENABLE); //ENABLE boost
emmanuelchio 0:9ec50d21947d 716 lcd.SDFopenDir("FullGUI"); //Open the FullGUI folder that contains the images of the Application
emmanuelchio 0:9ec50d21947d 717
emmanuelchio 0:9ec50d21947d 718 while(1){
emmanuelchio 0:9ec50d21947d 719 //draw MainMenu
emmanuelchio 0:9ec50d21947d 720 drawMainMenu();
emmanuelchio 0:9ec50d21947d 721
emmanuelchio 0:9ec50d21947d 722 icons=getTouchIconMainMenu(); //ask for a touch on one of the icons of main menu and return icon#
emmanuelchio 0:9ec50d21947d 723 switch(icons){
emmanuelchio 0:9ec50d21947d 724 case 1: //case icon 1
emmanuelchio 0:9ec50d21947d 725 backlight();
emmanuelchio 0:9ec50d21947d 726 break;
emmanuelchio 0:9ec50d21947d 727 case 2: //case icon 2
emmanuelchio 0:9ec50d21947d 728 //calculator();
emmanuelchio 0:9ec50d21947d 729 break;
emmanuelchio 0:9ec50d21947d 730 case 3: //case icon 3
emmanuelchio 0:9ec50d21947d 731 clocks();
emmanuelchio 0:9ec50d21947d 732 break;
emmanuelchio 0:9ec50d21947d 733 case 4: //case icon 4
emmanuelchio 0:9ec50d21947d 734 games();
emmanuelchio 0:9ec50d21947d 735 break;
emmanuelchio 0:9ec50d21947d 736 case 5: //case icon 5
emmanuelchio 0:9ec50d21947d 737 //maps();
emmanuelchio 0:9ec50d21947d 738 break;
emmanuelchio 0:9ec50d21947d 739 case 6: //case icon 6
emmanuelchio 0:9ec50d21947d 740 media();
emmanuelchio 0:9ec50d21947d 741 break;
emmanuelchio 0:9ec50d21947d 742 case 7: //case icon 7
emmanuelchio 0:9ec50d21947d 743 notes();
emmanuelchio 0:9ec50d21947d 744 break;
emmanuelchio 0:9ec50d21947d 745 case 8: //case icon 8
emmanuelchio 0:9ec50d21947d 746 photos();
emmanuelchio 0:9ec50d21947d 747 break;
emmanuelchio 0:9ec50d21947d 748 case 9: //case icon 9
emmanuelchio 0:9ec50d21947d 749 //wifi();
emmanuelchio 0:9ec50d21947d 750 break;
emmanuelchio 0:9ec50d21947d 751 case 10: //case icon 10
emmanuelchio 0:9ec50d21947d 752 //settings();
emmanuelchio 0:9ec50d21947d 753 break;
emmanuelchio 0:9ec50d21947d 754 case 11: //case icon 11
emmanuelchio 0:9ec50d21947d 755 //calls();
emmanuelchio 0:9ec50d21947d 756 break;
emmanuelchio 0:9ec50d21947d 757 case 12: //case icon 12
emmanuelchio 0:9ec50d21947d 758 music();
emmanuelchio 0:9ec50d21947d 759 break;
emmanuelchio 0:9ec50d21947d 760 case 13: //case icon 13
emmanuelchio 0:9ec50d21947d 761 wallpaper();
emmanuelchio 0:9ec50d21947d 762 break;
emmanuelchio 0:9ec50d21947d 763 default:
emmanuelchio 0:9ec50d21947d 764 //do nothing
emmanuelchio 0:9ec50d21947d 765 break;
emmanuelchio 0:9ec50d21947d 766 }
emmanuelchio 0:9ec50d21947d 767 }
emmanuelchio 0:9ec50d21947d 768 }