Simple Paint Demo - MBED + SmartGPU2 board

Dependencies:   SMARTGPU2 mbed

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