/** * ESP-IDF ST7735 Display Driver (basierend auf LilyGO T-Dongle-C5 Demo) * * GPIO-Pins für T-Dongle-C5: * CS = GPIO10, DC = GPIO3, RST = GPIO1 * BL = GPIO0, MOSI = GPIO2, SCK = GPIO6 * * Display: ST7735S, 80x160, Rotation 3 (invertiert), Offset x=26, y=1 */ #ifndef ST7735_H #define ST7735_H #include "esp_err.h" #include #ifdef __cplusplus extern "C" { #endif /* GPIO-Konfiguration für T-Dongle-C5 */ typedef struct { int cs_gpio; int dc_gpio; int rst_gpio; int bl_gpio; /* Backlight, aktiv LOW */ int mosi_gpio; int sck_gpio; } st7735_gpio_config_t; /* Standard GPIO-Konfiguration für T-Dongle-C5 */ #define ST7735_GPIO_CONFIG_DEFAULT() \ { \ .cs_gpio = 10, \ .dc_gpio = 3, \ .rst_gpio = 1, \ .bl_gpio = 0, \ .mosi_gpio = 2, \ .sck_gpio = 6, \ } /* Display Parameter */ #define ST7735_TFT_WIDTH 80 #define ST7735_TFT_HEIGHT 160 #define ST7735_COL_OFFSET 26 #define ST7735_ROW_OFFSET 1 /* Farben */ #define ST7735_BLACK 0x0000 #define ST7735_WHITE 0xFFFF #define ST7735_BLUE 0x001F #define ST7735_RED 0xF800 #define ST7735_GREEN 0x07E0 /* Rotationswinkel */ #define ST7735_ROTATION_0 0 /* 0° */ #define ST7735_ROTATION_90 1 /* 90° */ #define ST7735_ROTATION_180 2 /* 180° */ #define ST7735_ROTATION_270 3 /* 270° */ /** * ST7735 Display initialisieren * * @param gpio_config GPIO-Konfiguration (NULL = Default T-Dongle-C5 Pins) * @param rotation Display-Rotation (0, 1, 2, 3) * @param handle[out] Panel-Handle für weitere Befehle * @return ESP_OK bei Erfolg, Fehlercode sonst */ esp_err_t st7735_init(const st7735_gpio_config_t *gpio_config, uint8_t rotation, void **handle); /** * Display ausschalten */ esp_err_t st7735_display_off(void *handle); /** * Display einschalten */ esp_err_t st7735_display_on(void *handle); /** * Full-Screen füllen (eine Farbe) */ esp_err_t st7735_fill_screen(void *handle, uint16_t color); /** * Pixel zeichnen */ esp_err_t st7735_draw_pixel(void *handle, int16_t x, int16_t y, uint16_t color); /** * Rechteck zeichnen (x,y = Start, w/h = Größe, color = Füllfarbe) */ esp_err_t st7735_draw_rect(void *handle, int16_t x, int16_t y, uint16_t w, uint16_t h, uint16_t color); /** * Linie zeichnen */ esp_err_t st7735_draw_line(void *handle, int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color); #ifdef __cplusplus } #endif #endif /* ST7735_H */