Simple Window Demo - MBED + SmartGPU2 board

Dependencies:   SMARTGPU2 mbed

Committer:
emmanuelchio
Date:
Wed Jul 10 03:44:07 2013 +0000
Revision:
0:ad63c7ad3951
Child:
1:4a3db447aab6
Simple Window - MBED + SmartGPU2 board

Who changed what in which revision?

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