Skip to content

Commit

Permalink
Use Espressif st7701 driver
Browse files Browse the repository at this point in the history
  • Loading branch information
renzenicolai committed Oct 10, 2024
1 parent bed57b8 commit ec7108b
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 7 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

Abstraction layer for quickly experimenting with MIPI DSI displays.

| LCD controller | Component name |
| :------------: | :-------------------------------: |
| EK79007 | esp_lcd_ek79007 |
| ILI9981C | esp_lcd_ili9981c |
| ST7701 | nicolaielectronics/esp_lcd_st7701 |
| LCD controller | Component name | Note |
| :------------: | :-------------------------------: | :-----------------------------------------------------------------: |
| EK79007 | esp_lcd_ek79007 | Included in the ESP32-P4-Function-EV-Board with v0.1 chip kit |
| ILI9981C | esp_lcd_ili9981c | Included in the ESP32-P4 devkit with v0.0 chip |
| ST7701(S) | esp_lcd_st7701 | Configured for use with the display on the WHY2025 badge / Tanmatsu |

## Add to project

Expand All @@ -21,6 +21,11 @@ You can add them to your project via `idf.py add-dependancy`, e.g.

Alternatively, you can create `idf_component.yml`. More is in [Espressif's documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-component-manager.html).

## Note

This component was made to facilitate easier testing for our firmwares on both the devkits and our target hardware and thus
the configurations we use are the only supported display configurations.

## Example

```
Expand Down
50 changes: 50 additions & 0 deletions dsi_panel_nicolaielectronics_st7701.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "esp_err.h"
#include "esp_log.h"
#include "esp_lcd_st7701.h"
#include "esp_lcd_panel_commands.h"

static const char *TAG = "ST7701 panel";

Expand All @@ -34,6 +35,50 @@ static const char *TAG = "ST7701 panel";
#define PANEL_MIPI_DSI_LANE_NUM 2 // 2 data lanes
#define PANEL_MIPI_DSI_LANE_BITRATE_MBPS 250 // 250 Mbps

static const st7701_lcd_init_cmd_t tanmatsu_display_init_sequence[] = {
// {cmd, { data }, data_size, delay_ms}
{0xFF, (uint8_t []){0x77, 0x01, 0x00, 0x00, 0x00}, 5, 0}, // Regular command function
{LCD_CMD_NORON, (uint8_t []){0x00}, 0, 0}, // Turn on normal display mode
{0xEF, (uint8_t []){0x08}, 1, 0}, //

{0xFF, (uint8_t []){0x77, 0x01, 0x00, 0x00, 0x10}, 5, 0}, // Command 2 BK0 function
{0xC0, (uint8_t []){0x63, 0x00}, 2, 0}, // LNESET (Display Line Setting): (0x63+1)*8 = 800 lines
{0xC1, (uint8_t []){0x10, 0x02}, 2, 0}, // PORCTRL (Porch Control): VBP = 16, VFP = 2
{0xC2, (uint8_t []){0x37, 0x08}, 2, 0}, // INVSET (Inversion sel. & frame rate control): PCLK=512+(8*16) = 640
{0xCC, (uint8_t []){0x38}, 1, 0}, //
{0xB0, (uint8_t []){0x40, 0xC9, 0x90, 0x0D, 0x0F, 0x04, 0x00, 0x07, 0x07, 0x1C, 0x04, 0x52, 0x0F, 0xDF, 0x26, 0xCF}, 16, 0}, // PVGAMCTRL
{0xB1, (uint8_t []){0x40, 0xC9, 0xCF, 0x0C, 0x90, 0x04, 0x00, 0x07, 0x08, 0x1B, 0x06, 0x55, 0x13, 0x62, 0xE7, 0xCF}, 16, 0}, // NVGAMCTRL

{0xFF, (uint8_t []){0x77, 0x01, 0x00, 0x00, 0x11}, 5, 0}, // Command 2 BK1 function
{0xB0, (uint8_t []){0x5D}, 1, 0}, // VRHS
{0xB1, (uint8_t []){0x2D}, 1, 0}, // VCOMS
{0xB2, (uint8_t []){0x07}, 1, 0}, // VGH
{0xB3, (uint8_t []){0x80}, 1, 0}, // TESTCMD
{0xB5, (uint8_t []){0x08}, 1, 0}, // VGLS
{0xB7, (uint8_t []){0x85}, 1, 0}, // PWCTRL1
{0xB8, (uint8_t []){0x20}, 1, 0}, // PWCTRL2
{0xB9, (uint8_t []){0x10}, 1, 0}, // DGMLUTR
{0xC1, (uint8_t []){0x78}, 1, 0}, // SPD1
{0xC2, (uint8_t []){0x78}, 1, 0}, // SPD2
{0xD0, (uint8_t []){0x88}, 1, 100}, // MIPISET1
{0xE0, (uint8_t []){0x00, 0x19, 0x02}, 3, 0}, //
{0xE1, (uint8_t []){0x05, 0xA0, 0x07, 0xA0, 0x04, 0xA0, 0x06, 0xA0, 0x00, 0x44, 0x44}, 11, 0}, //
{0xE2, (uint8_t []){0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 13, 0}, //
{0xE3, (uint8_t []){0x00, 0x00, 0x33, 0x33}, 5, 0}, //
{0xE4, (uint8_t []){0x44, 0x44}, 2, 0}, //
{0xE5, (uint8_t []){0x0D, 0x31, 0xC8, 0xAF, 0x0F, 0x33, 0xC8, 0xAF, 0x09, 0x2D, 0xC8, 0xAF, 0x0B, 0x2F, 0xC8, 0xAF}, 16, 0}, //
{0xE6, (uint8_t []){0x00, 0x00, 0x33, 0x33}, 4, 0}, //
{0xE7, (uint8_t []){0x44, 0x44}, 2, 0}, //
{0xE8, (uint8_t []){0x0C, 0x30, 0xC8, 0xAF, 0x0E, 0x32, 0xC8, 0xAF, 0x08, 0x2C, 0xC8, 0xAF, 0x0A, 0x2E, 0xC8, 0xAF}, 16, 0}, //
{0xEB, (uint8_t []){0x02, 0x00, 0xE4, 0xE4, 0x44, 0x00, 0x40}, 7, 0}, //
{0xEC, (uint8_t []){0x3C, 0x00}, 2, 0}, //
{0xED, (uint8_t []){0xAB, 0x89, 0x76, 0x54, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x10, 0x45, 0x67, 0x98, 0xBA}, 16, 0}, //

{0xFF, (uint8_t []){0x77, 0x01, 0x00, 0x00, 0x00}, 5, 0}, // Regular command function
{LCD_CMD_SLPOUT, (uint8_t []){0x00}, 0, 120}, // Exit sleep mode
{LCD_CMD_DISPON, (uint8_t []){0x00}, 0, 0}, // Display on (enable frame buffer output)
};

static esp_lcd_panel_handle_t mipi_dpi_panel = NULL;

esp_lcd_panel_handle_t st7701_get_panel(void) {
Expand Down Expand Up @@ -93,10 +138,15 @@ void st7701_initialize(gpio_num_t reset_pin) {
};

st7701_vendor_config_t vendor_config = {
.init_cmds = tanmatsu_display_init_sequence,
.init_cmds_size = sizeof(tanmatsu_display_init_sequence) / sizeof(st7701_lcd_init_cmd_t),
.mipi_config = {
.dsi_bus = mipi_dsi_bus,
.dpi_config = &dpi_config,
},
.flags = {
.use_mipi_interface = true,
}
};
esp_lcd_panel_dev_config_t lcd_dev_config = {
.reset_gpio_num = reset_pin,
Expand Down
3 changes: 1 addition & 2 deletions idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "1.0.0"
targets:
- esp32p4
description: MIPI DSI display abstraction layer
Expand All @@ -10,5 +9,5 @@ dependencies:
cmake_utilities: "0.*"
esp_lcd_ek79007: "^1.0.0"
esp_lcd_ili9881c: "^1.0.0"
nicolaielectronics/esp_lcd_st7701: "^0.0.1"
esp_lcd_st7701: "^1.0.0"
license: "MIT"

0 comments on commit ec7108b

Please sign in to comment.