support for ILI9342 in the ILI9341.c file

This commit is contained in:
Bassam 2022-11-24 10:09:23 +02:00
parent 32296b4fa6
commit dd78dccca4

View file

@ -53,28 +53,28 @@ static void ili9341_send_color(void * data, uint16_t length);
void ili9341_init(void)
{
lcd_init_cmd_t ili_init_cmds[]={
{0xCF, {0x00, 0x83, 0X30}, 3},
{0xED, {0x64, 0x03, 0X12, 0X81}, 4},
{0xE8, {0x85, 0x01, 0x79}, 3},
{0xCB, {0x39, 0x2C, 0x00, 0x34, 0x02}, 5},
{0xF7, {0x20}, 1},
{0xEA, {0x00, 0x00}, 2},
// {0xCF, {0x00, 0x83, 0X30}, 3},
// {0xED, {0x64, 0x03, 0X12, 0X81}, 4},
// {0xE8, {0x85, 0x01, 0x79}, 3},
// {0xCB, {0x39, 0x2C, 0x00, 0x34, 0x02}, 5},
// {0xF7, {0x20}, 1},
// {0xEA, {0x00, 0x00}, 2},
{0xC0, {0x26}, 1}, /*Power control*/
{0xC1, {0x11}, 1}, /*Power control */
{0xC5, {0x35, 0x3E}, 2}, /*VCOM control*/
{0xC7, {0xBE}, 1}, /*VCOM control*/
{0x36, {0x28}, 1}, /*Memory Access Control*/
{0x36, {0x08}, 1}, //{0x36, {0x28}, 1}, /*Memory Access Control*/
{0x3A, {0x55}, 1}, /*Pixel Format Set*/
{0xB1, {0x00, 0x1B}, 2},
{0xF2, {0x08}, 1},
{0x26, {0x01}, 1},
{0xE0, {0x1F, 0x1A, 0x18, 0x0A, 0x0F, 0x06, 0x45, 0X87, 0x32, 0x0A, 0x07, 0x02, 0x07, 0x05, 0x00}, 15},
{0XE1, {0x00, 0x25, 0x27, 0x05, 0x10, 0x09, 0x3A, 0x78, 0x4D, 0x05, 0x18, 0x0D, 0x38, 0x3A, 0x1F}, 15},
{0x2A, {0x00, 0x00, 0x00, 0xEF}, 4},
{0x2B, {0x00, 0x00, 0x01, 0x3f}, 4},
{0x2C, {0}, 0},
{0xB7, {0x07}, 1},
{0xB6, {0x0A, 0x82, 0x27, 0x00}, 4},
{0xB1, {0x00, 0x18}, 2},//{0xB1, {0x00, 0x1B}, 2}, //[BJ] frame rate.
//{0xF2, {0x08}, 1},
{0x26, {0x01}, 1}, //[BJ] Gamma set
{0xE0, {0x1F, 0x1A, 0x18, 0x0A, 0x0F, 0x06, 0x45, 0X87, 0x32, 0x0A, 0x07, 0x02, 0x07, 0x05, 0x00}, 15},//[BJ] + Gamma correction
{0XE1, {0x00, 0x25, 0x27, 0x05, 0x10, 0x09, 0x3A, 0x78, 0x4D, 0x05, 0x18, 0x0D, 0x38, 0x3A, 0x1F}, 15},//[BJ] - Gamma correction
{0x2A, {0x00, 0x00, 0x00, 0xEF}, 4}, //[BJ] column address set
{0x2B, {0x00, 0x00, 0x01, 0x3f}, 4},//[BJ] page address set
{0x2C, {0}, 0},//[BJ] memory write.
{0xB7, {0x07}, 1},//[BJ] Entry mode set
{0xB6, {0x0A, 0x82, 0x27, 0x00}, 4}, //[BJ] display function control
{0x11, {0}, 0x80},
{0x29, {0}, 0x80},
{0, {0}, 0xff},
@ -108,7 +108,7 @@ void ili9341_init(void)
cmd++;
}
ili9341_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
// ili9341_set_orientation(CONFIG_LV_DISPLAY_ORIENTATION);
#if ILI9341_INVERT_COLORS == 1
ili9341_send_cmd(0x21);
@ -187,25 +187,25 @@ static void ili9341_send_color(void * data, uint16_t length)
static void ili9341_set_orientation(uint8_t orientation)
{
// ESP_ASSERT(orientation < 4);
// orientation = 2;
// const char *orientation_str[] = {
// "PORTRAIT", "PORTRAIT_INVERTED", "LANDSCAPE", "LANDSCAPE_INVERTED"
// };
const char *orientation_str[] = {
"PORTRAIT", "PORTRAIT_INVERTED", "LANDSCAPE", "LANDSCAPE_INVERTED"
};
// ESP_LOGI(TAG, "Display orientation: %s", orientation_str[orientation]);
ESP_LOGI(TAG, "Display orientation: %s", orientation_str[orientation]);
// #if defined CONFIG_LV_PREDEFINED_DISPLAY_M5STACK
// uint8_t data[] = {0x68, 0x68, 0x08, 0x08};
// #elif defined (CONFIG_LV_PREDEFINED_DISPLAY_M5CORE2)
// uint8_t data[] = {0x08, 0x88, 0x28, 0xE8};
// #elif defined (CONFIG_LV_PREDEFINED_DISPLAY_WROVER4)
// uint8_t data[] = {0x6C, 0xEC, 0xCC, 0x4C};
// #elif defined (CONFIG_LV_PREDEFINED_DISPLAY_NONE)
// uint8_t data[] = {0x48, 0x88, 0x28, 0xE8};
// #endif
#if defined CONFIG_LV_PREDEFINED_DISPLAY_M5STACK
uint8_t data[] = {0x68, 0x68, 0x08, 0x08};
#elif defined (CONFIG_LV_PREDEFINED_DISPLAY_M5CORE2)
uint8_t data[] = {0x08, 0x88, 0x28, 0xE8};
#elif defined (CONFIG_LV_PREDEFINED_DISPLAY_WROVER4)
uint8_t data[] = {0x6C, 0xEC, 0xCC, 0x4C};
#elif defined (CONFIG_LV_PREDEFINED_DISPLAY_NONE)
uint8_t data[] = {0x48, 0x88, 0x28, 0xE8};
#endif
// ESP_LOGI(TAG, "0x36 command value: 0x%02X", data[orientation]);
ESP_LOGI(TAG, "0x36 command value: 0x%02X", data[orientation]);
ili9341_send_cmd(0x36);
ili9341_send_data((void *) &data[orientation], 1);
// ili9341_send_cmd(0x36);
// ili9341_send_data((void *) &data[orientation], 1);
}