50static const char*
const s_tag =
"ra8_display_pal_eink";
73typedef enum : uint32_t {
93typedef enum : uint16_t {
128 const uint32_t r8 = (r5 << 3U) | (r5 >> 2U);
129 const uint32_t g8 = (g6 << 2U) | (g6 >> 4U);
130 const uint32_t b8 = (b5 << 3U) | (b5 >> 2U);
134 return (uint8_t)luma;
212 const uint32_t need_bytes =
247 s_eink_ctx.caps.supports_partial_update =
true;
288 if ((uint32_t)r.
x + (uint32_t)r.
w > (uint32_t)caps->
width_px) {
291 if ((uint32_t)r.
y + (uint32_t)r.
h > (uint32_t)caps->
height_px) {
328 for (uint32_t col = 0U; col < (uint32_t)width; col += px_per_byte) {
333 const uint32_t next = col + 1U;
334 const uint8_t lo_px = (next < (uint32_t)width)
375 const uint16_t* fb = (
const uint16_t*)c->
fb.
pixels;
376 const uint32_t width = (uint32_t)c->
fb.
width_px;
377 for (uint16_t row = 0U; row < rect.
h; ++row) {
378 const uint16_t* src = &fb[(((uint32_t)rect.
y + row) * width) + rect.
x];
381 .y = (uint16_t)(rect.
y + row),
596 uint16_t* pixels = (uint16_t*)c->
fb.
pixels;
598 const uint16_t rgb565 = (uint16_t)(color & (uint32_t)UINT16_MAX);
599 for (uint32_t i = 0U; i < pixels_total; ++i) {
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Display Platform Abstraction Layer for the RA8D2.
@ k_display_pixfmt_rgb565
16 bpp, 5/6/5 packed.
struct display_backend_iface display_backend_iface_t
display_refresh_hint_t
Intent passed into display_flush; backends map this onto whatever waveform/mode their controller offe...
@ k_display_refresh_fast
Prioritise latency.
@ k_display_refresh_init
Full reset of the panel.
static ra8_err_t internal_eink_validate_cfg(const display_cfg_t *cfg)
Validate the caller cfg against the e-ink backend's rules.
static ra8_err_t internal_eink_get_caps(const void *ctx, display_caps_t *out)
Vtable get_caps – O(1) copy from s_eink_ctx.caps.
static ra8_err_t internal_eink_deinit(void *ctx)
Vtable deinit – sleep the panel and drop state.
static ra8_err_t internal_eink_init(const display_cfg_t *cfg, void **out_ctx)
E-ink backend init – validate, bring up the IT8951, snapshot.
static ra8_err_t internal_eink_clear(void *ctx, uint32_t color)
Vtable clear – fill the RGB565 framebuffer with color.
uint8_t ra8_display_pal_eink_luma_from_rgb565(uint16_t px)
Convert one RGB565 pixel to an 8 bpp greyscale (Rec.601 luma).
static ra8_epaper_waveform_t internal_eink_waveform(display_refresh_hint_t hint)
Map a PAL refresh hint onto an IT8951 waveform mode.
static uint8_t s_eink_line[k_eink_line_max_px]
Bounded RGB565 -> 4 bpp conversion scratch (one panel row).
static void internal_eink_pack_row_4bpp(const uint16_t *src, uint16_t width)
Pack one RGB565 span into s_eink_line as 4 bpp greyscale.
static void internal_eink_snapshot(const display_cfg_t *cfg)
Snapshot the validated cfg into s_eink_ctx.
static ra8_err_t internal_eink_get_framebuffer(void *ctx, display_fb_t *out)
Vtable get_framebuffer – hand back the RGB565 FB descriptor.
static ra8_err_t internal_eink_load_rect(const eink_ctx_t *c, display_rect_t rect)
Convert + stream each row of rect into the IT8951 frame RAM.
static ra8_err_t internal_eink_flush(void *ctx, display_rect_t rect, display_refresh_hint_t hint)
Vtable flush – convert rect to 8bpp and refresh the panel.
ra8_display_pal_eink_const_t
Internal numeric constants (no magic numbers).
@ k_eink_line_max_px
Max row width (= panel max).
@ k_eink_luma_b
Rec.601 B weight (0.114*256).
@ k_eink_nibble_mask
Low-nibble mask.
@ k_eink_rgb565_bpp
Bytes per RGB565 pixel.
@ k_eink_luma_shift
Luma weight denominator shift.
@ k_eink_px_per_byte_4bpp
Pixels packed per 4bpp byte.
@ k_eink_white_nibble
4bpp white, used to pad tails.
@ k_eink_luma_r
Rec.601 R weight (0.299*256).
@ k_eink_luma_g
Rec.601 G weight (0.587*256).
@ k_eink_nibble_shift
8bpp luma -> 4bpp nibble shift.
@ k_eink_refresh_quality_us
Typical GC16 latency.
static ra8_err_t internal_eink_check_rect(const display_caps_t *caps, display_rect_t r)
Confirm a rectangle stays inside the active framebuffer.
static eink_ctx_t s_eink_ctx
Single e-ink backend context.
ra8_display_pal_eink_rgb_t
RGB565 field shifts / masks for luma extraction.
@ k_eink_g6_mask
6-bit green mask.
@ k_eink_b5_mask
5-bit blue mask.
@ k_eink_r5_shift
Red field shift in RGB565.
@ k_eink_g6_shift
Green field shift in RGB565.
@ k_eink_r5_mask
5-bit red mask.
E-ink backend (IT8951) for the display PAL.
const display_backend_iface_t k_display_backend_eink_it8951
E-ink (IT8951) backend vtable.
Internal vtable + handle types for the display PAL.
IT8951 e-paper controller SPI driver – public API.
@ k_ra8_epaper_pf_4bpp
4 bpp, 2 px per byte – preferred.
ra8_err_t ra8_epaper_display_area(const ra8_epaper_area_t *area, ra8_epaper_waveform_t waveform)
Refresh the indicated rectangle on the physical panel.
ra8_epaper_waveform_t
Symbolic IT8951 panel-refresh waveform selectors.
@ k_ra8_epaper_wf_init
INIT - flush to white, slowest.
@ k_ra8_epaper_wf_a2
A2 - black/white only, fastest.
@ k_ra8_epaper_wf_gc16
GC16 - 16-grey full quality.
ra8_err_t ra8_epaper_init(const ra8_epaper_cfg_t *cfg)
Bring up the IT8951 panel against the injected SPI bus seam.
@ k_ra8_epaper_endian_little
Host buffer is little-endian.
ra8_err_t ra8_epaper_sleep(void)
Drop the panel into deep-sleep (~15 uA per Waveshare AN).
ra8_err_t ra8_epaper_load_image(const ra8_epaper_area_t *area, const uint8_t *buf, size_t buf_len, ra8_epaper_pixel_format_t pf, ra8_epaper_endian_t endian)
Push a packed greyscale buffer into the controller's frame RAM.
ra8_err_t ra8_epaper_image_bytes(const ra8_epaper_area_t *area, ra8_epaper_pixel_format_t pf, size_t *out_bytes)
Bytes a packed source buffer needs for area at depth pf.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_not_supported
Requested feature not compiled in, not wired, or not supported by this MCU variant.
@ k_ra8_err_busy
Resource busy – blocking operation cannot proceed.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Lightweight Logging Interface for ra8-firmware.
#define ra8_log_info(tag, message)
RA8 log info.
#define ra8_log_error(tag, message)
RA8 log error.
Capabilities a backend reports after display_init.
uint16_t width_px
Display visible width.
uint16_t height_px
Display visible height.
Configuration descriptor passed into display_init.
void * framebuffer
Application framebuffer storage (caller owns).
display_pixfmt_t pixfmt
Pixel format of framebuffer.
uint16_t width_px
Visible framebuffer width in pixels.
uint32_t framebuffer_bytes
Size of the framebuffer buffer in bytes.
uint16_t height_px
Visible framebuffer height in pixels.
const void * panel_timing
Panel RGB timing for parallel-RGB backends, opaque here so the generic PAL stays HAL-agnostic.
Framebuffer descriptor returned by display_get_framebuffer.
uint16_t width_px
Framebuffer width.
uint16_t height_px
Framebuffer height.
void * pixels
Base of pixel data (RGB565 unless noted).
Rectangle in framebuffer coordinates passed into display_flush.
uint16_t h
Height in pixels.
uint16_t w
Width in pixels.
uint16_t y
Top edge in pixels.
uint16_t x
Left edge in pixels.
E-ink backend context attached to the PAL handle.
bool initialised
Initialised.
Rectangle descriptor (top-left + size) used by load + display.
Configuration descriptor for ra8_epaper_init.