Vizic Technologies
/
SimplePaint_SG2
Simple Paint Demo - MBED + SmartGPU2 board
Revision 2:747505abb216, committed 2014-04-18
- Comitter:
- emmanuelchio
- Date:
- Fri Apr 18 00:22:40 2014 +0000
- Parent:
- 1:1111ecf2d67c
- Child:
- 3:840b97775616
- Commit message:
- SmartGPU2 SimplePaint_SG2 demo- Please select(uncomment) your smartGPU2 board under SMARTGPU2.h file before compiling!!!
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Apr 17 23:54:05 2014 +0000 +++ b/main.cpp Fri Apr 18 00:22:40 2014 +0000 @@ -15,7 +15,7 @@ SMARTGPU2 lcd(TXPIN,RXPIN,RESETPIN); //create our object called "lcd" -#define PENSIZE 1 //size of the drawing pen +#define PENSIZE 3 //size of the drawing pen /***************************************************/ /***************************************************/ @@ -29,35 +29,35 @@ /***************************************************/ /***************************************************/ int main() { - POINT point; - ICON icon; - NUMBEROFBYTES charsPrinted; - - initializeSmartGPU2(); //Init communication with SmartGPU2 board - - lcd.baudChange(BAUD6); //set a fast baud! for fast drawing + POINT point; + + lcd.baudChange(BAUD6); // Set a fast baud!, always that we use touch functions is recommended to use fast baud rates - //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 - } - } + //front cover + lcd.setTextColour(YELLOW); + lcd.setTextSize(FONT4); + lcd.string(85,50,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"Mini Paint",0); + lcd.setTextColour(BLUE); + lcd.setTextSize(FONT3); + lcd.string(70,95,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"Touch on corner \nto erase screen",0); + lcd.setTextColour(MAGENTA); + lcd.setTextSize(FONT2); + lcd.string(50,170,MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"Touch screen to begin",0); + + while(lcd.touchScreen(&point)==INVALID); // Wait for a touch on the screen to start + lcd.erase(); + lcd.objButton(MAX_X_LANDSCAPE-40,0,MAX_X_LANDSCAPE,25,DESELECTED,"clear"); + delay(500); + + while(1){ // Loop forever + if(lcd.touchScreen(&point)==VALID){ // If we receive a touch on the screen + if((point.x > (MAX_X_LANDSCAPE-40)) && (point.y < 25)){ // if touch on clear button + lcd.erase(); + lcd.objButton(MAX_X_LANDSCAPE-40,0,MAX_X_LANDSCAPE,25,DESELECTED,"clear"); + delay(200); + }else{ // touch anywhere on the screen + lcd.drawCircle(point.x,point.y,PENSIZE,YELLOW,FILL); // Draw circle on touched coordinates + } + } + } } \ No newline at end of file