TB2026-YDS Firmware
Loading...
Searching...
No Matches
gfx.h
Go to the documentation of this file.
1
9#pragma once
10
11#include <stdint.h>
12
19
20#define GFX_W 176
21#define GFX_H 176
22
23typedef uint16_t gfx_color_t;
24
30static inline gfx_color_t gfx_rgb(uint8_t r, uint8_t g, uint8_t b)
31{
32 return (gfx_color_t)(((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3));
33}
34
35#define GFX_BLACK ((gfx_color_t)0x0000)
36#define GFX_WHITE ((gfx_color_t)0xFFFF)
37
38/* Built-in 5x7 font, drawn in a 6x8 cell (1px gap). Multiply by scale for size. */
39#define GFX_CHAR_W 6
40#define GFX_CHAR_H 8
41
43void gfx_clear(gfx_color_t color);
44
46void gfx_pixel(int x, int y, gfx_color_t color);
47
49void gfx_fill_rect(int x, int y, int w, int h, gfx_color_t color);
50
52void gfx_draw_rect(int x, int y, int w, int h, gfx_color_t color);
53
61void gfx_draw_text(int x, int y, const char *s, gfx_color_t color, int scale);
62
76void gfx_blit_1bpp(int x, int y, int w, int h, const uint8_t *bitmap, gfx_color_t color);
77
79void gfx_flush(void);
80
85const gfx_color_t *gfx_buffer(void);
86
uint16_t gfx_color_t
Definition gfx.h:23
void gfx_pixel(int x, int y, gfx_color_t color)
Set one pixel; off-canvas coordinates are ignored.
Definition gfx.c:27
const gfx_color_t * gfx_buffer(void)
Read-only access to the framebuffer (GFX_W*GFX_H pixels).
Definition gfx.c:17
void gfx_draw_rect(int x, int y, int w, int h, gfx_color_t color)
Draw a 1px rectangle outline.
Definition gfx.c:46
void gfx_clear(gfx_color_t color)
Fill the whole framebuffer with one color.
Definition gfx.c:22
void gfx_blit_1bpp(int x, int y, int w, int h, const uint8_t *bitmap, gfx_color_t color)
Draw a 1-bpp bitmap; set bits are drawn in color, clear bits are skipped.
Definition gfx.c:110
void gfx_flush(void)
Blit the framebuffer to the OLED over SPI.
Definition gfx.c:121
void gfx_draw_text(int x, int y, const char *s, gfx_color_t color, int scale)
Draw an ASCII string (0x20..0x7E) left to right.
Definition gfx.c:94
void gfx_fill_rect(int x, int y, int w, int h, gfx_color_t color)
Fill a rectangle, clipped to the canvas.
Definition gfx.c:33