BMP Images Photo Frame Demo - MBED + SmartGPU2 board

Dependencies:   SMARTGPU2 mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /**************************************************************************************/
00002 /**************************************************************************************/
00003 /*SMARTGPU2 intelligent embedded graphics processor unit
00004  those examples are for using the SMARTGPU2 with the mbed microcontoller, just connect tx,rx,and reset
00005  Board:
00006  http://www.vizictechnologies.com/
00007  
00008  www.vizictechnologies.com 
00009  Vizic Technologies copyright 2014 */
00010 /**************************************************************************************/
00011 /**************************************************************************************/
00012 
00013 #include "mbed.h"
00014 #include "SMARTGPU2.h"
00015 
00016 SMARTGPU2 lcd(TXPIN,RXPIN,RESETPIN);  //create our object called "lcd"
00017 
00018 char imagesOnSDCard[8][30]={"Penguins","Koala","Hydrangeas","Light House","Jellyfish","Tulips","Desert","Flower"}; //array containing the names of the different called images
00019 
00020 /***************************************************/
00021 /***************************************************/
00022 void initializeSmartGPU2(void){      //Initialize SMARTGPU2 Board
00023   lcd.reset();                       //physically reset SMARTGPU2
00024   lcd.start();                       //initialize the SMARTGPU2 processor
00025 }
00026 
00027 /***************************************************/
00028 /***************************************************/
00029 /***************************************************/
00030 /***************************************************/
00031 int main() {
00032   POINT point;
00033   int pic=0;
00034     
00035   initializeSmartGPU2();                     //Init communication with SmartGPU2 board
00036   
00037   lcd.SDFopenDir("BMP Images");              //Open the BMP Images that contains the images
00038   
00039   while(1){   //Loop forever in the slide show!
00040     lcd.imageBMPSD(0,0,imagesOnSDCard[pic]); //Load image from SD card, all images are full screen so we load them from top left corner X:0,Y:0
00041     lcd.imageBMPSD(3,LCD_HEIGHT-20,"previous");        //Load the previous icon          
00042     lcd.imageBMPSD(LCD_WIDTH-20,LCD_HEIGHT-20,"next"); //Load the next icon
00043        
00044     wait_ms(100);                            //A little delay to avoid fast image changing
00045     while(lcd.touchScreen(&point)==INVALID); //Wait for a touch on the screen to show next or previous picture
00046     
00047     //check if we go to the next image, or to the previous one
00048     if(point.x>(LCD_WIDTH/2)){               //if the received touch was on the right middle of the screen we advance the image, else we decrease and go to previous image
00049       pic++;                                 //decrease image selector
00050       if(pic>7){                             //if we reach the position of the last image, we restart to image 0
00051         pic=0;                 
00052       }        
00053     }else{    
00054       pic--;    
00055       if(pic<0){                          //if we reach the position of the first image, we move to image 7
00056         pic=7;  
00057       }    
00058     }   
00059   }
00060 }