Simple Window Demo - MBED + SmartGPU2 board

Dependencies:   SMARTGPU2 mbed

Committer:
emmanuelchio
Date:
Thu Apr 17 23:55:22 2014 +0000
Revision:
1:4a3db447aab6
Parent:
0:ad63c7ad3951
SmartGPU2 Window_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:4a3db447aab6 1 /**************************************************************************************/
emmanuelchio 0:ad63c7ad3951 2 /**************************************************************************************/
emmanuelchio 0:ad63c7ad3951 3 /*SMARTGPU2 intelligent embedded graphics processor unit
emmanuelchio 1:4a3db447aab6 4 those examples are for using the SMARTGPU2 with the mbed microcontoller, just connect tx,rx,and reset
emmanuelchio 0:ad63c7ad3951 5 Board:
emmanuelchio 1:4a3db447aab6 6 http://www.vizictechnologies.com/
emmanuelchio 0:ad63c7ad3951 7
emmanuelchio 0:ad63c7ad3951 8 www.vizictechnologies.com
emmanuelchio 1:4a3db447aab6 9 Vizic Technologies copyright 2014 */
emmanuelchio 0:ad63c7ad3951 10 /**************************************************************************************/
emmanuelchio 0:ad63c7ad3951 11 /**************************************************************************************/
emmanuelchio 0:ad63c7ad3951 12
emmanuelchio 0:ad63c7ad3951 13 #include "mbed.h"
emmanuelchio 0:ad63c7ad3951 14 #include "SMARTGPU2.h"
emmanuelchio 0:ad63c7ad3951 15
emmanuelchio 0:ad63c7ad3951 16 SMARTGPU2 lcd(TXPIN,RXPIN,RESETPIN); //create our object called "lcd"
emmanuelchio 0:ad63c7ad3951 17
emmanuelchio 0:ad63c7ad3951 18 //FUNCTION THAT DRAWS A MANUAL WINDOW
emmanuelchio 0:ad63c7ad3951 19 /***************************************************/
emmanuelchio 0:ad63c7ad3951 20 void createWindow(AXIS x1, AXIS y1, AXIS x2, AXIS y2, COLOUR top, COLOUR text, char *name){
emmanuelchio 0:ad63c7ad3951 21 AXIS aux;
emmanuelchio 0:ad63c7ad3951 22 NUMBEROFBYTES charsPrinted;
emmanuelchio 0:ad63c7ad3951 23
emmanuelchio 0:ad63c7ad3951 24 lcd.setTextSize(FONT3);
emmanuelchio 0:ad63c7ad3951 25 lcd.drawRectangle(x1,y1,x2,y2,0xDEFB,FILL); //draw grey 0xDEFB back
emmanuelchio 0:ad63c7ad3951 26 aux = ((y2-y1) * 20) / 100;
emmanuelchio 0:ad63c7ad3951 27 if(aux<10) aux=10;
emmanuelchio 0:ad63c7ad3951 28 lcd.drawGradientRect(x1,y1,x2-1,y1+aux,top,WHITE,VERTICAL); //draw top
emmanuelchio 0:ad63c7ad3951 29 lcd.drawLine(x1,y1,x2,y1,WHITE);
emmanuelchio 0:ad63c7ad3951 30 lcd.drawLine(x1,y2,x2,y2,BLACK);
emmanuelchio 0:ad63c7ad3951 31 lcd.drawLine(x1,y1,x1,y2,WHITE);
emmanuelchio 0:ad63c7ad3951 32 lcd.drawLine(x2,y1,x2,y2,BLACK);
emmanuelchio 0:ad63c7ad3951 33 lcd.string(x1+5,y1+5,x2,y2,name,&charsPrinted);
emmanuelchio 0:ad63c7ad3951 34 }
emmanuelchio 0:ad63c7ad3951 35
emmanuelchio 0:ad63c7ad3951 36 /***************************************************/
emmanuelchio 0:ad63c7ad3951 37 /***************************************************/
emmanuelchio 0:ad63c7ad3951 38 void initializeSmartGPU2(void){ //Initialize SMARTGPU2 Board
emmanuelchio 0:ad63c7ad3951 39 lcd.reset(); //physically reset SMARTGPU2
emmanuelchio 0:ad63c7ad3951 40 lcd.start(); //initialize the SMARTGPU2 processor
emmanuelchio 0:ad63c7ad3951 41 }
emmanuelchio 0:ad63c7ad3951 42
emmanuelchio 0:ad63c7ad3951 43 /***************************************************/
emmanuelchio 0:ad63c7ad3951 44 /***************************************************/
emmanuelchio 0:ad63c7ad3951 45 /***************************************************/
emmanuelchio 0:ad63c7ad3951 46 /***************************************************/
emmanuelchio 0:ad63c7ad3951 47 int main() {
emmanuelchio 0:ad63c7ad3951 48
emmanuelchio 0:ad63c7ad3951 49 initializeSmartGPU2(); //Init communication with SmartGPU2 board
emmanuelchio 0:ad63c7ad3951 50
emmanuelchio 0:ad63c7ad3951 51 lcd.baudChange(BAUD7); //set a fast baud! for fast drawing
emmanuelchio 0:ad63c7ad3951 52
emmanuelchio 0:ad63c7ad3951 53 lcd.setEraseBackColour(GREEN); //set the erase background colour
emmanuelchio 0:ad63c7ad3951 54
emmanuelchio 0:ad63c7ad3951 55 while(1){//forever
emmanuelchio 0:ad63c7ad3951 56 //erase screen
emmanuelchio 0:ad63c7ad3951 57 lcd.erase();
emmanuelchio 0:ad63c7ad3951 58 //draw the manual window
emmanuelchio 0:ad63c7ad3951 59 createWindow(20,20,300,200,BLUE,WHITE,"window 1");
emmanuelchio 0:ad63c7ad3951 60 //wait
emmanuelchio 0:ad63c7ad3951 61 wait_ms(3000);
emmanuelchio 0:ad63c7ad3951 62
emmanuelchio 0:ad63c7ad3951 63 //erase screen
emmanuelchio 0:ad63c7ad3951 64 lcd.erase();
emmanuelchio 0:ad63c7ad3951 65 //draw the internal SmartGPU2 object window
emmanuelchio 0:ad63c7ad3951 66 lcd.objWindow(20,20,300,200,FONT2,SELECTEDGRAY,"window 1");
emmanuelchio 0:ad63c7ad3951 67 //wait
emmanuelchio 0:ad63c7ad3951 68 wait_ms(3000);
emmanuelchio 0:ad63c7ad3951 69 }
emmanuelchio 0:ad63c7ad3951 70 }