From f96a5444ac9525b3eab76c788457813f2684ac3f Mon Sep 17 00:00:00 2001 From: lewisxhe Date: Wed, 29 May 2024 16:53:11 +0800 Subject: [PATCH] Added rm67162 spi interface method --- src/LilyGo_AMOLED.cpp | 129 ++++- src/LilyGo_AMOLED.h | 55 ++- src/RM67162_AMOLED_SPI.cpp | 268 +++++++++++ src/RM67162_AMOLED_SPI.h | 85 ++++ src/initSequence.cpp | 942 +++++++++++++++++++------------------ src/initSequence.h | 3 + 6 files changed, 999 insertions(+), 483 deletions(-) create mode 100644 src/RM67162_AMOLED_SPI.cpp create mode 100644 src/RM67162_AMOLED_SPI.h diff --git a/src/LilyGo_AMOLED.cpp b/src/LilyGo_AMOLED.cpp index 90da3a1..f668141 100644 --- a/src/LilyGo_AMOLED.cpp +++ b/src/LilyGo_AMOLED.cpp @@ -10,6 +10,7 @@ #include "LilyGo_AMOLED.h" #include #include +#include "RM67162_AMOLED_SPI.h" #define SEND_BUF_SIZE (16384) #define TFT_SPI_MODE SPI_MODE0 @@ -17,7 +18,9 @@ LilyGo_AMOLED::LilyGo_AMOLED() : boards(NULL) { + panel_handle = NULL; pBuffer = NULL; + spi = NULL; _brightness = AMOLED_DEFAULT_BRIGHTNESS; // Prevent previously set hold switch (esp_sleep_get_wakeup_cause()) { @@ -39,6 +42,11 @@ LilyGo_AMOLED::~LilyGo_AMOLED() free(pBuffer); pBuffer = NULL; } + + if (panel_handle) { + esp_lcd_panel_del(*panel_handle); + panel_handle = NULL; + } } const char *LilyGo_AMOLED::getName() @@ -49,6 +57,8 @@ const char *LilyGo_AMOLED::getName() return "1.91 inch"; } else if (boards == &BOARD_AMOLED_241) { return "2.41 inch"; + } else if (boards == &BOARD_AMOLED_191_SPI) { + return "1.91 inch(SPI Interface)"; } return "Unknown"; } @@ -61,6 +71,8 @@ uint8_t LilyGo_AMOLED::getBoardID() return LILYGO_AMOLED_191; } else if (boards == &BOARD_AMOLED_241) { return LILYGO_AMOLED_241; + } else if (boards == &BOARD_AMOLED_191_SPI) { + return LILYGO_AMOLED_191_SPI; } return LILYGO_AMOLED_UNKNOWN; } @@ -94,7 +106,7 @@ bool LilyGo_AMOLED::isPressed() { if (boards == &BOARD_AMOLED_147) { return TouchDrvCHSC5816::isPressed(); - } else if (boards == &BOARD_AMOLED_191 || boards == &BOARD_AMOLED_241) { + } else if (boards == &BOARD_AMOLED_191 || boards == &BOARD_AMOLED_241 || boards == &BOARD_AMOLED_191_SPI) { return TouchDrvCSTXXX::isPressed(); } return false; @@ -105,7 +117,7 @@ uint8_t LilyGo_AMOLED::getPoint(int16_t *x, int16_t *y, uint8_t get_point ) uint8_t point = 0; if (boards == &BOARD_AMOLED_147) { point = TouchDrvCHSC5816::getPoint(x, y); - } else if (boards == &BOARD_AMOLED_191 || boards == &BOARD_AMOLED_241) { + } else if (boards == &BOARD_AMOLED_191 || boards == &BOARD_AMOLED_241 || boards == &BOARD_AMOLED_191_SPI) { point = TouchDrvCSTXXX::getPoint(x, y); } return point; @@ -124,7 +136,11 @@ uint16_t LilyGo_AMOLED::getBattVoltage(void) } } else if (boards->adcPins != -1) { esp_adc_cal_characteristics_t adc_chars; +#if ESP_IDF_VERSION_VAL(4,4,7) < ESP_IDF_VERSION esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_11, ADC_WIDTH_BIT_12, 1100, &adc_chars); +#else + esp_adc_cal_characterize(ADC_UNIT_1, ADC_ATTEN_DB_12, ADC_WIDTH_BIT_12, 1100, &adc_chars); +#endif uint32_t v1 = 0, raw = 0; raw = analogRead(boards->adcPins); v1 = esp_adc_cal_raw_to_voltage(raw, &adc_chars) * 2; @@ -382,7 +398,14 @@ bool LilyGo_AMOLED::begin() Wire.begin(3, 2); Wire.beginTransmission(CSTXXX_SLAVE_ADDRESS); if (Wire.endTransmission() == 0) { - return beginAMOLED_191(true); + + // Check RTC Slave address + Wire.beginTransmission(0x51); + if (Wire.endTransmission() == 0) { + return beginAMOLED_191_SPI(true); + } else { + return beginAMOLED_191(true); + } } log_e("Unable to detect 1.91-inch touch board model!"); @@ -447,6 +470,60 @@ bool LilyGo_AMOLED::beginAMOLED_191(bool touchFunc) return true; } +bool LilyGo_AMOLED::beginAMOLED_191_SPI(bool touchFunc) +{ + boards = &BOARD_AMOLED_191_SPI; + + if (boards->PMICEnPins != -1) { + pinMode(boards->PMICEnPins, OUTPUT); + digitalWrite(boards->PMICEnPins, HIGH); + } + + panel_handle = panel_rm67162_init_spi_bus(DEFAULT_SPI_HANDLER, + boards->display.d0, + -1, + boards->display.sck, + boards->display.d1, + boards->display.cs, + boards->display.rst, + boards->display.freq + ); + if (!panel_handle) { + while (1) { + Serial.println("attach spi bus failed !"); delay(1000); + } + } + + if (touchFunc && boards->touch) { + if (boards->touch->sda != -1 && boards->touch->scl != -1) { + Wire.begin(boards->touch->sda, boards->touch->scl); + deviceScan(&Wire, &Serial); + + // Try to find touch device + Wire.beginTransmission(CST816_SLAVE_ADDRESS); + if (Wire.endTransmission() == 0) { + TouchDrvCSTXXX::setPins(boards->touch->rst, boards->touch->irq); + bool res = TouchDrvCSTXXX::begin(Wire, CST816_SLAVE_ADDRESS, boards->touch->sda, boards->touch->scl); + if (!res) { + log_e("Failed to find CST816T - check your wiring!"); + // return false; + _touchOnline = false; + } else { + _touchOnline = true; + TouchDrvCSTXXX::setCenterButtonCoordinate(600, 120); //AMOLED 1.91 inch + } + } + } + } else { + _touchOnline = false; + } + + setRotation(0); + + return true; +} + + bool LilyGo_AMOLED::beginAMOLED_241() { @@ -481,7 +558,7 @@ bool LilyGo_AMOLED::beginAMOLED_241() SPI.begin(boards->sd->sck, boards->sd->miso, boards->sd->mosi); // Set mount point to /fs if (!SD.begin(boards->sd->cs, SPI, 4000000U, "/fs")) { - log_e("Failed to dected SDCard!"); + log_e("Failed to detect SD Card!"); } if (SD.cardType() != CARD_NONE) { log_i("SD Card Size: %llu MB\n", SD.cardSize() / (1024 * 1024)); @@ -535,7 +612,7 @@ bool LilyGo_AMOLED::installSD(int miso, int mosi, int sclk, int cs) // Set mount point to /fs if (!SD.begin(cs, SPI, 4000000U, "/fs")) { - log_e("Failed to dected SDCard!"); + log_e("Failed to detect SD Card!!"); return false; } if (SD.cardType() != CARD_NONE) { @@ -609,17 +686,25 @@ bool LilyGo_AMOLED::beginAMOLED_147() return true; } -void LilyGo_AMOLED::writeCommand(uint32_t cmd, uint8_t *pdat, uint32_t lenght) +void LilyGo_AMOLED::writeCommand(uint32_t cmd, uint8_t *pdat, uint32_t length) { + + // SPI + if (panel_handle) { + panel_rm67162_write_command(*panel_handle, cmd, pdat, length); + return; + } + + // QSPI setCS(); spi_transaction_t t; memset(&t, 0, sizeof(t)); t.flags = (SPI_TRANS_MULTILINE_CMD | SPI_TRANS_MULTILINE_ADDR); t.cmd = 0x02; - t.addr = cmd; - if (lenght != 0) { + t.addr = cmd << 8; + if (length != 0) { t.tx_buffer = pdat; - t.length = 8 * lenght; + t.length = 8 * length; } else { t.tx_buffer = NULL; t.length = 0; @@ -631,7 +716,7 @@ void LilyGo_AMOLED::writeCommand(uint32_t cmd, uint8_t *pdat, uint32_t lenght) void LilyGo_AMOLED::setBrightness(uint8_t level) { _brightness = level; - lcd_cmd_t t = {0x5100, {level}, 0x01}; + lcd_cmd_t t = {LCD_CMD_BRIGHTNESS, {level}, 0x01}; writeCommand(t.addr, t.param, t.len); } @@ -648,7 +733,7 @@ void LilyGo_AMOLED::setAddrWindow(uint16_t xs, uint16_t ys, uint16_t xe, uint16_ ye += _offset_y; lcd_cmd_t t[3] = { { - 0x2A00, { + LCD_CMD_CASET, { (uint8_t)((xs >> 8) & 0xFF), (uint8_t)(xs & 0xFF), (uint8_t)((xe >> 8) & 0xFF), @@ -656,7 +741,7 @@ void LilyGo_AMOLED::setAddrWindow(uint16_t xs, uint16_t ys, uint16_t xe, uint16_ }, 0x04 }, { - 0x2B00, { + LCD_CMD_RASET, { (uint8_t)((ys >> 8) & 0xFF), (uint8_t)(ys & 0xFF), (uint8_t)((ye >> 8) & 0xFF), @@ -664,7 +749,7 @@ void LilyGo_AMOLED::setAddrWindow(uint16_t xs, uint16_t ys, uint16_t xe, uint16_ }, 0x04 }, { - 0x2C00, { + LCD_CMD_RAMWR, { 0x00 }, 0x00 }, @@ -678,6 +763,12 @@ void LilyGo_AMOLED::setAddrWindow(uint16_t xs, uint16_t ys, uint16_t xe, uint16_ // Push (aka write pixel) colours to the TFT (use setAddrWindow() first) void LilyGo_AMOLED::pushColors(uint16_t *data, uint32_t len) { + + if (panel_handle) { + panel_rm67162_tx_colors(*panel_handle, data, len * sizeof(uint16_t)); + return; + } + bool first_send = true; uint16_t *p = data; assert(p); @@ -819,7 +910,7 @@ void LilyGo_AMOLED::sleep() assert(boards); //Wire amoled to sleep mode - lcd_cmd_t t = {0x1000, {0x00}, 1}; //Sleep in + lcd_cmd_t t = {LCD_CMD_SLPIN, {0x00}, 1}; //Sleep in writeCommand(t.addr, t.param, t.len); if (boards) { @@ -833,7 +924,7 @@ void LilyGo_AMOLED::sleep() TouchDrvCSTXXX::sleep(); } else if (boards == &BOARD_AMOLED_147) { - Serial.println("PMU Disbale AMOLED Power"); + Serial.println("PMU Disable AMOLED Power"); // Turn off Sensor SensorCM32181::powerDown(); @@ -872,7 +963,7 @@ void LilyGo_AMOLED::sleep() void LilyGo_AMOLED::wakeup() { - lcd_cmd_t t = {0x1100, {0x00}, 1};// Sleep Out + lcd_cmd_t t = {0x11, {0x00}, 1};// Sleep Out writeCommand(t.addr, t.param, t.len); } @@ -891,7 +982,7 @@ void LilyGo_AMOLED::setRotation(uint8_t rotation) uint8_t data = 0x00; rotation %= 4; _rotation = rotation; - if (boards == &BOARD_AMOLED_191) { + if (boards == &BOARD_AMOLED_191 || boards == &BOARD_AMOLED_191_SPI) { switch (_rotation) { case 1: data = RM67162_MADCTL_RGB; @@ -934,7 +1025,7 @@ void LilyGo_AMOLED::setRotation(uint8_t rotation) } break; } - writeCommand(0x3600, &data, 1); + writeCommand(LCD_CMD_MADCTL, &data, 1); } else if (boards == &BOARD_AMOLED_241) { switch (_rotation) { case 1: @@ -986,7 +1077,7 @@ void LilyGo_AMOLED::setRotation(uint8_t rotation) } break; } - writeCommand(0x3600, &data, 1); + writeCommand(LCD_CMD_MADCTL, &data, 1); } else { Serial.println("The screen you are currently using does not support screen rotation!!!"); } diff --git a/src/LilyGo_AMOLED.h b/src/LilyGo_AMOLED.h index ea86544..a28bc5d 100644 --- a/src/LilyGo_AMOLED.h +++ b/src/LilyGo_AMOLED.h @@ -32,6 +32,9 @@ #include #endif +#include + + #if ARDUINO_USB_CDC_ON_BOOT != 1 #warning "If you need to monitor printed data, be sure to set USB_CDC_ON_BOOT to ENABLE, otherwise you will not see any data in the serial monitor" #endif @@ -63,7 +66,7 @@ #define DEFAULT_SCK_SPEED (30 * 1000 * 1000) typedef struct __DisplayConfigure { - int d0; + int d0; int d1; int d2; int d3; @@ -162,7 +165,7 @@ static const DisplayConfigure_t RM67162_AMOLED = { 18,//BOARD_DISP_DATA0, 7,//BOARD_DISP_DATA1, 48,//BOARD_DISP_DATA2, - 5,//BOARD_DISP_DATA3, + 5,//BOARD_DISP_DATA3, 47,//BOARD_DISP_SCK, 6,//BOARD_DISP_CS, BOARD_NONE_PIN,//DC @@ -179,6 +182,28 @@ static const DisplayConfigure_t RM67162_AMOLED = { false //fullRefresh }; +// LILYGO 1.91 Inch AMOLED(RM67162) S3R8 +// https://www.lilygo.cc/products/t-display-s3-amoled +static const DisplayConfigure_t RM67162_AMOLED_SPI = { + 18,//BOARD_DISP_DATA0, //MOSI + 7,//BOARD_DISP_DATA1, //DC + -1,//BOARD_DISP_DATA2, + -1,//BOARD_DISP_DATA3, + 47,//BOARD_DISP_SCK, //SCK + 6,//BOARD_DISP_CS, //CS + BOARD_NONE_PIN,//DC + 17,//BOARD_DISP_RESET, //RST + 9, //BOARD_DISP_TE, + 8, //command bit + 24,//address bit + 40000000, + (lcd_cmd_t *)rm67162_cmd, + RM67162_INIT_SEQUENCE_LENGTH, + RM67162_WIDTH,//width + RM67162_HEIGHT,//height + 0,//frameBufferSize + false //fullRefresh +}; // LILYGO 2.41 Inch AMOLED(RM690B0) S3R8 @@ -224,6 +249,21 @@ static const BoardsConfigure_t BOARD_AMOLED_191 = { false,//framebuffer }; +static const BoardsConfigure_t BOARD_AMOLED_191_SPI = { + // RM67162 Driver + RM67162_AMOLED_SPI, + &AMOLED_191_TOUCH_PINS, //Touch CST816T + NULL,//PMU + NULL,//SENSOR + NULL,//SDCard + AMOLED_191_BUTTONTS,//Button Pins + 1, //Button Number + -1,//pixelsPins + 4, //adcPins + 38,//PMICEnPins + false,//framebuffer +}; + // T-Display AMOLED H593 // https://www.lilygo.cc/products/t-display-amoled static const BoardsConfigure_t BOARD_AMOLED_147 = { @@ -262,6 +302,7 @@ enum AmoledBoardID { LILYGO_AMOLED_147 = 0x01, LILYGO_AMOLED_191, LILYGO_AMOLED_241, + LILYGO_AMOLED_191_SPI, LILYGO_AMOLED_UNKNOWN, }; @@ -287,11 +328,15 @@ class LilyGo_AMOLED: // https://www.lilygo.cc/products/t-display-s3-amoled bool beginAMOLED_191(bool touchFunc = true); + // LILYGO 1.91 Inc AMOLED(RM67162 SPI Interface) S3R8 + bool beginAMOLED_191_SPI(bool touchFunc = true); + // LILYGO 1.47 Inc AMOLED(SH8501) S3R8 // https://www.lilygo.cc/products/t-display-amoled bool beginAMOLED_147(); - + // LILYGO 2.41 Inc AMOLED(RM690B0) S3R8 + // https://www.lilygo.cc/products/t4-s3 bool beginAMOLED_241(); @@ -348,7 +393,7 @@ class LilyGo_AMOLED: bool initPMU(); void inline setCS(); void inline clrCS(); - void writeCommand(uint32_t cmd, uint8_t *pdat, uint32_t lenght); + void writeCommand(uint32_t cmd, uint8_t *pdat, uint32_t length); uint16_t *pBuffer; spi_device_handle_t spi; uint8_t _brightness; @@ -356,6 +401,8 @@ class LilyGo_AMOLED: bool _touchOnline; uint16_t _width, _height; + esp_lcd_panel_handle_t *panel_handle; + #if ESP_IDF_VERSION > ESP_IDF_VERSION_VAL(5,0,0) temperature_sensor_handle_t temp_sensor; #endif diff --git a/src/RM67162_AMOLED_SPI.cpp b/src/RM67162_AMOLED_SPI.cpp new file mode 100644 index 0000000..0c1473f --- /dev/null +++ b/src/RM67162_AMOLED_SPI.cpp @@ -0,0 +1,268 @@ +/** + * @file RM67162_AMOLED_SPI.cpp + * @author Lewis He (lewishe@outlook.com) + * @license MIT + * @copyright Copyright (c) 2024 ShenZhen XinYuan Electronic Technology Co., Ltd + * @date 2024-05-28 + * + */ +#include "RM67162_AMOLED_SPI.h" +#include "initSequence.h" +#include + +__BEGIN_DECLS + +#define TAG "rm67162" + +static esp_lcd_panel_handle_t panel_handle; + +static esp_err_t panel_rm67162_del(esp_lcd_panel_t *panel); +static esp_err_t panel_rm67162_reset(esp_lcd_panel_t *panel); +static esp_err_t panel_rm67162_init(esp_lcd_panel_t *panel); +static esp_err_t panel_rm67162_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, const void *color_data); +static esp_err_t panel_rm67162_set_rotation(esp_lcd_panel_t *panel, uint8_t r); + + +static esp_err_t esp_lcd_new_panel_rm67162(const esp_lcd_panel_io_handle_t io, const esp_lcd_panel_dev_config_t *panel_dev_config, esp_lcd_panel_handle_t *ret_panel) +{ + esp_err_t ret = ESP_OK; + rm67162_panel_t *rm67162 = NULL; + uint8_t fb_bits_per_pixel = 0; + + ESP_GOTO_ON_FALSE(io && panel_dev_config && ret_panel, ESP_ERR_INVALID_ARG, err, TAG, "invalid argument"); + rm67162 = (rm67162_panel_t *)calloc(1, sizeof(rm67162_panel_t)); + ESP_GOTO_ON_FALSE(rm67162, ESP_ERR_NO_MEM, err, TAG, "no mem for rm67162 panel"); + if (panel_dev_config->reset_gpio_num >= 0) { + pinMode(panel_dev_config->reset_gpio_num, OUTPUT); + } + switch (panel_dev_config->bits_per_pixel) { + case 16: // RGB565 + rm67162->colmod_cal = 0x55; + fb_bits_per_pixel = 16; + break; + case 18: // RGB666 + rm67162->colmod_cal = 0x66; + // each color component (R/G/B) should occupy the 6 high bits of a byte, which means 3 full bytes are required for a pixel + fb_bits_per_pixel = 24; + break; + default: + ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported pixel width"); + break; + } + rm67162->io = io; + rm67162->fb_bits_per_pixel = fb_bits_per_pixel; + rm67162->reset_gpio_num = panel_dev_config->reset_gpio_num; + rm67162->reset_level = panel_dev_config->flags.reset_active_high; + rm67162->base.del = panel_rm67162_del; + rm67162->base.reset = panel_rm67162_reset; + rm67162->base.init = panel_rm67162_init; + rm67162->base.draw_bitmap = panel_rm67162_draw_bitmap; + rm67162->base.invert_color = NULL; + rm67162->base.set_gap = NULL; + rm67162->base.mirror = NULL; + rm67162->base.swap_xy = NULL; + *ret_panel = &(rm67162->base); + log_d("new rm67162 panel @%p", rm67162); + return ESP_OK; +err: + if (rm67162) { + if (panel_dev_config->reset_gpio_num >= 0) { + pinMode(panel_dev_config->reset_gpio_num, OPEN_DRAIN); + } + free(rm67162); + } + return ret; +} + + +static esp_err_t panel_rm67162_del(esp_lcd_panel_t *panel) +{ + rm67162_panel_t *rm67162 = __containerof(panel, rm67162_panel_t, base); + if (rm67162->reset_gpio_num >= 0) { + pinMode(rm67162->reset_gpio_num, OPEN_DRAIN); + } + log_d("del rm67162 panel @%p", rm67162); + free(rm67162); + return ESP_OK; +} + +static esp_err_t panel_rm67162_reset(esp_lcd_panel_t *panel) +{ + rm67162_panel_t *rm67162 = __containerof(panel, rm67162_panel_t, base); + esp_lcd_panel_io_handle_t io = rm67162->io; + if (rm67162->reset_gpio_num >= 0) { + digitalWrite(rm67162->reset_gpio_num, rm67162->reset_level); + vTaskDelay(pdMS_TO_TICKS(100)); + digitalWrite(rm67162->reset_gpio_num, !rm67162->reset_level); + vTaskDelay(pdMS_TO_TICKS(100)); + } else { + esp_lcd_panel_io_tx_param(io, LCD_CMD_SWRESET, NULL, 0); + vTaskDelay(pdMS_TO_TICKS(20)); + } + return ESP_OK; +} + +static esp_err_t panel_rm67162_init(esp_lcd_panel_t *panel) +{ + rm67162_panel_t *rm67162 = __containerof(panel, rm67162_panel_t, base); + esp_lcd_panel_io_handle_t io = rm67162->io; + int cmd = 0; + while (rm67162_spi_cmd[cmd].len != 0xff) { + esp_lcd_panel_io_tx_param(io, rm67162_spi_cmd[cmd].addr, rm67162_spi_cmd[cmd].param, rm67162_spi_cmd[cmd].len & 0x7F); + if (rm67162_spi_cmd[cmd].len & 0x80) { + vTaskDelay(pdMS_TO_TICKS(120)); + } + cmd++; + } + rm67162->rotation = 0; + + esp_lcd_panel_io_tx_param(io, LCD_CMD_SLPOUT, NULL, 0); + vTaskDelay(pdMS_TO_TICKS(120)); + esp_lcd_panel_io_tx_param(io, rm67162->colmod_cal, NULL, 0); + vTaskDelay(pdMS_TO_TICKS(5)); + esp_lcd_panel_io_tx_param(io, LCD_CMD_DISPON, NULL, 0); + vTaskDelay(pdMS_TO_TICKS(120)); + panel_rm67162_set_rotation(panel, rm67162->rotation); + return ESP_OK; +} + +static esp_err_t panel_rm67162_draw_bitmap(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, const void *color_data) +{ + rm67162_panel_t *rm67162 = __containerof(panel, rm67162_panel_t, base); + esp_lcd_panel_io_handle_t io = rm67162->io; + assert((x_start < x_end) && (y_start < y_end) && "start position must be smaller than end position"); + uint8_t data1[] = {lowByte(x_start >> 8), lowByte(x_start), lowByte((x_end - 1) >> 8), lowByte(x_end - 1)}; + esp_lcd_panel_io_tx_param(io, LCD_CMD_CASET, data1, 4); + uint8_t data2[] = {lowByte(y_start >> 8), lowByte(y_start), lowByte((y_end - 1) >> 8), lowByte(y_end - 1)}; + esp_lcd_panel_io_tx_param(io, LCD_CMD_RASET, data2, 4); + size_t write_colors_bytes = (x_end - x_start) * (y_end - y_start) * rm67162->fb_bits_per_pixel / 8; + esp_lcd_panel_io_tx_color(io, LCD_CMD_RAMWR, color_data, write_colors_bytes); + return ESP_OK; +} + + + +static esp_err_t panel_rm67162_set_rotation(esp_lcd_panel_t *panel, uint8_t r) +{ + rm67162_panel_t *rm67162 = __containerof(panel, rm67162_panel_t, base); + esp_lcd_panel_io_handle_t io = rm67162->io; + uint8_t write_data = 0x00; + switch (r) { + case 1: + write_data = RM67162_MADCTL_RGB; + rm67162->height = RM67162_HEIGHT; + rm67162->width = RM67162_WIDTH; + break; + case 2: + write_data = RM67162_MADCTL_MV | RM67162_MADCTL_MY | RM67162_MADCTL_RGB; + rm67162->height = RM67162_WIDTH; + rm67162->width = RM67162_HEIGHT; + break; + case 3: + write_data = RM67162_MADCTL_MX | RM67162_MADCTL_MY | RM67162_MADCTL_RGB; + rm67162->height = RM67162_HEIGHT; + rm67162->width = RM67162_WIDTH; + break; + default: // case 0: + write_data = RM67162_MADCTL_MX | RM67162_MADCTL_MV | RM67162_MADCTL_RGB; + rm67162->height = RM67162_WIDTH; + rm67162->width = RM67162_HEIGHT; + break; + } + rm67162->rotation = r; + // log_i("set_rotation:%d write reg :0x%X , data : 0x%X Width:%d Height:%d", r, LCD_CMD_MADCTL, write_data, rm67162->width, rm67162->height); + esp_lcd_panel_io_tx_param(io, LCD_CMD_MADCTL, &write_data, 1); + return ESP_OK; +} +__END_DECLS + + + +esp_err_t panel_rm67162_tx_colors(esp_lcd_panel_t *panel, const void *color_data, size_t colors_size) +{ + rm67162_panel_t *rm67162 = __containerof(panel, rm67162_panel_t, base); + esp_lcd_panel_io_handle_t io = rm67162->io; + esp_lcd_panel_io_tx_color(io, LCD_CMD_RAMWR, color_data, colors_size); + return ESP_OK; +} + +esp_err_t panel_rm67162_write_command(esp_lcd_panel_t *panel, uint32_t cmd, uint8_t *pdat, uint32_t length) +{ + rm67162_panel_t *rm67162 = __containerof(panel, rm67162_panel_t, base); + esp_lcd_panel_io_handle_t io = rm67162->io; + ESP_RETURN_ON_ERROR(esp_lcd_panel_io_tx_param(io, cmd, pdat, length), TAG, "io tx command failed"); + return ESP_OK; +} + +esp_lcd_panel_handle_t *panel_rm67162_init_spi_bus(spi_host_device_t host_id, int mosi, int miso, int sck, int dc, int cs, int rst, uint32_t speed_clk_mhz) +{ + spi_bus_config_t buscfg = {0}; + buscfg.mosi_io_num = mosi; + buscfg.miso_io_num = miso; + buscfg.sclk_io_num = sck; + buscfg.quadwp_io_num = -1; + buscfg.quadhd_io_num = -1; + buscfg.data4_io_num = 0; + buscfg.data5_io_num = 0; + buscfg.data6_io_num = 0; + buscfg.data7_io_num = 0; + buscfg.max_transfer_sz = RM67162_WIDTH * 80 * sizeof(uint16_t); + buscfg.flags = 0x00; + buscfg.intr_flags = 0x00; + +#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3,0,0) + buscfg.isr_cpu_id = INTR_CPU_ID_AUTO; +#endif + + ESP_ERROR_CHECK(spi_bus_initialize(host_id, &buscfg, SPI_DMA_CH_AUTO)); + + log_i( "Install panel IO"); + + esp_lcd_panel_io_handle_t io_handle = NULL; + esp_lcd_panel_io_spi_config_t io_config = {0}; + io_config.cs_gpio_num = cs; + io_config.dc_gpio_num = dc; + io_config.spi_mode = 0; + io_config.pclk_hz = speed_clk_mhz; + io_config.trans_queue_depth = 30; + io_config.on_color_trans_done = NULL; + io_config.user_ctx = NULL; + io_config.lcd_cmd_bits = 8; + io_config.lcd_param_bits = 8; + io_config.flags.dc_low_on_data = 0; + io_config.flags.octal_mode = 0; + io_config.flags.lsb_first = 0; + +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5,0,0) + io_config.flags.quad_mode = 0; + io_config.flags.sio_mode = 0; + io_config.flags.cs_high_active = 0; +#else + io_config.flags.dc_as_cmd_phase = 0; +#endif + + ESP_ERROR_CHECK(esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t )host_id, &io_config, &io_handle)); + + esp_lcd_panel_dev_config_t panel_config = {0}; + panel_config.reset_gpio_num = rst; +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5,0,0) + panel_config.color_space = ESP_LCD_COLOR_SPACE_RGB; +#else + panel_config.color_space = LCD_RGB_ELEMENT_ORDER_RGB; +#endif + panel_config.flags.reset_active_high = 0; + panel_config.vendor_config = NULL; + panel_config.bits_per_pixel = 16; + + log_i( "Install RM67162 panel driver"); + + ESP_ERROR_CHECK(esp_lcd_new_panel_rm67162(io_handle, &panel_config, &panel_handle)); + + ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle)); + + ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle)); + + return &panel_handle; +} + + diff --git a/src/RM67162_AMOLED_SPI.h b/src/RM67162_AMOLED_SPI.h new file mode 100644 index 0000000..73c16c7 --- /dev/null +++ b/src/RM67162_AMOLED_SPI.h @@ -0,0 +1,85 @@ +/** + * @file RM67162_AMOLED_SPI.h + * @author Lewis He (lewishe@outlook.com) + * @license MIT + * @copyright Copyright (c) 2024 ShenZhen XinYuan Electronic Technology Co., Ltd + * @date 2024-05-29 + * + */ + +#pragma once + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#ifndef LCD_CMD_MADCTL +#define LCD_CMD_MADCTL 0x36 // Memory data access control +#endif +#ifndef LCD_CMD_CASET +#define LCD_CMD_CASET 0x2A // Set column address +#endif + +#ifndef LCD_CMD_RASET +#define LCD_CMD_RASET 0x2B // Set row address +#endif + +#ifndef LCD_CMD_RAMWR +#define LCD_CMD_RAMWR 0x2C // Write frame memory +#endif + + +#ifndef LCD_CMD_SLPIN +#define LCD_CMD_SLPIN 0x10 // Go into sleep mode (DC/DC, oscillator, scanning stopped, but memory keeps content) +#endif + +#ifndef LCD_CMD_BRIGHTNESS +#define LCD_CMD_BRIGHTNESS 0x51 +#endif + +typedef struct { + esp_lcd_panel_t base; + esp_lcd_panel_io_handle_t io; + int reset_gpio_num; + bool reset_level; + int x_gap; + int y_gap; + uint8_t fb_bits_per_pixel; + uint8_t colmod_cal; // save surrent value of LCD_CMD_COLMOD register + uint8_t rotation; + uint16_t width; + uint16_t height; +} rm67162_panel_t; + + + +esp_lcd_panel_handle_t *panel_rm67162_init_spi_bus(spi_host_device_t host_id, int mosi, int miso, int sck, int dc, int cs, int rst, uint32_t speed_clk_mhz); +esp_err_t panel_rm67162_write_command(esp_lcd_panel_t *panel, uint32_t cmd, uint8_t *pdat, uint32_t length); +esp_err_t panel_rm67162_tx_colors(esp_lcd_panel_t *panel, const void *color_data, size_t colors_size); + + + + + + + + + + + + + + + + + + diff --git a/src/initSequence.cpp b/src/initSequence.cpp index 0ecdc45..bf94c6e 100644 --- a/src/initSequence.cpp +++ b/src/initSequence.cpp @@ -13,462 +13,463 @@ const lcd_cmd_t sh8501_cmd[SH8501_INIT_SEQUENCE_LENGTH] = { // === CMD2 password === - {0xfe00, {0x20}, 0x01}, - {0xf400, {0x5a}, 0x01}, - {0xf500, {0x59}, 0x01}, + {0xfe, {0x20}, 0x01}, + {0xf4, {0x5a}, 0x01}, + {0xf5, {0x59}, 0x01}, // === ID code === - {0xfe00, {0x40}, 0x01}, - {0xd800, {0x33}, 0x01}, - {0xd900, {0x06}, 0x01}, - {0xda00, {0x00}, 0x01}, + {0xfe, {0x40}, 0x01}, + {0xd8, {0x33}, 0x01}, + {0xd9, {0x06}, 0x01}, + {0xda, {0x00}, 0x01}, // === QSPI setting === - {0xfe00, {0x20}, 0x01}, - {0x1a00, {0x15}, 0x01}, - {0x1900, {0x10}, 0x01}, - {0x1c00, {0xa0}, 0x01}, + {0xfe, {0x20}, 0x01}, + {0x1a, {0x15}, 0x01}, + {0x19, {0x10}, 0x01}, + {0x1c, {0xa0}, 0x01}, // === Timing Gen === - {0xfe00, {0x40}, 0x01}, - {0x0100, {0x90}, 0x01}, - {0x0200, {0x5c}, 0x01}, - {0x5900, {0x01}, 0x01}, - {0x5a00, {0x58}, 0x01}, - {0x5b00, {0x08}, 0x01}, - {0x5c00, {0x08}, 0x01}, - {0x7000, {0x01}, 0x01}, - {0x7100, {0x58}, 0x01}, - {0x7200, {0x08}, 0x01}, - {0x7300, {0x08}, 0x01}, + {0xfe, {0x40}, 0x01}, + {0x01, {0x90}, 0x01}, + {0x02, {0x5c}, 0x01}, + {0x59, {0x01}, 0x01}, + {0x5a, {0x58}, 0x01}, + {0x5b, {0x08}, 0x01}, + {0x5c, {0x08}, 0x01}, + {0x70, {0x01}, 0x01}, + {0x71, {0x58}, 0x01}, + {0x72, {0x08}, 0x01}, + {0x73, {0x08}, 0x01}, // === AOD setting=== - {0xfe00, {0x40}, 0x01}, - {0x5d00, {0x24}, 0x01}, - {0x6000, {0x08}, 0x01}, - {0x6100, {0x04}, 0x01}, - {0x6200, {0x7f}, 0x01}, - {0x6900, {0x06}, 0x01}, - {0x0c00, {0xd7}, 0x01}, - {0x0d00, {0xfc}, 0x01}, - {0x3900, {0x24}, 0x01}, - {0x3d00, {0x08}, 0x01}, - {0x4700, {0x06}, 0x01}, - {0x6d00, {0x04}, 0x01}, - {0x1000, {0x11}, 0x01}, - {0x1100, {0x09}, 0x01}, + {0xfe, {0x40}, 0x01}, + {0x5d, {0x24}, 0x01}, + {0x60, {0x08}, 0x01}, + {0x61, {0x04}, 0x01}, + {0x62, {0x7f}, 0x01}, + {0x69, {0x06}, 0x01}, + {0x0c, {0xd7}, 0x01}, + {0x0d, {0xfc}, 0x01}, + {0x39, {0x24}, 0x01}, + {0x3d, {0x08}, 0x01}, + {0x47, {0x06}, 0x01}, + {0x6d, {0x04}, 0x01}, + {0x10, {0x11}, 0x01}, + {0x11, {0x09}, 0x01}, // === Power Settings === - {0xfe00, {0xe0}, 0x01}, - {0x0000, {0x14}, 0x01}, - {0x0100, {0x01}, 0x01}, - {0x0200, {0x00}, 0x01}, //{0x0200,{0x00},0x01}, - {0x0400, {0x04}, 0x01}, - {0x0600, {0x0f}, 0x01}, - {0x0800, {0x00}, 0x01}, - {0x0900, {0x14}, 0x01}, - {0x0a00, {0x01}, 0x01}, - {0x0b00, {0x00}, 0x01}, //{0x0b00,{0x00},0x01}, - {0x0c00, {0x04}, 0x01}, - {0x0e00, {0x0f}, 0x01}, - {0x0f00, {0x00}, 0x01}, - {0x1000, {0x14}, 0x01}, - {0x1100, {0x10}, 0x01}, - {0x2400, {0x00}, 0x01}, - {0x2100, {0x99}, 0x01}, - {0x2d00, {0x99}, 0x01}, - {0x3200, {0x99}, 0x01}, - {0x2600, {0x41}, 0x01}, - {0x2200, {0x1a}, 0x01}, - {0x2300, {0x13}, 0x01}, - {0x3000, {0x01}, 0x01}, - {0xfe00, {0x40}, 0x01}, - {0x5700, {0x43}, 0x01}, //{0x5700,{0x43},0x01}, - {0x5800, {0x33}, 0x01}, - {0x6e00, {0x43}, 0x01}, //{0x6e00,{0x43},0x01}, - {0x6f00, {0x33}, 0x01}, - {0x7400, {0x43}, 0x01}, //{0x7400,{0x43},0x01}, - {0x7500, {0x33}, 0x01}, + {0xfe, {0xe0}, 0x01}, + {0x00, {0x14}, 0x01}, + {0x01, {0x01}, 0x01}, + {0x02, {0x00}, 0x01}, //{0x0200,{0x00},0x01}, + {0x04, {0x04}, 0x01}, + {0x06, {0x0f}, 0x01}, + {0x08, {0x00}, 0x01}, + {0x09, {0x14}, 0x01}, + {0x0a, {0x01}, 0x01}, + {0x0b, {0x00}, 0x01}, //{0x0b00,{0x00},0x01}, + {0x0c, {0x04}, 0x01}, + {0x0e, {0x0f}, 0x01}, + {0x0f, {0x00}, 0x01}, + {0x10, {0x14}, 0x01}, + {0x11, {0x10}, 0x01}, + {0x24, {0x00}, 0x01}, + {0x21, {0x99}, 0x01}, + {0x2d, {0x99}, 0x01}, + {0x32, {0x99}, 0x01}, + {0x26, {0x41}, 0x01}, + {0x22, {0x1a}, 0x01}, + {0x23, {0x13}, 0x01}, + {0x30, {0x01}, 0x01}, + {0xfe, {0x40}, 0x01}, + {0x57, {0x43}, 0x01}, //{0x5700,{0x43},0x01}, + {0x58, {0x33}, 0x01}, + {0x6e, {0x43}, 0x01}, //{0x6e00,{0x43},0x01}, + {0x6f, {0x33}, 0x01}, + {0x74, {0x43}, 0x01}, //{0x7400,{0x43},0x01}, + {0x75, {0x33}, 0x01}, // // === swire setting for RT4722 === - // {0xfe00,{0x40},0x01}, - // {0x1200,{0xfe},0x01}, - // {0x1300,{0x08},0x01}, - // {0xc900,{0x21},0x01}, - // {0x9600,{0x00},0x01}, - // {0x9700,{0x02},0x01}, - // {0xa500,{0xff},0x01},//{0xa500,{0xff},0x01}, - // {0xaa00,{0x21},0x01},//{0xaa00,{0x21},0x01}, - // {0xab00,{0x00},0x01},//{0xab00,{0x00},0x01}, - // {0x9800,{0x00},0x01}, - // {0xa700,{0x21},0x01}, - // {0xa900,{0x00},0x01}, + // {0xfe,{0x40},0x01}, + // {0x12,{0xfe},0x01}, + // {0x13,{0x08},0x01}, + // {0xc9,{0x21},0x01}, + // {0x96,{0x00},0x01}, + // {0x97,{0x02},0x01}, + // {0xa5,{0xff},0x01},//{0xa500,{0xff},0x01}, + // {0xaa,{0x21},0x01},//{0xaa00,{0x21},0x01}, + // {0xab,{0x00},0x01},//{0xab00,{0x00},0x01}, + // {0x98,{0x00},0x01}, + // {0xa7,{0x21},0x01}, + // {0xa9,{0x00},0x01}, // === swire setting for BV6802 === - {0xfe00, {0x40}, 0x01}, - {0x1200, {0xfe}, 0x01}, - {0x1300, {0x08}, 0x01}, - {0xc900, {0x5f}, 0x01}, - {0x9600, {0x38}, 0x01}, - {0x9700, {0x02}, 0x01}, - {0xa500, {0xff}, 0x01}, - {0xaa00, {0x38}, 0x01}, - {0xab00, {0x5f}, 0x01}, - {0x9800, {0x00}, 0x01}, - {0xa700, {0x38}, 0x01}, - {0xa900, {0x5f}, 0x01}, + {0xfe, {0x40}, 0x01}, + {0x12, {0xfe}, 0x01}, + {0x13, {0x08}, 0x01}, + {0xc9, {0x5f}, 0x01}, + {0x96, {0x38}, 0x01}, + {0x97, {0x02}, 0x01}, + {0xa5, {0xff}, 0x01}, + {0xaa, {0x38}, 0x01}, + {0xab, {0x5f}, 0x01}, + {0x98, {0x00}, 0x01}, + {0xa7, {0x38}, 0x01}, + {0xa9, {0x5f}, 0x01}, //=== GOA mapping === - {0xfe00, {0x70}, 0x01}, - {0x9b00, {0x02}, 0x01}, - {0x9c00, {0x03}, 0x01}, - {0x9d00, {0x08}, 0x01}, - {0x9e00, {0x19}, 0x01}, - {0x9f00, {0x19}, 0x01}, - {0xa000, {0x19}, 0x01}, - {0xa200, {0x19}, 0x01}, - {0xa300, {0x19}, 0x01}, - {0xa400, {0x19}, 0x01}, - {0xa500, {0x19}, 0x01}, - {0xa600, {0x11}, 0x01}, - {0xa700, {0x10}, 0x01}, - {0xa900, {0x0f}, 0x01}, - {0xaa00, {0x19}, 0x01}, - {0xab00, {0x19}, 0x01}, - {0xac00, {0x19}, 0x01}, - {0xad00, {0x19}, 0x01}, - {0xae00, {0x19}, 0x01}, - {0xaf00, {0x19}, 0x01}, - {0xb000, {0x19}, 0x01}, - {0xb100, {0x19}, 0x01}, - {0xb200, {0x19}, 0x01}, - {0xb300, {0x19}, 0x01}, - {0xb400, {0x19}, 0x01}, - {0xb500, {0x19}, 0x01}, - {0xb600, {0x19}, 0x01}, - {0xb700, {0x19}, 0x01}, - {0xb800, {0x00}, 0x01}, - {0xb900, {0x01}, 0x01}, - {0xba00, {0x09}, 0x01}, - {0xbb00, {0x19}, 0x01}, - {0xbc00, {0x19}, 0x01}, - {0xbd00, {0xf9}, 0x01}, - {0xbe00, {0x19}, 0x01}, - {0xbf00, {0x19}, 0x01}, - {0xc000, {0x0e}, 0x01}, - {0xc100, {0x0d}, 0x01}, - {0xc200, {0x0c}, 0x01}, - {0xc300, {0x19}, 0x01}, - {0xc400, {0x19}, 0x01}, - {0xc500, {0x19}, 0x01}, - {0xc600, {0x19}, 0x01}, - {0xc700, {0x19}, 0x01}, - {0xc800, {0x19}, 0x01}, + {0xfe, {0x70}, 0x01}, + {0x9b, {0x02}, 0x01}, + {0x9c, {0x03}, 0x01}, + {0x9d, {0x08}, 0x01}, + {0x9e, {0x19}, 0x01}, + {0x9f, {0x19}, 0x01}, + {0xa0, {0x19}, 0x01}, + {0xa2, {0x19}, 0x01}, + {0xa3, {0x19}, 0x01}, + {0xa4, {0x19}, 0x01}, + {0xa5, {0x19}, 0x01}, + {0xa6, {0x11}, 0x01}, + {0xa7, {0x10}, 0x01}, + {0xa9, {0x0f}, 0x01}, + {0xaa, {0x19}, 0x01}, + {0xab, {0x19}, 0x01}, + {0xac, {0x19}, 0x01}, + {0xad, {0x19}, 0x01}, + {0xae, {0x19}, 0x01}, + {0xaf, {0x19}, 0x01}, + {0xb0, {0x19}, 0x01}, + {0xb1, {0x19}, 0x01}, + {0xb2, {0x19}, 0x01}, + {0xb3, {0x19}, 0x01}, + {0xb4, {0x19}, 0x01}, + {0xb5, {0x19}, 0x01}, + {0xb6, {0x19}, 0x01}, + {0xb7, {0x19}, 0x01}, + {0xb8, {0x00}, 0x01}, + {0xb9, {0x01}, 0x01}, + {0xba, {0x09}, 0x01}, + {0xbb, {0x19}, 0x01}, + {0xbc, {0x19}, 0x01}, + {0xbd, {0xf9}, 0x01}, + {0xbe, {0x19}, 0x01}, + {0xbf, {0x19}, 0x01}, + {0xc0, {0x0e}, 0x01}, + {0xc1, {0x0d}, 0x01}, + {0xc2, {0x0c}, 0x01}, + {0xc3, {0x19}, 0x01}, + {0xc4, {0x19}, 0x01}, + {0xc5, {0x19}, 0x01}, + {0xc6, {0x19}, 0x01}, + {0xc7, {0x19}, 0x01}, + {0xc8, {0x19}, 0x01}, // === source/mux sequence === - {0xfe00, {0x40}, 0x01}, - {0x4c00, {0x22}, 0x01}, - {0x5300, {0xa0}, 0x01}, - {0x0800, {0x0a}, 0x01}, + {0xfe, {0x40}, 0x01}, + {0x4c, {0x22}, 0x01}, + {0x53, {0xa0}, 0x01}, + {0x08, {0x0a}, 0x01}, // === SD/SW_Toggle_Sequence_Control === - {0xfe00, {0xf0}, 0x01}, - {0x7200, {0x33}, 0x01}, - {0x7300, {0x66}, 0x01}, - {0x7400, {0x22}, 0x01}, - {0x7500, {0x55}, 0x01}, - {0x7600, {0x11}, 0x01}, - {0x7700, {0x44}, 0x01}, - {0x7800, {0x33}, 0x01}, - {0x7900, {0x66}, 0x01}, - {0x7a00, {0x22}, 0x01}, - {0x7b00, {0x55}, 0x01}, - {0x7c00, {0x11}, 0x01}, - {0x7d00, {0x44}, 0x01}, - {0x7e00, {0x66}, 0x01}, - {0x7f00, {0x33}, 0x01}, - {0x8000, {0x55}, 0x01}, - {0x8100, {0x22}, 0x01}, - {0x8200, {0x44}, 0x01}, - {0x8300, {0x11}, 0x01}, - {0x8400, {0x66}, 0x01}, - {0x8500, {0x33}, 0x01}, - {0x8600, {0x55}, 0x01}, - {0x8700, {0x22}, 0x01}, - {0x8800, {0x44}, 0x01}, - {0x8900, {0x11}, 0x01}, + {0xfe, {0xf0}, 0x01}, + {0x72, {0x33}, 0x01}, + {0x73, {0x66}, 0x01}, + {0x74, {0x22}, 0x01}, + {0x75, {0x55}, 0x01}, + {0x76, {0x11}, 0x01}, + {0x77, {0x44}, 0x01}, + {0x78, {0x33}, 0x01}, + {0x79, {0x66}, 0x01}, + {0x7a, {0x22}, 0x01}, + {0x7b, {0x55}, 0x01}, + {0x7c, {0x11}, 0x01}, + {0x7d, {0x44}, 0x01}, + {0x7e, {0x66}, 0x01}, + {0x7f, {0x33}, 0x01}, + {0x80, {0x55}, 0x01}, + {0x81, {0x22}, 0x01}, + {0x82, {0x44}, 0x01}, + {0x83, {0x11}, 0x01}, + {0x84, {0x66}, 0x01}, + {0x85, {0x33}, 0x01}, + {0x86, {0x55}, 0x01}, + {0x87, {0x22}, 0x01}, + {0x88, {0x44}, 0x01}, + {0x89, {0x11}, 0x01}, // === GIP Setting === - {0xfe00, {0x70}, 0x01}, - {0x0000, {0xc0}, 0x01}, - {0x0100, {0x08}, 0x01}, - {0x0200, {0x02}, 0x01}, - {0x0300, {0x00}, 0x01}, - {0x0400, {0x00}, 0x01}, - {0x0500, {0x01}, 0x01}, - {0x0600, {0x28}, 0x01}, - {0x0700, {0x28}, 0x01}, - {0x0900, {0xc0}, 0x01}, - {0x0a00, {0x08}, 0x01}, - {0x0b00, {0x02}, 0x01}, - {0x0c00, {0x00}, 0x01}, - {0x0d00, {0x00}, 0x01}, - {0x0e00, {0x00}, 0x01}, - {0x0f00, {0x28}, 0x01}, - {0x1000, {0x28}, 0x01}, - {0x1200, {0xc0}, 0x01}, - {0x1300, {0x08}, 0x01}, - {0x1400, {0x02}, 0x01}, - {0x1500, {0x00}, 0x01}, - {0x1600, {0x00}, 0x01}, - {0x1700, {0x01}, 0x01}, - {0x1800, {0xd8}, 0x01}, - {0x1900, {0x18}, 0x01}, - {0x1b00, {0xc0}, 0x01}, - {0x1c00, {0x08}, 0x01}, - {0x1d00, {0x02}, 0x01}, - {0x1e00, {0x00}, 0x01}, - {0x1f00, {0x00}, 0x01}, - {0x2000, {0x00}, 0x01}, - {0x2100, {0xd8}, 0x01}, - {0x2200, {0x18}, 0x01}, - {0x4c00, {0x80}, 0x01}, - {0x4d00, {0x00}, 0x01}, - {0x4e00, {0x01}, 0x01}, - {0x4f00, {0x00}, 0x01}, - {0x5000, {0x01}, 0x01}, - {0x5100, {0x01}, 0x01}, - {0x5200, {0x01}, 0x01}, - {0x5300, {0xc6}, 0x01}, - {0x5400, {0x00}, 0x01}, - {0x5500, {0x03}, 0x01}, - {0x5600, {0x28}, 0x01}, - {0x5800, {0x28}, 0x01}, - {0x6500, {0x80}, 0x01}, - {0x6600, {0x05}, 0x01}, - {0x6700, {0x10}, 0x01}, + {0xfe, {0x70}, 0x01}, + {0x00, {0xc0}, 0x01}, + {0x01, {0x08}, 0x01}, + {0x02, {0x02}, 0x01}, + {0x03, {0x00}, 0x01}, + {0x04, {0x00}, 0x01}, + {0x05, {0x01}, 0x01}, + {0x06, {0x28}, 0x01}, + {0x07, {0x28}, 0x01}, + {0x09, {0xc0}, 0x01}, + {0x0a, {0x08}, 0x01}, + {0x0b, {0x02}, 0x01}, + {0x0c, {0x00}, 0x01}, + {0x0d, {0x00}, 0x01}, + {0x0e, {0x00}, 0x01}, + {0x0f, {0x28}, 0x01}, + {0x10, {0x28}, 0x01}, + {0x12, {0xc0}, 0x01}, + {0x13, {0x08}, 0x01}, + {0x14, {0x02}, 0x01}, + {0x15, {0x00}, 0x01}, + {0x16, {0x00}, 0x01}, + {0x17, {0x01}, 0x01}, + {0x18, {0xd8}, 0x01}, + {0x19, {0x18}, 0x01}, + {0x1b, {0xc0}, 0x01}, + {0x1c, {0x08}, 0x01}, + {0x1d, {0x02}, 0x01}, + {0x1e, {0x00}, 0x01}, + {0x1f, {0x00}, 0x01}, + {0x20, {0x00}, 0x01}, + {0x21, {0xd8}, 0x01}, + {0x22, {0x18}, 0x01}, + {0x4c, {0x80}, 0x01}, + {0x4d, {0x00}, 0x01}, + {0x4e, {0x01}, 0x01}, + {0x4f, {0x00}, 0x01}, + {0x50, {0x01}, 0x01}, + {0x51, {0x01}, 0x01}, + {0x52, {0x01}, 0x01}, + {0x53, {0xc6}, 0x01}, + {0x54, {0x00}, 0x01}, + {0x55, {0x03}, 0x01}, + {0x56, {0x28}, 0x01}, + {0x58, {0x28}, 0x01}, + {0x65, {0x80}, 0x01}, + {0x66, {0x05}, 0x01}, + {0x67, {0x10}, 0x01}, // === MUX Sequence Control === - {0xfe00, {0xf0}, 0x01}, - {0xa300, {0x00}, 0x01}, - - {0xfe00, {0x70}, 0x01}, - {0x7600, {0x00}, 0x01}, - {0x7700, {0x00}, 0x01}, - {0x7800, {0x05}, 0x01}, - {0x6800, {0x08}, 0x01}, - {0x6900, {0x08}, 0x01}, - {0x6a00, {0x10}, 0x01}, - {0x6b00, {0x08}, 0x01}, - {0x6c00, {0x08}, 0x01}, - {0x6d00, {0x08}, 0x01}, - - {0xfe00, {0xf0}, 0x01}, - {0xa900, {0x18}, 0x01}, - {0xaa00, {0x18}, 0x01}, - {0xab00, {0x18}, 0x01}, - {0xac00, {0x18}, 0x01}, - {0xad00, {0x18}, 0x01}, - {0xae00, {0x18}, 0x01}, - - {0xfe00, {0x70}, 0x01}, - {0x9300, {0x00}, 0x01}, - {0x9400, {0x00}, 0x01}, - {0x9600, {0x05}, 0x01}, - {0xdb00, {0x08}, 0x01}, - {0xdc00, {0x08}, 0x01}, - {0xdd00, {0x10}, 0x01}, - {0xde00, {0x08}, 0x01}, - {0xdf00, {0x08}, 0x01}, - {0xe000, {0x08}, 0x01}, - {0xe700, {0x18}, 0x01}, - {0xe800, {0x18}, 0x01}, - {0xe900, {0x18}, 0x01}, - {0xea00, {0x18}, 0x01}, - {0xeb00, {0x18}, 0x01}, - {0xec00, {0x18}, 0x01}, + {0xfe, {0xf0}, 0x01}, + {0xa3, {0x00}, 0x01}, + + {0xfe, {0x70}, 0x01}, + {0x76, {0x00}, 0x01}, + {0x77, {0x00}, 0x01}, + {0x78, {0x05}, 0x01}, + {0x68, {0x08}, 0x01}, + {0x69, {0x08}, 0x01}, + {0x6a, {0x10}, 0x01}, + {0x6b, {0x08}, 0x01}, + {0x6c, {0x08}, 0x01}, + {0x6d, {0x08}, 0x01}, + + {0xfe, {0xf0}, 0x01}, + {0xa9, {0x18}, 0x01}, + {0xaa, {0x18}, 0x01}, + {0xab, {0x18}, 0x01}, + {0xac, {0x18}, 0x01}, + {0xad, {0x18}, 0x01}, + {0xae, {0x18}, 0x01}, + + {0xfe, {0x70}, 0x01}, + {0x93, {0x00}, 0x01}, + {0x94, {0x00}, 0x01}, + {0x96, {0x05}, 0x01}, + {0xdb, {0x08}, 0x01}, + {0xdc, {0x08}, 0x01}, + {0xdd, {0x10}, 0x01}, + {0xde, {0x08}, 0x01}, + {0xdf, {0x08}, 0x01}, + {0xe0, {0x08}, 0x01}, + {0xe7, {0x18}, 0x01}, + {0xe8, {0x18}, 0x01}, + {0xe9, {0x18}, 0x01}, + {0xea, {0x18}, 0x01}, + {0xeb, {0x18}, 0x01}, + {0xec, {0x18}, 0x01}, // === Power on/off sequence Blank period control === - {0xfe00, {0x70}, 0x01}, - {0xd100, {0xf0}, 0x01}, - {0xd200, {0xff}, 0x01}, - {0xd300, {0xf0}, 0x01}, - {0xd400, {0xff}, 0x01}, - {0xd500, {0xa0}, 0x01}, - {0xd600, {0xaa}, 0x01}, - {0xd700, {0xf0}, 0x01}, - {0xd800, {0xff}, 0x01}, + {0xfe, {0x70}, 0x01}, + {0xd1, {0xf0}, 0x01}, + {0xd2, {0xff}, 0x01}, + {0xd3, {0xf0}, 0x01}, + {0xd4, {0xff}, 0x01}, + {0xd5, {0xa0}, 0x01}, + {0xd6, {0xaa}, 0x01}, + {0xd7, {0xf0}, 0x01}, + {0xd8, {0xff}, 0x01}, // === Source === - {0xfe00, {0x40}, 0x01}, - {0x4d00, {0xaa}, 0x01}, - {0x4e00, {0x00}, 0x01}, - {0x4f00, {0xa0}, 0x01}, - {0x5000, {0x00}, 0x01}, - {0x5100, {0xf3}, 0x01}, - {0x5200, {0x23}, 0x01}, - {0x6b00, {0xf3}, 0x01}, - {0x6c00, {0x13}, 0x01}, - {0x8f00, {0xff}, 0x01}, - {0x9000, {0xff}, 0x01}, - {0x9100, {0x3f}, 0x01}, - {0xa200, {0x10}, 0x01}, - {0x0700, {0x21}, 0x01}, - {0x3500, {0x81}, 0x01}, + {0xfe, {0x40}, 0x01}, + {0x4d, {0xaa}, 0x01}, + {0x4e, {0x00}, 0x01}, + {0x4f, {0xa0}, 0x01}, + {0x50, {0x00}, 0x01}, + {0x51, {0xf3}, 0x01}, + {0x52, {0x23}, 0x01}, + {0x6b, {0xf3}, 0x01}, + {0x6c, {0x13}, 0x01}, + {0x8f, {0xff}, 0x01}, + {0x90, {0xff}, 0x01}, + {0x91, {0x3f}, 0x01}, + {0xa2, {0x10}, 0x01}, + {0x07, {0x21}, 0x01}, + {0x35, {0x81}, 0x01}, // === gamma setting === - {0xfe00, {0x40}, 0x01}, - {0x3300, {0x10}, 0x01}, - {0xfe00, {0x50}, 0x01}, - {0xa900, {0x30}, 0x01}, - {0xaa00, {0xb8}, 0x01}, - {0xab00, {0x01}, 0x01}, - {0xfe00, {0x60}, 0x01}, - {0xa900, {0x30}, 0x01}, - {0xaa00, {0x90}, 0x01}, - {0xab00, {0x01}, 0x01}, + {0xfe, {0x40}, 0x01}, + {0x33, {0x10}, 0x01}, + {0xfe, {0x50}, 0x01}, + {0xa9, {0x30}, 0x01}, + {0xaa, {0xb8}, 0x01}, + {0xab, {0x01}, 0x01}, + {0xfe, {0x60}, 0x01}, + {0xa9, {0x30}, 0x01}, + {0xaa, {0x90}, 0x01}, + {0xab, {0x01}, 0x01}, //=== Watchedge === - {0xfe00, {0x90}, 0x01}, - {0xa400, {0x16}, 0x01}, //{0xa400,{0x16},0x01}, - {0xa500, {0x16}, 0x01}, //{0xa500,{0x16},0x01}, - {0xa600, {0x00}, 0x01}, - {0xa700, {0x16}, 0x01}, //{0xa700,{0x16},0x01}, - {0xa900, {0x16}, 0x01}, //{0xa900,{0x16},0x01}, - {0xaa00, {0x80}, 0x01}, - {0xab00, {0x0f}, 0x01}, //{0xab00,{0x0f},0x01}, - {0xac00, {0xff}, 0x01}, //{0xac00,{0xff},0x01}, - {0xae00, {0x3f}, 0x01}, //{0xae00,{0x3f},0x01}, - - {0x3f00, {0x58}, 0x01}, - {0x4000, {0xb4}, 0x01}, - {0x4100, {0x29}, 0x01}, + {0xfe, {0x90}, 0x01}, + {0xa4, {0x16}, 0x01}, //{0xa400,{0x16},0x01}, + {0xa5, {0x16}, 0x01}, //{0xa500,{0x16},0x01}, + {0xa6, {0x00}, 0x01}, + {0xa7, {0x16}, 0x01}, //{0xa700,{0x16},0x01}, + {0xa9, {0x16}, 0x01}, //{0xa900,{0x16},0x01}, + {0xaa, {0x80}, 0x01}, + {0xab, {0x0f}, 0x01}, //{0xab00,{0x0f},0x01}, + {0xac, {0xff}, 0x01}, //{0xac00,{0xff},0x01}, + {0xae, {0x3f}, 0x01}, //{0xae00,{0x3f},0x01}, + + {0x3f, {0x58}, 0x01}, + {0x40, {0xb4}, 0x01}, + {0x41, {0x29}, 0x01}, //=== SCC === - {0xfe00, {0x90}, 0x01}, - {0x5100, {0x00}, 0x01}, - {0x5200, {0x08}, 0x01}, - {0x5300, {0x00}, 0x01}, - {0x5400, {0x18}, 0x01}, - {0x5500, {0x00}, 0x01}, - {0x5600, {0x00}, 0x01}, - {0x5700, {0x00}, 0x01}, - {0x5800, {0x00}, 0x01}, - {0x5900, {0x08}, 0x01}, - {0x5a00, {0x00}, 0x01}, - {0x5b00, {0x18}, 0x01}, - {0x5c00, {0x00}, 0x01}, - {0x5d00, {0x00}, 0x01}, - {0x5e00, {0x80}, 0x01}, - {0x5f00, {0x00}, 0x01}, - {0x6000, {0x00}, 0x01}, - {0x6100, {0x00}, 0x01}, - {0x6200, {0x18}, 0x01}, - {0x6300, {0x00}, 0x01}, - {0x6400, {0x00}, 0x01}, - {0x6500, {0x00}, 0x01}, - {0x6600, {0x08}, 0x01}, - {0x6700, {0x80}, 0x01}, - {0x6800, {0x40}, 0x01}, - {0x6900, {0x00}, 0x01}, - {0x6a00, {0x00}, 0x01}, - {0x6b00, {0x00}, 0x01}, - {0x6c00, {0x00}, 0x01}, - {0x6d00, {0x00}, 0x01}, - {0x6e00, {0x00}, 0x01}, - {0x6f00, {0x18}, 0x01}, - {0x7000, {0x80}, 0x01}, - {0x7100, {0x00}, 0x01}, - {0x7200, {0x00}, 0x01}, - {0x7300, {0x00}, 0x01}, - {0x7400, {0x00}, 0x01}, - {0x7500, {0x00}, 0x01}, - {0x7600, {0x18}, 0x01}, - {0x7700, {0x00}, 0x01}, - {0x7800, {0x08}, 0x01}, - {0x7900, {0x00}, 0x01}, - {0x7a00, {0x00}, 0x01}, - {0x7b00, {0x00}, 0x01}, - {0x7c00, {0x00}, 0x01}, - {0x7d00, {0x18}, 0x01}, - {0x7e00, {0x00}, 0x01}, - {0x7f00, {0x08}, 0x01}, - {0x8000, {0x00}, 0x01}, - {0x8100, {0x00}, 0x01}, - {0x8200, {0x80}, 0x01}, - {0x8300, {0x40}, 0x01}, - {0x8400, {0x00}, 0x01}, - {0x8500, {0x00}, 0x01}, - {0x8600, {0x08}, 0x01}, - {0x8700, {0x00}, 0x01}, - {0x8800, {0x04}, 0x01}, - {0x8900, {0x00}, 0x01}, - {0x8a00, {0x18}, 0x01}, - {0x8b00, {0x40}, 0x01}, - {0x8c00, {0x00}, 0x01}, - {0x8d00, {0x00}, 0x01}, - {0x8e00, {0x00}, 0x01}, - {0x8f00, {0x04}, 0x01}, - {0x9000, {0x00}, 0x01}, - {0x9100, {0x18}, 0x01}, - {0x9200, {0x00}, 0x01}, - {0x9300, {0x04}, 0x01}, - {0x9400, {0x40}, 0x01}, - {0x9500, {0x00}, 0x01}, - {0x9600, {0x00}, 0x01}, - {0x9700, {0x00}, 0x01}, - {0x9800, {0x18}, 0x01}, - {0x9900, {0x00}, 0x01}, - {0x9a00, {0x04}, 0x01}, - {0x9b00, {0x00}, 0x01}, - {0x9c00, {0x04}, 0x01}, - {0x9d00, {0x80}, 0x01}, - {0x9e00, {0x40}, 0x01}, - {0x9f00, {0x00}, 0x01}, - {0xa000, {0x00}, 0x01}, - {0xa200, {0x04}, 0x01}, + {0xfe, {0x90}, 0x01}, + {0x51, {0x00}, 0x01}, + {0x52, {0x08}, 0x01}, + {0x53, {0x00}, 0x01}, + {0x54, {0x18}, 0x01}, + {0x55, {0x00}, 0x01}, + {0x56, {0x00}, 0x01}, + {0x57, {0x00}, 0x01}, + {0x58, {0x00}, 0x01}, + {0x59, {0x08}, 0x01}, + {0x5a, {0x00}, 0x01}, + {0x5b, {0x18}, 0x01}, + {0x5c, {0x00}, 0x01}, + {0x5d, {0x00}, 0x01}, + {0x5e, {0x80}, 0x01}, + {0x5f, {0x00}, 0x01}, + {0x60, {0x00}, 0x01}, + {0x61, {0x00}, 0x01}, + {0x62, {0x18}, 0x01}, + {0x63, {0x00}, 0x01}, + {0x64, {0x00}, 0x01}, + {0x65, {0x00}, 0x01}, + {0x66, {0x08}, 0x01}, + {0x67, {0x80}, 0x01}, + {0x68, {0x40}, 0x01}, + {0x69, {0x00}, 0x01}, + {0x6a, {0x00}, 0x01}, + {0x6b, {0x00}, 0x01}, + {0x6c, {0x00}, 0x01}, + {0x6d, {0x00}, 0x01}, + {0x6e, {0x00}, 0x01}, + {0x6f, {0x18}, 0x01}, + {0x70, {0x80}, 0x01}, + {0x71, {0x00}, 0x01}, + {0x72, {0x00}, 0x01}, + {0x73, {0x00}, 0x01}, + {0x74, {0x00}, 0x01}, + {0x75, {0x00}, 0x01}, + {0x76, {0x18}, 0x01}, + {0x77, {0x00}, 0x01}, + {0x78, {0x08}, 0x01}, + {0x79, {0x00}, 0x01}, + {0x7a, {0x00}, 0x01}, + {0x7b, {0x00}, 0x01}, + {0x7c, {0x00}, 0x01}, + {0x7d, {0x18}, 0x01}, + {0x7e, {0x00}, 0x01}, + {0x7f, {0x08}, 0x01}, + {0x80, {0x00}, 0x01}, + {0x81, {0x00}, 0x01}, + {0x82, {0x80}, 0x01}, + {0x83, {0x40}, 0x01}, + {0x84, {0x00}, 0x01}, + {0x85, {0x00}, 0x01}, + {0x86, {0x08}, 0x01}, + {0x87, {0x00}, 0x01}, + {0x88, {0x04}, 0x01}, + {0x89, {0x00}, 0x01}, + {0x8a, {0x18}, 0x01}, + {0x8b, {0x40}, 0x01}, + {0x8c, {0x00}, 0x01}, + {0x8d, {0x00}, 0x01}, + {0x8e, {0x00}, 0x01}, + {0x8f, {0x04}, 0x01}, + {0x90, {0x00}, 0x01}, + {0x91, {0x18}, 0x01}, + {0x92, {0x00}, 0x01}, + {0x93, {0x04}, 0x01}, + {0x94, {0x40}, 0x01}, + {0x95, {0x00}, 0x01}, + {0x96, {0x00}, 0x01}, + {0x97, {0x00}, 0x01}, + {0x98, {0x18}, 0x01}, + {0x99, {0x00}, 0x01}, + {0x9a, {0x04}, 0x01}, + {0x9b, {0x00}, 0x01}, + {0x9c, {0x04}, 0x01}, + {0x9d, {0x80}, 0x01}, + {0x9e, {0x40}, 0x01}, + {0x9f, {0x00}, 0x01}, + {0xa0, {0x00}, 0x01}, + {0xa2, {0x04}, 0x01}, // === Power saving === - {0xfe00, {0x70}, 0x01}, - {0x9800, {0x74}, 0x01}, - {0xc900, {0x05}, 0x01}, - {0xca00, {0x05}, 0x01}, - {0xcb00, {0x05}, 0x01}, - {0xcc00, {0x05}, 0x01}, - {0xcd00, {0x05}, 0x01}, - {0xce00, {0x85}, 0x01}, - {0xcf00, {0x05}, 0x01}, - {0xd000, {0x45}, 0x01}, - - {0xfe00, {0xe0}, 0x01}, - {0x1900, {0x42}, 0x01}, - {0x1e00, {0x42}, 0x01}, - {0x1c00, {0x41}, 0x01}, - {0x1800, {0x00}, 0x01}, - {0x1b00, {0x0c}, 0x01}, - {0x1a00, {0x9a}, 0x01}, - {0x1d00, {0xda}, 0x01}, - {0x2800, {0x5f}, 0x01}, - - {0xfe00, {0x40}, 0x01}, - {0x5400, {0xac}, 0x01}, - {0x5500, {0xa0}, 0x01}, - {0x4800, {0xaa}, 0x01}, + {0xfe, {0x70}, 0x01}, + {0x98, {0x74}, 0x01}, + {0xc9, {0x05}, 0x01}, + {0xca, {0x05}, 0x01}, + {0xcb, {0x05}, 0x01}, + {0xcc, {0x05}, 0x01}, + {0xcd, {0x05}, 0x01}, + {0xce, {0x85}, 0x01}, + {0xcf, {0x05}, 0x01}, + {0xd0, {0x45}, 0x01}, + + {0xfe, {0xe0}, 0x01}, + {0x19, {0x42}, 0x01}, + {0x1e, {0x42}, 0x01}, + {0x1c, {0x41}, 0x01}, + {0x18, {0x00}, 0x01}, + {0x1b, {0x0c}, 0x01}, + {0x1a, {0x9a}, 0x01}, + {0x1d, {0xda}, 0x01}, + {0x28, {0x5f}, 0x01}, + + {0xfe, {0x40}, 0x01}, + {0x54, {0xac}, 0x01}, + {0x55, {0xa0}, 0x01}, + {0x48, {0xaa}, 0x01}, //======================== 194*368 setting =========================== - {0xfe00, {0x40}, 0x01}, - {0x7600, {0x96}, 0x01}, - {0x7700, {0xc2}, 0x01}, - {0x7800, {0x8e}, 0x01}, - {0x7900, {0xb3}, 0x01}, - {0x7a00, {0x8d}, 0x01}, - {0x7b00, {0x11}, 0x01}, + {0xfe, {0x40}, 0x01}, + {0x76, {0x96}, 0x01}, + {0x77, {0xc2}, 0x01}, + {0x78, {0x8e}, 0x01}, + {0x79, {0xb3}, 0x01}, + {0x7a, {0x8d}, 0x01}, + {0x7b, {0x11}, 0x01}, //======================== EDGE SETTING =========================== - {0xfe00, {0x20}, 0x01}, - {0x2700, {0xC2}, 0x01}, - // {0xfe00,{0x40},0x01},//{0xfe00,{0x40},0x01}, - // {0x7600,{0x01},0x01}, + {0xfe, {0x20}, 0x01}, + {0x27, {0xC2}, 0x01}, + // {0xfe,{0x40},0x01}, + // {0xfe,{0x40},0x01}, + // {0x76,{0x01},0x01}, /*******BIST Star**********/// // CS0=0;SPI_WriteComm(0xFE);SPI_WriteData(0x90);CS0=1;Delay(10); @@ -478,69 +479,90 @@ const lcd_cmd_t sh8501_cmd[SH8501_INIT_SEQUENCE_LENGTH] = { // CS0=0;SPI_WriteComm(0x4D);SPI_WriteData(0x1F);CS0=1;Delay(10);// 02:Write 04:Red 08:Green 10:Blue // CS0=0;SPI_WriteComm(0xFE);SPI_WriteData(0x40);CS0=1;Delay(10); // CS0=0;SPI_WriteComm(0x54);SPI_WriteData(0xAF);CS0=1;Delay(10); - // {0xFE00,{0x90},0x01}, - // {0xAA00,{0x00},0x01}, - // {0xFE00,{0xD0},0x01}, - // {0x4E00,{0x80},0x01}, - // {0x4D00,{0x1F},0x01}, - // {0xFE00,{0x40},0x01}, - // {0x5400,{0xAF},0x01}, + // {0xFE,{0x90},0x01}, + // {0xAA,{0x00},0x01}, + // {0xFE,{0xD0},0x01}, + // {0x4E,{0x80},0x01}, + // {0x4D,{0x1F},0x01}, + // {0xFE,{0x40},0x01}, + // {0x54,{0xAF},0x01}, /************BIST end***********/// //=== CMD1 setting === - {0xfe00, {0x00}, 0x01}, - {0xc400, {0x80}, 0x01}, - {0x3a00, {0x55}, 0x01}, - {0x3500, {0x00}, 0x01}, - {0x5300, {0x20}, 0x01}, - {0x5100, {AMOLED_DEFAULT_BRIGHTNESS}, 0x01}, - {0x6300, {0xff}, 0x01}, - {0x2a00, {0x00, 0x00, 0x00, 0xc1}, 0x04}, - {0x2b00, {0x00, 0x00, 0x01, 0x6f}, 0x04}, - {0x1100, {}, 0x80}, - {0x2900, {}, 0x80}, + {0xfe, {0x00}, 0x01}, + {0xc4, {0x80}, 0x01}, + {0x3a, {0x55}, 0x01}, + {0x35, {0x00}, 0x01}, + {0x53, {0x20}, 0x01}, + {0x51, {AMOLED_DEFAULT_BRIGHTNESS}, 0x01}, + {0x63, {0xff}, 0x01}, + {0x2a, {0x00, 0x00, 0x00, 0xc1}, 0x04}, + {0x2b, {0x00, 0x00, 0x01, 0x6f}, 0x04}, + {0x11, {}, 0x80}, + {0x29, {}, 0x80}, }; const lcd_cmd_t rm67162_cmd[RM67162_INIT_SEQUENCE_LENGTH] = { - {0xFE00, {0x00}, 0x01}, //SET APGE 00H - {0x1100, {0x00}, 0x80}, // Sleep Out + {0xFE, {0x00}, 0x01}, //SET APGE 00H + {0x11, {0x00}, 0x80}, // Sleep Out - {0xFE00, {0x05}, 0x01}, //SET APGE - {0x0500, {0x05}, 0x01}, //OVSS control set elvss -3.95v + {0xFE, {0x05}, 0x01}, //SET APGE + {0x05, {0x05}, 0x01}, //OVSS control set elvss -3.95v - {0xFE00, {0x01}, 0x01}, //SET APGE - {0x7300, {0x25}, 0x01}, //set OVSS voltage level.= -4.0V + {0xFE, {0x01}, 0x01}, //SET APGE + {0x73, {0x25}, 0x01}, //set OVSS voltage level.= -4.0V - {0xFE00, {0x00}, 0x01}, //SET APGE 00H + {0xFE, {0x00}, 0x01}, //SET APGE 00H // {0x44, {0x01, 0x66},0x02}, //Set_Tear_Scanline // {0x35, {0x00}, 0x00}, //TE ON // {0x34, {0x00}, 0x00}, //TE OFF // {0x36, {0x00}, 0x01}, //Scan Direction Control - {0x3600, {0x60}, 0x01}, // - {0x3A00, {0x55}, 0x01}, // Interface Pixel Format 16bit/pixel + {0x36, {0x60}, 0x01}, // + {0x3A, {0x55}, 0x01}, // Interface Pixel Format 16bit/pixel // {0x3A, {0x66}, 0x01}, //Interface Pixel Format 18bit/pixel // {0x3A, {0x77}, 0x01}, //Interface Pixel Format 24bit/pixel - {0x5100, {0x00}, 0x01}, // Write Display Brightness MAX_VAL=0XFF - {0x2900, {0x00}, 0x80}, // Display on - {0x5100, {AMOLED_DEFAULT_BRIGHTNESS}, 0x01} // Write Display Brightness MAX_VAL=0XFF + {0x51, {0x00}, 0x01}, // Write Display Brightness MAX_VAL=0XFF + {0x29, {0x00}, 0x80}, // Display on + {0x51, {AMOLED_DEFAULT_BRIGHTNESS}, 0x01} // Write Display Brightness MAX_VAL=0XFF }; - +const lcd_cmd_t rm67162_spi_cmd[RM67162_INIT_SPI_SEQUENCE_LENGTH] = { + {0xFE, {0x04}, 0x01}, //SET APGE3 + {0x6A, {0x00}, 0x01}, + {0xFE, {0x05}, 0x01}, //SET APGE4 + {0xFE, {0x07}, 0x01}, //SET APGE6 + {0x07, {0x4F}, 0x01}, + {0xFE, {0x01}, 0x01}, //SET APGE0 + {0x2A, {0x02}, 0x01}, + {0x2B, {0x73}, 0x01}, + {0xFE, {0x0A}, 0x01}, //SET APGE9 + {0x29, {0x10}, 0x01}, + {0xFE, {0x00}, 0x01}, + {0x51, {AMOLED_DEFAULT_BRIGHTNESS}, 0x01}, + {0x53, {0x20}, 0x01}, + {0x35, {0x00}, 0x01}, + + {0x3A, {0x75}, 0x01}, // Interface Pixel Format 16bit/pixel + {0xC4, {0x80}, 0x01}, + // {0x11, {0x00}, 0x01 | 0x80}, + // {0x29, {0x00}, 0x01 | 0x80}, + {0, {0}, 0xff}, +}; const lcd_cmd_t rm690b0_cmd[RM690B0_INIT_SEQUENCE_LENGTH] = { - {0xFE00, {0x20}, 0x01}, //SET PAGE - {0x2600, {0x0A}, 0x01}, //MIPI OFF - {0x2400, {0x80}, 0x01}, //SPI write RAM - {0x5A00, {0x51}, 0x01}, //! 230918:SWIRE FOR BV6804 - {0x5B00, {0x2E}, 0x01}, //! 230918:SWIRE FOR BV6804 - {0xFE00, {0x00}, 0x01}, //SET PAGE - {0x3A00, {0x55}, 0x01}, //Interface Pixel Format 16bit/pixel - {0xC200, {0x00}, 0x21}, //delay_ms(10); - {0x3500, {0x00}, 0x01}, //TE ON - {0x5100, {0x00}, 0x01}, //Write Display Brightness MAX_VAL=0XFF - {0x1100, {0x00}, 0x80}, //Sleep Out delay_ms(120); - {0x2900, {0x00}, 0x20}, //Display on delay_ms(10); - {0x5100, {0xFF}, 0x01}, //Write Display Brightness MAX_VAL=0XFF + {0xFE, {0x20}, 0x01}, //SET PAGE + {0x26, {0x0A}, 0x01}, //MIPI OFF + {0x24, {0x80}, 0x01}, //SPI write RAM + {0x5A, {0x51}, 0x01}, //! 230918:SWIRE FOR BV6804 + {0x5B, {0x2E}, 0x01}, //! 230918:SWIRE FOR BV6804 + {0xFE, {0x00}, 0x01}, //SET PAGE + {0x3A, {0x55}, 0x01}, //Interface Pixel Format 16bit/pixel + {0xC2, {0x00}, 0x21}, //delay_ms(10); + {0x35, {0x00}, 0x01}, //TE ON + {0x51, {0x00}, 0x01}, //Write Display Brightness MAX_VAL=0XFF + {0x11, {0x00}, 0x80}, //Sleep Out delay_ms(120); + {0x29, {0x00}, 0x20}, //Display on delay_ms(10); + {0x51, {0xFF}, 0x01}, //Write Display Brightness MAX_VAL=0XFF }; const lcd_cmd_t jd9613_cmd[JD9613_INIT_SEQUENCE_LENGTH] = { diff --git a/src/initSequence.h b/src/initSequence.h index 45532bb..418451d 100644 --- a/src/initSequence.h +++ b/src/initSequence.h @@ -54,6 +54,9 @@ extern const lcd_cmd_t jd9613_cmd[JD9613_INIT_SEQUENCE_LENGTH]; #define JD9613_HEIGHT 126 +#define RM67162_INIT_SPI_SEQUENCE_LENGTH 19 +extern const lcd_cmd_t rm67162_spi_cmd[RM67162_INIT_SPI_SEQUENCE_LENGTH]; +