BMP Images Photo Frame Demo - MBED + SmartGPU2 board

Dependencies:   SMARTGPU2 mbed

Committer:
emmanuelchio
Date:
Wed Jul 10 03:37:48 2013 +0000
Revision:
0:cf88c34846f1
Child:
1:5fbcbf55bb8f
Images Photo Frame Demo - MBED + SmartGPU2 board

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emmanuelchio 0:cf88c34846f1 1 /**************************************************************************************/
emmanuelchio 0:cf88c34846f1 2 /*SMARTGPU2 intelligent embedded graphics processor unit
emmanuelchio 0:cf88c34846f1 3 those examples are for use the SMARTGPU2 with the mbed microcontoller, just connect tx,rx,and reset
emmanuelchio 0:cf88c34846f1 4 Board:
emmanuelchio 0:cf88c34846f1 5 http://vizictechnologies.com/#/smart-gpu-2/4577779046
emmanuelchio 0:cf88c34846f1 6
emmanuelchio 0:cf88c34846f1 7 www.vizictechnologies.com
emmanuelchio 0:cf88c34846f1 8 Vizic Technologies copyright 2013 */
emmanuelchio 0:cf88c34846f1 9 /**************************************************************************************/
emmanuelchio 0:cf88c34846f1 10
emmanuelchio 0:cf88c34846f1 11 #include "mbed.h"
emmanuelchio 0:cf88c34846f1 12 #include "SMARTGPU2.h"
emmanuelchio 0:cf88c34846f1 13
emmanuelchio 0:cf88c34846f1 14 SMARTGPU2 lcd(TXPIN,RXPIN,RESETPIN); //create our object called "lcd"
emmanuelchio 0:cf88c34846f1 15
emmanuelchio 0:cf88c34846f1 16 char imagesOnSDCard[8][30]={"Penguins","Koala","Hydrangeas","Light House","Jellyfish","Tulips","Desert","Flower"}; //array containing the names of the different called images
emmanuelchio 0:cf88c34846f1 17
emmanuelchio 0:cf88c34846f1 18 /***************************************************/
emmanuelchio 0:cf88c34846f1 19 /***************************************************/
emmanuelchio 0:cf88c34846f1 20 void initializeSmartGPU2(void){ //Initialize SMARTGPU2 Board
emmanuelchio 0:cf88c34846f1 21 lcd.reset(); //physically reset SMARTGPU2
emmanuelchio 0:cf88c34846f1 22 lcd.start(); //initialize the SMARTGPU2 processor
emmanuelchio 0:cf88c34846f1 23 }
emmanuelchio 0:cf88c34846f1 24
emmanuelchio 0:cf88c34846f1 25 /***************************************************/
emmanuelchio 0:cf88c34846f1 26 /***************************************************/
emmanuelchio 0:cf88c34846f1 27 /***************************************************/
emmanuelchio 0:cf88c34846f1 28 /***************************************************/
emmanuelchio 0:cf88c34846f1 29 int main() {
emmanuelchio 0:cf88c34846f1 30 POINT point;
emmanuelchio 0:cf88c34846f1 31 int pic=0;
emmanuelchio 0:cf88c34846f1 32
emmanuelchio 0:cf88c34846f1 33 initializeSmartGPU2(); //Init communication with SmartGPU2 board
emmanuelchio 0:cf88c34846f1 34
emmanuelchio 0:cf88c34846f1 35 lcd.SDFopenDir("BMP Images"); //Open the BMP Images that contains the images
emmanuelchio 0:cf88c34846f1 36
emmanuelchio 0:cf88c34846f1 37 while(1){ //Loop forever in the slide show!
emmanuelchio 0:cf88c34846f1 38 lcd.imageBMPSD(0,0,imagesOnSDCard[pic]); //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:cf88c34846f1 39 lcd.imageBMPSD(3,219,"previous"); //Load the previous icon
emmanuelchio 0:cf88c34846f1 40 lcd.imageBMPSD(300,219,"next"); //Load the next icon
emmanuelchio 0:cf88c34846f1 41
emmanuelchio 0:cf88c34846f1 42 wait_ms(100); //A little delay to avoid fast image changing
emmanuelchio 0:cf88c34846f1 43 while(lcd.touchScreen(&point)==INVALID); //Wait for a touch on the screen to show next or previous picture
emmanuelchio 0:cf88c34846f1 44
emmanuelchio 0:cf88c34846f1 45 //check if we go to the next image, or to the previous one
emmanuelchio 0:cf88c34846f1 46 if(point.x>160){ //if the received touch was on the right middle of the screen we advance the image, else we decrease and go to previous image
emmanuelchio 0:cf88c34846f1 47 pic++; //decrease image selector
emmanuelchio 0:cf88c34846f1 48 if(pic>7){ //if we reach the position of the last image, we restart to image 0
emmanuelchio 0:cf88c34846f1 49 pic=0;
emmanuelchio 0:cf88c34846f1 50 }
emmanuelchio 0:cf88c34846f1 51 }else{
emmanuelchio 0:cf88c34846f1 52 pic--;
emmanuelchio 0:cf88c34846f1 53 if(pic<0){ //if we reach the position of the first image, we move to image 7
emmanuelchio 0:cf88c34846f1 54 pic=7;
emmanuelchio 0:cf88c34846f1 55 }
emmanuelchio 0:cf88c34846f1 56 }
emmanuelchio 0:cf88c34846f1 57 }
emmanuelchio 0:cf88c34846f1 58 }