Mini SmartGPU Intelligent Graphics Processor- Vizic Technologies 2012

Dependencies:   MINISMARTGPU mbed

Committer:
emmanuelchio
Date:
Thu Aug 30 21:52:13 2012 +0000
Revision:
0:8d4b3e2f4958
Mini SmartGPU Intelligent Graphics Processor- Vizic Technologies 2012

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emmanuelchio 0:8d4b3e2f4958 1 /*********************************************************
emmanuelchio 0:8d4b3e2f4958 2 VIZIC TECHNOLOGIES. COPYRIGHT 2012.
emmanuelchio 0:8d4b3e2f4958 3 THE DATASHEETS, SOFTWARE AND LIBRARIES ARE PROVIDED "AS IS."
emmanuelchio 0:8d4b3e2f4958 4 VIZIC EXPRESSLY DISCLAIM ANY WARRANTY OF ANY KIND, WHETHER
emmanuelchio 0:8d4b3e2f4958 5 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED
emmanuelchio 0:8d4b3e2f4958 6 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
emmanuelchio 0:8d4b3e2f4958 7 OR NONINFRINGEMENT. IN NO EVENT SHALL VIZIC BE LIABLE FOR
emmanuelchio 0:8d4b3e2f4958 8 ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES,
emmanuelchio 0:8d4b3e2f4958 9 LOST PROFITS OR LOST DATA, HARM TO YOUR EQUIPMENT, COST OF
emmanuelchio 0:8d4b3e2f4958 10 PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES,
emmanuelchio 0:8d4b3e2f4958 11 ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO
emmanuelchio 0:8d4b3e2f4958 12 ANY DEFENCE THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION,
emmanuelchio 0:8d4b3e2f4958 13 OR OTHER SIMILAR COSTS.
emmanuelchio 0:8d4b3e2f4958 14 *********************************************************/
emmanuelchio 0:8d4b3e2f4958 15 /**************************************************************************************/
emmanuelchio 0:8d4b3e2f4958 16 /*MINI SMARTGPU intelligent embedded graphics processor unit
emmanuelchio 0:8d4b3e2f4958 17 those examples are for use the MINI SMARTGPU with the mbed microcontoller, just connect tx,rx,and reset
emmanuelchio 0:8d4b3e2f4958 18 Board:
emmanuelchio 0:8d4b3e2f4958 19 http://vizictechnologies.com/#/mini-smart-gpu/4566376187
emmanuelchio 0:8d4b3e2f4958 20
emmanuelchio 0:8d4b3e2f4958 21 www.vizictechnologies.com
emmanuelchio 0:8d4b3e2f4958 22 Vizic Technologies copyright 2012*/
emmanuelchio 0:8d4b3e2f4958 23 /**************************************************************************************/
emmanuelchio 0:8d4b3e2f4958 24 /**************************************************************************************/
emmanuelchio 0:8d4b3e2f4958 25
emmanuelchio 0:8d4b3e2f4958 26 #include "mbed.h"
emmanuelchio 0:8d4b3e2f4958 27 #include "MINISMARTGPU.h"
emmanuelchio 0:8d4b3e2f4958 28
emmanuelchio 0:8d4b3e2f4958 29 MINISMARTGPU lcd(p13,p14,p15); //(TX,RX,Reset); Create Object "lcd"
emmanuelchio 0:8d4b3e2f4958 30
emmanuelchio 0:8d4b3e2f4958 31 // defines for balls
emmanuelchio 0:8d4b3e2f4958 32 #define radiusBall1 10 //ball1 size
emmanuelchio 0:8d4b3e2f4958 33 #define colourBall1 GREEN //ball1 colour
emmanuelchio 0:8d4b3e2f4958 34 #define radiusBall2 5 //ball2 size
emmanuelchio 0:8d4b3e2f4958 35 #define colourBall2 YELLOW //ball2 colour
emmanuelchio 0:8d4b3e2f4958 36 #define radiusBall3 8 //ball3 size
emmanuelchio 0:8d4b3e2f4958 37 #define colourBall3 RED //ball3 colour
emmanuelchio 0:8d4b3e2f4958 38 #define radiusBall4 15 //ball4 size
emmanuelchio 0:8d4b3e2f4958 39 #define colourBall4 BLUE //ball4 colour
emmanuelchio 0:8d4b3e2f4958 40
emmanuelchio 0:8d4b3e2f4958 41 //variables used by move ball methods
emmanuelchio 0:8d4b3e2f4958 42 int speedBall1=2; //ball1 moving speed - amount of pixels that ball move each time
emmanuelchio 0:8d4b3e2f4958 43 int speedBall2=3; //ball2 moving speed - amount of pixels that ball move each time
emmanuelchio 0:8d4b3e2f4958 44 int speedBall3=5; //ball3 moving speed - amount of pixels that ball move each time
emmanuelchio 0:8d4b3e2f4958 45 int speedBall4=4; //ball4 moving speed - amount of pixels that ball move each time
emmanuelchio 0:8d4b3e2f4958 46 int dirx1=1; //xball1 initial positive direction
emmanuelchio 0:8d4b3e2f4958 47 int diry1=1; //yball1 initial positive direction
emmanuelchio 0:8d4b3e2f4958 48 int xBall1=110; //x initial position of ball1
emmanuelchio 0:8d4b3e2f4958 49 int yBall1=80; //y initial position of ball1
emmanuelchio 0:8d4b3e2f4958 50 int dirx2=-1; //xball2 initial negative direction
emmanuelchio 0:8d4b3e2f4958 51 int diry2=-1; //yball2 initial negative direction
emmanuelchio 0:8d4b3e2f4958 52 int xBall2=20; //x initial position of ball2
emmanuelchio 0:8d4b3e2f4958 53 int yBall2=70; //y initial position of ball2
emmanuelchio 0:8d4b3e2f4958 54 int dirx3=-1; //xball3 initial negative direction
emmanuelchio 0:8d4b3e2f4958 55 int diry3=1; //yball3 initial negative direction
emmanuelchio 0:8d4b3e2f4958 56 int xBall3=60; //x initial position of ball3
emmanuelchio 0:8d4b3e2f4958 57 int yBall3=15; //y initial position of ball3
emmanuelchio 0:8d4b3e2f4958 58 int dirx4=1; //xball4 initial negative direction
emmanuelchio 0:8d4b3e2f4958 59 int diry4=-1; //yball4 initial negative direction
emmanuelchio 0:8d4b3e2f4958 60 int xBall4=130; //x initial position of ball4
emmanuelchio 0:8d4b3e2f4958 61 int yBall4=80; //y initial position of ball4
emmanuelchio 0:8d4b3e2f4958 62
emmanuelchio 0:8d4b3e2f4958 63 /***************************************************/
emmanuelchio 0:8d4b3e2f4958 64 //Function that updates the current position of the ball1
emmanuelchio 0:8d4b3e2f4958 65 void moveBall1(){
emmanuelchio 0:8d4b3e2f4958 66 lcd.drawCircle(xBall1,yBall1,radiusBall1,BLACK,UNFILL); // Erase previous ball position
emmanuelchio 0:8d4b3e2f4958 67 xBall1+=(dirx1*speedBall1); // Calculate new x coordinate for ball1
emmanuelchio 0:8d4b3e2f4958 68 yBall1+=(diry1*speedBall1); // Calculate new y coordinate for ball1
emmanuelchio 0:8d4b3e2f4958 69 lcd.drawCircle(xBall1,yBall1,radiusBall1,colourBall1,UNFILL); // Draw new ball position
emmanuelchio 0:8d4b3e2f4958 70 if((xBall1+speedBall1+radiusBall1)>158 | (xBall1-speedBall1-radiusBall1)<=1){ // if ball reaches the left or right corner, we invert moving direction
emmanuelchio 0:8d4b3e2f4958 71 dirx1= dirx1*(-1); // Invert the moving direction by multiplying by -1
emmanuelchio 0:8d4b3e2f4958 72 }
emmanuelchio 0:8d4b3e2f4958 73 if((yBall1+speedBall1+radiusBall1)>126 | (yBall1-speedBall1-radiusBall1)<=1){ // if ball reaches the top or bottom corner, we invert moving direction
emmanuelchio 0:8d4b3e2f4958 74 diry1= diry1*(-1); // Invert the moving direction by multiplying by -1
emmanuelchio 0:8d4b3e2f4958 75 }
emmanuelchio 0:8d4b3e2f4958 76 }
emmanuelchio 0:8d4b3e2f4958 77
emmanuelchio 0:8d4b3e2f4958 78 /***************************************************/
emmanuelchio 0:8d4b3e2f4958 79 //Function that updates the current position of the ball2
emmanuelchio 0:8d4b3e2f4958 80 void moveBall2(){
emmanuelchio 0:8d4b3e2f4958 81 lcd.drawCircle(xBall2,yBall2,radiusBall2,BLACK,FILL); // Erase previous ball position
emmanuelchio 0:8d4b3e2f4958 82 xBall2+=(dirx2*speedBall2); // Calculate new x coordinate for ball2
emmanuelchio 0:8d4b3e2f4958 83 yBall2+=(diry2*speedBall2); // Calculate new y coordinate for ball2
emmanuelchio 0:8d4b3e2f4958 84 lcd.drawCircle(xBall2,yBall2,radiusBall2,colourBall2,FILL); // Draw new ball position
emmanuelchio 0:8d4b3e2f4958 85 if((xBall2+speedBall2+radiusBall2)>158 | (xBall2-speedBall2-radiusBall2)<=1){ // if ball reaches the left or right corner, we invert moving direction
emmanuelchio 0:8d4b3e2f4958 86 dirx2= dirx2*(-1); // Invert the moving direction by multiplying by -1
emmanuelchio 0:8d4b3e2f4958 87 }
emmanuelchio 0:8d4b3e2f4958 88 if((yBall2+speedBall2+radiusBall2)>126 | (yBall2-speedBall2-radiusBall2)<=1){ // if ball reaches the top or bottom corner, we invert moving direction
emmanuelchio 0:8d4b3e2f4958 89 diry2= diry2*(-1); // Invert the moving direction by multiplying by -1
emmanuelchio 0:8d4b3e2f4958 90 }
emmanuelchio 0:8d4b3e2f4958 91 }
emmanuelchio 0:8d4b3e2f4958 92
emmanuelchio 0:8d4b3e2f4958 93 /***************************************************/
emmanuelchio 0:8d4b3e2f4958 94 //Function that updates the current position of the ball3
emmanuelchio 0:8d4b3e2f4958 95 void moveBall3(){
emmanuelchio 0:8d4b3e2f4958 96 lcd.drawCircle(xBall3,yBall3,radiusBall3,BLACK,FILL); // Erase previous ball position
emmanuelchio 0:8d4b3e2f4958 97 xBall3+=(dirx3*speedBall3); // Calculate new x coordinate for ball3
emmanuelchio 0:8d4b3e2f4958 98 yBall3+=(diry3*speedBall3); // Calculate new y coordinate for ball3
emmanuelchio 0:8d4b3e2f4958 99 lcd.drawCircle(xBall3,yBall3,radiusBall3,colourBall3,FILL); // Draw new ball position
emmanuelchio 0:8d4b3e2f4958 100 if((xBall3+speedBall3+radiusBall3)>158 | (xBall3-speedBall3-radiusBall3)<=1){ // if ball reaches the left or right corner, we invert moving direction
emmanuelchio 0:8d4b3e2f4958 101 dirx3= dirx3*(-1); // Invert the moving direction by multiplying by -1
emmanuelchio 0:8d4b3e2f4958 102 }
emmanuelchio 0:8d4b3e2f4958 103 if((yBall3+speedBall3+radiusBall3)>126 | (yBall3-speedBall3-radiusBall3)<=1){ // if ball reaches the top or bottom corner, we invert moving direction
emmanuelchio 0:8d4b3e2f4958 104 diry3= diry3*(-1); // Invert the moving direction by multiplying by -1
emmanuelchio 0:8d4b3e2f4958 105 }
emmanuelchio 0:8d4b3e2f4958 106 }
emmanuelchio 0:8d4b3e2f4958 107
emmanuelchio 0:8d4b3e2f4958 108 /***************************************************/
emmanuelchio 0:8d4b3e2f4958 109 //Function that updates the current position of the ball4
emmanuelchio 0:8d4b3e2f4958 110 void moveBall4(){
emmanuelchio 0:8d4b3e2f4958 111 lcd.drawCircle(xBall4,yBall4,radiusBall4,BLACK,UNFILL); // Erase previous ball position
emmanuelchio 0:8d4b3e2f4958 112 xBall4+=(dirx4*speedBall4); // Calculate new x coordinate for ball4
emmanuelchio 0:8d4b3e2f4958 113 yBall4+=(diry4*speedBall4); // Calculate new y coordinate for ball4
emmanuelchio 0:8d4b3e2f4958 114 lcd.drawCircle(xBall4,yBall4,radiusBall4,colourBall4,UNFILL); // Draw new ball position
emmanuelchio 0:8d4b3e2f4958 115 if((xBall4+speedBall4+radiusBall4)>158 | (xBall4-speedBall4-radiusBall4)<=1){ // if ball reaches the left or right corner, we invert moving direction
emmanuelchio 0:8d4b3e2f4958 116 dirx4= dirx4*(-1); // Invert the moving direction by multiplying by -1
emmanuelchio 0:8d4b3e2f4958 117 }
emmanuelchio 0:8d4b3e2f4958 118 if((yBall4+speedBall4+radiusBall4)>126 | (yBall4-speedBall4-radiusBall4)<=1){ // if ball reaches the top or bottom corner, we invert moving direction
emmanuelchio 0:8d4b3e2f4958 119 diry4= diry4*(-1); // Invert the moving direction by multiplying by -1
emmanuelchio 0:8d4b3e2f4958 120 }
emmanuelchio 0:8d4b3e2f4958 121 }
emmanuelchio 0:8d4b3e2f4958 122
emmanuelchio 0:8d4b3e2f4958 123 /**********************************************************************************/
emmanuelchio 0:8d4b3e2f4958 124 /**********************************************************************************/
emmanuelchio 0:8d4b3e2f4958 125 /**********************************************************************************/
emmanuelchio 0:8d4b3e2f4958 126 int main() {
emmanuelchio 0:8d4b3e2f4958 127 lcd.reset(); //physically reset MINISMARTGPU
emmanuelchio 0:8d4b3e2f4958 128 lcd.start(); //initialize the MINISMARTGPU processor
emmanuelchio 0:8d4b3e2f4958 129 wait_ms(200);
emmanuelchio 0:8d4b3e2f4958 130
emmanuelchio 0:8d4b3e2f4958 131 lcd.baudChange(1000000); //set a fast baud! for fast drawing
emmanuelchio 0:8d4b3e2f4958 132 lcd.drawRectangle(0,0,159,127,MAGENTA,UNFILL); //draw corners
emmanuelchio 0:8d4b3e2f4958 133
emmanuelchio 0:8d4b3e2f4958 134 while(1){ // Loop forever
emmanuelchio 0:8d4b3e2f4958 135 moveBall1(); // move ball1
emmanuelchio 0:8d4b3e2f4958 136 moveBall2(); // move ball2
emmanuelchio 0:8d4b3e2f4958 137 moveBall3(); // move ball3
emmanuelchio 0:8d4b3e2f4958 138 moveBall4(); // move ball4
emmanuelchio 0:8d4b3e2f4958 139 wait_ms(15); // wait a little
emmanuelchio 0:8d4b3e2f4958 140 }
emmanuelchio 0:8d4b3e2f4958 141 }