JPG Images decompression from the microSD card using SmartGPU2 board - MBED + SmartGPU2 board

Dependencies:   SMARTGPU2 mbed

Committer:
emmanuelchio
Date:
Fri Apr 18 00:51:42 2014 +0000
Revision:
2:b40561f97cc5
Parent:
1:39094523c711
SmartGPU2 GalleryJPG_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:39094523c711 1 /**************************************************************************************/
emmanuelchio 0:699e70ed46ee 2 /**************************************************************************************/
emmanuelchio 0:699e70ed46ee 3 /*SMARTGPU2 intelligent embedded graphics processor unit
emmanuelchio 1:39094523c711 4 those examples are for using the SMARTGPU2 with the mbed microcontoller, just connect tx,rx,and reset
emmanuelchio 0:699e70ed46ee 5 Board:
emmanuelchio 1:39094523c711 6 http://www.vizictechnologies.com/
emmanuelchio 0:699e70ed46ee 7
emmanuelchio 0:699e70ed46ee 8 www.vizictechnologies.com
emmanuelchio 1:39094523c711 9 Vizic Technologies copyright 2014 */
emmanuelchio 0:699e70ed46ee 10 /**************************************************************************************/
emmanuelchio 1:39094523c711 11 /**************************************************************************************/
emmanuelchio 1:39094523c711 12
emmanuelchio 0:699e70ed46ee 13
emmanuelchio 0:699e70ed46ee 14 #include "mbed.h"
emmanuelchio 0:699e70ed46ee 15 #include "SMARTGPU2.h"
emmanuelchio 0:699e70ed46ee 16
emmanuelchio 0:699e70ed46ee 17 SMARTGPU2 lcd(TXPIN,RXPIN,RESETPIN); //create our object called "lcd"
emmanuelchio 0:699e70ed46ee 18
emmanuelchio 0:699e70ed46ee 19 char imagesOnSDCard[8][30]={"Penguins","Koala","Hydrangeas","Light House","Jellyfish","Tulips","Desert","Flower"}; //array containing the names of the different called images
emmanuelchio 0:699e70ed46ee 20
emmanuelchio 0:699e70ed46ee 21 /***************************************************/
emmanuelchio 0:699e70ed46ee 22 /***************************************************/
emmanuelchio 0:699e70ed46ee 23 void initializeSmartGPU2(void){ //Initialize SMARTGPU2 Board
emmanuelchio 0:699e70ed46ee 24 lcd.reset(); //physically reset SMARTGPU2
emmanuelchio 0:699e70ed46ee 25 lcd.start(); //initialize the SMARTGPU2 processor
emmanuelchio 0:699e70ed46ee 26 }
emmanuelchio 0:699e70ed46ee 27
emmanuelchio 0:699e70ed46ee 28 /***************************************************/
emmanuelchio 0:699e70ed46ee 29 /***************************************************/
emmanuelchio 0:699e70ed46ee 30 /***************************************************/
emmanuelchio 0:699e70ed46ee 31 /***************************************************/
emmanuelchio 0:699e70ed46ee 32 int main() {
emmanuelchio 0:699e70ed46ee 33 POINT point;
emmanuelchio 0:699e70ed46ee 34 char pic=0;
emmanuelchio 0:699e70ed46ee 35 unsigned char i=0;
emmanuelchio 0:699e70ed46ee 36 NUMBEROFBYTES charsPrinted;
emmanuelchio 0:699e70ed46ee 37
emmanuelchio 0:699e70ed46ee 38 initializeSmartGPU2(); //Init communication with SmartGPU2 board
emmanuelchio 0:699e70ed46ee 39
emmanuelchio 2:b40561f97cc5 40 lcd.baudChange(BAUD6); //set a fast baud! for fast drawing
emmanuelchio 2:b40561f97cc5 41 lcd.SDFopenDir("JPG Images"); // Open the JPG Images that contain the jpg images
emmanuelchio 0:699e70ed46ee 42 //strings config
emmanuelchio 0:699e70ed46ee 43 lcd.setTextColour(GREEN);
emmanuelchio 0:699e70ed46ee 44 lcd.setTextSize(FONT1);
emmanuelchio 0:699e70ed46ee 45
emmanuelchio 0:699e70ed46ee 46 while(1){ //Loop forever in the slide show!
emmanuelchio 0:699e70ed46ee 47 for(i=0;i<4;i++){
emmanuelchio 2:b40561f97cc5 48 lcd.imageJPGSD(i*(LCD_WIDTH/4),(LCD_HEIGHT/8),SCALE1_4,imagesOnSDCard[i]); //Load image from SD card
emmanuelchio 0:699e70ed46ee 49 }
emmanuelchio 0:699e70ed46ee 50 for(i=0;i<4;i++){
emmanuelchio 2:b40561f97cc5 51 lcd.imageJPGSD(i*(LCD_WIDTH/4),(LCD_HEIGHT/8)*5,SCALE1_4,imagesOnSDCard[i+4]); //Load image from SD card
emmanuelchio 0:699e70ed46ee 52 }
emmanuelchio 2:b40561f97cc5 53
emmanuelchio 2:b40561f97cc5 54 lcd.string(LCD_WIDTH/5,10,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"Touch image to load!",&charsPrinted);
emmanuelchio 2:b40561f97cc5 55 while(lcd.touchScreen(&point)==INVALID); //Wait for a touch on the screen to show next or previous picture
emmanuelchio 2:b40561f97cc5 56 lcd.erase();
emmanuelchio 0:699e70ed46ee 57
emmanuelchio 2:b40561f97cc5 58 if(point.y<(LCD_HEIGHT/2)){ //touch on upper part
emmanuelchio 0:699e70ed46ee 59 lcd.imageJPGSD(0,0,SCALE1_1,imagesOnSDCard[point.x/(LCD_WIDTH/4)]); //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:699e70ed46ee 60 }else{ //touch on upper part
emmanuelchio 0:699e70ed46ee 61 lcd.imageJPGSD(0,0,SCALE1_1,imagesOnSDCard[(point.x/(LCD_WIDTH/4))+4]); //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:699e70ed46ee 62 }
emmanuelchio 2:b40561f97cc5 63
emmanuelchio 2:b40561f97cc5 64 lcd.string(LCD_WIDTH/5,LCD_HEIGHT-25,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"Touch image to exit!",&charsPrinted);
emmanuelchio 0:699e70ed46ee 65 while(lcd.touchScreen(&point)==INVALID); //Wait for a touch on the screen to show next or previous picture
emmanuelchio 0:699e70ed46ee 66 lcd.erase();
emmanuelchio 0:699e70ed46ee 67 }
emmanuelchio 0:699e70ed46ee 68 }