81#include <soc/gpio_num.h>
82#include <hal/spi_types.h>
83#include <driver/ledc.h>
89#define MAX_TFT_BRIGHTNESS 7
91#if defined(CONFIG_ST7735_160x80)
94#elif defined(CONFIG_ST7735_128x160)
96 #define TFT_HEIGHT 128
97#elif defined(CONFIG_ST7789_240x135)
99 #define TFT_HEIGHT 135
100#elif defined(CONFIG_ST7789_240x240)
101 #define TFT_WIDTH 240
102 #define TFT_HEIGHT 240
103#elif defined(CONFIG_GC9307_240x280)
104 #define TFT_WIDTH 280
105 #define TFT_HEIGHT 240
107 #error "Please pick a screen size"
125void initTFT(spi_host_device_t spiHost, gpio_num_t sclk, gpio_num_t mosi, gpio_num_t dc, gpio_num_t cs, gpio_num_t rst,
126 gpio_num_t backlight,
bool isPwmBacklight, ledc_channel_t ledcChannel, ledc_timer_t ledcTimer,
139#if defined(__XTENSA__)
143 #define SETUP_FOR_TURBO() register uint32_t dispPx = (uint32_t)getPxTftFramebuffer();
151 #define TURBO_SET_PIXEL(opxc, opy, colorVal) \
152 asm volatile("mul16u a4, %[width], %[y]\nadd a4, a4, %[px]\nadd a4, a4, %[opx]\ns8i %[val],a4, 0" \
154 : [opx] "a"(opxc), [y] "a"(opy), [px] "a"(dispPx), [val] "a"(colorVal), [width] "a"(TFT_WIDTH) \
165 #define TURBO_SET_PIXEL_BOUNDS(opxc, opy, colorVal) \
167 "bgeu %[opx], %[width], failthrough%=\nbgeu %[y], %[height], failthrough%=\nmul16u a4, %[width], " \
168 "%[y]\nadd a4, a4, %[px]\nadd a4, a4, %[opx]\ns8i %[val],a4, 0\nfailthrough%=:\n" \
170 : [opx] "a"(opxc), [y] "a"(opy), [px] "a"(dispPx), [val] "a"(colorVal), [width] "a"(TFT_WIDTH), \
171 [height] "a"(TFT_HEIGHT) \
175 #define SETUP_FOR_TURBO()
177 #define TURBO_SET_PIXEL(opxc, opy, colorVal) setPxTft(opxc, opy, colorVal)
179 #define TURBO_SET_PIXEL_BOUNDS(opxc, opy, colorVal) setPxTft(opxc, opy, colorVal)
void disableTFTBacklight(void)
Disable the backlight (for power down)
Definition hdw-tft.c:309
paletteColor_t * getPxTftFramebuffer(void)
Return the pixel framebuffer, which is (TFT_WIDTH * TFT_HEIGHT) pixels in row order,...
Definition hdw-tft.c:300
void clearPxTft(void)
Clear all pixels in the display to black.
Definition hdw-tft.c:404
void enableTFTBacklight(void)
Enable the backlight.
Definition hdw-tft.c:327
void(* fnBackgroundDrawCallback_t)(int16_t x, int16_t y, int16_t w, int16_t h, int16_t up, int16_t upNum)
This is a typedef for a function pointer passed to drawDisplayTft() which will be called to draw a ba...
Definition hdw-tft.h:123
esp_err_t setTFTBacklightBrightness(uint8_t intensity)
Set TFT Backlight brightness. setTftBrightnessSetting() should be called instead if the new volume sh...
Definition hdw-tft.c:135
void initTFT(spi_host_device_t spiHost, gpio_num_t sclk, gpio_num_t mosi, gpio_num_t dc, gpio_num_t cs, gpio_num_t rst, gpio_num_t backlight, bool isPwmBacklight, ledc_channel_t ledcChannel, ledc_timer_t ledcTimer, uint8_t brightness)
Initialize a TFT display and return it through a pointer arg.
Definition hdw-tft.c:171
void deinitTFT(void)
Deinitialize the TFT display.
Definition hdw-tft.c:278
void setPxTft(int16_t x, int16_t y, paletteColor_t px)
Set a single pixel in the display, with bounds check.
Definition hdw-tft.c:377
void drawDisplayTft(fnBackgroundDrawCallback_t cb)
Send the current framebuffer to the TFT display over the SPI bus.
Definition hdw-tft.c:419
paletteColor_t getPxTft(int16_t x, int16_t y)
Get a single pixel in the display.
Definition hdw-tft.c:392
paletteColor_t
All 216 possible colors, named like cRGB.
Definition palette.h:23