![]() |
CHGame 0.3.0
Libraries for the CHGame handheld
|
Talking to the ST7735 without the framebuffer: chip select, commands, address windows, DMA fills and raw blits. More...
Functions | |
| void | gfx_select (void) |
| Asserts the panel's chip select. | |
| void | gfx_deselect (void) |
| Waits for the last byte to leave SPI1, then releases the panel's chip select. | |
| void | gfx_setWindow (uint8_t x, uint8_t y, uint8_t w, uint8_t h) |
| Sets the panel's address window and starts a memory write (CASET, RASET, RAMWR). | |
| void | gfx_cmd (uint8_t c) |
| Sends one command byte (D/C low), then sets D/C back to data. | |
| void | gfx_data8 (uint8_t d) |
| Sends one data byte (D/C high). | |
| void | gfx_writeColorLut (void) |
| Programs the ST7735 RGBSET (2Dh) colour-depth conversion LUT for the current mode. | |
| void | gfx_setWriteColorLut (bool on) |
| Chooses whether entering 12 bpp writes the colour LUT (gfx_writeColorLut()). | |
| void | gfx_directFillRect (uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint16_t rgb565) |
| Fills a rectangle of the panel with one colour by DMA, bypassing the framebuffer. | |
| void | gfx_directBlit (const void *data, uint32_t bytes, bool halfword) |
| Sends a caller-owned buffer, already in panel format, by DMA and waits for it. | |
| void | gfx_blockingWrite (const uint8_t *data, uint32_t bytes) |
| Sends bytes one at a time in a polled loop, for baseline comparisons. | |
Talking to the ST7735 without the framebuffer: chip select, commands, address windows, DMA fills and raw blits.
These write to the panel at once, so call them only when no flush is in flight (after gfx_wait()); the SD card shares the bus too. Raw pixel data must already be in the panel's current format.
| void gfx_select | ( | void | ) |
Asserts the panel's chip select.
Assert once, stream a whole frame, deassert - that is the entire performance thesis of this driver in two functions. The panel latches nothing while CS is high.
| void gfx_deselect | ( | void | ) |
Waits for the last byte to leave SPI1, then releases the panel's chip select.
| void gfx_setWindow | ( | uint8_t | x, |
| uint8_t | y, | ||
| uint8_t | w, | ||
| uint8_t | h | ||
| ) |
Sets the panel's address window and starts a memory write (CASET, RASET, RAMWR).
Pixel data sent after it fills the window left to right, top to bottom. The panel offsets (gfx_setPanelOffsets()) are added; nothing is clipped. Needs gfx_select() first.
| x | Left edge, in screen pixels. |
| y | Top edge, in screen pixels. |
| w | Width in pixels, 1 or more. |
| h | Height in pixels, 1 or more. |
| void gfx_cmd | ( | uint8_t | c | ) |
Sends one command byte (D/C low), then sets D/C back to data.
| c | ST7735 command. |
| void gfx_data8 | ( | uint8_t | d | ) |
Sends one data byte (D/C high).
| d | The byte. |
| void gfx_writeColorLut | ( | void | ) |
Programs the ST7735 RGBSET (2Dh) colour-depth conversion LUT for the current mode.
Done automatically for 12 bpp because the datasheet says the table powers up "Random"; call gfx_setWriteColorLut(false) before gfx_setColorMode() if you would rather trust the factory contents.
| void gfx_setWriteColorLut | ( | bool | on | ) |
Chooses whether entering 12 bpp writes the colour LUT (gfx_writeColorLut()).
| on | true (the default) to write it, false to trust the panel's factory contents. |
| void gfx_directFillRect | ( | uint8_t | x, |
| uint8_t | y, | ||
| uint8_t | w, | ||
| uint8_t | h, | ||
| uint16_t | rgb565 | ||
| ) |
Fills a rectangle of the panel with one colour by DMA, bypassing the framebuffer.
DMA with memory-increment DISABLED: the DMA engine re-reads one halfword N times. Zero RAM, zero CPU, full wire speed. Waits for any flush in flight; handles chip select itself; not clipped.
| x | Left edge, in screen pixels. |
| y | Top edge, in screen pixels. |
| w | Width in pixels. |
| h | Height in pixels. |
| rgb565 | The colour, in RGB565. |
| void gfx_directBlit | ( | const void * | data, |
| uint32_t | bytes, | ||
| bool | halfword | ||
| ) |
Sends a caller-owned buffer, already in panel format, by DMA and waits for it.
Needs gfx_select() and gfx_setWindow() first.
| data | The pixel data. |
| bytes | Its length in bytes (even when halfword). |
| halfword | true to send 16-bit SPI frames (RGB565 as uint16_t, 16 bpp), false for bytes (12 and 18 bpp). |
| void gfx_blockingWrite | ( | const uint8_t * | data, |
| uint32_t | bytes | ||
| ) |
Sends bytes one at a time in a polled loop, for baseline comparisons.
| data | The bytes. |
| bytes | How many. |