![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
BMP Images Photo Frame Demo - MBED + SmartGPU2 board
main.cpp@1:5fbcbf55bb8f, 2014-04-17 (annotated)
- Committer:
- emmanuelchio
- Date:
- Thu Apr 17 23:51:42 2014 +0000
- Revision:
- 1:5fbcbf55bb8f
- Parent:
- 0:cf88c34846f1
- Child:
- 2:0aca9184311d
SmartGPU2 Photoframe_SG2 demo- Please select(uncomment) your smartGPU2 board under SMARTGPU2.h file before compiling!!!
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emmanuelchio | 1:5fbcbf55bb8f | 1 | /**************************************************************************************/ |
emmanuelchio | 0:cf88c34846f1 | 2 | /**************************************************************************************/ |
emmanuelchio | 0:cf88c34846f1 | 3 | /*SMARTGPU2 intelligent embedded graphics processor unit |
emmanuelchio | 1:5fbcbf55bb8f | 4 | those examples are for using the SMARTGPU2 with the mbed microcontoller, just connect tx,rx,and reset |
emmanuelchio | 0:cf88c34846f1 | 5 | Board: |
emmanuelchio | 1:5fbcbf55bb8f | 6 | http://www.vizictechnologies.com/ |
emmanuelchio | 0:cf88c34846f1 | 7 | |
emmanuelchio | 0:cf88c34846f1 | 8 | www.vizictechnologies.com |
emmanuelchio | 1:5fbcbf55bb8f | 9 | Vizic Technologies copyright 2014 */ |
emmanuelchio | 1:5fbcbf55bb8f | 10 | /**************************************************************************************/ |
emmanuelchio | 0:cf88c34846f1 | 11 | /**************************************************************************************/ |
emmanuelchio | 0:cf88c34846f1 | 12 | |
emmanuelchio | 0:cf88c34846f1 | 13 | #include "mbed.h" |
emmanuelchio | 0:cf88c34846f1 | 14 | #include "SMARTGPU2.h" |
emmanuelchio | 0:cf88c34846f1 | 15 | |
emmanuelchio | 0:cf88c34846f1 | 16 | SMARTGPU2 lcd(TXPIN,RXPIN,RESETPIN); //create our object called "lcd" |
emmanuelchio | 0:cf88c34846f1 | 17 | |
emmanuelchio | 0:cf88c34846f1 | 18 | 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 | 19 | |
emmanuelchio | 0:cf88c34846f1 | 20 | /***************************************************/ |
emmanuelchio | 0:cf88c34846f1 | 21 | /***************************************************/ |
emmanuelchio | 0:cf88c34846f1 | 22 | void initializeSmartGPU2(void){ //Initialize SMARTGPU2 Board |
emmanuelchio | 0:cf88c34846f1 | 23 | lcd.reset(); //physically reset SMARTGPU2 |
emmanuelchio | 0:cf88c34846f1 | 24 | lcd.start(); //initialize the SMARTGPU2 processor |
emmanuelchio | 0:cf88c34846f1 | 25 | } |
emmanuelchio | 0:cf88c34846f1 | 26 | |
emmanuelchio | 0:cf88c34846f1 | 27 | /***************************************************/ |
emmanuelchio | 0:cf88c34846f1 | 28 | /***************************************************/ |
emmanuelchio | 0:cf88c34846f1 | 29 | /***************************************************/ |
emmanuelchio | 0:cf88c34846f1 | 30 | /***************************************************/ |
emmanuelchio | 0:cf88c34846f1 | 31 | int main() { |
emmanuelchio | 0:cf88c34846f1 | 32 | POINT point; |
emmanuelchio | 0:cf88c34846f1 | 33 | int pic=0; |
emmanuelchio | 0:cf88c34846f1 | 34 | |
emmanuelchio | 0:cf88c34846f1 | 35 | initializeSmartGPU2(); //Init communication with SmartGPU2 board |
emmanuelchio | 0:cf88c34846f1 | 36 | |
emmanuelchio | 0:cf88c34846f1 | 37 | lcd.SDFopenDir("BMP Images"); //Open the BMP Images that contains the images |
emmanuelchio | 0:cf88c34846f1 | 38 | |
emmanuelchio | 0:cf88c34846f1 | 39 | while(1){ //Loop forever in the slide show! |
emmanuelchio | 0:cf88c34846f1 | 40 | 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 | 41 | lcd.imageBMPSD(3,219,"previous"); //Load the previous icon |
emmanuelchio | 0:cf88c34846f1 | 42 | lcd.imageBMPSD(300,219,"next"); //Load the next icon |
emmanuelchio | 0:cf88c34846f1 | 43 | |
emmanuelchio | 0:cf88c34846f1 | 44 | wait_ms(100); //A little delay to avoid fast image changing |
emmanuelchio | 0:cf88c34846f1 | 45 | while(lcd.touchScreen(&point)==INVALID); //Wait for a touch on the screen to show next or previous picture |
emmanuelchio | 0:cf88c34846f1 | 46 | |
emmanuelchio | 0:cf88c34846f1 | 47 | //check if we go to the next image, or to the previous one |
emmanuelchio | 0:cf88c34846f1 | 48 | 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 | 49 | pic++; //decrease image selector |
emmanuelchio | 0:cf88c34846f1 | 50 | if(pic>7){ //if we reach the position of the last image, we restart to image 0 |
emmanuelchio | 0:cf88c34846f1 | 51 | pic=0; |
emmanuelchio | 0:cf88c34846f1 | 52 | } |
emmanuelchio | 0:cf88c34846f1 | 53 | }else{ |
emmanuelchio | 0:cf88c34846f1 | 54 | pic--; |
emmanuelchio | 0:cf88c34846f1 | 55 | if(pic<0){ //if we reach the position of the first image, we move to image 7 |
emmanuelchio | 0:cf88c34846f1 | 56 | pic=7; |
emmanuelchio | 0:cf88c34846f1 | 57 | } |
emmanuelchio | 0:cf88c34846f1 | 58 | } |
emmanuelchio | 0:cf88c34846f1 | 59 | } |
emmanuelchio | 0:cf88c34846f1 | 60 | } |