Skip to content

Commit 78e5e66

Browse files
committed
Added ILI9486
1 parent c312b25 commit 78e5e66

File tree

2 files changed

+84
-44
lines changed

2 files changed

+84
-44
lines changed

Arduino-STM32-8bitTFT.cpp

+79-11
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ static uint8_t is8347 = 0;
4242
STM32_TFT_8bit::STM32_TFT_8bit(void)
4343
: Adafruit_GFX(TFTWIDTH, TFTHEIGHT) {
4444

45+
//enable TFT_CNTRL port clock
4546
enablePortClock(TFT_CNTRL);
46-
47+
4748
// set control pin mode
4849
LL_GPIO_SetPinMode(TFT_CNTRL, TFT_RD, LL_GPIO_MODE_OUTPUT);
4950
LL_GPIO_SetPinMode(TFT_CNTRL, TFT_WR, LL_GPIO_MODE_OUTPUT);
@@ -92,12 +93,12 @@ STM32_TFT_8bit::STM32_TFT_8bit(void)
9293
_pins[6] = TFT_D6;
9394
_pins[7] = TFT_D7;
9495

95-
//enable GPIO port clock
96+
//enable TFT_DATA port clock
9697
enablePortClock(TFT_DATA);
9798

9899
}
99100

100-
101+
// STM32F103 does not have GPIOE defined
101102
void STM32_TFT_8bit::enablePortClock(GPIO_TypeDef *gpio) {
102103
if (gpio == GPIOA) {
103104
__HAL_RCC_GPIOA_CLK_ENABLE();
@@ -106,12 +107,11 @@ void STM32_TFT_8bit::enablePortClock(GPIO_TypeDef *gpio) {
106107
} else if (gpio == GPIOC) {
107108
__HAL_RCC_GPIOC_CLK_ENABLE();
108109
} else if (gpio == GPIOD) {
109-
__HAL_RCC_GPIOE_CLK_ENABLE();
110-
} else if (gpio == GPIOE) {
111-
__HAL_RCC_GPIOE_CLK_ENABLE();
110+
__HAL_RCC_GPIOD_CLK_ENABLE();
112111
}
113112
}
114113

114+
115115
void STM32_TFT_8bit::setWriteDataBus(void) {
116116
for (int i=0;i<8;i++) {
117117
LL_GPIO_SetPinMode(TFT_DATA, _pins[i], LL_GPIO_MODE_OUTPUT);
@@ -733,11 +733,6 @@ void STM32_TFT_8bit::begin(uint16_t ID) {
733733
table8_ads = ILI9342_regValues_CPT24, table_size = sizeof(ILI9342_regValues_CPT24); //
734734
//table8_ads = ILI9342_regValues_Tianma23, table_size = sizeof(ILI9342_regValues_Tianma23); //
735735
//table8_ads = ILI9342_regValues_HSD23, table_size = sizeof(ILI9342_regValues_HSD23); //
736-
737-
p16 = (int16_t *) & HEIGHT;
738-
*p16 = 240;
739-
p16 = (int16_t *) & WIDTH;
740-
*p16 = 320;
741736
break;
742737

743738
case 0x1581: //no BGR in MADCTL. set BGR in Panel Control
@@ -838,6 +833,79 @@ void STM32_TFT_8bit::begin(uint16_t ID) {
838833

839834
break;
840835

836+
case 0x9486:
837+
_lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS; //Red 3.5", Blue 3.5"
838+
// _lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS | REV_SCREEN; //old Red 3.5"
839+
static const uint8_t ILI9486_regValues[] PROGMEM = {
840+
/*
841+
0xF2, 9, 0x1C, 0xA3, 0x32, 0x02, 0xB2, 0x12, 0xFF, 0x12, 0x00, //f.k
842+
0xF1, 2, 0x36, 0xA4, //
843+
0xF8, 2, 0x21, 0x04, //
844+
0xF9, 2, 0x00, 0x08, //
845+
*/
846+
0xC0, 2, 0x0d, 0x0d, //Power Control 1 [0E 0E]
847+
0xC1, 2, 0x43, 0x00, //Power Control 2 [43 00]
848+
0xC2, 1, 0x00, //Power Control 3 [33]
849+
0xC5, 4, 0x00, 0x48, 0x00, 0x48, //VCOM Control 1 [00 40 00 40]
850+
0xB4, 1, 0x00, //Inversion Control [00]
851+
0xB6, 3, 0x02, 0x02, 0x3B, // Display Function Control [02 02 3B]
852+
#define GAMMA9486 4
853+
#if GAMMA9486 == 0
854+
// default GAMMA terrible
855+
#elif GAMMA9486 == 1
856+
// GAMMA f.k. bad
857+
0xE0, 15, 0x0f, 0x31, 0x2b, 0x0c, 0x0e, 0x08, 0x4e, 0xf1, 0x37, 0x07, 0x10, 0x03, 0x0e, 0x09, 0x00,
858+
0xE1, 15, 0x00, 0x0e, 0x14, 0x03, 0x11, 0x07, 0x31, 0xC1, 0x48, 0x08, 0x0f, 0x0c, 0x31, 0x36, 0x0f,
859+
#elif GAMMA9486 == 2
860+
// 1.2 CPT 3.5 Inch Initial Code not bad
861+
0xE0, 15, 0x0F, 0x1B, 0x18, 0x0B, 0x0E, 0x09, 0x47, 0x94, 0x35, 0x0A, 0x13, 0x05, 0x08, 0x03, 0x00,
862+
0xE1, 15, 0x0F, 0x3A, 0x37, 0x0B, 0x0C, 0x05, 0x4A, 0x24, 0x39, 0x07, 0x10, 0x04, 0x27, 0x25, 0x00,
863+
#elif GAMMA9486 == 3
864+
// 2.2 HSD 3.5 Inch Initial Code not bad
865+
0xE0, 15, 0x0F, 0x1F, 0x1C, 0x0C, 0x0F, 0x08, 0x48, 0x98, 0x37, 0x0A, 0x13, 0x04, 0x11, 0x0D, 0x00,
866+
0xE1, 15, 0x0F, 0x32, 0x2E, 0x0B, 0x0D, 0x05, 0x47, 0x75, 0x37, 0x06, 0x10, 0x03, 0x24, 0x20, 0x00,
867+
#elif GAMMA9486 == 4
868+
// 3.2 TM 3.2 Inch Initial Code not bad
869+
0xE0, 15, 0x0F, 0x21, 0x1C, 0x0B, 0x0E, 0x08, 0x49, 0x98, 0x38, 0x09, 0x11, 0x03, 0x14, 0x10, 0x00,
870+
0xE1, 15, 0x0F, 0x2F, 0x2B, 0x0C, 0x0E, 0x06, 0x47, 0x76, 0x37, 0x07, 0x11, 0x04, 0x23, 0x1E, 0x00,
871+
#elif GAMMA9486 == 5
872+
// 4.2 WTK 3.5 Inch Initial Code too white
873+
0xE0, 15, 0x0F, 0x10, 0x08, 0x05, 0x09, 0x05, 0x37, 0x98, 0x26, 0x07, 0x0F, 0x02, 0x09, 0x07, 0x00,
874+
0xE1, 15, 0x0F, 0x38, 0x36, 0x0D, 0x10, 0x08, 0x59, 0x76, 0x48, 0x0A, 0x16, 0x0A, 0x37, 0x2F, 0x00,
875+
#endif
876+
};
877+
table8_ads = ILI9486_regValues, table_size = sizeof(ILI9486_regValues);
878+
break;
879+
880+
case 0x7796:
881+
_lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS; //thanks to safari1
882+
static const uint8_t PROGMEM ST7796_regValues[] = {
883+
0xB7, 1, 0xC6, //Entry Mode [06]
884+
0xE8, 8, 0x40, 0x8A, 0x00, 0x00, 0x29, 0x19, 0xA5, 0x33, //Adj3 [40 8A 00 00 25 0A 38 33]
885+
};
886+
table8_ads = ST7796_regValues, table_size = sizeof(ST7796_regValues);
887+
break;
888+
889+
case 0x9487: //with thanks to Charlyf
890+
case 0x9488:
891+
_lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS | READ_24BITS;
892+
common_9488:
893+
static const uint8_t ILI9488_regValues_max[] PROGMEM = { // Atmel MaxTouch
894+
0xC0, 2, 0x10, 0x10, //Power Control 1 [0E 0E]
895+
0xC1, 1, 0x41, //Power Control 2 [43]
896+
0xC5, 4, 0x00, 0x22, 0x80, 0x40, //VCOM Control 1 [00 40 00 40]
897+
0x36, 1, 0x68, //Memory Access [00]
898+
0xB0, 1, 0x00, //Interface [00]
899+
0xB1, 2, 0xB0, 0x11, //Frame Rate Control [B0 11]
900+
0xB4, 1, 0x02, //Inversion Control [02]
901+
0xB6, 3, 0x02, 0x02, 0x3B, // Display Function Control [02 02 3B] .kbv NL=480
902+
0xB7, 1, 0xC6, //Entry Mode [06]
903+
0x3A, 1, 0x55, //Interlace Pixel Format [XX]
904+
0xF7, 4, 0xA9, 0x51, 0x2C, 0x82, //Adjustment Control 3 [A9 51 2C 82]
905+
};
906+
table8_ads = ILI9488_regValues_max, table_size = sizeof(ILI9488_regValues_max);
907+
break;
908+
841909
case 0x6814:
842910
_lcd_capable = AUTO_READINC | MIPI_DCS_REV1 | MV_AXIS;
843911
static const uint8_t RM68140_regValues_max[] PROGMEM = { //

Arduino-STM32-8bitTFT.h

+5-33
Original file line numberDiff line numberDiff line change
@@ -172,34 +172,6 @@ Define pins and Output Data Registers
172172
//Pin stm32 |PD15|PD14|PD13|PD12|PD11|PD10|PD9|PD8|
173173
#endif
174174

175-
#if 0
176-
#define TFT_DATA GPIOE
177-
#define TFT_D0 LL_GPIO_PIN_0
178-
#define TFT_D1 LL_GPIO_PIN_1
179-
#define TFT_D2 LL_GPIO_PIN_2
180-
#define TFT_D3 LL_GPIO_PIN_3
181-
#define TFT_D4 LL_GPIO_PIN_4
182-
#define TFT_D5 LL_GPIO_PIN_5
183-
#define TFT_D6 LL_GPIO_PIN_6
184-
#define TFT_D7 LL_GPIO_PIN_7
185-
//Port data |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 |
186-
//Pin stm32 |PE7|PE6|PE5|PE4|PE3|PE2|PE1|PE0|
187-
#endif
188-
189-
#if 0
190-
#define TFT_DATA GPIOE
191-
#define TFT_D0 LL_GPIO_PIN_8
192-
#define TFT_D1 LL_GPIO_PIN_9
193-
#define TFT_D2 LL_GPIO_PIN_10
194-
#define TFT_D3 LL_GPIO_PIN_11
195-
#define TFT_D4 LL_GPIO_PIN_12
196-
#define TFT_D5 LL_GPIO_PIN_13
197-
#define TFT_D6 LL_GPIO_PIN_14
198-
#define TFT_D7 LL_GPIO_PIN_15
199-
//Port data |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 |
200-
//Pin stm32 |PE15|PE14|PE13|PE12|PE11|PE10|PE9|PE8|
201-
#endif
202-
203175

204176
#define TFT_CNTRL GPIOB
205177
#define LL_LOW(LL_GPIO_PIN) LL_GPIO_WriteOutputPort(TFT_CNTRL, (LL_GPIO_ReadOutputPort(TFT_CNTRL) & ~(LL_GPIO_PIN)))
@@ -209,11 +181,11 @@ Define pins and Output Data Registers
209181
// Note:
210182
// PA15 PB3 PB4 is assigned to JTAG debug port by default on some boards.
211183
// Therefore, it may not be available by default.
212-
#define TFT_RD LL_GPIO_PIN_0 // Px0
213-
#define TFT_WR LL_GPIO_PIN_1 // Px1
214-
#define TFT_RS LL_GPIO_PIN_5 // Px5
215-
#define TFT_CS LL_GPIO_PIN_6 // Px6
216-
#define TFT_RST LL_GPIO_PIN_7 // Px7
184+
#define TFT_RD LL_GPIO_PIN_0 // PB0
185+
#define TFT_WR LL_GPIO_PIN_1 // PB1
186+
#define TFT_RS LL_GPIO_PIN_5 // PB5
187+
#define TFT_CS LL_GPIO_PIN_6 // PB6
188+
#define TFT_RST LL_GPIO_PIN_7 // PB7
217189

218190
//#define DELAY delayMicroseconds(10);
219191
#define DELAY (void)0 // NOP

0 commit comments

Comments
 (0)