Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
|
Macros | |
#define | SWAP(x) ((x >> 8) | (x << 8)) |
Swap the upper and lower bytes in a 16-bit word. | |
#define | PARALLEL_LINES 16 |
The number of parallel lines used in a SPI transfer. | |
#define | LCD_BK_LIGHT_ON_LEVEL 1 |
The GPIO level to turn the backlight on. | |
#define | LCD_BK_LIGHT_OFF_LEVEL 0 |
The GPIO level to turn the backlight off. | |
#define | LCD_CMD_BITS 8 |
The number of bits in an LCD control command. | |
#define | LCD_PARAM_BITS 8 |
The number of bits for an LCD control command's parameter. | |
#define | NUM_S_LINES 2 |
Functions | |
esp_err_t | setTFTBacklightBrightness (uint8_t intensity) |
Set TFT Backlight brightness. setTftBrightnessSetting() should be called instead if the new volume should be persistent through a reboot. | |
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. | |
void | deinitTFT (void) |
Deinitialize the TFT display. | |
paletteColor_t * | getPxTftFramebuffer (void) |
Return the pixel framebuffer, which is (TFT_WIDTH * TFT_HEIGHT) pixels in row order, starting from the top left. This can be used t directly modify individual pixels without calling setPxTft() | |
void | disableTFTBacklight (void) |
Disable the backlight (for power down) | |
void | enableTFTBacklight (void) |
Enable the backlight. | |
void | setPxTft (int16_t x, int16_t y, paletteColor_t px) |
Set a single pixel in the display, with bounds check. | |
paletteColor_t | getPxTft (int16_t x, int16_t y) |
Get a single pixel in the display. | |
void | clearPxTft (void) |
Clear all pixels in the display to black. | |
void | drawDisplayTft (fnBackgroundDrawCallback_t fnBackgroundDrawCallback) |
Send the current framebuffer to the TFT display over the SPI bus. | |
Variables | |
paletteColor_t * | pFrameBuffer = NULL |
#define SWAP | ( | x | ) | ((x >> 8) | (x << 8)) |
Swap the upper and lower bytes in a 16-bit word.
#define PARALLEL_LINES 16 |
The number of parallel lines used in a SPI transfer.
To speed up transfers, every SPI transfer sends a bunch of lines. This define specifies how many. More means more memory use, but less overhead for setting up and finishing transfers. Make sure TFT_HEIGHT is dividable by this.
#define LCD_BK_LIGHT_ON_LEVEL 1 |
The GPIO level to turn the backlight on.
#define LCD_BK_LIGHT_OFF_LEVEL 0 |
The GPIO level to turn the backlight off.
#define LCD_CMD_BITS 8 |
The number of bits in an LCD control command.
#define LCD_PARAM_BITS 8 |
The number of bits for an LCD control command's parameter.
#define NUM_S_LINES 2 |
esp_err_t setTFTBacklightBrightness | ( | uint8_t | intensity | ) |
Set TFT Backlight brightness. setTftBrightnessSetting() should be called instead if the new volume should be persistent through a reboot.
intensity | The brightness, 0 to MAX_TFT_BRIGHTNESS |
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.
spiHost | The SPI host to use for this display |
sclk | The GPIO for the SCLK pin |
mosi | The GPIO for the MOSI pin |
dc | The GPIO for the TFT SPI data or command selector pin |
cs | The GPIO for the chip select pin |
rst | The GPIO for the RESET pin |
backlight | The GPIO used to PWM control the backlight |
isPwmBacklight | true to set up the backlight as PWM, false to have it be on/off |
ledcChannel | The LEDC channel to use for the PWM backlight |
ledcTimer | The LEDC timer to use for the PWM backlight |
brightness | The initial backlight brightness |
void deinitTFT | ( | void | ) |
Deinitialize the TFT display.
paletteColor_t * getPxTftFramebuffer | ( | void | ) |
Return the pixel framebuffer, which is (TFT_WIDTH * TFT_HEIGHT) pixels in row order, starting from the top left. This can be used t directly modify individual pixels without calling setPxTft()
void disableTFTBacklight | ( | void | ) |
Disable the backlight (for power down)
void enableTFTBacklight | ( | void | ) |
Enable the backlight.
void setPxTft | ( | int16_t | x, |
int16_t | y, | ||
paletteColor_t | px ) |
Set a single pixel in the display, with bounds check.
x | The x coordinate of the pixel to set |
y | The y coordinate of the pixel to set |
px | The color of the pixel to set |
paletteColor_t getPxTft | ( | int16_t | x, |
int16_t | y ) |
Get a single pixel in the display.
x | The x coordinate of the pixel to get |
y | The y coordinate of the pixel to get |
void clearPxTft | ( | void | ) |
Clear all pixels in the display to black.
void drawDisplayTft | ( | fnBackgroundDrawCallback_t | fnBackgroundDrawCallback | ) |
Send the current framebuffer to the TFT display over the SPI bus.
This function can be called as quickly as possible
Because the SPI driver handles transactions in the background, we can calculate the next line while the previous one is being sent.
fnBackgroundDrawCallback | A function pointer to draw backgrounds while the transmission is occurring |
paletteColor_t* pFrameBuffer = NULL |