Simple program for the RETRO to compare the performance of the DisplayN18 and LCD_ST7735 libraries.
This is a very simple program for the RETRO to compare the performance of some of the primitives of the DisplayN18 and LCD_ST7735 libraries
WARNING - WARNING - WARNING
If you're sensitive to ugly coding techniques, lack of best practice, ignorance of proper design patterns, abuse of object orientation or to total disregards of any coding guidelines, then don't - I repeat - DON'T look at this code...
P.S. Regardless the performance, I do think the N18 library has a much nicer font!
Diff: main.cpp
- Revision:
- 1:e3193760dd98
- Parent:
- 0:59d6b70df5a4
- Child:
- 2:dcf8e6db342d
--- a/main.cpp Fri Jan 16 19:18:45 2015 +0000 +++ b/main.cpp Fri Jan 16 19:59:19 2015 +0000 @@ -1,6 +1,6 @@ //////////////////////// // -// Simple program to compare the performance of the DisplayN18 and LCD_ST7735 libraries +// Simple program for the RETRO to compare the performance of the DisplayN18 and LCD_ST7735 libraries // /////////////////////// @@ -47,6 +47,20 @@ iPerfMs+=tPerformance.read_ms(); wait(0.5); + // filled rectangles + iStartUs=tPerformance.read_us(); + disp.clear(); + sprintf(buf,"fillRect..."); + disp.drawString(DisplayN18::WIDTH / 2 - (DisplayN18::CHAR_WIDTH + DisplayN18::CHAR_SPACING) * strlen(buf) / 2, 0, buf, DisplayN18::GREEN, DisplayN18::BLACK); + for(int i=1; i<100; i+=2) + { + disp.fillRect(0, 0, i, i, DisplayN18::GREEN); + } + sprintf(buf,"fillRect:%u ", tPerformance.read_us()-iStartUs); + disp.drawString(DisplayN18::WIDTH / 2 - (DisplayN18::CHAR_WIDTH + DisplayN18::CHAR_SPACING) * strlen(buf) / 2, DisplayN18::HEIGHT-DisplayN18::CHAR_HEIGHT, buf, DisplayN18::GREEN, DisplayN18::BLACK); + iPerfMs+=tPerformance.read_ms(); + wait(0.5); + // circles iStartUs=tPerformance.read_us(); disp.clear(); @@ -61,6 +75,20 @@ iPerfMs+=tPerformance.read_ms(); wait(0.5); + // filled circles + iStartUs=tPerformance.read_us(); + disp.clear(); + sprintf(buf,"fillCircle..."); + disp.drawString(DisplayN18::WIDTH / 2 - (DisplayN18::CHAR_WIDTH + DisplayN18::CHAR_SPACING) * strlen(buf) / 2, 0, buf, DisplayN18::GREEN, DisplayN18::BLACK); + for(int i=1; i<100; i+=2) + { + disp.fillCircle(i, i, i/2, DisplayN18::GREEN); + } + sprintf(buf,"fillCircle:%u ", tPerformance.read_us()-iStartUs); + disp.drawString(DisplayN18::WIDTH / 2 - (DisplayN18::CHAR_WIDTH + DisplayN18::CHAR_SPACING) * strlen(buf) / 2, DisplayN18::HEIGHT-DisplayN18::CHAR_HEIGHT, buf, DisplayN18::GREEN, DisplayN18::BLACK); + iPerfMs+=tPerformance.read_ms(); + wait(0.5); + // lines iStartUs=tPerformance.read_us(); disp.clear(); @@ -68,7 +96,7 @@ disp.drawString(DisplayN18::WIDTH / 2 - (DisplayN18::CHAR_WIDTH + DisplayN18::CHAR_SPACING) * strlen(buf) / 2, 0, buf, DisplayN18::GREEN, DisplayN18::BLACK); for(int i=1; i<100; i++) { - disp.drawLine(0, 0, i, i, DisplayN18::GREEN); + disp.drawLine(0, 0, i, 100, DisplayN18::GREEN); } sprintf(buf,"drawLine:%u ", tPerformance.read_us()-iStartUs); disp.drawString(DisplayN18::WIDTH / 2 - (DisplayN18::CHAR_WIDTH + DisplayN18::CHAR_SPACING) * strlen(buf) / 2, DisplayN18::HEIGHT-DisplayN18::CHAR_HEIGHT, buf, DisplayN18::GREEN, DisplayN18::BLACK); @@ -134,6 +162,20 @@ iPerfMs+=tPerformance.read_ms(); wait(0.5); + // filled rectangles + iStartUs=tPerformance.read_us(); + disp.clearScreen(); + sprintf(buf,"drawRect..."); + disp.drawString(font_ibm, 160 / 2 - (8 + 0) * strlen(buf) / 2, 0, buf); + for(int i=1; i<100; i+=2) + { + disp.fillRect(0, 0, i, i, Color565::Yellow, Color565::Blue); + } + sprintf(buf,"drawRect:%u ", tPerformance.read_us()-iStartUs); + disp.drawString(font_ibm, 160 / 2 - (8 + 0) * strlen(buf) / 2, 128-8, buf); + iPerfMs+=tPerformance.read_ms(); + wait(0.5); + // circles iStartUs=tPerformance.read_us(); disp.clearScreen(); @@ -148,6 +190,20 @@ iPerfMs+=tPerformance.read_ms(); wait(0.5); + // filled circles + iStartUs=tPerformance.read_us(); + disp.clearScreen(); + sprintf(buf,"fillCircle..."); + disp.drawString(font_ibm, 160 / 2 - (8 + 0) * strlen(buf) / 2, 0, buf); + for(int i=1; i<100; i+=2) + { + disp.fillCircle(i, i, i/2, Color565::Yellow, Color565::Blue); + } + sprintf(buf,"fillCircle:%u ", tPerformance.read_us()-iStartUs); + disp.drawString(font_ibm, 160 / 2 - (8 + 0) * strlen(buf) / 2, 128-8, buf); + iPerfMs+=tPerformance.read_ms(); + wait(0.5); + // lines iStartUs=tPerformance.read_us(); disp.clearScreen(); @@ -155,7 +211,7 @@ disp.drawString(font_ibm, 160 / 2 - (8 + 0) * strlen(buf) / 2, 0, buf); for(int i=1; i<100; i++) { - disp.drawLine(0, 0, i, i, Color565::Blue); + disp.drawLine(0, 0, i, 100, Color565::Blue); } sprintf(buf,"drawLine:%u ", tPerformance.read_us()-iStartUs); disp.drawString(font_ibm, 160 / 2 - (8 + 0) * strlen(buf) / 2, 128-8, buf); @@ -175,11 +231,24 @@ { int iDisplayN18=testDisplayN18(); int iDisplayST7735=testDisplayST7735(); + char buf[256]; + + DisplayN18 disp; + disp.clear(); + sprintf(buf,"Totals --->"); + disp.drawString(0, 0, buf, DisplayN18::WHITE, DisplayN18::BLACK); + sprintf(buf,"N18: %u ms", iDisplayN18); + disp.drawString(0, DisplayN18::CHAR_HEIGHT, buf, DisplayN18::GREEN, DisplayN18::BLACK); + sprintf(buf,"ST7735: %u ms", iDisplayST7735); + disp.drawString(0, 2*DisplayN18::CHAR_HEIGHT, buf, DisplayN18::BLUE, DisplayN18::BLACK); + DigitalOut led1(P0_9, false); + DigitalOut led2(P0_8, true); while (true) { led1 = !led1; + led2 = !led2; wait(.5); }