Skip to content

Commit

Permalink
Fixed display init
Browse files Browse the repository at this point in the history
  • Loading branch information
hnzlmnn committed Jun 5, 2024
1 parent 1514265 commit 6ed3b9b
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions components/spi-st77xx/st77xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const uint8_t st77xx_init_data[] = {
ST77XX_RASET, 4, 0x00, 0x00, 0x01, 0x3F,
// Display on
ST77XX_DISPON, 0,
0x00,
};

esp_err_t ST7789VI_send(ST77XX* device, const uint8_t *data, const int len,const bool dc_level) {
Expand Down Expand Up @@ -163,12 +164,13 @@ esp_err_t st77xx_reset(ST77XX* device) {
return ESP_OK;
}

esp_err_t st77xx_write_init_data(ST77XX* device, const uint8_t * data, size_t size) {
esp_err_t st77xx_write_init_data(ST77XX* device, const uint8_t * data) {
if (device->spi_device == NULL) return ESP_FAIL;
esp_err_t res;
uint8_t cmd, len;
for (int i = 0; i < size; i++) {
while (true) {
cmd = *data++;
if (!cmd) break;
len = *data++;
ESP_LOGD(TAG, "Sending command %x", cmd);
res = st77xx_send_command(device, cmd);
Expand Down Expand Up @@ -197,12 +199,30 @@ esp_err_t st77xx_init(ST77XX* device) {

if (device->mutex != NULL) xSemaphoreGive(device->mutex);

res = gpio_set_direction(device->pin_dcx, GPIO_MODE_OUTPUT);
if (res != ESP_OK) return res;
ESP_LOGD(TAG, "pin_reset: %d", device->pin_reset);
ESP_LOGD(TAG, "pin_dcx: %d", device->pin_dcx);

res = gpio_set_direction(device->pin_reset, GPIO_MODE_OUTPUT);
/* Setup reset */
gpio_config_t reset_io_conf = {
.intr_type = GPIO_INTR_DISABLE,
.mode = GPIO_MODE_OUTPUT,
.pin_bit_mask = 1LL << device->pin_reset,
.pull_down_en = 0,
.pull_up_en = 0,
};
res = gpio_config(&reset_io_conf);
if (res != ESP_OK) return res;

/* Setup DS */
gpio_config_t dc_io_conf = {
.intr_type = GPIO_INTR_DISABLE,
.mode = GPIO_MODE_OUTPUT,
.pin_bit_mask = 1LL << device->pin_dcx,
.pull_down_en = 0,
.pull_up_en = 0,
};
res = gpio_config(&dc_io_conf);
if (res != ESP_OK) return res;
res = gpio_set_level(device->pin_dcx, true);
if (res != ESP_OK) return res;

Expand Down Expand Up @@ -241,12 +261,11 @@ esp_err_t st77xx_init(ST77XX* device) {
ESP_LOGE(TAG, "DC pin %d", device->pin_dcx);

//Send the initialization data to the LCD display
res = st77xx_write_init_data(device, st77xx_init_data, sizeof(st77xx_init_data) / sizeof(st77xx_init_data[0]));
res = st77xx_write_init_data(device, st77xx_init_data);
if (res != ESP_OK) return res;




st77xx_send_command(device, ST77XX_RAMWR); /* Ram Write*/
for (uint32_t j = 0; j < 240; j++)
{
Expand Down

0 comments on commit 6ed3b9b

Please sign in to comment.