driver for ST7735/89 & LED PWM

This commit is contained in:
Philippe G
2020-07-28 18:35:10 -07:00
parent c41d30f883
commit 3c76f6fcb5
14 changed files with 483 additions and 75 deletions

View File

@@ -52,14 +52,15 @@ static const char *known_drivers[] = {"SH1106",
"SSD1327",
"SSD1675",
"SSD1351",
"ST77xx",
"ILI9341",
NULL
};
static void displayer_task(void *args);
struct GDS_Device *display;
extern GDS_DetectFunc SSD1306_Detect, SSD132x_Detect, SH1106_Detect, SSD1675_Detect, SSD1322_Detect, SSD1351_Detect, ILI9341_Detect;
GDS_DetectFunc *drivers[] = { SH1106_Detect, SSD1306_Detect, SSD132x_Detect, SSD1675_Detect, SSD1322_Detect, SSD1351_Detect, ILI9341_Detect, NULL };
extern GDS_DetectFunc SSD1306_Detect, SSD132x_Detect, SH1106_Detect, SSD1675_Detect, SSD1322_Detect, SSD1351_Detect, ST77xx_Detect, ILI9341_Detect;
GDS_DetectFunc *drivers[] = { SH1106_Detect, SSD1306_Detect, SSD132x_Detect, SSD1675_Detect, SSD1322_Detect, SSD1351_Detect, ST77xx_Detect, ILI9341_Detect, NULL };
/****************************************************************************************
*
@@ -73,16 +74,22 @@ void display_init(char *welcome) {
return;
}
int width = -1, height = -1;
int width = -1, height = -1, backlight_pin = -1;
char *p, *drivername = strstr(config, "driver");
if ((p = strcasestr(config, "width")) != NULL) width = atoi(strchr(p, '=') + 1);
if ((p = strcasestr(config, "height")) != NULL) height = atoi(strchr(p, '=') + 1);
if ((p = strcasestr(config, "back")) != NULL) backlight_pin = atoi(strchr(p, '=') + 1);
// query drivers to see if we have a match
ESP_LOGI(TAG, "Trying to configure display with %s", config);
display = GDS_AutoDetect(drivername ? drivername : "SSD1306", drivers);
if (backlight_pin >= 0) {
struct GDS_BacklightPWM PWMConfig = { .Channel = pwm_system.base_channel++, .Timer = pwm_system.timer, .Max = pwm_system.max, .Init = false };
display = GDS_AutoDetect(drivername, drivers, &PWMConfig);
} else {
display = GDS_AutoDetect(drivername, drivers, NULL);
}
if ((p = strcasestr(config, "width")) != NULL) width = atoi(strchr(p, '=') + 1);
if ((p = strcasestr(config, "height")) != NULL) height = atoi(strchr(p, '=') + 1);
// so far so good
if (display && width > 0 && height > 0) {
int RST_pin = -1;
@@ -96,7 +103,7 @@ void display_init(char *welcome) {
init = true;
GDS_I2CInit( i2c_system_port, -1, -1, i2c_system_speed ) ;
GDS_I2CAttachDevice( display, width, height, address, RST_pin );
GDS_I2CAttachDevice( display, width, height, address, RST_pin, backlight_pin );
ESP_LOGI(TAG, "Display is I2C on port %u", address);
} else if (strstr(config, "SPI") && spi_system_host != -1) {
@@ -107,7 +114,7 @@ void display_init(char *welcome) {
init = true;
GDS_SPIInit( spi_system_host, spi_system_dc_gpio );
GDS_SPIAttachDevice( display, width, height, CS_pin, RST_pin, speed );
GDS_SPIAttachDevice( display, width, height, CS_pin, RST_pin, backlight_pin, speed );
ESP_LOGI(TAG, "Display is SPI host %u with cs:%d", spi_system_host, CS_pin);
} else {
@@ -213,7 +220,7 @@ static void displayer_task(void *args) {
scroll_sleep -= sleep;
vTaskDelay(sleep / portTICK_PERIOD_MS);
}
}
}
/****************************************************************************************
*