Triangle Drawing Demo - MBED + SmartGPU2 board

Dependencies:   SMARTGPU2 mbed

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