speedtest

Dependencies:   UniGraphic mbed

Fork of Nucleo_UniGraphic_demo by Toshiaki Asano

Files at this revision

API Documentation at this revision

Comitter:
Aleksk
Date:
Sun Sep 03 19:31:15 2017 +0000
Parent:
6:c9088eb90616
Commit message:
speed test single and double math

Changed in this revision

UniGraphic.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r c9088eb90616 -r c704bfdbfcc3 UniGraphic.lib
--- a/UniGraphic.lib	Sun Mar 13 09:09:47 2016 +0000
+++ b/UniGraphic.lib	Sun Sep 03 19:31:15 2017 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/GraphicsDisplay/code/UniGraphic/#87855d03d91a
+http://developer.mbed.org/teams/GraphicsDisplay/code/UniGraphic/#f87f06292637
diff -r c9088eb90616 -r c704bfdbfcc3 main.cpp
--- a/main.cpp	Sun Mar 13 09:09:47 2016 +0000
+++ b/main.cpp	Sun Sep 03 19:31:15 2017 +0000
@@ -1,249 +1,107 @@
-//
-//    UniGraphic demo on Nucleo-F401RE and UL024TF (Adafruit 2.2" parallel TFT shield compatible)
-//
-//      2016.3.13
+
 //
-//        reference: https://developer.mbed.org/questions/6893/BusOut-instead-of-PortName/
-//
+// using 2.4TFT shield 320x240 on NucleoF411RE
 //
-//
-
 #include "stdio.h"
 #include "mbed.h"
 #include "string"
-#include "Arial12x12.h"
 #include "Arial24x23.h"
-//#include "Terminal6x8.h"
-#include "Arial43x48_numb.h"
-#include "pict.h"
-#include "pavement_48x34.h"
+#include "ILI9341.h"
 
-//#include "IST3020.h"
-//#include "UC1608.h"
-//#include "ST7565.h"
-#include "ILI932x.h"
-//#include "ILI9341.h"
-//#include "ILI9486.h"
-//#include "TFT_MIPI.h"
-//#include "SSD1306.h"
+#define PI (3.141592653589793)
 
 Serial pc(USBTX, USBRX);
 
-//IST3020 myLCD(PAR_8, PortC, PC_8, PC_9, PA_0, PA_1, PA_4,"myLCD", 192, 64); // Parallel 8bit, Port, CS, reset, A0, WR, RD for F302
-//UC1608 myLCD(SPI_16, 10000000, D11, D12, D13, D10, D9, D8,"myLCD", 240, 120); // Spi 16bit, 10MHz, mosi, miso, sclk, cs, reset, dc
-//ST7565 myLCD(PAR_8, PortC, PC_8, PC_9, PA_0, PA_1, PA_4,"myLCD", 128, 64); // Parallel 8bit, Port, CS, reset, A0, WR, RD
-//ILI932x myLCD(PAR_8, PortC, PH_0, PH_1, PA_0, PA_1, PA_4,"myLCD"); // Parallel 8bit, Port, CS, reset, RS, WR, RD for F401
-//ILI932x myLCD(SPI_16, 10000000, D11, D12, D13, D10, D9,"myLCD"); // Spi 16bit, 12MHz, mosi, miso, sclk, cs, reset
-//ILI9341 myLCD(SPI_16, 12000000, D11, D12, D13, D10, D9, D8,"myLCD"); // Spi 16bit, 12MHz, mosi, miso, sclk, cs, reset, dc
-//ILI9341 myLCD(PAR_16, PortC, PH_0, PH_1, PA_0, PA_1, PA_4,"myLCD"); // Parallel 16bit, Port, CS, reset, DC, WR, RD for F401
-//ILI9486 myLCD(PAR_16, PortC, PH_0, PH_1, PA_0, PA_1, PA_4,"myLCD"); // Parallel 16bit, Port, CS, reset, DC, WR, RD for F401
-//TFT_MIPI myLCD(PAR_16, PortC, PH_0, PH_1, PA_0, PA_1, PA_4,"myLCD"); // Parallel 16bit, Port, CS, reset, DC, WR, RD for F401
-//SSD1306 myLCD(SPI_16, 10000000, D11, D12, D13, D10, D9, D8,"myLCD", 240, 120); // Spi 16bit, 10MHz, mosi, miso, sclk, cs, reset, dc
-//ILI9486 myLCD(SPI_8, 12000000, PA_7, PA_6, PA_5, PB_6, PA_8, PA_9,"myLCD"); // Spi 16bit, 12MHz, mosi, miso, sclk, cs, reset, dc for minimaple
-//ILI9341 myLCD(SPI_8, 12000000, PA_7, PA_6, PA_5, PB_6, PA_8, PA_9,"myLCD"); // Spi 16bit, 12MHz, mosi, miso, sclk, cs, reset, dc for minimaple
+PinName buspins[8]={D8,D9,D2,D3,D4,D5,D6,D7};
+ILI9341 myLCD(BUS_8, buspins, A3, A4, A2, A1, A0,"myLCD"); // Parallel Bus 8bit, buspins array, CS, reset, RS, WR, RD
 
