Simple Paint Demo - MBED + SmartGPU2 board

Dependencies:   SMARTGPU2 mbed

main.cpp

Committer:
emmanuelchio
Date:
2013-07-10
Revision:
0:b6d1a54b364d
Child:
1:1111ecf2d67c

File content as of revision 0:b6d1a54b364d:

/**************************************************************************************/
/*SMARTGPU2 intelligent embedded graphics processor unit
 those examples are for use the SMARTGPU2 with the mbed microcontoller, just connect tx,rx,and reset
 Board:
 http://vizictechnologies.com/#/smart-gpu-2/4577779046
 
 www.vizictechnologies.com 
 Vizic Technologies copyright 2013 */
/**************************************************************************************/

#include "mbed.h"
#include "SMARTGPU2.h"

SMARTGPU2 lcd(TXPIN,RXPIN,RESETPIN);  //create our object called "lcd"

#define PENSIZE 1         //size of the drawing pen 

/***************************************************/
/***************************************************/
void initializeSmartGPU2(void){      //Initialize SMARTGPU2 Board
  lcd.reset();                       //physically reset SMARTGPU2
  lcd.start();                       //initialize the SMARTGPU2 processor
}

/***************************************************/
/***************************************************/
/***************************************************/
/***************************************************/
int main() {
  POINT point;
  ICON icon;
  NUMBEROFBYTES charsPrinted;
      
  initializeSmartGPU2();             //Init communication with SmartGPU2 board
  
  lcd.baudChange(BAUD7);             //set a fast baud! for fast drawing

  //front cover
  lcd.setTextColour(YELLOW);
  lcd.setTextSize(FONT4);    
  lcd.string(85,50,290,220,"Mini Paint",&charsPrinted);        
  lcd.setTextColour(BLUE);
  lcd.setTextSize(FONT3);        
  lcd.string(70,95,290,220,"Touch any icon \nto erase screen",&charsPrinted);
  lcd.setTextColour(MAGENTA);
  lcd.setTextSize(FONT2);        
  lcd.string(50,170,310,220,"Touch screen to begin",&charsPrinted);
  
  while(lcd.touchScreen(&point)==INVALID);                     // Wait for a touch on the screen to start
  lcd.erase();
  wait_ms(500);
  
  while(1){                                                    // Loop forever
    if(lcd.touchScreen(&point)==VALID){                        // If we receive a touch on the screen
      lcd.drawCircle(point.x,point.y,PENSIZE,GREEN,FILL);      // Draw circle on touched coordinates
    }
    if(lcd.touchIcon(&icon)==VALID){                           // If we receive a touch on any icon
      lcd.erase();                                             // Erase screen         
    }
  }    
}