OTM8009A config files fix / cleanup

This commit is contained in:
Mike 2020-07-10 10:12:59 +02:00
parent 8cad9f4973
commit 40cf9a5111
3 changed files with 63 additions and 77 deletions

View File

@ -1,41 +1,39 @@
// Change the width and height if required (defined in portrait mode)
// or use the constructor to over-ride defaults
#define TFT_WIDTH 800
#define TFT_HEIGHT 480
#define TFT_WIDTH 480
#define TFT_HEIGHT 800
// Delay between some initialisation commands
#define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked
// Generic commands used by TFT_eSPI.cpp
#define TFT_NOP 0x00
#define TFT_SWRST 0x01
#define TFT_NOP 0x0000
#define TFT_SWRST 0x0100
#define TFT_SLPIN 0x10
#define TFT_SLPOUT 0x11
#define TFT_SLPIN 0x1000
#define TFT_SLPOUT 0x1100
#define TFT_INVOFF 0x20
#define TFT_INVON 0x21
#define TFT_INVOFF 0x2000
#define TFT_INVON 0x2100
#define TFT_DISPOFF 0x28
#define TFT_DISPON 0x29
#define TFT_DISPOFF 0x2800
#define TFT_DISPON 0x2900
#define TFT_CASET 0x2A00
#define TFT_PASET 0x2B00
#define TFT_RAMWR 0x2C
#define TFT_RAMWR 0x2C00
#define TFT_RAMRD 0x2E
#define TFT_RAMRD 0x2E00
#define TFT_MADCTL 0x36
#define TFT_MADCTL 0x3600
#define TFT_MAD_MY 0x80
#define TFT_MAD_MX 0x40
#define TFT_MAD_MV 0x20
#define TFT_MAD_ML 0x10
#define TFT_MAD_RGB 0x00
#define TFT_MAD_BGR 0x08
//#define TFT_MAD_MH 0x04
//#define TFT_MAD_SS 0x02
//#define TFT_MAD_GS 0x01
#define TFT_MAD_MY 0x80 /* Row Address Order */
#define TFT_MAD_MX 0x40 /* Column Address Order */
#define TFT_MAD_MV 0x20 /* Row / Column Exchange */
#define TFT_MAD_ML 0x10 /* Vertical Refresh Order - Bottom to Top */
#define TFT_MAD_RGB 0x00 /* RGB color filter panel */
#define TFT_MAD_BGR 0x08 /* BGR color filter panel */
/* Manufacturer Command Set */
#define MCS_ADRSFT 0x0000 /* Address Shift Function */
@ -78,4 +76,33 @@
#define MCS_GMCT2_2N 0xE200 /* Gamma Correction 2.2- Setting */
#define MCS_NO_DOC3 0xF5B6 /* Command not documented */
#define MCS_CMD2_ENA1 0xFF00 /* Enable Access Command2 "CMD2" */
#define MCS_CMD2_ENA2 0xFF80 /* Enable Access Orise Command2 */
#define MCS_CMD2_ENA2 0xFF80 /* Enable Access Orise Command2 */
#define Byte8H(ByteH) ((uint8_t)(((uint16_t)(ByteH)&0xFF00)>>8))
#define Byte8L(ByteL) ((uint8_t)( (uint16_t)(ByteL)&0x00FF))
#define TFT_CASET_CMD(x0, x1) \
DC_C; tft_Write_16(TFT_CASET); \
DC_D; tft_Write_16(Byte8H(x0)); \
DC_C; tft_Write_16(TFT_CASET + 1); \
DC_D; tft_Write_16(Byte8L(x0)); \
DC_C; tft_Write_16(TFT_CASET + 2); \
DC_D; tft_Write_16(Byte8H(x1)); \
DC_C; tft_Write_16(TFT_CASET + 3); \
DC_D; tft_Write_16(Byte8L(x1))
#define TFT_PASET_CMD(y0, y1) \
DC_C; tft_Write_16(TFT_PASET); \
DC_D; tft_Write_16(Byte8H(y0)); \
DC_C; tft_Write_16(TFT_PASET + 1); \
DC_D; tft_Write_16(Byte8L(y0)); \
DC_C; tft_Write_16(TFT_PASET + 2); \
DC_D; tft_Write_16(Byte8H(y1)); \
DC_C; tft_Write_16(TFT_PASET + 3); \
DC_D; tft_Write_16(Byte8L(y1))
#define writecommand16(cmd) \
writecommand(Byte8H(cmd)); writecommand(Byte8L(cmd))
#define writedata16(data) \
writedata(Byte8H(data)); writedata(Byte8L(data))

