|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Concrete ereader chrome widgets composited on the live GLCDC panel (#145 Phase 2). 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"#include "ra8_widget_book.h"#include "ra8_widget_nav_bar.h"#include "ra8_widget_progress_bar.h"#include "ra8_widget_status_bar.h"#include "ra8_widget_toolbar.h"Go to the source code of this file.
Enumerations | |
| enum | wd_geom_t : uint16_t { k_wd_fb_w = 512U , k_wd_fb_h = 512U , k_wd_status_h = 44U , k_wd_toolbar_h = 40U , k_wd_prog_h = 12U , k_wd_nav_h = 40U , k_wd_pad = 8U , k_wd_gap = 8U , k_wd_label_h = 18U , k_wd_bar_h = 6U , k_wd_count_w = 96U } |
| Framebuffer + band geometry (no magic numbers). More... | |
| enum | wd_color_t : uint32_t { k_wd_col_clear = 0x000008U , k_wd_col_paper = 0xF4F0E8U , k_wd_col_status = 0x1E2A40U , k_wd_col_toolbar = 0x14141AU , k_wd_col_field = 0x2A2A34U , k_wd_col_rule = 0x50607AU , k_wd_col_ink = 0x101018U , k_wd_col_dim = 0x808494U , k_wd_col_white = 0xFFFFFFU , k_wd_col_cover_a = 0x806040U , k_wd_col_cover_b = 0x404060U , k_wd_col_cover_c = 0x406050U , k_wd_col_cover_d = 0x604048U , k_wd_col_track = 0x303038U , k_wd_col_fill = 0xE0A020U , k_wd_col_nav = 0x14141AU } |
| 0xRRGGBB palette (ra8_gfx packs to RGB565). More... | |
| enum | wd_child_idx_t : uint16_t { k_wd_w_status = 0U , k_wd_w_toolbar = 1U , k_wd_w_grid = 2U , k_wd_w_prog = 3U , k_wd_w_nav = 4U , k_wd_root_n = 5U , k_wd_root_cap = 6U } |
| Index of each chrome band within the root panel array. More... | |
| enum | wd_data_t : uint32_t { k_wd_book_count = 4U , k_wd_grid_cols = 2U , k_wd_prog_value = 3U , k_wd_prog_total = 10U , k_wd_uart_baud = 115200U , k_wd_frame_ms = 500U , k_wd_fnv_offset = 2166136261U , k_wd_fnv_prime = 16777619U , k_wd_hex_nibbles = 8U , k_wd_nibble_bits = 4U , k_wd_nibble_mask = 0x0FU , k_wd_dec_ten = 10U , k_wd_clock_len = 6U } |
| Book count + progress + console constants. More... | |
| enum | wd_book_pct_t : uint8_t { k_wd_pct_dune = 42U , k_wd_pct_1984 = 100U , k_wd_pct_solaris = 12U , k_wd_pct_neuromancer = 70U } |
| Sample reading-progress percentages for the four demo books. More... | |
Functions | |
| static void | wd_fill (void *user, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color) |
| Paint backend: fill a rectangle through ra8_gfx. | |
| static void | wd_text (void *user, int32_t x, int32_t y, const char *str, uint32_t fg, uint32_t bg) |
| Paint backend: draw ASCII text through ra8_gfx. | |
| static void | wd_size (void *user, const char *str, int32_t *out_w, int32_t *out_h) |
| Paint backend: measure a string's pixel size through ra8_gfx. | |
| static void | wd_print (const uint8_t *msg, uint32_t len) |
| Emit a byte run on the board console. | |
| static void | wd_fail_halt (const uint8_t *msg, uint32_t len) |
| Print a fail banner and park forever in WFI. | |
| static void | wd_print_hex (uint32_t value) |
Print value as 8 uppercase hex digits. | |
| static void | wd_print_uint (uint32_t value) |
| Print a small unsigned integer in decimal. | |
| static uint32_t | wd_framebuffer_hash (void) |
| FNV-1a-32 over the composited framebuffer bytes. | |
| static void | wd_clock_fmt (void) |
| Reformat s_clock as the decimal s_clock_val (bounded, NUL-term). | |
| static void | wd_leaf_init (ra8_widget_t *w, const ra8_widget_vtable_t *vt, void *ctx, int16_t fixed, uint16_t flex) |
| Build a leaf widget bound to a vtable + context. | |
| static bool | wd_build_tree (void) |
| Assemble the chrome panel tree; return false on a bind error. | |
| static ra8_err_t | wd_compose (ra8_ui_rect_t *dmg, ra8_widget_refresh_t *hint, uint16_t *dirty) |
| Compose the chrome tree into the framebuffer; report the flush rect. | |
| static void | wd_invalidate_all (ra8_widget_refresh_t refresh) |
| Mark every chrome band dirty so the next compose repaints the tree. | |
| static bool | wd_panel_up (void) |
| Bring up the GLCDC panel and bind ra8_gfx to its framebuffer. | |
| static display_refresh_hint_t | wd_map_hint (ra8_widget_refresh_t hint) |
| Map a widget refresh hint to the display PAL refresh hint. | |
| static void | wd_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 | wd_check_full (uint32_t *out_crc, uint16_t *out_dirty) |
| Assert the full compose: all 5 chrome bands dirty, full-frame quality. | |
| static bool | wd_check_partial (uint32_t *out_crc, uint16_t *out_dirty) |
| Assert the partial compose: status-only damage, fast hint. | |
| static bool | wd_selfcheck (uint32_t *crc0, uint16_t *d0, uint32_t *crc1, uint16_t *d1) |
| Run the whole deterministic surface; return both composites' CRCs. | |
| static void | wd_setup_or_halt (void) |
| Bring up clocks/MSTP/time and the console. | |
| static void | wd_print_banner (uint16_t d0, uint32_t crc0, uint16_t d1, uint32_t crc1) |
| Emit the PASS banner once every self-check assertion holds. | |
| static void | wd_tick_live (void) |
| Advance the clock and partial-flush only the status band. | |
| void | main (void) |
| App entry: bring the panel up, self-check the chrome, run the live loop. | |
Variables | |
| static uint16_t | s_framebuffer [(uint32_t) k_wd_fb_w *(uint32_t) k_wd_fb_h] |
| GLCDC-scanned render target in SRAM, AXI-burst aligned. | |
| static display_handle_t * | s_display = nullptr |
| Live display handle once the GLCDC panel is up. | |
| static char | s_clock [k_wd_clock_len] = "0" |
| Status-bar right-side clock string (advances each partial flush). | |
| static uint32_t | s_clock_val = 0U |
| Monotonic clock counter shown in the status bar. | |
| static const ra8_widget_book_t | s_books [k_wd_book_count] |
| The four book records shown in the grid. | |
| static const char *const | s_nav_items [] = {"Library", "Store", "Settings"} |
| Nav-strip destinations. | |
| static const ra8_widget_paint_t | k_wd_paint |
| The single paint backend the chrome widgets share. | |
| static ra8_widget_status_bar_t | s_status |
| static ra8_widget_toolbar_t | s_toolbar |
| static ra8_widget_book_grid_t | s_grid |
| static ra8_widget_progress_bar_t | s_prog |
| static ra8_widget_nav_bar_t | s_nav |
| static ra8_widget_t | s_root_kids [k_wd_root_n] |
| The five chrome bands. | |
| static ra8_box_t | s_root_scratch [k_wd_root_cap] |
| Root layout scratch. | |
| static ra8_widget_panel_t | s_root_panel |
| Root column-panel descriptor tiling the five chrome bands. | |
| static ra8_widget_t | s_root |
| The root panel widget (composed each frame). | |
| static const uint8_t | k_wd_msg_boot [] = "widget-chrome-demo: boot\r\n" |
| static const uint8_t | k_wd_msg_finit [] = "widget-chrome-demo: FAIL init\r\n" |
| static const uint8_t | k_wd_msg_fpanl [] = "widget-chrome-demo: FAIL panel\r\n" |
| static const uint8_t | k_wd_msg_ftree [] = "widget-chrome-demo: FAIL tree\r\n" |
| static const uint8_t | k_wd_msg_fchk [] = "widget-chrome-demo: FAIL selfcheck\r\n" |
| static const uint8_t | k_wd_msg_pre [] = "widget-chrome-demo: dirty0=" |
| static const uint8_t | k_wd_msg_crc0 [] = " crc0=" |
| static const uint8_t | k_wd_msg_d1 [] = " dirty1=" |
| static const uint8_t | k_wd_msg_crc1 [] = " crc1=" |
| static const uint8_t | k_wd_msg_tail [] = " flush=512x44 hint=fast" |
| static const uint8_t | k_wd_msg_pass [] = " PASS\r\n" |
| static const display_cfg_t | k_wd_display_cfg |
| Display PAL config: GLCDC LCD backend bound to the SRAM framebuffer. | |
Concrete ereader chrome widgets composited on the live GLCDC panel (#145 Phase 2).
The sibling widget_compose_demo proves the ra8_widget_panel compositor primitive with generic tiles. This app is the focused demonstration of issue #145 Phase 2: the concrete ereader chrome widgets now extracted into the ra8_widget library, each a reusable leaf that paints through the injected ra8_widget_paint_t backend. It composes them into one panel tree on the GLCDC panel:
root (column panel) |- status bar (ra8_widget_status_bar_t, fixed) – title + live clock + rule |- toolbar (ra8_widget_toolbar_t, fixed) – search field + count chip |- book grid (ra8_widget_book_grid_t, flex) – 2-column cover / title / bar |- progress bar (ra8_widget_progress_bar_t,fixed) – an overall read gauge |- nav strip (ra8_widget_nav_bar_t, fixed) – Library / Store / Settings
The whole tree is composed by one ra8_widget_panel_compose call, which lays the children out, computes the minimal damage rect + refresh hint, and renders only the dirty children. The leaf renders go through a single ra8_widget_paint_t backend bound to ra8_gfx – the same DI seam the host unit tests bind to a recording mock, so the widgets run byte-for-byte the same logic on the host and on the M85.
A deterministic self-check runs before the live loop:
It then emits one banner so the app doubles as a ra8_emulator gate:
widget-chrome-demo: dirty0=5 crc0=<8hex> dirty1=1 crc1=<8hex> flush=512x44 hint=fast PASS
Any failed assertion prints FAIL ... and parks. After the banner the loop advances the clock and partial-composes the status bar live, so the panel visibly updates only its top band (the damage-tracked A2 path).
[Ring 6 / APP] {World: S}
Definition in file main.c.
| enum wd_book_pct_t : uint8_t |
| enum wd_child_idx_t : uint16_t |
Index of each chrome band within the root panel array.
| enum wd_color_t : uint32_t |
0xRRGGBB palette (ra8_gfx packs to RGB565).
| enum wd_data_t : uint32_t |
Book count + progress + console constants.
| enum wd_geom_t : uint16_t |
Framebuffer + band geometry (no magic numbers).
| void main | ( | void | ) |
App entry: bring the panel up, self-check the chrome, run the live loop.
The application entry point Reset_Handler hands control to.
Definition at line 714 of file main.c.
References k_ra8_ok, k_ra8_widget_refresh_none, k_ra8_widget_refresh_quality, k_wd_col_clear, k_wd_frame_ms, k_wd_msg_boot, k_wd_msg_fchk, k_wd_msg_fpanl, k_wd_msg_ftree, ra8_delay_ms(), ra8_gfx_clear(), ra8_isr_globals_enable(), wd_build_tree(), wd_compose(), wd_fail_halt(), wd_flush_rect(), wd_invalidate_all(), wd_panel_up(), wd_print(), wd_print_banner(), wd_selfcheck(), wd_setup_or_halt(), and wd_tick_live().
|
static |
Assemble the chrome panel tree; return false on a bind error.
Definition at line 478 of file main.c.
References k_ra8_ok, k_wd_nav_h, k_wd_prog_h, k_wd_status_h, k_wd_toolbar_h, k_wd_w_grid, k_wd_w_nav, k_wd_w_prog, k_wd_w_status, k_wd_w_toolbar, ra8_widget_book_grid_vtable(), ra8_widget_nav_bar_vtable(), ra8_widget_panel_init(), ra8_widget_progress_bar_vtable(), ra8_widget_status_bar_vtable(), ra8_widget_toolbar_vtable(), s_grid, s_nav, s_prog, s_root, s_root_kids, s_root_panel, s_status, s_toolbar, and wd_leaf_init().
Referenced by main().
|
static |
Assert the full compose: all 5 chrome bands dirty, full-frame quality.
Definition at line 588 of file main.c.
References ra8_ui_rect_t::h, k_ra8_ok, k_ra8_widget_refresh_none, k_ra8_widget_refresh_quality, k_wd_fb_h, k_wd_fb_w, k_wd_root_n, ra8_ui_rect_t::w, wd_compose(), wd_framebuffer_hash(), and wd_invalidate_all().
Referenced by wd_selfcheck().
|
static |
Assert the partial compose: status-only damage, fast hint.
Definition at line 612 of file main.c.
References ra8_ui_rect_t::h, k_ra8_ok, k_ra8_widget_refresh_fast, k_ra8_widget_refresh_none, k_wd_fb_w, k_wd_status_h, k_wd_w_status, ra8_widget_invalidate(), s_clock_val, s_root_kids, ra8_ui_rect_t::w, wd_clock_fmt(), wd_compose(), wd_framebuffer_hash(), ra8_ui_rect_t::x, and ra8_ui_rect_t::y.
Referenced by wd_selfcheck().
|
static |
Reformat s_clock as the decimal s_clock_val (bounded, NUL-term).
Definition at line 442 of file main.c.
References k_wd_clock_len, k_wd_dec_ten, s_clock, and s_clock_val.
Referenced by wd_check_partial(), and wd_tick_live().
|
static |
Compose the chrome tree into the framebuffer; report the flush rect.
Definition at line 505 of file main.c.
References k_wd_fb_h, k_wd_fb_w, ra8_widget_panel_compose(), and s_root.
Referenced by main(), wd_check_full(), wd_check_partial(), and wd_tick_live().
|
static |
Print a fail banner and park forever in WFI.
Definition at line 385 of file main.c.
References wd_print().
|
static |
Paint backend: fill a rectangle through ra8_gfx.
| [in] | user | Unused backend handle. |
| [in] | x | Left edge, pixels. |
| [in] | y | Top edge, pixels. |
| [in] | w | Width, pixels. |
| [in] | h | Height, pixels. |
| [in] | color | Fill colour, 0xRRGGBB. |
w and h are the widget rect extents. Definition at line 227 of file main.c.
References ra8_gfx_rect().
|
static |
Flush only dmg to the panel with the mapped refresh hint.
Definition at line 567 of file main.c.
References display_flush(), ra8_ui_rect_t::h, s_display, ra8_ui_rect_t::w, wd_map_hint(), ra8_ui_rect_t::x, and ra8_ui_rect_t::y.
Referenced by main(), and wd_tick_live().
|
static |
FNV-1a-32 over the composited framebuffer bytes.
Definition at line 425 of file main.c.
References k_wd_fnv_offset, k_wd_fnv_prime, and s_framebuffer.
|
static |
Mark every chrome band dirty so the next compose repaints the tree.
Definition at line 512 of file main.c.
References k_wd_root_n, ra8_widget_invalidate(), and s_root_kids.
Referenced by main(), and wd_check_full().
|
static |
Build a leaf widget bound to a vtable + context.
Definition at line 463 of file main.c.
Referenced by wd_build_tree().
|
static |
Map a widget refresh hint to the display PAL refresh hint.
Definition at line 558 of file main.c.
References k_display_refresh_fast, k_display_refresh_quality, and k_ra8_widget_refresh_fast.
Referenced by wd_flush_rect().
|
static |
Bring up the GLCDC panel and bind ra8_gfx to its framebuffer.
Definition at line 536 of file main.c.
References display_get_framebuffer(), display_init(), k_ra8_gfx_format_rgb565, k_ra8_ok, k_wd_display_cfg, k_wd_fb_h, k_wd_fb_w, display_fb_t::pixels, ra8_gfx_init(), s_display, and s_framebuffer.
|
static |
Emit a byte run on the board console.
Definition at line 379 of file main.c.
References ra8_board_uart_console_write().
|
static |
Emit the PASS banner once every self-check assertion holds.
Definition at line 676 of file main.c.
References k_wd_msg_crc0, k_wd_msg_crc1, k_wd_msg_d1, k_wd_msg_pass, k_wd_msg_pre, k_wd_msg_tail, wd_print(), wd_print_hex(), and wd_print_uint().
|
static |
Print value as 8 uppercase hex digits.
Definition at line 394 of file main.c.
References k_wd_dec_ten, k_wd_hex_nibbles, k_wd_nibble_bits, k_wd_nibble_mask, and wd_print().
|
static |
Print a small unsigned integer in decimal.
Definition at line 406 of file main.c.
References k_wd_dec_ten, and wd_print().
|
static |
Run the whole deterministic surface; return both composites' CRCs.
Definition at line 641 of file main.c.
References wd_check_full(), and wd_check_partial().
|
static |
Bring up clocks/MSTP/time and the console.
Definition at line 658 of file main.c.
References k_ra8_clock_id_cpuclk0, k_ra8_ok, k_wd_msg_finit, k_wd_uart_baud, ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_mstp_init(), ra8_time_init(), and wd_fail_halt().
|
static |
Paint backend: measure a string's pixel size through ra8_gfx.
| [in] | user | Unused backend handle. |
| [in] | str | NUL-terminated ASCII string. |
| [out] | out_w | Receives the pixel width. |
| [out] | out_h | Receives the pixel height. |
str, out_w, out_h are non-NULL. Definition at line 269 of file main.c.
References ra8_gfx_font_8x16, and ra8_gfx_text_size().
|
static |
Paint backend: draw ASCII text through ra8_gfx.
| [in] | user | Unused backend handle. |
| [in] | x | Pen X, pixels. |
| [in] | y | Pen Y, pixels. |
| [in] | str | NUL-terminated ASCII string. |
| [in] | fg | Text colour, 0xRRGGBB. |
| [in] | bg | Background colour behind the glyphs, 0xRRGGBB. |
str is NUL-terminated. x, y). Definition at line 249 of file main.c.
References ra8_gfx_font_8x16, and ra8_gfx_text_out().
|
static |
Advance the clock and partial-flush only the status band.
Definition at line 691 of file main.c.
References k_ra8_ok, k_ra8_widget_refresh_fast, k_ra8_widget_refresh_none, k_wd_w_status, ra8_widget_invalidate(), s_clock_val, s_root_kids, wd_clock_fmt(), wd_compose(), and wd_flush_rect().
Referenced by main().
|
static |
Display PAL config: GLCDC LCD backend bound to the SRAM framebuffer.
|
static |
|
static |
Definition at line 367 of file main.c.
Referenced by wd_print_banner().
|
static |
Definition at line 369 of file main.c.
Referenced by wd_print_banner().
|
static |
Definition at line 368 of file main.c.
Referenced by wd_print_banner().
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Definition at line 370 of file main.c.
Referenced by wd_print_banner().
|
static |
The single paint backend the chrome widgets share.
|
static |
The four book records shown in the grid.
|
static |
|
static |
Monotonic clock counter shown in the status bar.
Definition at line 170 of file main.c.
Referenced by wd_check_partial(), wd_clock_fmt(), and wd_tick_live().
|
static |
|
static |
Definition at line 315 of file main.c.
Referenced by wd_build_tree().
|
static |
|
static |
|
static |
Definition at line 330 of file main.c.
Referenced by wd_build_tree().
|
static |
The root panel widget (composed each frame).
Definition at line 359 of file main.c.
Referenced by wc_build_tree(), wc_compose(), wd_build_tree(), wd_compose(), wk_build_tree(), wk_compose(), and wk_route_touch().
|
static |
The five chrome bands.
Definition at line 345 of file main.c.
Referenced by wc_build_tree(), wc_check_partial(), wc_invalidate_all(), wc_tick_live(), wd_build_tree(), wd_check_partial(), wd_invalidate_all(), wd_tick_live(), wk_build_tree(), wk_invalidate_all(), and wk_on_button_press().
|
static |
Root column-panel descriptor tiling the five chrome bands.
Definition at line 349 of file main.c.
Referenced by wc_build_tree(), wd_build_tree(), and wk_build_tree().
|
static |
|
static |
Definition at line 292 of file main.c.
Referenced by wc_build_tree(), wc_check_partial(), wc_tick_live(), and wd_build_tree().
|
static |
Definition at line 302 of file main.c.
Referenced by wd_build_tree().