Simple Paint Demo - MBED + SmartGPU2 board

Dependencies:   SMARTGPU2 mbed

Committer:
emmanuelchio
Date:
Wed Jul 10 03:41:40 2013 +0000
Revision:
0:b6d1a54b364d
Child:
1:1111ecf2d67c
Simple Paint Demo - MBED + SmartGPU2 board

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emmanuelchio 0:b6d1a54b364d 1 /**************************************************************************************/
emmanuelchio 0:b6d1a54b364d 2 /*SMARTGPU2 intelligent embedded graphics processor unit
emmanuelchio 0:b6d1a54b364d 3 those examples are for use the SMARTGPU2 with the mbed microcontoller, just connect tx,rx,and reset
emmanuelchio 0:b6d1a54b364d 4 Board:
emmanuelchio 0:b6d1a54b364d 5 http://vizictechnologies.com/#/smart-gpu-2/4577779046
emmanuelchio 0:b6d1a54b364d 6
emmanuelchio 0:b6d1a54b364d 7 www.vizictechnologies.com
emmanuelchio 0:b6d1a54b364d 8 Vizic Technologies copyright 2013 */
emmanuelchio 0:b6d1a54b364d 9 /**************************************************************************************/
emmanuelchio 0:b6d1a54b364d 10
emmanuelchio 0:b6d1a54b364d 11 #include "mbed.h"
emmanuelchio 0:b6d1a54b364d 12 #include "SMARTGPU2.h"
emmanuelchio 0:b6d1a54b364d 13
emmanuelchio 0:b6d1a54b364d 14 SMARTGPU2 lcd(TXPIN,RXPIN,RESETPIN); //create our object called "lcd"
emmanuelchio 0:b6d1a54b364d 15
emmanuelchio 0:b6d1a54b364d 16 #define PENSIZE 1 //size of the drawing pen
emmanuelchio 0:b6d1a54b364d 17
emmanuelchio 0:b6d1a54b364d 18 /***************************************************/
emmanuelchio 0:b6d1a54b364d 19 /***************************************************/
emmanuelchio 0:b6d1a54b364d 20 void initializeSmartGPU2(void){ //Initialize SMARTGPU2 Board
emmanuelchio 0:b6d1a54b364d 21 lcd.reset(); //physically reset SMARTGPU2
emmanuelchio 0:b6d1a54b364d 22 lcd.start(); //initialize the SMARTGPU2 processor
emmanuelchio 0:b6d1a54b364d 23 }
emmanuelchio 0:b6d1a54b364d 24
emmanuelchio 0:b6d1a54b364d 25 /***************************************************/
emmanuelchio 0:b6d1a54b364d 26 /***************************************************/
emmanuelchio 0:b6d1a54b364d 27 /***************************************************/
emmanuelchio 0:b6d1a54b364d 28 /***************************************************/
emmanuelchio 0:b6d1a54b364d 29 int main() {
emmanuelchio 0:b6d1a54b364d 30 POINT point;
emmanuelchio 0:b6d1a54b364d 31 ICON icon;
emmanuelchio 0:b6d1a54b364d 32 NUMBEROFBYTES charsPrinted;
emmanuelchio 0:b6d1a54b364d 33
emmanuelchio 0:b6d1a54b364d 34 initializeSmartGPU2(); //Init communication with SmartGPU2 board
emmanuelchio 0:b6d1a54b364d 35
emmanuelchio 0:b6d1a54b364d 36 lcd.baudChange(BAUD7); //set a fast baud! for fast drawing
emmanuelchio 0:b6d1a54b364d 37
emmanuelchio 0:b6d1a54b364d 38 //front cover
emmanuelchio 0:b6d1a54b364d 39 lcd.setTextColour(YELLOW);
emmanuelchio 0:b6d1a54b364d 40 lcd.setTextSize(FONT4);
emmanuelchio 0:b6d1a54b364d 41 lcd.string(85,50,290,220,"Mini Paint",&charsPrinted);
emmanuelchio 0:b6d1a54b364d 42 lcd.setTextColour(BLUE);
emmanuelchio 0:b6d1a54b364d 43 lcd.setTextSize(FONT3);
emmanuelchio 0:b6d1a54b364d 44 lcd.string(70,95,290,220,"Touch any icon \nto erase screen",&charsPrinted);
emmanuelchio 0:b6d1a54b364d 45 lcd.setTextColour(MAGENTA);
emmanuelchio 0:b6d1a54b364d 46 lcd.setTextSize(FONT2);
emmanuelchio 0:b6d1a54b364d 47 lcd.string(50,170,310,220,"Touch screen to begin",&charsPrinted);
emmanuelchio 0:b6d1a54b364d 48
emmanuelchio 0:b6d1a54b364d 49 while(lcd.touchScreen(&point)==INVALID); // Wait for a touch on the screen to start
emmanuelchio 0:b6d1a54b364d 50 lcd.erase();
emmanuelchio 0:b6d1a54b364d 51 wait_ms(500);
emmanuelchio 0:b6d1a54b364d 52
emmanuelchio 0:b6d1a54b364d 53 while(1){ // Loop forever
emmanuelchio 0:b6d1a54b364d 54 if(lcd.touchScreen(&point)==VALID){ // If we receive a touch on the screen
emmanuelchio 0:b6d1a54b364d 55 lcd.drawCircle(point.x,point.y,PENSIZE,GREEN,FILL); // Draw circle on touched coordinates
emmanuelchio 0:b6d1a54b364d 56 }
emmanuelchio 0:b6d1a54b364d 57 if(lcd.touchIcon(&icon)==VALID){ // If we receive a touch on any icon
emmanuelchio 0:b6d1a54b364d 58 lcd.erase(); // Erase screen
emmanuelchio 0:b6d1a54b364d 59 }
emmanuelchio 0:b6d1a54b364d 60 }
emmanuelchio 0:b6d1a54b364d 61 }