Mini SmartGPU Intelligent Graphics Processor- Vizic Technologies 2012

Dependencies:   MINISMARTGPU mbed

Committer:
emmanuelchio
Date:
Thu Aug 30 21:51:28 2012 +0000
Revision:
0:59e3d3991c14
Mini SmartGPU Intelligent Graphics Processor- Vizic Technologies 2012

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emmanuelchio 0:59e3d3991c14 1 /*********************************************************
emmanuelchio 0:59e3d3991c14 2 VIZIC TECHNOLOGIES. COPYRIGHT 2012.
emmanuelchio 0:59e3d3991c14 3 THE DATASHEETS, SOFTWARE AND LIBRARIES ARE PROVIDED "AS IS."
emmanuelchio 0:59e3d3991c14 4 VIZIC EXPRESSLY DISCLAIM ANY WARRANTY OF ANY KIND, WHETHER
emmanuelchio 0:59e3d3991c14 5 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED
emmanuelchio 0:59e3d3991c14 6 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
emmanuelchio 0:59e3d3991c14 7 OR NONINFRINGEMENT. IN NO EVENT SHALL VIZIC BE LIABLE FOR
emmanuelchio 0:59e3d3991c14 8 ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES,
emmanuelchio 0:59e3d3991c14 9 LOST PROFITS OR LOST DATA, HARM TO YOUR EQUIPMENT, COST OF
emmanuelchio 0:59e3d3991c14 10 PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES,
emmanuelchio 0:59e3d3991c14 11 ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO
emmanuelchio 0:59e3d3991c14 12 ANY DEFENCE THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION,
emmanuelchio 0:59e3d3991c14 13 OR OTHER SIMILAR COSTS.
emmanuelchio 0:59e3d3991c14 14 *********************************************************/
emmanuelchio 0:59e3d3991c14 15 /**************************************************************************************/
emmanuelchio 0:59e3d3991c14 16 /*MINI SMARTGPU intelligent embedded graphics processor unit
emmanuelchio 0:59e3d3991c14 17 those examples are for use the MINI SMARTGPU with the mbed microcontoller, just connect tx,rx,and reset
emmanuelchio 0:59e3d3991c14 18 Board:
emmanuelchio 0:59e3d3991c14 19 http://vizictechnologies.com/#/mini-smart-gpu/4566376187
emmanuelchio 0:59e3d3991c14 20
emmanuelchio 0:59e3d3991c14 21 www.vizictechnologies.com
emmanuelchio 0:59e3d3991c14 22 Vizic Technologies copyright 2012*/
emmanuelchio 0:59e3d3991c14 23 /**************************************************************************************/
emmanuelchio 0:59e3d3991c14 24 /**************************************************************************************/
emmanuelchio 0:59e3d3991c14 25
emmanuelchio 0:59e3d3991c14 26 #include "mbed.h"
emmanuelchio 0:59e3d3991c14 27 #include "MINISMARTGPU.h"
emmanuelchio 0:59e3d3991c14 28
emmanuelchio 0:59e3d3991c14 29 MINISMARTGPU lcd(p13,p14,p15); //(TX,RX,Reset); Create Object "lcd"
emmanuelchio 0:59e3d3991c14 30
emmanuelchio 0:59e3d3991c14 31 // defines for balls
emmanuelchio 0:59e3d3991c14 32 #define radiusBall1 7 //ball1 size
emmanuelchio 0:59e3d3991c14 33 #define colourBall1 RED //ball1 colour
emmanuelchio 0:59e3d3991c14 34
emmanuelchio 0:59e3d3991c14 35 //variables used by move ball method
emmanuelchio 0:59e3d3991c14 36 int speedBall1=2; //ball1 moving speed - amount of pixels that ball move each time
emmanuelchio 0:59e3d3991c14 37 int dirx1=1; //xball1 initial positive direction
emmanuelchio 0:59e3d3991c14 38 int diry1=-1; //yball1 initial negative direction
emmanuelchio 0:59e3d3991c14 39 int xBall1=80; //x initial position of ball1
emmanuelchio 0:59e3d3991c14 40 int yBall1=60; //y initial position of ball1
emmanuelchio 0:59e3d3991c14 41
emmanuelchio 0:59e3d3991c14 42 /***************************************************/
emmanuelchio 0:59e3d3991c14 43 //Function that updates the current position of the ball1
emmanuelchio 0:59e3d3991c14 44 void moveBall1(){
emmanuelchio 0:59e3d3991c14 45 lcd.drawCircle(xBall1,yBall1,radiusBall1,BLACK,FILL); // Erase previous ball position
emmanuelchio 0:59e3d3991c14 46 xBall1+=(dirx1*speedBall1); // Calculate new x coordinate for ball1
emmanuelchio 0:59e3d3991c14 47 yBall1+=(diry1*speedBall1); // Calculate new y coordinate for ball1
emmanuelchio 0:59e3d3991c14 48 lcd.drawCircle(xBall1,yBall1,radiusBall1,colourBall1,FILL); // Draw new ball position
emmanuelchio 0:59e3d3991c14 49 if((xBall1+speedBall1+radiusBall1)>158 | (xBall1-speedBall1-radiusBall1)<=1){ // if ball reaches the left or right corner, we invert moving direction
emmanuelchio 0:59e3d3991c14 50 dirx1= dirx1*(-1); // Invert the moving direction by multiplying by -1
emmanuelchio 0:59e3d3991c14 51 }
emmanuelchio 0:59e3d3991c14 52 if((yBall1+speedBall1+radiusBall1)>126 | (yBall1-speedBall1-radiusBall1)<=1){ // if ball reaches the top or bottom corner, we invert moving direction
emmanuelchio 0:59e3d3991c14 53 diry1= diry1*(-1); // Invert the moving direction by multiplying by -1
emmanuelchio 0:59e3d3991c14 54 }
emmanuelchio 0:59e3d3991c14 55 }
emmanuelchio 0:59e3d3991c14 56
emmanuelchio 0:59e3d3991c14 57 /**********************************************************************************/
emmanuelchio 0:59e3d3991c14 58 /**********************************************************************************/
emmanuelchio 0:59e3d3991c14 59 /**********************************************************************************/
emmanuelchio 0:59e3d3991c14 60 int main() {
emmanuelchio 0:59e3d3991c14 61 lcd.reset(); //physically reset MINISMARTGPU
emmanuelchio 0:59e3d3991c14 62 lcd.start(); //initialize the MINISMARTGPU processor
emmanuelchio 0:59e3d3991c14 63 wait_ms(200);
emmanuelchio 0:59e3d3991c14 64
emmanuelchio 0:59e3d3991c14 65 lcd.baudChange(1000000); //set a fast baud! for fast drawing
emmanuelchio 0:59e3d3991c14 66 lcd.drawRectangle(0,0,159,127,YELLOW,UNFILL); //draw corners
emmanuelchio 0:59e3d3991c14 67
emmanuelchio 0:59e3d3991c14 68 while(1){ // Loop forever
emmanuelchio 0:59e3d3991c14 69 moveBall1(); // move ball1
emmanuelchio 0:59e3d3991c14 70 wait_ms(15); // wait a little
emmanuelchio 0:59e3d3991c14 71 }
emmanuelchio 0:59e3d3991c14 72 }