LGDP4535 TFT használata Arduino-DUE fejlesztő modullal
Ez a kijelző sajnos nincs az Arduino által támogatott típusok között, ráadásul Arduino Due alaplaphoz nem készült semmilyen könyvtár.
Amit tudni érdemes róla:
Felbontás: 320x240pixel, 262144 szín (18bit)
A kijelzőn látható, hogy a http://www.mcufriend.com oldalról származik
Lábkiosztása:
LCD_RD A0
LCD_WR A1
LCD_RS A2
LCD_CS A3
LCD_RST A4
LCD_D7 7
LCD_D6 6
LCD_D5 5
LCD_D4 4
LCD_D3 3
LCD_D2 2
LCD_D1 9
LCD_D0 8
SD_SS 10
SD_DI 11
SD_DO 12
SD_SCK 13
Működő kód:
#include <Adafruit_GFX.h> // Hardware-specific library
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
void setup()
{
// put your setup code here, to run once:
Serial.begin(9600);
tft.reset();
uint16_t identifier = tft.readID();
Serial.print("ID = 0x");
Serial.println(identifier, HEX);
if (identifier == 0xEFEF) identifier = 0x9486;
tft.begin(identifier);
int xDir = 1;
// tft.fillScreen(BLACK);
}
char *msg[] = { "PORTRAIT", "LANDSCAPE", "PORTRAIT_REV", "LANDSCAPE_REV" };
uint8_t aspect;
void loop()
{
// put your main code here, to run repeatedly:
uint16_t x = 50, y = 100;
tft.setRotation(aspect);
tft.fillScreen(0x0000);
tft.setCursor(0, 0);
tft.setTextSize(2);
tft.println(msg[aspect]);
tft.setCursor(x, y);
tft.println("[x=" + String(x) + ",y=" + String(y) + "]");
delay(5000);
tft.println("INVERT ON");
tft.invertDisplay(true);
delay(1000);
tft.invertDisplay(false);
tft.println("INVERT OFF");
delay(1000);
if (++aspect >= 4) aspect = 0;
}
Sajnos a képernyőn a feliratok tükörképe jelent meg. (CGRAM írási irány konfigurációs hiba)
Az MCUFRIEND_kbv.cpp fájlban módosítani kellett a kijelzőre vonatkozó részt:
Az eredeti:
switch (_lcd_ID) {
case 0x9325:
case 0x9335:
case 0x4535:
case 0x7783:
val ^= 0x80; //.kbv ILI9320 has NOT inverted logic on GS (MY)
case 0x9320:
_MC = 0x20, _MP = 0x21, _MW = 0x22, _SC = 0x50, _EC = 0x51, _SP = 0x52, _EP = 0x53;
GS = (val & 0x80) ? (1 << 15) : 0;
SS = (val & 0x40) ? (1 << 8) : 0;
ORG = (val & 0x20) ? (1 << 3) : 0;
WriteCmdData(0x01, SS); // set Driver Output Control
WriteCmdData(0x60, GS | 0x2700); // Gate Scan Line (0xA700)
WriteCmdData(0x03, ORG | 0x1030); // set GRAM write direction and BGR=1.
break;
A módosított:
switch (_lcd_ID) {
case 0x9325:
case 0x9335:
case 0x4535:
_MC = 0x20, _MP = 0x21, _MW = 0x22, _SC = 0x50, _EC = 0x51, _SP = 0x52, _EP = 0x53;
GS = (val & 0x80) ? (1 << 15) : 0;
SS = (val & 0x40) ? (1 << 8) : 0;
ORG = (val & 0x20) ? (1 << 3) : 0;
WriteCmdData(0x01, SS); // set Driver Output Control
WriteCmdData(0x60, GS | 0x2700); // Gate Scan Line (0xA700)
WriteCmdData(0x03, ORG | 0x1030); // set GRAM write direction and BGR=1.
break;
case 0x7783:
val ^= 0x80; //.kbv ILI9320 has NOT inverted logic on GS (MY)
case 0x9320:
_MC = 0x20, _MP = 0x21, _MW = 0x22, _SC = 0x50, _EC = 0x51, _SP = 0x52, _EP = 0x53;
GS = (val & 0x80) ? (1 << 15) : 0;
SS = (val & 0x40) ? (1 << 8) : 0;
ORG = (val & 0x20) ? (1 << 3) : 0;
WriteCmdData(0x01, SS); // set Driver Output Control
WriteCmdData(0x60, GS | 0x2700); // Gate Scan Line (0xA700)
WriteCmdData(0x03, ORG | 0x1030); // set GRAM write direction and BGR=1.
break;
A módosított fájl letölthető az alábbi linken:
Az eredeti oldal: www.mcufriend.com
Adrian Corner