Triangle Drawing Demo - MBED + SmartGPU2 board

Dependencies:   SMARTGPU2 mbed

Committer:
emmanuelchio
Date:
Wed Jul 10 03:42:12 2013 +0000
Revision:
0:6c3f2e4dca14
Child:
1:28df954ecec5
Triangles Demo - MBED + SmartGPU2 board

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emmanuelchio 0:6c3f2e4dca14 1 /**************************************************************************************/
emmanuelchio 0:6c3f2e4dca14 2 /*SMARTGPU2 intelligent embedded graphics processor unit
emmanuelchio 0:6c3f2e4dca14 3 those examples are for use the SMARTGPU2 with the mbed microcontoller, just connect tx,rx,and reset
emmanuelchio 0:6c3f2e4dca14 4 Board:
emmanuelchio 0:6c3f2e4dca14 5 http://vizictechnologies.com/#/smart-gpu-2/4577779046
emmanuelchio 0:6c3f2e4dca14 6
emmanuelchio 0:6c3f2e4dca14 7 www.vizictechnologies.com
emmanuelchio 0:6c3f2e4dca14 8 Vizic Technologies copyright 2013 */
emmanuelchio 0:6c3f2e4dca14 9 /**************************************************************************************/
emmanuelchio 0:6c3f2e4dca14 10
emmanuelchio 0:6c3f2e4dca14 11 #include "mbed.h"
emmanuelchio 0:6c3f2e4dca14 12 #include "SMARTGPU2.h"
emmanuelchio 0:6c3f2e4dca14 13
emmanuelchio 0:6c3f2e4dca14 14 SMARTGPU2 lcd(TXPIN,RXPIN,RESETPIN); //create our object called "lcd"
emmanuelchio 0:6c3f2e4dca14 15
emmanuelchio 0:6c3f2e4dca14 16
emmanuelchio 0:6c3f2e4dca14 17 /***************************************************/
emmanuelchio 0:6c3f2e4dca14 18 /***************************************************/
emmanuelchio 0:6c3f2e4dca14 19 void initializeSmartGPU2(void){ //Initialize SMARTGPU2 Board
emmanuelchio 0:6c3f2e4dca14 20 lcd.reset(); //physically reset SMARTGPU2
emmanuelchio 0:6c3f2e4dca14 21 lcd.start(); //initialize the SMARTGPU2 processor
emmanuelchio 0:6c3f2e4dca14 22 }
emmanuelchio 0:6c3f2e4dca14 23
emmanuelchio 0:6c3f2e4dca14 24 /***************************************************/
emmanuelchio 0:6c3f2e4dca14 25 /***************************************************/
emmanuelchio 0:6c3f2e4dca14 26 /***************************************************/
emmanuelchio 0:6c3f2e4dca14 27 /***************************************************/
emmanuelchio 0:6c3f2e4dca14 28 int main() {
emmanuelchio 0:6c3f2e4dca14 29 POINT p1, p2, p3;
emmanuelchio 0:6c3f2e4dca14 30 COLOUR colour;
emmanuelchio 0:6c3f2e4dca14 31 FILLGEOM fill;
emmanuelchio 0:6c3f2e4dca14 32
emmanuelchio 0:6c3f2e4dca14 33 initializeSmartGPU2(); //Init communication with SmartGPU2 board
emmanuelchio 0:6c3f2e4dca14 34
emmanuelchio 0:6c3f2e4dca14 35 lcd.baudChange(BAUD7); //set a fast baud! for fast drawing
emmanuelchio 0:6c3f2e4dca14 36
emmanuelchio 0:6c3f2e4dca14 37 while(1){//forever
emmanuelchio 0:6c3f2e4dca14 38 p1.x= (rand()%LCD_WIDTH); //get a random number 0-319
emmanuelchio 0:6c3f2e4dca14 39 p1.y= (rand()%LCD_HEIGHT); //get a random number 0-239
emmanuelchio 0:6c3f2e4dca14 40 p2.x= (rand()%LCD_WIDTH); //get a random number 0-319
emmanuelchio 0:6c3f2e4dca14 41 p2.y= (rand()%LCD_HEIGHT); //get a random number 0-239
emmanuelchio 0:6c3f2e4dca14 42 p3.x= (rand()%LCD_WIDTH); //get a random number 0-319
emmanuelchio 0:6c3f2e4dca14 43 p3.y= (rand()%LCD_HEIGHT); //get a random number 0-239
emmanuelchio 0:6c3f2e4dca14 44 colour= (rand()%65536); //get a random number 0-65535
emmanuelchio 0:6c3f2e4dca14 45 fill=(FILLGEOM)(rand()%2); //get a random number 0-1
emmanuelchio 0:6c3f2e4dca14 46
emmanuelchio 0:6c3f2e4dca14 47 //draw the triangle
emmanuelchio 0:6c3f2e4dca14 48 if(lcd.drawTriangle(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, colour,fill) != 'O'){ //draw random triangles
emmanuelchio 0:6c3f2e4dca14 49 while(1); //loop forever if different than 'O'--OK
emmanuelchio 0:6c3f2e4dca14 50 }
emmanuelchio 0:6c3f2e4dca14 51 }
emmanuelchio 0:6c3f2e4dca14 52 }