Scanline buffering for generic rendering engines on serial displays
- Scanline based buffering
- No dynamic memory allocation
- Minimal RAM needed
- Double buffering to support DMA
- Overlappig segments supported
- Interlacing
| name | default | note |
|---|---|---|
| SBF_SW | 240 | width |
| SBF_SH | 240 | height |
| SBF_MAX_SECTIONS | 8 | max number of sections in a scanline, depends on the complexity of the object |
- two scanlines -- SBF_SW * 2
- scanline buffer -- SBF_SH * SBF_MAX_SECTIONS * 4 bytes
- work array -- SBF_SH / 2 bytes
- define
SBUF_IMPLEMENTATION - include
sbuf.h - implement the callback function
void fill_scanline_type(uint8_t *buf, int y, int x0, int x1) { if( NULL == buf ) { // clear this scanline 'y' between x0 and x1 including x0 and x1 // or render the background image to this area } else { // render the provided 'buf' to line 'y' from x0 to x1 } }
- call
sbf_init()once - render your scene calling
sbf_add_segment()as many times as needed NOTE: No more thanSBF_MAX_SECTIONScalls per scanline! - call
sbf_render_frame()to render the result - if interlacing is used, negate the flip marker
st7789-driver-demo.mp4
also using the ninety3d library