Simple Paint Demo - MBED + SmartGPU2 board

Dependencies:   SMARTGPU2 mbed

Committer:
emmanuelchio
Date:
Fri Apr 18 00:30:20 2014 +0000
Revision:
4:be44a445d990
Parent:
3:840b97775616
Child:
5:2318aa0508db
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 2:747505abb216 18 #define PENSIZE 3 //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 2:747505abb216 32 POINT point;
emmanuelchio 4:be44a445d990 33 NUMBEROFBYTES bytes;
emmanuelchio 2:747505abb216 34
emmanuelchio 2:747505abb216 35 lcd.baudChange(BAUD6); // Set a fast baud!, always that we use touch functions is recommended to use fast baud rates
emmanuelchio 0:b6d1a54b364d 36
emmanuelchio 2:747505abb216 37 //front cover
emmanuelchio 2:747505abb216 38 lcd.setTextColour(YELLOW);
emmanuelchio 2:747505abb216 39 lcd.setTextSize(FONT4);
emmanuelchio 3:840b97775616 40 lcd.string(85,50,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"Mini Paint",&bytes);
emmanuelchio 2:747505abb216 41 lcd.setTextColour(BLUE);
emmanuelchio 2:747505abb216 42 lcd.setTextSize(FONT3);
emmanuelchio 3:840b97775616 43 lcd.string(70,95,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"Touch on corner \nto erase screen",&bytes);
emmanuelchio 2:747505abb216 44 lcd.setTextColour(MAGENTA);
emmanuelchio 2:747505abb216 45 lcd.setTextSize(FONT2);
emmanuelchio 3:840b97775616 46 lcd.string(50,170,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"Touch screen to begin",&bytes);
emmanuelchio 2:747505abb216 47
emmanuelchio 2:747505abb216 48 while(lcd.touchScreen(&point)==INVALID); // Wait for a touch on the screen to start
emmanuelchio 2:747505abb216 49 lcd.erase();
emmanuelchio 2:747505abb216 50 lcd.objButton(MAX_X_LANDSCAPE-40,0,MAX_X_LANDSCAPE,25,DESELECTED,"clear");
emmanuelchio 2:747505abb216 51 delay(500);
emmanuelchio 2:747505abb216 52
emmanuelchio 2:747505abb216 53 while(1){ // Loop forever
emmanuelchio 2:747505abb216 54 if(lcd.touchScreen(&point)==VALID){ // If we receive a touch on the screen
emmanuelchio 2:747505abb216 55 if((point.x > (MAX_X_LANDSCAPE-40)) && (point.y < 25)){ // if touch on clear button
emmanuelchio 2:747505abb216 56 lcd.erase();
emmanuelchio 2:747505abb216 57 lcd.objButton(MAX_X_LANDSCAPE-40,0,MAX_X_LANDSCAPE,25,DESELECTED,"clear");
emmanuelchio 2:747505abb216 58 delay(200);
emmanuelchio 2:747505abb216 59 }else{ // touch anywhere on the screen
emmanuelchio 2:747505abb216 60 lcd.drawCircle(point.x,point.y,PENSIZE,YELLOW,FILL); // Draw circle on touched coordinates
emmanuelchio 2:747505abb216 61 }
emmanuelchio 2:747505abb216 62 }
emmanuelchio 2:747505abb216 63 }
emmanuelchio 0:b6d1a54b364d 64 }