ILI9325 based TFT Arduino shield on KL25Z
Dependencies: TFTLCD_8bit mbed
This is for cheap touch screen TFT from Thiha Electronics (http://www.thiha-elec.com/shield.html).
main.cpp@7:8ba4518ba2f8, 2014-12-03 (annotated)
- Committer:
- ThihaElectronics
- Date:
- Wed Dec 03 17:09:27 2014 +0000
- Revision:
- 7:8ba4518ba2f8
- Parent:
- 6:f7d4a6a500f3
added line, circle, triangle drawing
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ThihaElectronics | 0:968ea69b9984 | 1 | #include "mbed.h" |
ThihaElectronics | 5:922253f4e70b | 2 | #include "ili9328.h" |
ThihaElectronics | 5:922253f4e70b | 3 | |
ThihaElectronics | 0:968ea69b9984 | 4 | // prepare the data bus for writing commands and pixel data |
ThihaElectronics | 0:968ea69b9984 | 5 | //BusOut dataBus( p30, p29, p28, p27, p26, p25, p24, p23, p22, p21, p20, p19, p18, p17, p16, p15 ); // 16 pins |
ThihaElectronics | 0:968ea69b9984 | 6 | BusOut dataBus( PTA13, PTD5, PTD4, PTA12, PTA4, PTA5, PTC8, PTC9 ); // 16 pins |
ThihaElectronics | 0:968ea69b9984 | 7 | // create the lcd instance |
ThihaElectronics | 5:922253f4e70b | 8 | ILI9328_LCD lcd( PTB3, PTC2, PTB2, PTB1, &dataBus, NC, PTB0); // control pins and data bus |
ThihaElectronics | 0:968ea69b9984 | 9 | //CS, RESET, RS, WR |
ThihaElectronics | 0:968ea69b9984 | 10 | int main() |
ThihaElectronics | 0:968ea69b9984 | 11 | { |
ThihaElectronics | 7:8ba4518ba2f8 | 12 | int ii,height,width; |
ThihaElectronics | 7:8ba4518ba2f8 | 13 | |
ThihaElectronics | 7:8ba4518ba2f8 | 14 | height = lcd.GetHeight(); |
ThihaElectronics | 7:8ba4518ba2f8 | 15 | width = lcd.GetWidth(); |
ThihaElectronics | 0:968ea69b9984 | 16 | // initialize display - place it in standard portrait mode and set background to black and |
ThihaElectronics | 0:968ea69b9984 | 17 | // foreground to white color. |
ThihaElectronics | 0:968ea69b9984 | 18 | lcd.Initialize(); |
ThihaElectronics | 5:922253f4e70b | 19 | // set current font to the smallest 8x12 pixels font. |
ThihaElectronics | 5:922253f4e70b | 20 | // lcd.SetFont( Font8x12 ); |
ThihaElectronics | 5:922253f4e70b | 21 | // print something on the screen |
ThihaElectronics | 5:922253f4e70b | 22 | lcd.Print( "Hello, World!", CENTER, 50); // align text to center horizontally and use starndard colors |
ThihaElectronics | 0:968ea69b9984 | 23 | |
ThihaElectronics | 7:8ba4518ba2f8 | 24 | wait(2); |
ThihaElectronics | 7:8ba4518ba2f8 | 25 | |
ThihaElectronics | 6:f7d4a6a500f3 | 26 | lcd.ClearScreen(); |
ThihaElectronics | 6:f7d4a6a500f3 | 27 | |
ThihaElectronics | 6:f7d4a6a500f3 | 28 | // for(ii=0;ii<240;ii++) |
ThihaElectronics | 6:f7d4a6a500f3 | 29 | // height = lcd.GetHeight(); |
ThihaElectronics | 6:f7d4a6a500f3 | 30 | // for(ii=0;ii<lcd.GetHeight1();ii++) |
ThihaElectronics | 6:f7d4a6a500f3 | 31 | for(ii=0;ii<width;ii++) |
ThihaElectronics | 6:f7d4a6a500f3 | 32 | { |
ThihaElectronics | 6:f7d4a6a500f3 | 33 | // lcd.DrawLine(0, 0, lcd.GetWidth1(), ii,COLOR_GREEN); |
ThihaElectronics | 6:f7d4a6a500f3 | 34 | lcd.DrawLine(0, 0, height, ii,COLOR_GREEN); |
ThihaElectronics | 6:f7d4a6a500f3 | 35 | // lcd.DrawLine(0, 0, 320, ii,COLOR_GREEN); |
ThihaElectronics | 6:f7d4a6a500f3 | 36 | ii = ii+10; |
ThihaElectronics | 6:f7d4a6a500f3 | 37 | } |
ThihaElectronics | 7:8ba4518ba2f8 | 38 | wait(2); |
ThihaElectronics | 6:f7d4a6a500f3 | 39 | |
ThihaElectronics | 6:f7d4a6a500f3 | 40 | lcd.DrawCircle(height/4, width/4, 20, COLOR_GREEN); |
ThihaElectronics | 7:8ba4518ba2f8 | 41 | wait(2); |
ThihaElectronics | 6:f7d4a6a500f3 | 42 | |
ThihaElectronics | 6:f7d4a6a500f3 | 43 | lcd.FillCircle(height/2, width/2, 50, COLOR_GREEN); |
ThihaElectronics | 7:8ba4518ba2f8 | 44 | wait(2); |
ThihaElectronics | 6:f7d4a6a500f3 | 45 | |
ThihaElectronics | 6:f7d4a6a500f3 | 46 | lcd.FillTriangle(height/4, width/4,(height/4)+20, (width/4)+40,(height/4)-20, (width/4)+40, COLOR_RED); |
ThihaElectronics | 7:8ba4518ba2f8 | 47 | |
ThihaElectronics | 6:f7d4a6a500f3 | 48 | |
ThihaElectronics | 0:968ea69b9984 | 49 | while ( 1 ) { } |
ThihaElectronics | 0:968ea69b9984 | 50 | } |