|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Concrete ra8_widget leaf widgets composited on the GLCDC panel (#145). More...
#include <stddef.h>#include <stdint.h>#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_box.h"#include "ra8_cgc.h"#include "ra8_display_pal.h"#include "ra8_display_pal_lcd.h"#include "ra8_err.h"#include "ra8_gfx.h"#include "ra8_gfx_font.h"#include "ra8_glcdc.h"#include "ra8_isr.h"#include "ra8_mstp.h"#include "ra8_panel.h"#include "ra8_panel_timing.h"#include "ra8_time.h"#include "ra8_ui.h"#include "ra8_widget.h"Go to the source code of this file.
Enumerations | |
| enum | wk_geom_t : uint16_t { k_wk_fb_w = 512U , k_wk_fb_h = 512U , k_wk_title_h = 44U , k_wk_footer_h = 28U , k_wk_body_h = 440U , k_wk_pad = 6U , k_wk_btn_gap = 8U , k_wk_btn_border = 2U } |
| Framebuffer + band geometry (no magic numbers). More... | |
| enum | wk_color_t : uint32_t { k_wk_col_clear = 0x000010U , k_wk_col_title_bg = 0x182438U , k_wk_col_footer_bg = 0x101018U , k_wk_col_text = 0xFFFFFFU , k_wk_col_dim = 0xA8A8B8U , k_wk_col_btn_a = 0x204060U , k_wk_col_btn_a_hi = 0x3A6CB0U , k_wk_col_btn_b = 0x603020U , k_wk_col_btn_b_hi = 0xB06030U , k_wk_col_btn_brd = 0x05080CU } |
| 0xRRGGBB palette (ra8_gfx packs to RGB565). More... | |
| enum | wk_widget_idx_t : uint16_t { k_wk_w_title = 0U , k_wk_w_body = 1U , k_wk_w_footer = 2U , k_wk_root_n = 3U , k_wk_root_cap = 4U , k_wk_w_btn_a = 0U , k_wk_w_btn_b = 1U , k_wk_body_n = 2U , k_wk_body_cap = 3U , k_wk_act_a = 10U , k_wk_act_b = 11U } |
| Index + action id of each widget within its parent array. More... | |
| enum | wk_touch_t : int32_t { k_wk_touch_ax = 120 , k_wk_touch_bx = 392 , k_wk_touch_y = 264 } |
| Synthetic touch points used by the self-check + live loop. More... | |
| enum | wk_console_t : uint32_t { k_wk_uart_baud = 115200U , k_wk_frame_ms = 500U , k_wk_fnv_offset = 2166136261U , k_wk_fnv_prime = 16777619U , k_wk_hex_nibbles = 8U , k_wk_nibble_bits = 4U , k_wk_nibble_mask = 0x0FU , k_wk_dec_ten = 10U } |
| Console baud + text-format constants. More... | |
Functions | |
| static void | wk_paint_fill (void *user, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color) |
| Paint backend fill: a solid ra8_gfx rectangle. | |
| static void | wk_paint_text (void *user, int32_t x, int32_t y, const char *str, uint32_t fg, uint32_t bg) |
| Paint backend text: an 8x16 ra8_gfx string. | |
| static void | wk_paint_size (void *user, const char *str, int32_t *out_w, int32_t *out_h) |
| Paint backend measure: 8x16 ra8_gfx string size (for centring). | |
| static void | wk_on_button_press (ra8_widget_t *w) |
| Mark the body band dirty so a button press flushes only that rect. | |
| static void | wk_print (const uint8_t *msg, uint32_t len) |
| Emit a byte run on the board console. | |
| static void | wk_fail_halt (const uint8_t *msg, uint32_t len) |
| Print a fail banner and park forever in WFI. | |
| static void | wk_print_hex (uint32_t value) |
Print value as 8 uppercase hex digits. | |
| static uint32_t | wk_framebuffer_hash (void) |
| FNV-1a-32 over the composited framebuffer bytes. | |
| static bool | wk_build_tree (void) |
| Assemble the nested widget tree; return false on a bind error. | |
| static void | wk_invalidate_all (ra8_widget_refresh_t refresh) |
| Mark every root child dirty so the next compose repaints the tree. | |
| static ra8_err_t | wk_compose (ra8_ui_rect_t *dmg, ra8_widget_refresh_t *hint, uint16_t *dirty) |
| Compose the tree into the framebuffer; report the flush rect. | |
| static bool | wk_route_touch (int32_t x, int32_t y) |
| Route a synthetic touch through the root panel to a leaf widget. | |
| static bool | wk_panel_up (void) |
| Bring up the GLCDC panel and bind ra8_gfx to its framebuffer. | |
| static display_refresh_hint_t | wk_map_hint (ra8_widget_refresh_t hint) |
| Map a widget refresh hint to the display PAL refresh hint. | |
| static void | wk_flush_rect (const ra8_ui_rect_t *dmg, ra8_widget_refresh_t hint) |
Flush only dmg to the panel with the mapped refresh hint. | |
| static bool | wk_check_full (uint32_t *out_crc) |
| Assert the full compose: clear, 3 dirty, full-frame quality. | |
| static bool | wk_check_press (void) |
| Assert button A latches a routed touch + invalidates the body. | |
| static bool | wk_check_partial (uint32_t *out_crc) |
| Assert the partial compose: body-only damage, fast hint. | |
| static bool | wk_selfcheck (uint32_t *crc0, uint32_t *crc1) |
| Run the whole deterministic surface; return both composites' CRCs. | |
| static void | wk_setup_or_halt (void) |
| Bring up clocks/MSTP/time and the console. | |
| static void | wk_print_banner (uint32_t crc0, uint32_t crc1) |
| Emit the PASS banner once every self-check assertion holds. | |
| static void | wk_tick_live (void) |
| Alternate-tap a button and partial-flush only the body band. | |
| void | main (void) |
| App entry: bring the panel up, self-check, then run the live loop. | |
Variables | |
| static uint16_t | s_framebuffer [(uint32_t) k_wk_fb_w *(uint32_t) k_wk_fb_h] |
| GLCDC-scanned render target in SRAM, AXI-burst aligned. | |
| static const ra8_widget_paint_t | k_wk_paint |
| The shared paint backend every leaf widget draws through. | |
| static ra8_widget_label_t | s_title |
| Title label: a centred heading over the slate band. | |
| static ra8_widget_label_t | s_footer |
| Footer label: a left-aligned hint line. | |
| static ra8_widget_button_t | s_btn_a |
| Button A ("Prev"): blue face, latches + flushes the body on tap. | |
| static ra8_widget_button_t | s_btn_b |
| Button B ("Next"): brown face, latches + flushes the body on tap. | |
| static ra8_widget_t | s_root_kids [k_wk_root_n] |
| [title, body, footer]. | |
| static ra8_widget_t | s_body_kids [k_wk_body_n] |
| [button A, button B]. | |
| static ra8_box_t | s_body_scratch [k_wk_body_cap] |
| Body layout scratch. | |
| static ra8_box_t | s_root_scratch [k_wk_root_cap] |
| Root layout scratch. | |
| static ra8_widget_panel_t | s_body_panel |
| Body row-panel descriptor (the nested panel of buttons). | |
| static ra8_widget_panel_t | s_root_panel |
| Root column-panel descriptor. | |
| static ra8_widget_t | s_root |
| The root panel widget (composed each frame). | |
| static display_handle_t * | s_display = nullptr |
| Live display handle once the GLCDC panel is up. | |
| static uint32_t | s_tick = 0U |
| Live-loop tick used to alternate which button is tapped. | |
| static const uint8_t | k_wk_msg_boot [] = "widget-kit-demo: boot\r\n" |
| static const uint8_t | k_wk_msg_finit [] = "widget-kit-demo: FAIL init\r\n" |
| static const uint8_t | k_wk_msg_fpanl [] = "widget-kit-demo: FAIL panel\r\n" |
| static const uint8_t | k_wk_msg_ftree [] = "widget-kit-demo: FAIL tree\r\n" |
| static const uint8_t | k_wk_msg_fchk [] = "widget-kit-demo: FAIL selfcheck\r\n" |
| static const uint8_t | k_wk_msg_pre [] = "widget-kit-demo: dirty0=3 crc0=" |
| static const uint8_t | k_wk_msg_mid [] = " press=1 dirty1=1 crc1=" |
| static const uint8_t | k_wk_msg_tail [] = " flush=512x440 hint=fast PASS\r\n" |
| static const display_cfg_t | k_wk_display_cfg |
| Display PAL config: GLCDC LCD backend bound to the SRAM framebuffer. | |
Concrete ra8_widget leaf widgets composited on the GLCDC panel (#145).
widget_compose_demo proved the ra8_widget_panel compositor with anonymous tile leaves. This app is the Phase-2 demonstration of the concrete leaf widgets the panel can now composite: ra8_widget_label_t (a background fill plus aligned text) and ra8_widget_button_t (a bordered face + label that latches on a tap and reports the press through on_input). Both draw through an injected ra8_widget_paint_t backend wired to ra8_gfx, so ra8_widget itself stays graphics free.
The tree (dwm-style, each piece opt-in):
root (column panel) |- title (LABEL, fixed) – centred heading |- body (ROW PANEL) – a nested panel ... | |- button A (BUTTON, flex) – "Prev" | |- button B (BUTTON, flex) – "Next" |- footer (LABEL, fixed) – a left-aligned hint line
One ra8_widget_panel_compose call lays the children out, computes the minimal damage rect + refresh hint, and renders only the dirty children – a dirty nested panel repaints its whole subtree.
A deterministic self-check runs before the live loop:
It then emits one banner so the app doubles as a ra8_emulator gate:
widget-kit-demo: dirty0=3 crc0=<8hex> press=1 dirty1=1 crc1=<8hex> flush=512x440 hint=fast PASS
Any failed assertion prints FAIL ... and parks. After the banner the loop alternately taps button A / button B and partial-composes the body band, so the panel visibly toggles a button live (the damage-tracked A2 path).
[Ring 6 / APP] {World: S}
Definition in file main.c.
| enum wk_color_t : uint32_t |
0xRRGGBB palette (ra8_gfx packs to RGB565).
| enum wk_console_t : uint32_t |
Console baud + text-format constants.
| enum wk_geom_t : uint16_t |
Framebuffer + band geometry (no magic numbers).
| enum wk_touch_t : int32_t |
| enum wk_widget_idx_t : uint16_t |
Index + action id of each widget within its parent array.
| void main | ( | void | ) |
App entry: bring the panel up, self-check, then run the live loop.
The application entry point Reset_Handler hands control to.
Definition at line 617 of file main.c.
References k_ra8_ok, k_ra8_widget_refresh_none, k_ra8_widget_refresh_quality, k_wk_col_clear, k_wk_frame_ms, k_wk_msg_boot, k_wk_msg_fchk, k_wk_msg_fpanl, k_wk_msg_ftree, ra8_delay_ms(), ra8_gfx_clear(), ra8_isr_globals_enable(), wk_build_tree(), wk_compose(), wk_fail_halt(), wk_flush_rect(), wk_invalidate_all(), wk_panel_up(), wk_print(), wk_print_banner(), wk_selfcheck(), wk_setup_or_halt(), and wk_tick_live().
|
static |
Assemble the nested widget tree; return false on a bind error.
Definition at line 355 of file main.c.
References k_ra8_ok, k_wk_act_a, k_wk_act_b, k_wk_footer_h, k_wk_title_h, k_wk_w_body, k_wk_w_btn_a, k_wk_w_btn_b, k_wk_w_footer, k_wk_w_title, ra8_widget_button_init(), ra8_widget_label_init(), ra8_widget_panel_init(), s_body_kids, s_body_panel, s_btn_a, s_btn_b, s_footer, s_root, s_root_kids, s_root_panel, and s_title.
Referenced by main().
|
static |
Assert the full compose: clear, 3 dirty, full-frame quality.
Definition at line 482 of file main.c.
References ra8_ui_rect_t::h, k_ra8_ok, k_ra8_widget_refresh_none, k_ra8_widget_refresh_quality, k_wk_col_clear, k_wk_fb_h, k_wk_fb_w, k_wk_root_n, ra8_gfx_clear(), ra8_ui_rect_t::w, wk_compose(), wk_framebuffer_hash(), and wk_invalidate_all().
Referenced by wk_selfcheck().
|
static |
Assert the partial compose: body-only damage, fast hint.
Definition at line 521 of file main.c.
References ra8_ui_rect_t::h, k_ra8_ok, k_ra8_widget_refresh_fast, k_ra8_widget_refresh_none, k_wk_body_h, k_wk_title_h, wk_compose(), wk_framebuffer_hash(), and ra8_ui_rect_t::y.
Referenced by wk_selfcheck().
|
static |
Assert button A latches a routed touch + invalidates the body.
Definition at line 509 of file main.c.
References k_wk_touch_ax, k_wk_touch_y, s_btn_a, and wk_route_touch().
Referenced by wk_selfcheck().
|
static |
Compose the tree into the framebuffer; report the flush rect.
Definition at line 391 of file main.c.
References k_wk_fb_h, k_wk_fb_w, ra8_widget_panel_compose(), and s_root.
Referenced by main(), wk_check_full(), wk_check_partial(), and wk_tick_live().
|
static |
Print a fail banner and park forever in WFI.
Definition at line 310 of file main.c.
References wk_print().
Referenced by main(), and wk_setup_or_halt().
|
static |
Flush only dmg to the panel with the mapped refresh hint.
Definition at line 458 of file main.c.
References display_flush(), ra8_ui_rect_t::h, s_display, ra8_ui_rect_t::w, wk_map_hint(), ra8_ui_rect_t::x, and ra8_ui_rect_t::y.
Referenced by main(), and wk_tick_live().
|
static |
FNV-1a-32 over the composited framebuffer bytes.
Definition at line 331 of file main.c.
References k_wk_fnv_offset, k_wk_fnv_prime, and s_framebuffer.
Referenced by wk_check_full(), and wk_check_partial().
|
static |
Mark every root child dirty so the next compose repaints the tree.
Definition at line 383 of file main.c.
References k_wk_root_n, ra8_widget_invalidate(), and s_root_kids.
Referenced by main(), and wk_check_full().
|
static |
Map a widget refresh hint to the display PAL refresh hint.
Definition at line 449 of file main.c.
References k_display_refresh_fast, k_display_refresh_quality, and k_ra8_widget_refresh_fast.
Referenced by wk_flush_rect().
|
static |
Mark the body band dirty so a button press flushes only that rect.
Definition at line 348 of file main.c.
References k_ra8_widget_refresh_fast, k_wk_w_body, ra8_widget_invalidate(), and s_root_kids.
|
static |
Paint backend fill: a solid ra8_gfx rectangle.
Definition at line 169 of file main.c.
References ra8_gfx_rect().
|
static |
Paint backend measure: 8x16 ra8_gfx string size (for centring).
Definition at line 184 of file main.c.
References ra8_gfx_font_8x16, and ra8_gfx_text_size().
|
static |
Paint backend text: an 8x16 ra8_gfx string.
Definition at line 177 of file main.c.
References ra8_gfx_font_8x16, and ra8_gfx_text_out().
|
static |
Bring up the GLCDC panel and bind ra8_gfx to its framebuffer.
Definition at line 427 of file main.c.
References display_get_framebuffer(), display_init(), k_ra8_gfx_format_rgb565, k_ra8_ok, k_wk_display_cfg, k_wk_fb_h, k_wk_fb_w, display_fb_t::pixels, ra8_gfx_init(), s_display, and s_framebuffer.
Referenced by main().
|
static |
Emit a byte run on the board console.
Definition at line 304 of file main.c.
References ra8_board_uart_console_write().
Referenced by main(), wk_fail_halt(), wk_print_banner(), and wk_print_hex().
|
static |
Emit the PASS banner once every self-check assertion holds.
Definition at line 584 of file main.c.
References k_wk_msg_mid, k_wk_msg_pre, k_wk_msg_tail, wk_print(), and wk_print_hex().
Referenced by main().
|
static |
Print value as 8 uppercase hex digits.
Definition at line 319 of file main.c.
References k_wk_dec_ten, k_wk_hex_nibbles, k_wk_nibble_bits, k_wk_nibble_mask, and wk_print().
Referenced by wk_print_banner().
|
static |
Route a synthetic touch through the root panel to a leaf widget.
Definition at line 398 of file main.c.
References k_ra8_widget_ev_touch, and s_root.
Referenced by wk_check_press(), and wk_tick_live().
|
static |
Run the whole deterministic surface; return both composites' CRCs.
Definition at line 546 of file main.c.
References wk_check_full(), wk_check_partial(), and wk_check_press().
Referenced by main().
|
static |
Bring up clocks/MSTP/time and the console.
Definition at line 566 of file main.c.
References k_ra8_clock_id_cpuclk0, k_ra8_ok, k_wk_msg_finit, k_wk_uart_baud, ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_mstp_init(), ra8_time_init(), and wk_fail_halt().
Referenced by main().
|
static |
Alternate-tap a button and partial-flush only the body band.
Definition at line 594 of file main.c.
References k_ra8_ok, k_ra8_widget_refresh_none, k_wk_touch_ax, k_wk_touch_bx, k_wk_touch_y, s_tick, wk_compose(), wk_flush_rect(), and wk_route_touch().
Referenced by main().
|
static |
Display PAL config: GLCDC LCD backend bound to the SRAM framebuffer.
Definition at line 416 of file main.c.
Referenced by wk_panel_up().
|
static |
|
static |
|
static |
Definition at line 290 of file main.c.
Referenced by wk_setup_or_halt().
|
static |
|
static |
|
static |
Definition at line 295 of file main.c.
Referenced by wk_print_banner().
|
static |
Definition at line 294 of file main.c.
Referenced by wk_print_banner().
|
static |
Definition at line 296 of file main.c.
Referenced by wk_print_banner().
|
static |
The shared paint backend every leaf widget draws through.
|
static |
|
static |
Body row-panel descriptor (the nested panel of buttons).
|
static |
|
static |
Button A ("Prev"): blue face, latches + flushes the body on tap.
Definition at line 228 of file main.c.
Referenced by wk_build_tree(), and wk_check_press().
|
static |
Button B ("Next"): brown face, latches + flushes the body on tap.
Definition at line 243 of file main.c.
Referenced by wk_build_tree().
|
static |
|
static |
Footer label: a left-aligned hint line.
Definition at line 219 of file main.c.
Referenced by wk_build_tree().
|
static |
|
static |
|
static |
Root column-panel descriptor.
|
static |
|
static |
Live-loop tick used to alternate which button is tapped.
Definition at line 287 of file main.c.
Referenced by wk_tick_live().
|
static |
Title label: a centred heading over the slate band.
Definition at line 210 of file main.c.
Referenced by wk_build_tree().