
TFT ILI9341 Interfacing for mbed os 6.3
Revision 4:5ed8a8039560, committed 2020-10-08
- Comitter:
- amouroug
- Date:
- Thu Oct 08 05:13:36 2020 +0000
- Parent:
- 0:deb3a37d60f8
- Commit message:
- Update source to support mbed-os 6.3 pnemonics
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed-os.lib | Show annotated file Show diff for this revision Revisions of this file |
diff -r deb3a37d60f8 -r 5ed8a8039560 main.cpp --- a/main.cpp Tue Oct 06 05:16:43 2020 +0000 +++ b/main.cpp Thu Oct 08 05:13:36 2020 +0000 @@ -7,10 +7,6 @@ #include <ILI9341.h> - -Serial pc(USBTX, USBRX); - - ILI9341 myLCD(SPI_16, 12000000, PB_5,PB_4, PB_3, PA_10, PA_8, PB_10,"myLCD"); // Spi 16bit, 12MHz, mosi, miso, sclk, cs, reset, dc Timer t; @@ -27,8 +23,7 @@ // myLCD.set_contrast(46);//for ist3020 myLCD.set_orientation(orient); int time, time2; - pc.baud (115200); - pc.printf("\n\nSystem Core Clock = %.3f MHZ\r\n",(float)SystemCoreClock/1000000); + printf("\n\nSystem Core Clock = %.3f MHZ\r\n",(float)SystemCoreClock/1000000); t.start(); // myLCD.set_font((unsigned char*) Terminal6x8); // myLCD.claim(stdout); // send stdout to the LCD display @@ -41,7 +36,7 @@ myLCD.cls(); // clear the screen myLCD.locate(0,30); myLCD.printf("Display ID: %.8X\r\n", myLCD.tftID); - pc.printf("Display ID: %.8X\r\n", myLCD.tftID); + printf("Display ID: %.8X\r\n", myLCD.tftID); // mem write/read test unsigned short readback; unsigned short colorstep = (0x10000/myLCD.width()); @@ -53,12 +48,12 @@ readback = myLCD.pixelread(i,0); if(readback!=i*colorstep) { readerror=true; - pc.printf("pix %.4X readback %.4X\r\n", i*colorstep, readback); + printf("pix %.4X readback %.4X\r\n", i*colorstep, readback); } } myLCD.locate(0,10); myLCD.printf("pixelread test %s\r\n", readerror ? "FAIL":"PASS"); - ThisThread::sleep_for(2000); + ThisThread::sleep_for(2s); myLCD.cls(); myLCD.set_font((unsigned char*) Terminal6x8,32,127,false); //variable width disabled @@ -66,15 +61,15 @@ myLCD.printf("Display Test\r\nSome text just to see if auto carriage return works correctly"); myLCD.set_font((unsigned char*) Terminal6x8); myLCD.printf("\r\nDisplay Test\r\nSome text just to see if auto carriage return works correctly"); - pc.printf(" Display Test \r\n"); - ThisThread::sleep_for(3000); + printf(" Display Test \r\n"); + ThisThread::sleep_for(3s); t.reset(); myLCD.cls(); - time=t.read_us(); + time=t.elapsed_time().count(); myLCD.locate(2,55); myLCD.printf("cls: %.3fms", (float)time/1000); - pc.printf("cls: %.3fms\r\n", (float)time/1000); - ThisThread::sleep_for(3000); + printf("cls: %.3fms\r\n", (float)time/1000); + ThisThread::sleep_for(3s); myLCD.cls(); t.reset(); @@ -102,24 +97,24 @@ } - time=t.read_us(); + time=t.elapsed_time().count(); myLCD.locate(2,55); myLCD.set_font((unsigned char*) Terminal6x8); myLCD.printf("plot: %.3fms", (float)time/1000); - pc.printf("plot: %.3fms\r\n", (float)time/1000); - ThisThread::sleep_for(3000); + printf("plot: %.3fms\r\n", (float)time/1000); + ThisThread::sleep_for(3s); myLCD.cls(); t.reset(); myLCD.set_font((unsigned char*) Arial43x48_numb, 46, 58, false); //only numbers, variable-width disabled t.reset(); myLCD.locate(0,0); myLCD.printf("%d", 12345); - time=t.read_us(); + time=t.elapsed_time().count(); myLCD.locate(2,55); myLCD.set_font((unsigned char*) Terminal6x8); myLCD.printf("Big Font: %.3fms", (float)time/1000); - pc.printf("Big Font: %.3fms\r\n", (float)time/1000); - ThisThread::sleep_for(3000); + printf("Big Font: %.3fms\r\n", (float)time/1000); + ThisThread::sleep_for(3s); // sparse pixels test myLCD.cls(); myLCD.FastWindow(true); @@ -128,7 +123,7 @@ myLCD.pixel((i+(i*89)%myLCD.width()), (i+(i*61)%myLCD.height()), White); } myLCD.copy_to_lcd(); - time=t.read_us(); + time=t.elapsed_time().count(); myLCD.cls(); myLCD.FastWindow(false); t.reset(); @@ -136,11 +131,11 @@ myLCD.pixel((i+(i*89)%myLCD.width()), (i+(i*61)%myLCD.height()), White); } myLCD.copy_to_lcd(); - time2=t.read_us(); + time2=t.elapsed_time().count(); myLCD.locate(2,55); myLCD.printf("std:%.3fms fastw:%.3fms", (float)time2/1000, (float)time/1000); - pc.printf("std: %.3fms fastw: %.3fms\r\n", (float)time2/1000, (float)time/1000); - ThisThread::sleep_for(3000); + printf("std: %.3fms fastw: %.3fms\r\n", (float)time2/1000, (float)time/1000); + ThisThread::sleep_for(3s); // scroll test, only for TFT myLCD.cls(); @@ -150,29 +145,29 @@ myLCD.rect(0,0,myLCD.width()-1,myLCD.height()-1,White); myLCD.rect(1,1,myLCD.width()-2,myLCD.height()-2,Blue); myLCD.setscrollarea(0,myLCD.sizeY()); - ThisThread::sleep_for(1000); + ThisThread::sleep_for(1s); myLCD.scroll(1); //up 1 - ThisThread::sleep_for(1000); + ThisThread::sleep_for(1s); myLCD.scroll(0); //center - ThisThread::sleep_for(1000); + ThisThread::sleep_for(1s); myLCD.scroll(myLCD.sizeY()-1); //down 1 - ThisThread::sleep_for(1000); + ThisThread::sleep_for(1s); myLCD.scroll(myLCD.sizeY()); // same as 0, center - ThisThread::sleep_for(1000); + ThisThread::sleep_for(1s); myLCD.scroll(myLCD.sizeY()>>1); // half screen - ThisThread::sleep_for(1000); + ThisThread::sleep_for(1s); myLCD.scrollreset(); // center - ThisThread::sleep_for(1000); + ThisThread::sleep_for(1s); for(unsigned short i=1; i<=myLCD.sizeY(); i++) { myLCD.scroll(i); - ThisThread::sleep_for(2); + ThisThread::sleep_for(2ms); } - ThisThread::sleep_for(2000); + ThisThread::sleep_for(2s); // color inversion for(unsigned short i=0; i<=8; i++) { myLCD.invert(i&1); - ThisThread::sleep_for(200); + ThisThread::sleep_for(200ms); } - ThisThread::sleep_for(2000); + ThisThread::sleep_for(2s); } } \ No newline at end of file
diff -r deb3a37d60f8 -r 5ed8a8039560 mbed-os.lib --- a/mbed-os.lib Tue Oct 06 05:16:43 2020 +0000 +++ b/mbed-os.lib Thu Oct 08 05:13:36 2020 +0000 @@ -1,1 +1,1 @@ -https://github.com/ARMmbed/mbed-os/#0db72d0cf26539016efbe38f80d6f2cb7a3d4414 +https://github.com/ARMmbed/mbed-os/#aa70f680bb5755e8fea3f93fc6e04d9b3de235bb