-// using UL024TF on NucleoF401RE
-
-PinName buspins[8]={D8,D9,D2,D3,D4,D5,D6,D7};
-ILI932x myLCD(BUS_8, buspins, A3, A4, A2, A1, A0,"myLCD"); // Parallel Bus 8bit, buspins array, CS, reset, RS, WR, RD
+Timer timer;
 
-
-Timer t;
+const double d2r = PI / 180.0;
+const double r2d = 180.0 / PI;
 
-//unsigned short backgroundcolor=White;
-//unsigned short foregroundcolor=Black;
 unsigned short backgroundcolor=Black;
 unsigned short foregroundcolor=White;
 
-char orient=1;
-int main()
-{
-//    myLCD.set_contrast(26);//for uc1608
- //   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);
-    t.start();
- //   myLCD.set_font((unsigned char*) Terminal6x8);
-   // myLCD.claim(stdout);      // send stdout to the LCD display
-    //myLCD.claim(stderr);      // send stderr to the LCD display
-    myLCD.background(backgroundcolor);    // set background to black
-    myLCD.foreground(foregroundcolor);    // set chars to white
+float k0;
+float a;
+float m0[5];
+double k0_;
+double a_;
+double m0_[5];
 
-    while(1)
-    {
-    myLCD.set_orientation((orient++)%4);
-//    myLCD.set_orientation(2);
-    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);
-    // mem write/read test
-    unsigned short readback;
-    unsigned short colorstep = (0x10000/myLCD.width());
-    for(unsigned short i=0; i<myLCD.width(); i++)
-    {
-        myLCD.pixel(i,0,i*colorstep); // write line
-    }
-    bool readerror=false;
-    for(unsigned short i=0; i<myLCD.width(); i++) // verify line
-    {
-        readback = myLCD.pixelread(i,0);
-        if(readback!=i*colorstep)
-        {
-            readerror=true;
-            pc.printf("pix %.4X readback %.4X\r\n", i*colorstep, readback);
-        }
-    }
-    myLCD.locate(0,10);
-    myLCD.printf("pixelread test %s\r\n", readerror ? "FAIL":"PASS");
-    wait(2);
-    
-    myLCD.cls();
-    myLCD.set_font((unsigned char*) Terminal6x8,32,127,false); //variable width disabled
-    myLCD.locate(0,0);
-    myLCD.printf("Display Test\r\nSome text just to see if auto carriage return works correctly");
-    myLCD.set_font((unsigned char*) Terminal6x8);
- //   myLCD.locate(0,0);
-    myLCD.printf("\r\nDisplay Test\r\nSome text just to see if auto carriage return works correctly");
-    pc.printf("  Display Test \r\n");
-    wait(3);
-    t.reset();
-    myLCD.cls();
-    time=t.read_us();
-    myLCD.locate(2,55);
-    myLCD.printf("cls: %.3fms", (float)time/1000);
-    pc.printf("cls: %.3fms\r\n", (float)time/1000);
-    wait(3);
-
-    myLCD.cls();
-    t.reset();
-    // draw some graphics
-    //myLCD.cls();
-    myLCD.set_font((unsigned char*) Arial24x23);
-    myLCD.locate(10,10);
-    myLCD.printf("Test");
-
-    myLCD.line(0,0,myLCD.width()-1,0,foregroundcolor);
-    myLCD.line(0,0,0,myLCD.height()-1,foregroundcolor);
-    myLCD.line(0,0,myLCD.width()-1,myLCD.height()-1,foregroundcolor);
-
-    myLCD.rect(10,30,50,40,foregroundcolor);
-    myLCD.fillrect(60,30,100,40,foregroundcolor);
-
-    myLCD.circle(150,32,30,foregroundcolor);
-    myLCD.fillcircle(140,20,10,foregroundcolor);
-
-    double s;
-
-    for (unsigned short i=0; i<myLCD.width(); i++)
-        {
-        s =10 * sin((long double) i / 10 );
-        myLCD.pixel(i,40 + (int)s ,foregroundcolor);
-        }
 
 
-    time=t.read_us();
-    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);
-    wait(3);
-    myLCD.cls();
-    t.reset();
-    Bitmap_s pic = {
-    64, // XSize
-    64, // YSize
-    8, // Bytes in Line
-    burp,  // Pointer to picture data 
-    };
-    myLCD.Bitmap_BW(pic,myLCD.width()-64,0);
-    time=t.read_us();
-    myLCD.locate(2,55);
-    myLCD.printf("bmp: %.3fms", (float)time/1000);
-    pc.printf("bmp: %.3fms\r\n", (float)time/1000);
-    wait(3);
-    myLCD.cls();
-    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();
-    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);
-    wait(3);
-    // sparse pixels test
-    myLCD.cls();
-    myLCD.FastWindow(true);
-    t.reset();
-    for(unsigned int i=0; i<20000; i++)
-    {
-        myLCD.pixel((i+(i*89)%myLCD.width()), (i+(i*61)%myLCD.height()), White);
-    }
-    myLCD.copy_to_lcd();
-    time=t.read_us();
-    myLCD.cls();
-    myLCD.FastWindow(false);
-    t.reset();
-    for(unsigned int i=0; i<20000; i++)
+int main()
+{
+    int time;
+    timer.start();
+    myLCD.cls();   
+    myLCD.set_orientation(1);   
+    pc.baud (115200);
+    myLCD.background(Black);    // set background to black
+    myLCD.foreground(White);    // set chars to white
+    myLCD.set_font((unsigned char*) Arial24x23);
+    myLCD.locate(1,10);
+    myLCD.printf("Speedtest STM32F411");
+    
+    while(1)
     {
-        myLCD.pixel((i+(i*89)%myLCD.width()), (i+(i*61)%myLCD.height()), White);
-    }
-    myLCD.copy_to_lcd();
-    time2=t.read_us();
-    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);
-    wait(3);
-    // scroll test, only for TFT
-    myLCD.cls();
+ //Single precision   
+    timer.reset();               
+    
+    k0=0;
+M1:
+    k0=(k0+1);
+    a=(k0/2*3+4-5);
+    a=atan2(a,k0);
+    a=sin(a);
+    a=cos(a);
+    float y = sin(a) * cos(a * d2r);
+    float x = cos(a*d2r)*sin(a*d2r) - sin(a*d2r)*cos(a*d2r)*cos(a);
+    a= 360.0-(atan2(y,x)*r2d);
+    
+    for (unsigned short i=1; i<5; i++){m0[i]=a;}
+    if (k0<1000) {goto M1;}
+    
+    time=timer.read_us();
+    
     myLCD.set_font((unsigned char*) Arial24x23);
