Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: TFT-RFID_Finish mbed MFRC522 UniGraphic
main.cpp
- Committer:
- Geremia
- Date:
- 2015-02-17
- Revision:
- 2:2b781c215ac0
- Parent:
- 1:083257298075
- Child:
- 3:65af1a9fedda
File content as of revision 2:2b781c215ac0:
#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 "IST3020.h"
//#include "UC1608.h"
#include "ILI9341.h"
//#include "ILI9486.h"
//#include "TFT_MIPI.h"
Serial pc(USBTX, USBRX);
//IST3020 LCD(PAR_8, PortC, PC_8, PC_9, PA_0, PA_1, PA_4,"LCD"); // Parallel 8bit, Port, CS, reset, A0, WR, RD for F302
//UC1608 LCD(SPI_16, 10000000, D11, D12, D13, D10, D9, D8,"LCD"); // Spi 16bit, 10MHz, mosi, miso, sclk, cs, reset, dc
ILI9341 LCD(SPI_16, 10000000, D11, D12, D13, D10, D9, D8,"LCD"); // Spi 16bit, 10MHz, mosi, miso, sclk, cs, reset, dc
//ILI9486 LCD(PAR_16, PortC, PH_0, PH_1, PA_0, PA_1, PA_4,"LCD"); // Parallel 16bit, Port, CS, reset, A0, WR, RD for F401
//TFT_MIPI LCD(PAR_16, PortC, PH_0, PH_1, PA_0, PA_1, PA_4,"LCD"); // Parallel 16bit, Port, CS, reset, A0, WR, RD for F401
Timer t;
unsigned short backgroundcolor=Black;
unsigned short foregroundcolor=White;
char orient=1;
int main()
{
// LCD.set_contrast(26);//for uc1608
// LCD.set_contrast(46);//for ist3020
LCD.set_orientation(orient);
int time;
pc.baud (115200);
pc.printf("\n\nSystem Core Clock = %.3f MHZ\r\n",(float)SystemCoreClock/1000000);
t.start();
// LCD.claim(stdout); // send stdout to the LCD display
//LCD.claim(stderr); // send stderr to the LCD display
LCD.background(backgroundcolor); // set background to black
LCD.foreground(foregroundcolor); // set chars to white
LCD.cls(); // clear the screen
// LCD.set_font((unsigned char*) Terminal6x8);
LCD.locate(0,30);
LCD.printf("Display ID: %.8X\r\n", LCD.tftID);
// mem write/read test
unsigned short readback;
unsigned short colorstep = (0x10000/LCD.width());
for(unsigned short i=0; i<LCD.width(); i++)
{
LCD.pixel(i,0,i*colorstep); // write line
}
bool readerror=false;
for(unsigned short i=0; i<LCD.width(); i++) // verify line
{
readback = LCD.pixelread(i,0);
if(readback!=i*colorstep)
{
readerror=true;
pc.printf("pix %.4X readback %.4X\r\n", i*colorstep, readback);
}
}
LCD.locate(0,10);
LCD.printf("pixelread test %s\r\n", readerror ? "FAIL":"PASS");
wait(2);
while(1)
{
LCD.set_orientation((orient++)%4);
// LCD.set_orientation(2);
LCD.cls();
LCD.set_font((unsigned char*) Terminal6x8);
LCD.locate(0,0);
LCD.printf("Display Test\r\nSome text just to see if auto carriage return works correctly");
pc.printf(" Display Test \r\n");
wait(3);
t.reset();
LCD.cls();
time=t.read_us();
LCD.locate(2,55);
LCD.printf("cls: %.3fms", (float)time/1000);
pc.printf("cls: %.3fms\r\n", (float)time/1000);
wait(3);
LCD.cls();
t.reset();
// draw some graphics
//LCD.cls();
LCD.set_font((unsigned char*) Arial24x23);
LCD.locate(10,10);
LCD.printf("Test");
LCD.line(0,0,LCD.width()-1,0,foregroundcolor);
LCD.line(0,0,0,LCD.height()-1,foregroundcolor);
LCD.line(0,0,LCD.width()-1,LCD.height()-1,foregroundcolor);
LCD.rect(10,30,50,40,foregroundcolor);
LCD.fillrect(60,30,100,40,foregroundcolor);
LCD.circle(150,32,30,foregroundcolor);
LCD.fillcircle(140,20,10,foregroundcolor);
double s;
for (unsigned short i=0; i<LCD.width(); i++)
{
s =10 * sin((long double) i / 10 );
LCD.pixel(i,40 + (int)s ,foregroundcolor);
}
time=t.read_us();
LCD.locate(2,55);
LCD.set_font((unsigned char*) Terminal6x8);
LCD.printf("plot: %.3fms", (float)time/1000);
pc.printf("plot: %.3fms\r\n", (float)time/1000);
wait(3);
LCD.cls();
t.reset();
Bitmap_s pic = {
64, // XSize
64, // YSize
8, // Bytes in Line
burp, // Pointer to picture data
};
LCD.Bitmap_BW(pic,LCD.width()-64,0);
time=t.read_us();
LCD.locate(2,55);
LCD.printf("bmp: %.3fms", (float)time/1000);
pc.printf("bmp: %.3fms\r\n", (float)time/1000);
wait(3);
LCD.cls();
LCD.set_font((unsigned char*) Arial43x48_numb, 46, 58, false); //only numbers, variable-width disabled
t.reset();
LCD.locate(0,0);
LCD.printf("%d", 12345);
time=t.read_us();
LCD.locate(2,55);
LCD.set_font((unsigned char*) Terminal6x8);
LCD.printf("Big Font speed: %.3fms", (float)time/1000);
pc.printf("Big Font speed: %.3fms\r\n", (float)time/1000);
wait(3);
// scroll test, only for TFT
LCD.cls();
LCD.set_font((unsigned char*) Arial24x23);
LCD.locate(10,10);
LCD.printf("Scrolling");
LCD.rect(0,0,LCD.width()-1,LCD.height()-1,White);
LCD.rect(1,1,LCD.width()-2,LCD.height()-2,Blue);
LCD.setscrollarea(0,LCD.sizeY());
wait(1);
LCD.scroll(1); //up 1
wait(1);
LCD.scroll(0); //center
wait(1);
LCD.scroll(LCD.sizeY()-1); //down 1
wait(1);
LCD.scroll(LCD.sizeY()); // same as 0, center
wait(1);
LCD.scroll(LCD.sizeY()>>1); // half screen
wait(1);
LCD.scrollreset(); // center
wait(1);
for(unsigned short i=1; i<=LCD.sizeY(); i++)
{
LCD.scroll(i);
wait_ms(2);
}
wait(2);
// color inversion
for(unsigned short i=0; i<=8; i++)
{
LCD.invert(i&1);
wait_ms(200);
}
wait(2);
}
}