Mission Accomplished
Dependencies: DmTouch_UniGraphic UniGraphic mbed
Fork of DisplayModule24_demo by
Revision 13:2c26e73432fb, committed 2016-01-22
- Comitter:
- pstephens18
- Date:
- Fri Jan 22 21:24:36 2016 +0000
- Parent:
- 12:bc9a227679c7
- Commit message:
- Final
;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r bc9a227679c7 -r 2c26e73432fb main.cpp --- a/main.cpp Thu Jan 21 16:42:32 2016 +0000 +++ b/main.cpp Fri Jan 22 21:24:36 2016 +0000 @@ -10,6 +10,10 @@ #include "pavement_48x34.h" Serial pc(USBTX, USBRX); +DigitalOut led1(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut led4(LED4); /* Configure the DisplayModule ILI9325 2.4" display for 8-bit bus communication @@ -59,6 +63,7 @@ bool down, lastDown; touch.init(); t.start(); + myLCD.set_orientation(orient); myLCD.set_font((unsigned char*) Arial24x23); myLCD.background(Blue); // set background to Blue @@ -70,6 +75,7 @@ while(1) { + /* myLCD.cls(); // clear the screen myLCD.set_font((unsigned char*) Arial24x23); myLCD.locate(0,30); @@ -129,7 +135,9 @@ myLCD.pixel(i,80 + (int)s ,White); } wait(3); + */ + /* // Touch screen demo myLCD.background(Blue); // set background to Blue myLCD.foreground(White); // set chars to White @@ -142,41 +150,102 @@ myLCD.printf("Coming soon...\r\nTouch screen and coordinates will display\r\n"); myLCD.printf("Moves to next portion of demo after 30 seconds\r\n"); wait(2); + */ myLCD.background(Black); // set background to Black myLCD.foreground(White); // set chars to White - myLCD.cls(); // clear the screen + myLCD.cls(); + // clear the screen + myLCD.fillcircle(100,70,35,Cyan); + myLCD.locate(90,60); + myLCD.printf("1"); + myLCD.fillcircle(210,70,35,Red); + myLCD.locate(200,60); + myLCD.printf("2"); + myLCD.fillcircle(100,170,35,Green); + myLCD.locate(90,160); + myLCD.printf("3"); + myLCD.fillcircle(210,170,35,Yellow); + myLCD.locate(200,160); + myLCD.printf("4"); touch.setOrientation(orient); down = false; lastDown = false; tx = (uint16_t)0; ty = (uint16_t)0; - myLCD.locate(20,20); + myLCD.locate(20,10); myLCD.printf("x:"); - myLCD.locate(100, 20); + myLCD.locate(180, 10); myLCD.printf("y:"); t.reset(); - while (t.read()<30) { - touch.readTouchData(tx, ty, down); - if (down) { - myLCD.locate(40, 20); - myLCD.printf("%5i", tx); - myLCD.locate(120, 20); - myLCD.printf("%5i", ty); - myLCD.fillcircle(tx, ty, 2, Red); - } else if (lastDown) { - // no longer pressed, clean text - myLCD.locate(40, 20); - myLCD.printf(" ", tx); - myLCD.locate(120, 20); - myLCD.printf(" ", ty); + while (t.read()<30) + { + touch.readTouchData(tx, ty, down); + if (down) { + myLCD.locate(40, 20); + myLCD.printf("%5i", tx); + myLCD.locate(120, 20); + myLCD.printf("%5i", ty); + //myLCD.fillcircle(tx, ty, 2, Red); + } else if (lastDown) { + // no longer pressed, clean text + myLCD.locate(40, 20); + myLCD.printf(" ", tx); + myLCD.locate(120, 20); + myLCD.printf(" ", ty); + } + led1=0; + led2=0; + led3=0; + led4=0; + + ////////////////////////////////////////////////////////////////////////////////////// + + while(1) + { + touch.readTouchData(tx, ty, down); + while(down) + { + if(((tx-100)*(tx-100)+(ty-70)*(ty-70))<= (35*35)) + { + led1 =!led1; + } + if(((tx-210)*(tx-210)+(ty-70)*(ty-70))<= (35*35)) + { + led2 =!led2; + } + if(((tx-100)*(tx-100)+(ty-170)*(ty-170))<= (35*35)) + { + led3 =!led3; + } + if(((tx-210)*(tx-210)+(ty-170)*(ty-170))<= (35*35)) + { + led4 =!led4; + } + if (down) + { + myLCD.locate(10, 10); + myLCD.printf("%5i", tx); + myLCD.locate(170, 10); + myLCD.printf("%5i", ty); + //myLCD.fillcircle(tx, ty, 2, Red); + } + + while(down) + { + touch.readTouchData(tx, ty, down); + myLCD.printf(""); + } + + + + down=0; + } + } } - wait(0.040); - lastDown = down; - } - + /* // scroll test, only for TFT myLCD.cls(); myLCD.set_font((unsigned char*) Arial24x23); @@ -199,25 +268,26 @@ myLCD.scrollreset(); // center wait(1); for(unsigned short i=1; i<=myLCD.sizeY(); i++) - { - myLCD.scroll(i); - wait_ms(2); - } + { + myLCD.scroll(i); + wait_ms(2); + } wait(2); // color inversion for(unsigned short i=0; i<=8; i++) - { - myLCD.invert(i&1); - wait_ms(200); - } + { + myLCD.invert(i&1); + wait_ms(200); + } wait(2); // bmp 16bit test myLCD.cls(); for(int y=0; y<myLCD.height(); y+=34) - { - for(int x=0; x<myLCD.width(); x+=48) myLCD.Bitmap(x,y,48,34,(unsigned char *)pavement_48x34); - } + { + for(int x=0; x<myLCD.width(); x+=48) myLCD.Bitmap(x,y,48,34,(unsigned char *)pavement_48x34); + } wait(2); myLCD.set_orientation((++orient)%4); + */ } } \ No newline at end of file