View File

@ -1,37 +1,6 @@
// This is the command sequence that initialises the OTM8009A driver
// Configure OTM8009A display
#define Byte8H(ByteH) ((uint8_t)(((uint16_t)(ByteH)&0xFF00)>>8))
#define Byte8L(ByteL) ((uint8_t)( (uint16_t)(ByteL)&0x00FF))
#define TFT_CASET_CMD(x0, x1) \
DC_C; tft_Write_16(TFT_CASET); \
DC_D; tft_Write_16(Byte8H(x0)); \
DC_C; tft_Write_16(TFT_CASET + 1); \
DC_D; tft_Write_16(Byte8L(x0)); \
DC_C; tft_Write_16(TFT_CASET + 2); \
DC_D; tft_Write_16(Byte8H(x1)); \
DC_C; tft_Write_16(TFT_CASET + 3); \
DC_D; tft_Write_16(Byte8L(x1))
#define TFT_PASET_CMD(y0, y1) \
DC_C; tft_Write_16(TFT_PASET); \
DC_D; tft_Write_16(Byte8H(y0)); \
DC_C; tft_Write_16(TFT_PASET + 1); \
DC_D; tft_Write_16(Byte8L(y0)); \
DC_C; tft_Write_16(TFT_PASET + 2); \
DC_D; tft_Write_16(Byte8H(y1)); \
DC_C; tft_Write_16(TFT_PASET + 3); \
DC_D; tft_Write_16(Byte8L(y1))
#define writecommand16(cmd) \
writecommand(Byte8H(cmd)); writecommand(Byte8L(cmd))
#define writedata16(data) \
writedata(Byte8H(data)); writedata(Byte8L(data))
//3.97inch OTM8009 Init 20190116
/* Enter CMD2 */
writecommand16(MCS_CMD2_ENA1);
@ -397,9 +366,7 @@
/* Command not documented: 0x3A00 */
writecommand16(0x3A00);//ccaa[7:0] : reg setting for signal35 selection with u2d mode
writedata16(0x55);//0x55
// /* Exit CMD2 - new! */
// writecommand16(MCS_CMD2_ENA1);
// writedata16(0xFF);
@ -410,15 +377,13 @@
/* Sleep out */
writecommand(TFT_SLPOUT);
writecommand(TFT_NOP);
writecommand16(TFT_SLPOUT);
delay(100);
/* Display on */
writecommand(TFT_DISPON);
writecommand(TFT_NOP);
writecommand16(TFT_DISPON);
delay(50);
/* Memory Write */
//writecommand16(0x2C00);
//writecommand16(TFT_RAMWR);
// End of OTM8009A display configuration

View File

@ -1,32 +1,26 @@
// This is the command sequence that rotates the OTM8009A driver coordinate frame
rotation = m % 4;
writecommand(TFT_MADCTL);
writecommand(TFT_NOP);
writecommand16(TFT_MADCTL);
switch (rotation) {
case 0: // Portrait
writedata16(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_RGB);
_width = TFT_WIDTH;
_height = TFT_HEIGHT;
writedata(0x00);
writedata(0x00);
_height = TFT_HEIGHT;
break;
case 1: // Landscape (Portrait + 90)
writedata16(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_RGB);
_width = TFT_HEIGHT;
_height = TFT_WIDTH;
writedata((1<<5)|(1<<6));
writedata(0x00);
_height = TFT_WIDTH;
break;
case 2: // Inverter portrait
writedata16(TFT_MAD_RGB);
_width = TFT_WIDTH;
_height = TFT_HEIGHT;
writedata((1<<7)|(1<<6));
writedata(0x00);
_height = TFT_HEIGHT;
break;
case 3: // Inverted landscape
writedata16(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_RGB);
_width = TFT_HEIGHT;
_height = TFT_WIDTH;
writedata((1<<7)|(1<<5));
writedata(0x00);
break;
}