Mini SmartGPU Intelligent Graphics Processor- Vizic Technologies 2012

Dependencies:   MINISMARTGPU mbed

Committer:
emmanuelchio
Date:
Thu Aug 30 21:56:04 2012 +0000
Revision:
0:6d5a476a1c20
Mini SmartGPU Intelligent Graphics Processor- Vizic Technologies 2012

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emmanuelchio 0:6d5a476a1c20 1 /*********************************************************
emmanuelchio 0:6d5a476a1c20 2 VIZIC TECHNOLOGIES. COPYRIGHT 2012.
emmanuelchio 0:6d5a476a1c20 3 THE DATASHEETS, SOFTWARE AND LIBRARIES ARE PROVIDED "AS IS."
emmanuelchio 0:6d5a476a1c20 4 VIZIC EXPRESSLY DISCLAIM ANY WARRANTY OF ANY KIND, WHETHER
emmanuelchio 0:6d5a476a1c20 5 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED
emmanuelchio 0:6d5a476a1c20 6 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
emmanuelchio 0:6d5a476a1c20 7 OR NONINFRINGEMENT. IN NO EVENT SHALL VIZIC BE LIABLE FOR
emmanuelchio 0:6d5a476a1c20 8 ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES,
emmanuelchio 0:6d5a476a1c20 9 LOST PROFITS OR LOST DATA, HARM TO YOUR EQUIPMENT, COST OF
emmanuelchio 0:6d5a476a1c20 10 PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES,
emmanuelchio 0:6d5a476a1c20 11 ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO
emmanuelchio 0:6d5a476a1c20 12 ANY DEFENCE THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION,
emmanuelchio 0:6d5a476a1c20 13 OR OTHER SIMILAR COSTS.
emmanuelchio 0:6d5a476a1c20 14 *********************************************************/
emmanuelchio 0:6d5a476a1c20 15 /**************************************************************************************/
emmanuelchio 0:6d5a476a1c20 16 /*MINI SMARTGPU intelligent embedded graphics processor unit
emmanuelchio 0:6d5a476a1c20 17 those examples are for use the MINI SMARTGPU with the mbed microcontoller, just connect tx,rx,and reset
emmanuelchio 0:6d5a476a1c20 18 Board:
emmanuelchio 0:6d5a476a1c20 19 http://vizictechnologies.com/#/mini-smart-gpu/4566376187
emmanuelchio 0:6d5a476a1c20 20
emmanuelchio 0:6d5a476a1c20 21 www.vizictechnologies.com
emmanuelchio 0:6d5a476a1c20 22 Vizic Technologies copyright 2012*/
emmanuelchio 0:6d5a476a1c20 23 /**************************************************************************************/
emmanuelchio 0:6d5a476a1c20 24 /**************************************************************************************/
emmanuelchio 0:6d5a476a1c20 25
emmanuelchio 0:6d5a476a1c20 26 #include "mbed.h"
emmanuelchio 0:6d5a476a1c20 27 #include "MINISMARTGPU.h"
emmanuelchio 0:6d5a476a1c20 28
emmanuelchio 0:6d5a476a1c20 29 MINISMARTGPU lcd(p13,p14,p15); //(TX,RX,Reset); Create Object "lcd"
emmanuelchio 0:6d5a476a1c20 30
emmanuelchio 0:6d5a476a1c20 31 #define secCol RED //seconds hand colour
emmanuelchio 0:6d5a476a1c20 32 #define minCol BLACK //minutes hand colour
emmanuelchio 0:6d5a476a1c20 33 #define hourCol BLACK //hours hand colour
emmanuelchio 0:6d5a476a1c20 34 #define halfx 80 //this point represent the x center of the clock where math is done
emmanuelchio 0:6d5a476a1c20 35 #define halfy 64 //this point represent the y center of the clock where math is done
emmanuelchio 0:6d5a476a1c20 36
emmanuelchio 0:6d5a476a1c20 37 /**********************************************************************************/
emmanuelchio 0:6d5a476a1c20 38 /**********************************************************************************/
emmanuelchio 0:6d5a476a1c20 39 /**********************************************************************************/
emmanuelchio 0:6d5a476a1c20 40 int main() {
emmanuelchio 0:6d5a476a1c20 41 int secs=0;
emmanuelchio 0:6d5a476a1c20 42 int mins=48;
emmanuelchio 0:6d5a476a1c20 43 int hours=4;
emmanuelchio 0:6d5a476a1c20 44 int xs,ys,xm,ym,xh,yh;
emmanuelchio 0:6d5a476a1c20 45 int angleH,angleM,angleS;
emmanuelchio 0:6d5a476a1c20 46 int handHour=23;//hand size
emmanuelchio 0:6d5a476a1c20 47 int handMin=26;//hand size
emmanuelchio 0:6d5a476a1c20 48 int handSec=31;//hand size
emmanuelchio 0:6d5a476a1c20 49
emmanuelchio 0:6d5a476a1c20 50 lcd.reset(); //physically reset MINISMARTGPU
emmanuelchio 0:6d5a476a1c20 51 lcd.start(); //initialize the MINISMARTGPU processor
emmanuelchio 0:6d5a476a1c20 52 wait_ms(200);
emmanuelchio 0:6d5a476a1c20 53
emmanuelchio 0:6d5a476a1c20 54 lcd.baudChange(1000000); //set high baud for fast drawing
emmanuelchio 0:6d5a476a1c20 55 lcd.imageSD(0,0,"oldClk"); //draw the clock body
emmanuelchio 0:6d5a476a1c20 56
emmanuelchio 0:6d5a476a1c20 57 while(1){
emmanuelchio 0:6d5a476a1c20 58 //Do some Math to get the second point of the clock hands. (first point is always the center of the clock)
emmanuelchio 0:6d5a476a1c20 59 angleS=secs*6; //get the current seconds in angle form, a circle have 360 degrees divided by 60 seconds = 6, then we multiply the 6 by the current seconds to get current angle
emmanuelchio 0:6d5a476a1c20 60 xs=(sin((angleS*3.14)/180)) * handSec; //get X component of the second's hand
emmanuelchio 0:6d5a476a1c20 61 ys=(cos((angleS*3.14)/180)) * handSec; //get Y component of the second's hand
emmanuelchio 0:6d5a476a1c20 62 angleM=mins*6; //get the current minutes in angle form, a circle have 360 degrees divided by 60 minutes = 6, then we multiply the 6 by the current minutes to get current angle
emmanuelchio 0:6d5a476a1c20 63 xm=(sin((angleM*3.14)/180)) * handMin; //get X component of the minutes's hand
emmanuelchio 0:6d5a476a1c20 64 ym=(cos((angleM*3.14)/180)) * handMin; //get Y component of the minutes's hand
emmanuelchio 0:6d5a476a1c20 65 angleH=hours*30; //get the current hours in angle form, a circle have 360 degrees divided by 12 hours = 30, then we multiply the 30 by the current hours to get current angle
emmanuelchio 0:6d5a476a1c20 66 xh=(sin((angleH*3.14)/180)) * handHour; //get X component of the hours's hand
emmanuelchio 0:6d5a476a1c20 67 yh=(cos((angleH*3.14)/180)) * handHour; //get Y component of the hours's hand
emmanuelchio 0:6d5a476a1c20 68
emmanuelchio 0:6d5a476a1c20 69 //Draw current time hands
emmanuelchio 0:6d5a476a1c20 70 lcd.drawLine(halfx,halfy,halfx+xm,halfy-ym,minCol); // Draw the minutes hand, first point is the center of the clock, and the second is the point obtained by doing math
emmanuelchio 0:6d5a476a1c20 71 lcd.drawLine(halfx,halfy,halfx+xh,halfy-yh,hourCol); // Draw the hours hand, first point is the center of the clock, and the second is the point obtained by doing math
emmanuelchio 0:6d5a476a1c20 72 lcd.drawLine(halfx,halfy,halfx+xs,halfy-ys,secCol); // Draw the seconds hand, first point is the center of the clock, and the second is the point obtained by doing math
emmanuelchio 0:6d5a476a1c20 73 lcd.drawCircle(halfx,halfy,2,secCol,FILL); // Draw the center of the second's hand
emmanuelchio 0:6d5a476a1c20 74
emmanuelchio 0:6d5a476a1c20 75 wait_ms(1000); // wait for one second delay (we dont need to explain why we're waiting one second, right?)
emmanuelchio 0:6d5a476a1c20 76
emmanuelchio 0:6d5a476a1c20 77 secs++; // increase seconds
emmanuelchio 0:6d5a476a1c20 78 if(secs==60){ // if we reach 60 seconds
emmanuelchio 0:6d5a476a1c20 79 mins++; // increase the minutes
emmanuelchio 0:6d5a476a1c20 80 if(mins==60){ // if we reach 60 minutes
emmanuelchio 0:6d5a476a1c20 81 hours++; // increase the minutes
emmanuelchio 0:6d5a476a1c20 82 if(hours==12){ // if we reach 12 hours
emmanuelchio 0:6d5a476a1c20 83 hours=0; // clear hours
emmanuelchio 0:6d5a476a1c20 84 }
emmanuelchio 0:6d5a476a1c20 85 mins=0; // clear minutes
emmanuelchio 0:6d5a476a1c20 86 }
emmanuelchio 0:6d5a476a1c20 87 secs=0; // clear seconds
emmanuelchio 0:6d5a476a1c20 88 }
emmanuelchio 0:6d5a476a1c20 89
emmanuelchio 0:6d5a476a1c20 90 //Erase all hands
emmanuelchio 0:6d5a476a1c20 91 lcd.drawLine(halfx,halfy,halfx+xs,halfy-ys,WHITE); // Erase Second's hand
emmanuelchio 0:6d5a476a1c20 92 lcd.drawLine(halfx,halfy,halfx+xm,halfy-ym,WHITE); // Erase Minute's hand
emmanuelchio 0:6d5a476a1c20 93 lcd.drawLine(halfx,halfy,halfx+xh,halfy-yh,WHITE); // Erase Hour's hand
emmanuelchio 0:6d5a476a1c20 94 }
emmanuelchio 0:6d5a476a1c20 95 }