From bb63df4f61521a2d5f3b59ed42ab556e721178bd Mon Sep 17 00:00:00 2001 From: rkcf Date: Sat, 4 Feb 2023 18:31:49 -0600 Subject: [PATCH] Fix: change LCD backlight to use ledc pwm driver instead of gpio. Fixes #13 Refs: #13 --- main/esp32-sequencer.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/main/esp32-sequencer.c b/main/esp32-sequencer.c index 13fe86f..3a67641 100644 --- a/main/esp32-sequencer.c +++ b/main/esp32-sequencer.c @@ -298,10 +298,18 @@ static void lvgl_increase_tick(void *arg) { /* Setup for TFT LCD Display and LVGL GUI */ static void display_init(void) { ESP_LOGI(TAG, "Initialing LCD"); + // Configure backlight - gpio_reset_pin(LCD_BK_LIGHT_PIN); - gpio_set_direction(LCD_BK_LIGHT_PIN, GPIO_MODE_OUTPUT); - gpio_set_level(LCD_BK_LIGHT_PIN, 1); + ledc_channel_config_t ledc_lcd_bk_light_channel = { + .channel = LEDC_CHANNEL_2, + .gpio_num = LCD_BK_LIGHT_PIN, + .speed_mode = LEDC_LOW_SPEED_MODE, + .timer_sel = LEDC_TIMER_0, + .intr_type = LEDC_INTR_DISABLE, + .duty = 3000, + .hpoint = 0 + }; + ESP_ERROR_CHECK(ledc_channel_config(&ledc_lcd_bk_light_channel)); // Setup SPI Bus spi_bus_config_t spi_cfg = {