lib simple mais pas d'image (utiliser la 9341 pour cela) en revanche, très rapide
Dependencies: ILI9340_Driver_Lib mbed
Fork of ILI9340_Driver by
Diff: main.cpp
- Revision:
- 0:9c462c65176a
- Child:
- 1:0615e3c659c0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon May 26 09:23:40 2014 +0000 @@ -0,0 +1,79 @@ +/*************************************************************** + ILI9340_Driver v1.0 26.05.14 Ian Weston + +Driver and integrated graphics library for displays that use the +ILI9340 controller in SPI mode. + +The code was prted from several sources, the driver section +was completely ported from the Adafruits Arduino source code, and +the graphics functions were ported from the Adafruits GFX library +and some elements were ported from code by Elmicros seeduio port. + +Future revisions will include more advanced graphics functions. + +Rough and ready Demo code to for showing the driver and some +functions in action. + +***************************************************************/ + + +#include "mbed.h" +#include "ILI9340_Driver.h" + + +int main() { + + // create the display object + ILI9340_Display tft = ILI9340_Display(p5, p6, p7, p24, p25, p26); + + // initialise the display + tft.DispInit(); + + // clears the screen to remove all noise data + tft.FillScreen(ILI9340_WHITE); + + // draws a black window + tft.DrawRect(20, 20, 200, 280, ILI9340_BLACK); + + + + // set up variables for graphics functions + uint16_t c1, c2; + uint8_t r = 0, g = 0, b = 0; + char elapsed[] = "1111"; + int counter = 0; + + // Small amount of text to the display. + tft.DrawString("Hello Lib!", 80, 120, 1, ILI9340_BLACK); + tft.DrawString("Frame Count:", 70, 135, 1, ILI9340_BLACK); + + while(true) { + // convert the RGB values into values that can be writen to the screen + c1 = tft.Colour565(r, g, b); + c2 = tft.Colour565(r+50, g+50, b+50); + + // Print 2x square boxes to the screen that change colour with every iteration + tft.FillRect( 60, 60, 30, 30, c1); + tft.FillRect( 140, 220, 30, 30, c2); + + // change the RGB vlaues + r += 4; + g += 6; + b += 8; + + //Write the frame count to screen, first overwriting the previos value in the background colour + tft.IntToChars(elapsed, counter, 4, 10, 70, 160, 3, ILI9340_WHITE); + if (counter++ > 9999) {counter = 0;} + tft.IntToChars(elapsed, counter, 4, 10, 70, 160, 3, ILI9340_RED); + + // Make a mess of the screen by drawing random lines and, a ripple of circles. + tft.DrawLine(counter % r, counter % g, counter % b, r, counter*8); + tft.DrawCircle(120, 265, r, c1); + + // Do the waiting thang... + wait(0.050); + + } + +} +