Framebuffer API
Use the framebuffer API to implement displays (LCD, OLED, e-paper, etc.). The display size is defined in the .chip.json
file. The framebuffer uses 32 bits per pixel. The pixels are stored in the RGBA format. The total size of the buffer is pixel_width * pixel_height * 4
bytes.
buffer_t framebuffer_init(uint32_t *pixel_width, uint32_t *pixel_height)
Returns the framebuffer for the current chip, and the pixel dimensions (width/height) of the frame buffer.
注意
Note: framebuffer_init
can only be called from chip_init()
. Do not call it at a later time.
void buffer_write(buffer_t buffer, uint32_t offset, void *data, uint32_t data_len)
Copies data_len
bytes from data
into the frame buffer, at the given offset
.
void buffer_read(buffer_t buffer, uint32_t offset, void *data, uint32_t data_len)
Copies data_len
bytes at the given offset
of the frame buffer into data
.