75#if !__has_include(<Adafruit_GFX.h>)
76 #error "Adafruit_GFX.h not found. Install the Adafruit GFX Library, AND add \
77'#include <Adafruit_GFX.h>' to your .ino ABOVE this include - the Arduino \
78builder only resolves libraries that the sketch itself names."
81#include <Adafruit_GFX.h>
127 void drawPixel(int16_t x, int16_t y, uint16_t color)
override {
143 void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color)
override {
153 void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color)
override {
164 void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
override {
180 void writePixel(int16_t x, int16_t y, uint16_t color)
override {
191 void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color)
override {
276 static inline uint8_t idx(uint16_t color) {
277#ifdef CHGFX_GFX_AUTOMAP
283 return (uint8_t)(color & 0x0F);
CHGfx: a maximum-throughput ST7735 driver for the CHGame board (CH32X035G8U6 @ 48 MHz,...
An Adafruit_GFX display that draws into CHGfx's 4 bpp framebuffer and presents it by DMA.
Definition CHGfx_AdafruitGFX.h:106
uint8_t nearest(uint16_t rgb565) const
Nearest palette index for an RGB565 colour (gfx_nearest()): map Adafruit colour constants once at set...
Definition CHGfx_AdafruitGFX.h:268
void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) override
Fills a rectangle (gfx_fillRect()); the same as fillRect().
Definition CHGfx_AdafruitGFX.h:191
void writePixel(int16_t x, int16_t y, uint16_t color) override
Sets one pixel (gfx_pixel()); the same as drawPixel().
Definition CHGfx_AdafruitGFX.h:180
void writeFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) override
Draws a horizontal line (gfx_hline()); the same as drawFastHLine().
Definition CHGfx_AdafruitGFX.h:201
void endWrite(void) override
Does nothing: drawing goes to RAM, so there is nothing to batch.
Definition CHGfx_AdafruitGFX.h:218
void writeFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) override
Draws a vertical line (gfx_vline()); the same as drawFastVLine().
Definition CHGfx_AdafruitGFX.h:211
void setPalette(const uint16_t *p, uint8_t n)
Sets the first n palette entries (gfx_setPalette()).
Definition CHGfx_AdafruitGFX.h:255
void startWrite(void) override
Does nothing: drawing goes to RAM, so there is nothing to batch.
Definition CHGfx_AdafruitGFX.h:216
void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) override
Draws a horizontal line (gfx_hline()).
Definition CHGfx_AdafruitGFX.h:143
bool busy() const
Whether an async flush is in flight (gfx_busy()).
Definition CHGfx_AdafruitGFX.h:245
void setPaletteEntry(uint8_t i, uint16_t c)
Sets one palette entry (gfx_setPaletteEntry()).
Definition CHGfx_AdafruitGFX.h:261
void fillScreen(uint16_t color) override
Fills the screen (the clip rectangle) with one colour (gfx_clear()).
Definition CHGfx_AdafruitGFX.h:171
void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) override
Fills a rectangle (gfx_fillRect()).
Definition CHGfx_AdafruitGFX.h:164
CHGfx_GFX()
Makes a GFX_W x GFX_H display.
Definition CHGfx_AdafruitGFX.h:109
void displayRectAsync(int x, int y, int w, int h)
Starts sending one rectangle of the framebuffer and returns at once (gfx_flushRectAsync()).
Definition CHGfx_AdafruitGFX.h:243
void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) override
Draws a vertical line (gfx_vline()).
Definition CHGfx_AdafruitGFX.h:153
void begin(uint8_t spiDiv=GFX_DIV2, uint8_t colorMode=GFX_16BPP)
Starts the panel, as gfx_begin().
Definition CHGfx_AdafruitGFX.h:116
void display()
Sends the whole framebuffer to the panel and waits for it (gfx_flush()).
Definition CHGfx_AdafruitGFX.h:224
void drawPixel(int16_t x, int16_t y, uint16_t color) override
Sets one pixel in the framebuffer (gfx_pixel()).
Definition CHGfx_AdafruitGFX.h:127
void setColorMode(uint8_t m)
Switches the colour output mode (gfx_setColorMode()).
Definition CHGfx_AdafruitGFX.h:273
void wait()
Waits for the flush in flight to finish (gfx_wait()); draw after it.
Definition CHGfx_AdafruitGFX.h:247
void displayRect(int x, int y, int w, int h)
Sends one rectangle of the framebuffer and waits for it (gfx_flushRect()).
Definition CHGfx_AdafruitGFX.h:234
void displayAsync()
Starts sending the whole framebuffer by DMA and returns at once (gfx_flushAsync()).
Definition CHGfx_AdafruitGFX.h:226
#define GFX_H
Screen height in pixels (default 128).
Definition CHGfx.h:109
#define GFX_W
Screen width in pixels (default 128).
Definition CHGfx.h:105
@ GFX_DIV2
HCLK/2 = 24 MHz: the fastest the chip can clock SPI, and the default.
Definition CHGfx.h:232
@ GFX_16BPP
ST7735 COLMOD 0x05, RGB565, 2 bytes/px -> 90 fps.
Definition CHGfx.h:219
void gfx_hline(int x, int y, int w, uint8_t c)
Draws a horizontal line from (x, y), w pixels to the right.
void gfx_clear(uint8_t c)
Fills the clip rectangle (normally the whole screen) with one colour.
void gfx_pixel(int x, int y, uint8_t c)
Sets one pixel.
void gfx_fillRect(int x, int y, int w, int h, uint8_t c)
Fills a rectangle.
void gfx_vline(int x, int y, int h, uint8_t c)
Draws a vertical line from (x, y), h pixels down.
void gfx_setPaletteEntry(uint8_t index, uint16_t rgb565)
Sets one palette entry.
void gfx_setPalette(const uint16_t *rgb565, uint8_t count)
Sets the first count palette entries.
uint8_t gfx_nearest(uint16_t rgb565)
Nearest palette index for a full RGB565 colour.
void gfx_flushRectAsync(int x, int y, int w, int h)
Starts sending one rectangle of the framebuffer and returns at once, as gfx_flushAsync() does for the...
void gfx_flushAsync(void)
Starts sending the whole framebuffer and returns at once; the DMA interrupt does the rest.
void gfx_wait(void)
Waits until the flush in flight, if any, has finished.
bool gfx_busy(void)
Whether an async flush is still in flight.
void gfx_flushRect(int x, int y, int w, int h)
Sends one rectangle of the framebuffer to the panel and returns when it has gone out.
void gfx_flush(void)
Sends the whole framebuffer to the panel and returns when it has gone out.
static void gfx_begin(uint8_t spiDiv=GFX_DIV2, uint8_t colorMode=GFX_16BPP)
Starts the panel: pins, SPI1, DMA, a hardware reset and the ST7735 initialisation,...
Definition CHGfx.h:308
void gfx_setColorMode(uint8_t mode)
Switches the panel's colour output mode.