framebuffer - RGB framebuffer component¶
- group framebuffer
Simple abstraction of RGB framebuffer for ESP-IDF.
Copyright (c) 2021 Ruslan V. Uss unclerus@gmail.com
MIT Licensed as described in the file LICENSE
Typedefs
-
typedef struct framebuffer_s framebuffer_t¶
-
typedef esp_err_t (*fb_render_cb_t)(framebuffer_t *fb, void *arg)¶
Renderer callback prototype.
Enums
Functions
-
esp_err_t fb_init(framebuffer_t *fb, size_t width, size_t height, fb_render_cb_t render_cb)¶
Initialize framebuffer.
- Parameters
fb – Framebuffer descriptor
width – Frame width in pixels
height – Frame height in pixels
render_cb – Renderer callback function
- Returns
ESP_OK on success
-
esp_err_t fb_free(framebuffer_t *fb)¶
Free Framebuffer descriptor buffers.
- Parameters
fb – Framebuffer descriptor
- Returns
ESP_OK on success
-
esp_err_t fb_render(framebuffer_t *fb, void *ctx)¶
Render frambuffer to actual display or LED strip.
Rendering is performed by calling the callback function with passing it as arguments
fb
andctx
- Parameters
fb – Framebuffer descriptor
ctx – Argument to pass to callback
- Returns
ESP_OK on success
-
esp_err_t fb_set_pixel_rgb(framebuffer_t *fb, size_t x, size_t y, rgb_t color)¶
Set RGB color of framebuffer pixel.
- Parameters
fb – Framebuffer descriptor
x – X coordinate
y – Y coordinate
color – RGB color
- Returns
ESP_OK on success
-
esp_err_t fb_set_pixel_hsv(framebuffer_t *fb, size_t x, size_t y, hsv_t color)¶
Set HSV color of framebuffer pixel.
- Parameters
fb – Framebuffer descriptor
x – X coordinate
y – Y coordinate
color – HSV color
- Returns
ESP_OK on success
-
esp_err_t fb_set_pixelf_rgb(framebuffer_t *fb, float x, float y, rgb_t color)¶
Set RGB pixel with subpixel resolution.
- Parameters
fb – Framebuffer descriptor
x – X coordinate
y – Y coordinate
color – RGB color
- Returns
ESP_OK on success
-
esp_err_t fb_set_pixelf_hsv(framebuffer_t *fb, float x, float y, hsv_t color)¶
Set HSV pixel with subpixel resolution.
- Parameters
fb – Framebuffer descriptor
x – X coordinate
y – Y coordinate
color – HSV color
- Returns
ESP_OK on success
-
esp_err_t fb_get_pixel_rgb(framebuffer_t *fb, size_t x, size_t y, rgb_t *color)¶
Get RGB color of framebuffer pixel.
- Parameters
fb – Framebuffer descriptor
x – X coordinate
y – Y coordinate
color – [out] RGB color
- Returns
ESP_OK on success
-
esp_err_t fb_get_pixel_hsv(framebuffer_t *fb, size_t x, size_t y, hsv_t *color)¶
Get HSV color of framebuffer pixel.
- Parameters
fb – Framebuffer descriptor
x – X coordinate
y – Y coordinate
color – [out] HSV color
- Returns
ESP_OK on success
-
esp_err_t fb_clear(framebuffer_t *fb)¶
Clear framebuffer.
- Parameters
fb – Framebuffer descriptor
- Returns
ESP_OK on success
-
esp_err_t fb_shift(framebuffer_t *fb, size_t offs, fb_shift_direction_t dir)¶
Shift framebuffer.
- Parameters
fb – Framebuffer descriptor
offs – Shift size
dir – Shift direction
- Returns
ESP_OK on success
-
esp_err_t fb_fade(framebuffer_t *fb, uint8_t scale)¶
Fade pixels to black.
rgb_fade(pixel, scale) for all pixels in framebuffer
- Parameters
fb – Framebuffer descriptor
scale – Amount of scaling
- Returns
ESP_OK on success
-
esp_err_t fb_blur2d(framebuffer_t *fb, fract8 amount)¶
Aplly two-dimensional blur filter on framebuffer.
Spreads light to 8 XY neighbors.
0 = no spread at all 64 = moderate spreading 172 = maximum smooth, even spreading
173..255 = wider spreading, but increasing flicker
- Parameters
fb – Framebuffer descriptor
amount – Amount of bluring
- Returns
ESP_OK on success
-
esp_err_t fb_begin(framebuffer_t *fb)¶
Start frame rendering.
This function must be called in effects at the beginning of rendering frame
- Parameters
fb – Framebuffer descriptor
- Returns
ESP_OK on success
-
esp_err_t fb_end(framebuffer_t *fb)¶
Finish frame rendering.
This function must be called in effects at the end of rendering frame
- Parameters
fb – Framebuffer descriptor
- Returns
ESP_OK on success
-
struct framebuffer_s¶
- #include <framebuffer.h>
Framebuffer descriptor descriptor.
Public Members
-
size_t width¶
Framebuffer width.
-
size_t height¶
Framebuffer height.
-
size_t frame_num¶
Number of rendered frames.
-
uint64_t last_frame_us¶
Time of last rendered frame since boot in microseconds.
-
fb_render_cb_t render¶
See fb_render()
-
uint8_t *internal¶
Buffer for effect settings, internal vars, palettes and so on.
-
size_t width¶
-
typedef struct framebuffer_s framebuffer_t¶
Animation¶
- group animation
ESP-IDF abstraction of framebuffer animation.
Copyright (c) 2021 Ruslan V. Uss unclerus@gmail.com
MIT Licensed as described in the file LICENSE
Typedefs
-
typedef esp_err_t (*fb_draw_cb_t)(framebuffer_t *fb)¶
Draw funtion type.
Functions
-
esp_err_t fb_animation_init(fb_animation_t *animation, framebuffer_t *fb)¶
Create animation based on LED effect.
- Parameters
animation – Animation descriptor
fb – Framebuffer descriptor
- Returns
ESP_OK on success
-
esp_err_t fb_animation_play(fb_animation_t *animation, uint8_t fps, fb_draw_cb_t draw, void *render_ctx)¶
Play animation.
- Parameters
animation – Animation descriptor
fps – Target FPS
draw – Function for drawing on a framebuffer
render_ctx – Renderer callback argument
- Returns
ESP_OK on success
-
esp_err_t fb_animation_stop(fb_animation_t *animation)¶
Stop playing animation.
- Parameters
animation – Animation descriptor
- Returns
ESP_OK on success
-
esp_err_t fb_animation_free(fb_animation_t *animation)¶
Create animation based on LED effect.
- Parameters
animation – Animation descriptor
- Returns
ESP_OK on success
-
struct fb_animation_t¶
- #include <fbanimation.h>
Animation descriptor.
Public Members
-
framebuffer_t *fb¶
Framebuffer descriptor.
-
void *render_ctx¶
Renderer context.
-
esp_timer_handle_t timer¶
Animation timer.
-
fb_draw_cb_t draw¶
Draw function.
-
framebuffer_t *fb¶
-
typedef esp_err_t (*fb_draw_cb_t)(framebuffer_t *fb)¶