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
Demo.cpp
00001 /*************************************************************** 00002 ILI9340_Driver v1.1 26.05.14 Ian Weston 00003 00004 Demo project to demonstrate the ILI9340 display driver and graphics 00005 library in action. very simple, good base for any project. 00006 00007 About the Library: 00008 00009 Driver and integrated graphics library for displays that use the 00010 ILI9340 controller in SPI mode. 00011 00012 The code was prted from several sources, the driver section 00013 was completely ported from the Adafruits Arduino source code, and 00014 the graphics functions were ported from the Adafruits GFX library 00015 and some elements were ported from code by Elmicros seeduio port. 00016 00017 Future revisions will include more advanced graphics functions. 00018 00019 Rough and ready Demo code to for showing the driver and some 00020 functions in action. 00021 00022 ***************************************************************/ 00023 00024 00025 #include "mbed.h" 00026 #include "ILI9340_Driver.h" 00027 00028 00029 int main() { 00030 00031 // create the display object 00032 ILI9340_Display tft = ILI9340_Display(D11, D12, D13, D4, D2, D7); // mosi,miso,slck,cs,rst,dc 00033 00034 // initialise the display 00035 tft.DispInit(); 00036 00037 // clears the screen to remove all noise data 00038 tft.FillScreen(ILI9340_WHITE); 00039 00040 00041 00042 // set up variables for graphics functions 00043 uint16_t c1, c2, c3, c4, c5, c6; 00044 uint8_t r = 0, g = 0, b = 0; 00045 char elapsed[] = "1111"; 00046 int counter = 0; 00047 00048 // variables for the 'waiting..' squares 00049 int red[] = {0,30,60,90,120}; 00050 int green[] = {0,30,60,90,120}; 00051 int blue[] = {0,30,60,90,120}; 00052 00053 tft.InvertDisplay (true); 00054 00055 while(true) { 00056 // draws a black window 00057 tft.DrawRect(20, 20, 200, 280, ILI9340_BLACK); 00058 00059 // Small amount of text to the display. 00060 tft.DrawString("Hello ILI9340 Lib!", 50, 120, 1, ILI9340_BLACK); 00061 tft.DrawString("Frame Count:", 70, 135, 1, ILI9340_BLACK); 00062 tft.DrawString("Go Create!", 45, 210, 2, ILI9340_BLUE); 00063 00064 00065 00066 00067 // convert the RGB values into values that can be writen to the screen 00068 c1 = tft.Colour565(r, g, b); 00069 c2 = tft.Colour565(red[0], green[0], blue[0]); 00070 c3 = tft.Colour565(red[1], green[1], blue[1]); 00071 c4 = tft.Colour565(red[2], green[2], blue[2]); 00072 c5 = tft.Colour565(red[3], green[3], blue[3]); 00073 c6 = tft.Colour565(red[4], green[4], blue[4]); 00074 00075 // Print a 'waiting..' animation to the screen. 00076 tft.FillRect( 30, 60, 20, 20, c6); 00077 tft.FillRect( 70, 60, 20, 20, c5); 00078 tft.FillRect( 110, 60, 20, 20, c4); 00079 tft.FillRect( 150, 60, 20, 20, c3); 00080 tft.FillRect( 190, 60, 20, 20, c2); 00081 00082 // change the RGB vlaues for circle effect 00083 r += 4; g += 6; b += 8; 00084 00085 // change RGB values for the 'waiting' animation effect 00086 for (int i = 0; i < 5; i++) { 00087 red[i] += 5; 00088 green[i] += 5; 00089 blue[i] += 5; 00090 } 00091 00092 00093 //Write the frame count to screen, first overwriting the previos value in the background colour 00094 tft.IntToChars(elapsed, counter, 4, 10, 70, 160, 3, ILI9340_WHITE); 00095 if (counter++ > 9999) {counter = 0;} 00096 tft.IntToChars(elapsed, counter, 4, 10, 70, 160, 3, ILI9340_RED); 00097 00098 // Draw the circle ripples to the screen 00099 tft.DrawCircle(120, 265, r, c1); 00100 00101 00102 // Do the waiting thang... 00103 wait(0.025); 00104 00105 } 00106 00107 } 00108
Generated on Tue Jul 12 2022 23:07:03 by 1.7.2