-    myLCD.locate(2,10);
-    myLCD.printf("Scrolling");
-    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());
-    wait(1);
-    myLCD.scroll(1); //up 1
-    wait(1);
-    myLCD.scroll(0); //center
-    wait(1);
-    myLCD.scroll(myLCD.sizeY()-1); //down 1
-    wait(1);
-    myLCD.scroll(myLCD.sizeY()); // same as 0, center
-    wait(1);
-    myLCD.scroll(myLCD.sizeY()>>1); // half screen
+    myLCD.locate(1,50);
+    myLCD.printf("Time: %.3fms", (float)(time)/1000);
+    myLCD.set_font((unsigned char*) Terminal6x8);
+    myLCD.locate(1,100);
+    myLCD.printf("a = %.14f deg", a);
+    pc.printf("Time: %.3fms\r\n", (float)(time)/1000);
+    pc.printf("\n\nSystem Core Clock = %.3f MHZ\r\n",(float)SystemCoreClock/1000000);  
     wait(1);
-    myLCD.scrollreset(); // center
+    
+ //Double precision   
+    timer.reset();               
+    
+    k0_=0;
+M2:
+    k0_=(k0_+1);
+    a_=(k0_/2*3+4-5);
+    a_=atan2(a_,k0_);
+    a_=sin(a_);
+    a_=cos(a_);
+    double y_ = sin(a_) * cos(a_ * d2r);
+    double x_ = cos(a_*d2r)*sin(a_*d2r) - sin(a_*d2r)*cos(a_*d2r)*cos(a_);
+    a_= 360.0-(atan2(y_,x_)*r2d);
+    for (unsigned short i=1; i<5; i++){m0_[i]=a;}
+    if (k0_<1000) {goto M2;}
+    
+    time=timer.read_us();
+    
+    myLCD.set_font((unsigned char*) Arial24x23);
+    myLCD.locate(1,150);
+    myLCD.printf("Time: %.3fms", (float)(time)/1000);
+    myLCD.set_font((unsigned char*) Terminal6x8);
+    myLCD.locate(1,200);
+    myLCD.printf("a_ = %.14f deg", a_);
+    pc.printf("Time: %.3fms\r\n", (float)(time)/1000);
+    pc.printf("\n\nSystem Core Clock = %.3f MHZ\r\n",(float)SystemCoreClock/1000000);  
     wait(1);
-    for(unsigned short i=1; i<=myLCD.sizeY(); i++)
-    {
-        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);
-    }
-    wait(2);
-    // bmp 16bit test
-    myLCD.cls();
-    t.reset();
-    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);
-    }
-    time=t.read_us();
-    myLCD.locate(2,55);
-    myLCD.set_font((unsigned char*) Terminal6x8);
-    myLCD.printf("Bmp speed: %.3fms", (float)time/1000);
-    pc.printf("Bmp speed: %.3fms\r\n", (float)time/1000);
-    wait(2);
     }
 }
\ No newline at end of file
diff -r c9088eb90616 -r c704bfdbfcc3 mbed.bld
--- a/mbed.bld	Sun Mar 13 09:09:47 2016 +0000
+++ b/mbed.bld	Sun Sep 03 19:31:15 2017 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/487b796308b0
\ No newline at end of file
+https://mbed.org/users/mbed_official/code/mbed/builds/794e51388b66
\ No newline at end of file