ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
main.c File Reference

Interactive ra8_widget + ra8_app launcher on the live GLCDC panel. More...

#include <stddef.h>
#include <stdint.h>
#include "ra8_app.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_port_constants.h"
#include "ra8_port_utils.h"
#include "ra8_time.h"
#include "ra8_ui.h"
#include "ra8_widget.h"
Include dependency graph for main.c:

Go to the source code of this file.

Data Structures

struct  wa_content_t
 Per-app content widget state: a title over a list of text lines. More...
struct  wa_chrome_t
 Shared chrome state: the registry the status bar + tab bar read. More...
struct  wa_app_state_t
 Per-app state: its widget tree + a focus-lifecycle counter. More...

Macros

#define WA_APP_SETTINGS   (1)
 Build-time guard for the optional Settings app (#146 exclusion).

Enumerations

enum  wd_geom_t : uint16_t {
  k_wd_fb_w = 512U ,
  k_wd_fb_h = 512U ,
  k_wd_status_h = 44U ,
  k_wd_tabbar_h = 56U ,
  k_wd_pad = 8U ,
  k_wd_line_h = 18U ,
  k_wd_tab_inset = 3U
}
 Framebuffer + band geometry (no magic numbers). More...
enum  wd_color_t : uint32_t {
  k_wd_col_clear = 0x000008U ,
  k_wd_col_status_bg = 0x1E2A40U ,
  k_wd_col_tabbar_bg = 0x14141AU ,
  k_wd_col_tab_on = 0x3060C0U ,
  k_wd_col_tab_off = 0x303038U ,
  k_wd_col_text = 0xFFFFFFU ,
  k_wd_col_dim = 0xA0A0B0U ,
  k_wd_col_lib_bg = 0x102038U ,
  k_wd_col_rdr_bg = 0x382414U ,
  k_wd_col_set_bg = 0x102818U
}
 0xRRGGBB palette (ra8_gfx packs to RGB565). More...
enum  wd_app_id_t : uint16_t {
  k_wd_app_library = 1U ,
  k_wd_app_reader = 2U ,
  k_wd_app_settings = 3U
}
 Registered app ids (launch keys). More...
enum  wd_btn_t : uint16_t {
  k_wd_btn_prev = 1U ,
  k_wd_btn_next = 2U
}
 Navigation button ids carried in a button widget event. More...
enum  wd_widget_idx_t : uint16_t {
  k_wd_w_status = 0U ,
  k_wd_w_content = 1U ,
  k_wd_w_tabbar = 2U ,
  k_wd_w_count = 3U ,
  k_wd_box_cap = 4U
}
 Index of each widget within an app's tree. More...
enum  wd_console_t : uint32_t {
  k_wd_uart_baud = 115200U ,
  k_wd_frame_ms = 25U ,
  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
}
 Console baud + text-format constants. More...

Functions

static void wd_print (const uint8_t *msg, uint32_t len)
 Emit a byte run on the SCI8 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 const char * wd_active_name (const ra8_app_registry_t *reg)
 Name of the focused app, or a placeholder if none.
static void wd_status_render (ra8_widget_t *w)
 Status-bar render: fill + active app name + the button hint.
static void wd_content_render (ra8_widget_t *w)
 Content render: fill + title over the app's body lines.
static void wd_tabbar_render (ra8_widget_t *w)
 Tab-bar render: one cell per app, the active one highlighted.
static bool wd_tabbar_on_input (ra8_widget_t *w, const ra8_widget_event_t *ev)
 Tab-bar input: map a touch column to an app id (request a launch).
static int16_t wd_neighbor_id (int32_t dir)
 Resolve the app id at (active + dir), wrapped, or k_ra8_app_none.
static bool wd_app_on_input (ra8_app_t *a, const ra8_widget_event_t *ev)
 App input: SW button -> neighbour app; touch -> widget dispatch.
static void wd_app_render (const ra8_app_t *a)
 App render: clear, lay out the tree, mark all dirty, composite.
static void wd_app_enter (ra8_app_t *a)
static void wd_app_leave (ra8_app_t *a)
static void wd_state_init (wa_app_state_t *st, const char *title, const char *const *lines, uint16_t nlines, uint32_t bg)
 Build one app's widget tree: status (fixed) / content (flex) / tabs (fixed).
static bool wd_panel_up (void)
 Bring up the GLCDC panel and bind ra8_gfx to its framebuffer.
static void wd_flush_full (void)
 Push the whole composited frame to the panel (GC16-quality).
static void wd_render_active (void)
 Render the focused app and flush the whole panel.
static bool wd_sw_pressed (ra8_port_pin_t pin)
 Read a user switch (active-low); true == pressed.
static void wd_route_button (wd_btn_t btn)
 Route a navigation button through the focused app (#146).
static void wd_poll_buttons (void)
 Poll SW1/SW2 (edge-triggered) and route a fresh press as a button.
static void wd_service_request (void)
 Apply a pending app-switch request: launch + re-composite if changed.
static bool wd_register_apps (ra8_app_t *library, ra8_app_t *reader, ra8_app_t *settings)
 Initialise app state, the registry, and register every app.
static bool wd_check_touch_dispatch (void)
 Drive a synthetic touch on the Library tab while Reader is focused.
static bool wd_check_damage (void)
 Assert status-bar-only invalidation yields exactly its rect, fast.
static bool wd_selfcheck (uint32_t *out_lib, uint32_t *out_rdr)
 Run the whole deterministic surface; return the two composites' hashes.
static void wd_setup_or_halt (void)
 Bring up clocks/MSTP/time, the console, and the SW1/SW2 inputs.
static void wd_print_banner (uint32_t lib_crc, uint32_t rdr_crc)
 Emit the PASS banner once the self-check holds.
void main (void)
 App entry: bring the panel up, self-check, then run the launcher.

Variables

static ra8_port_pin_t s_wd_sw1_pin = k_ra8_pin_none
 SW1 (previous app) port pin, sourced from the board layer at init.
static ra8_port_pin_t s_wd_sw2_pin = k_ra8_pin_none
 SW2 (next app) port pin, sourced from the board layer at init.
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 ra8_app_registry_t s_reg
 The app registry.
static ra8_app_ts_slots [k_wd_app_settings]
 Registry storage (<=3).
static wa_chrome_t s_chrome = {.reg = &s_reg}
 Shared chrome state.
static wa_app_state_t s_library
 Library app state.
static wa_app_state_t s_reader
 Reader app state.
static wa_app_state_t s_settings
 Settings app state (optional).
static volatile int16_t g_wd_request = (int16_t)k_ra8_app_none
 App id an input handler asked to focus, or k_ra8_app_none.
static display_handle_ts_display = nullptr
 Live display handle once the GLCDC panel is up.
static bool s_was_sw1
 Debounce latch: true while SW1 is held (fire once per press).
static bool s_was_sw2
 Debounce latch: true while SW2 is held.
static const char *const k_wd_lib_lines []
static const char *const k_wd_rdr_lines []
static const char *const k_wd_set_lines []
static const uint8_t k_wd_msg_boot [] = "widget-app-demo: boot\r\n"
static const uint8_t k_wd_msg_finit [] = "widget-app-demo: FAIL init\r\n"
static const uint8_t k_wd_msg_fpanl [] = "widget-app-demo: FAIL panel\r\n"
static const uint8_t k_wd_msg_freg [] = "widget-app-demo: FAIL register\r\n"
static const uint8_t k_wd_msg_fchk [] = "widget-app-demo: FAIL selfcheck\r\n"
static const uint8_t k_wd_msg_pre [] = "widget-app-demo: apps="
static const uint8_t k_wd_msg_lib [] = " lib="
static const uint8_t k_wd_msg_rdr [] = " rdr="
static const uint8_t k_wd_msg_route [] = " route=ok flush=512x44 hint=fast"
static const uint8_t k_wd_msg_pass [] = " PASS\r\n"
static const ra8_widget_vtable_t k_wd_status_vt
 Status / content widgets ignore input (NULL handler never consumes).
static const ra8_widget_vtable_t k_wd_content_vt
static const ra8_widget_vtable_t k_wd_tabbar_vt
static const ra8_app_vtable_t k_wd_app_vt
 Shared app lifecycle vtable (every app behaves the same way).
static const display_cfg_t k_wd_display_cfg
 Display PAL config: GLCDC LCD backend bound to the SRAM framebuffer.

Detailed Description

Interactive ra8_widget + ra8_app launcher on the live GLCDC panel.

The companion widget_app gate proves the ra8_widget compositor (#145) and ra8_app framework (#146) headlessly (off-screen framebuffer + CRC). This app is the visible, interactive counterpart: it brings the GLCDC panel up so the composition is shown on ra8_emulator's panel window, and drives it with the physical SW1/SW2 push-buttons.

What it shows:

  • Three apps (Library, Reader, Settings) register into one ra8_app registry. Settings is removable and wrapped in a build-time guard (#if WA_APP_SETTINGS) – the "core uninstallable" pattern (#146): building with -DWA_APP_SETTINGS=0 drops it from the registry entirely.
  • Each app is a widget tree: a status bar (fixed) over per-app content (flex) over a tab bar (fixed), laid out by ra8_widget_layout_stack and drawn by each widget's render through ra8_gfx into the GLCDC buffer.
  • Input routing (#145 + #146): SW1 = previous app, SW2 = next app. A press is delivered as a button event through ra8_app_route_input to the focused app, whose on_input selects the neighbour app and launches it. A touch is routed through ra8_widget_dispatch to the tab bar, which maps the hit column to an app. Switching fires the focus lifecycle (on_leave / on_enter) and re-composites – visibly, on the panel.

Before the interactive loop a deterministic self-check exercises the whole surface (register, launch + lifecycle, distinct composites, touch dispatch, button routing, status-bar-only damage) and emits one banner:

widget-app-demo: apps=<n> lib=<8hex> rdr=<8hex> route=ok flush=512x44 hint=fast PASS

so the app doubles as a ra8_emulator regression gate; any failure prints a FAIL ... banner and parks. The 512x512 RGB565 framebuffer lives in SRAM (the full 1024x600 panel needs SDRAM, a separate task) and composites top-left over the GLCDC background plane.

[Ring 6 / APP] {World: S}

Since
0.1.0

Definition in file main.c.

Macro Definition Documentation

◆ WA_APP_SETTINGS

#define WA_APP_SETTINGS   (1)

Build-time guard for the optional Settings app (#146 exclusion).

WA APP SETTINGS.

Definition at line 73 of file main.c.

Enumeration Type Documentation

◆ wd_app_id_t

enum wd_app_id_t : uint16_t

Registered app ids (launch keys).

Since
0.1.0
Enumerator
k_wd_app_library 

Library / home app.

k_wd_app_reader 

EPUB reader app.

k_wd_app_settings 

Settings app (optional).

Definition at line 114 of file main.c.

◆ wd_btn_t

enum wd_btn_t : uint16_t

Navigation button ids carried in a button widget event.

Since
0.1.0
Enumerator
k_wd_btn_prev 

SW1: focus the previous app.

k_wd_btn_next 

SW2: focus the next app.

Definition at line 125 of file main.c.

◆ wd_color_t

enum wd_color_t : uint32_t

0xRRGGBB palette (ra8_gfx packs to RGB565).

Since
0.1.0
Enumerator
k_wd_col_clear 

Whole-frame clear (near black).

k_wd_col_status_bg 

Status-bar fill (slate).

k_wd_col_tabbar_bg 

Tab-bar fill (dark).

k_wd_col_tab_on 

Active tab cell (blue).

k_wd_col_tab_off 

Idle tab cell (gray).

k_wd_col_text 

Primary text (white).

k_wd_col_dim 

Secondary text (gray).

k_wd_col_lib_bg 

Library content (deep blue).

k_wd_col_rdr_bg 

Reader content (warm brown).

k_wd_col_set_bg 

Settings content (deep green).

Definition at line 96 of file main.c.

◆ wd_console_t

enum wd_console_t : uint32_t

Console baud + text-format constants.

Since
0.1.0
Enumerator
k_wd_uart_baud 

Console baud.

k_wd_frame_ms 

Input poll period (ms).

k_wd_fnv_offset 

FNV-1a-32 offset basis.

k_wd_fnv_prime 

FNV-1a-32 prime.

k_wd_hex_nibbles 

Hex digits per 32-bit.

k_wd_nibble_bits 

Bits per hex nibble.

k_wd_nibble_mask 

Low-nibble mask.

k_wd_dec_ten 

Hex/decimal split + buf.

Definition at line 148 of file main.c.

◆ wd_geom_t

enum wd_geom_t : uint16_t

Framebuffer + band geometry (no magic numbers).

Since
0.1.0
Enumerator
k_wd_fb_w 

Framebuffer width, pixels.

k_wd_fb_h 

Framebuffer height, pixels.

k_wd_status_h 

Status-bar band height, pixels.

k_wd_tabbar_h 

Tab-bar band height, pixels.

k_wd_pad 

Inner text padding, pixels.

k_wd_line_h 

Text line pitch (16px glyph + 2).

k_wd_tab_inset 

Tab cell inset from the band, pixels.

Definition at line 81 of file main.c.

◆ wd_widget_idx_t

enum wd_widget_idx_t : uint16_t

Index of each widget within an app's tree.

Since
0.1.0
Enumerator
k_wd_w_status 

Status bar (fixed).

k_wd_w_content 

Content (flex).

k_wd_w_tabbar 

Tab bar (fixed).

k_wd_w_count 

Widgets per app.

k_wd_box_cap 

ra8_box scratch (count + 1).

Definition at line 135 of file main.c.

Function Documentation

◆ main()

void main ( void )

App entry: bring the panel up, self-check, then run the launcher.

The application entry point Reset_Handler hands control to.

Precondition
Reset_Handler copied .data and zeroed .bss.
SystemInit set VTOR / FPU / priority grouping.
Postcondition
The PASS banner is emitted and the panel shows the Library app; the loop polls SW1/SW2 to switch apps live, otherwise idling.
Since
0.1.0

Definition at line 899 of file main.c.

References g_wd_request, k_ra8_app_none, k_wd_app_library, k_wd_frame_ms, k_wd_msg_boot, k_wd_msg_fchk, k_wd_msg_fpanl, k_wd_msg_freg, ra8_app_launch(), ra8_delay_ms(), ra8_isr_globals_enable(), s_reg, wd_fail_halt(), wd_panel_up(), wd_poll_buttons(), wd_print(), wd_print_banner(), wd_register_apps(), wd_render_active(), wd_selfcheck(), wd_service_request(), and wd_setup_or_halt().

◆ wd_active_name()

const char * wd_active_name ( const ra8_app_registry_t * reg)
static

Name of the focused app, or a placeholder if none.

Definition at line 331 of file main.c.

References k_ra8_ok, and ra8_app_active().

Referenced by wd_status_render().

◆ wd_app_enter()

void wd_app_enter ( ra8_app_t * a)
static

Definition at line 531 of file main.c.

◆ wd_app_leave()

void wd_app_leave ( ra8_app_t * a)
static

Definition at line 536 of file main.c.

◆ wd_app_on_input()

bool wd_app_on_input ( ra8_app_t * a,
const ra8_widget_event_t * ev )
static

App input: SW button -> neighbour app; touch -> widget dispatch.

Definition at line 488 of file main.c.

References ra8_widget_event_t::button_id, g_wd_request, k_ra8_widget_ev_button, k_wd_btn_next, k_wd_btn_prev, k_wd_w_count, ra8_widget_event_t::kind, ra8_widget_dispatch(), wd_neighbor_id(), and wa_app_state_t::widgets.

◆ wd_app_render()

void wd_app_render ( const ra8_app_t * a)
static

◆ wd_check_damage()

bool wd_check_damage ( void )
static

Assert status-bar-only invalidation yields exactly its rect, fast.

Definition at line 796 of file main.c.

References ra8_ui_rect_t::h, k_ra8_widget_refresh_fast, k_ra8_widget_refresh_none, k_wd_status_h, k_wd_w_count, k_wd_w_status, ra8_widget_damage(), ra8_widget_invalidate(), and s_reader.

Referenced by wd_selfcheck().

◆ wd_check_touch_dispatch()

bool wd_check_touch_dispatch ( void )
static

Drive a synthetic touch on the Library tab while Reader is focused.

Definition at line 770 of file main.c.

References g_wd_request, k_ra8_app_none, k_ra8_ok, k_ra8_widget_ev_touch, k_wd_app_library, k_wd_w_tabbar, ra8_app_count(), ra8_app_route_input(), s_reader, and s_reg.

Referenced by wd_selfcheck().

◆ wd_content_render()

void wd_content_render ( ra8_widget_t * w)
static

Content render: fill + title over the app's body lines.

Definition at line 365 of file main.c.

References wa_content_t::bg, k_wd_col_dim, k_wd_col_text, k_wd_line_h, k_wd_pad, wa_content_t::lines, wa_content_t::nlines, ra8_gfx_font_8x16, ra8_gfx_rect(), ra8_gfx_text_out(), and wa_content_t::title.

◆ wd_fail_halt()

void wd_fail_halt ( const uint8_t * msg,
uint32_t len )
static

Print a fail banner and park forever in WFI.

Definition at line 274 of file main.c.

References wd_print().

Referenced by main(), and wd_setup_or_halt().

◆ wd_flush_full()

void wd_flush_full ( void )
static

Push the whole composited frame to the panel (GC16-quality).

Definition at line 624 of file main.c.

References display_flush(), display_full_rect(), k_display_refresh_quality, and s_display.

Referenced by wd_render_active().

◆ wd_framebuffer_hash()

uint32_t wd_framebuffer_hash ( void )
static

FNV-1a-32 over the composited framebuffer bytes.

Definition at line 314 of file main.c.

References k_wd_fnv_offset, k_wd_fnv_prime, and s_framebuffer.

Referenced by wd_check_full(), wd_check_partial(), and wd_selfcheck().

◆ wd_neighbor_id()

int16_t wd_neighbor_id ( int32_t dir)
static

Resolve the app id at (active + dir), wrapped, or k_ra8_app_none.

Definition at line 466 of file main.c.

References k_ra8_app_none, k_ra8_ok, ra8_app_at(), ra8_app_count(), and s_reg.

Referenced by wd_app_on_input().

◆ wd_panel_up()

bool wd_panel_up ( void )
static

Bring up the GLCDC panel and bind ra8_gfx to its framebuffer.

Definition at line 602 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.

Referenced by main().

◆ wd_poll_buttons()

void wd_poll_buttons ( void )
static

Poll SW1/SW2 (edge-triggered) and route a fresh press as a button.

Definition at line 667 of file main.c.

References k_wd_btn_next, k_wd_btn_prev, s_was_sw1, s_was_sw2, s_wd_sw1_pin, s_wd_sw2_pin, wd_route_button(), and wd_sw_pressed().

Referenced by main().

◆ wd_print()

void wd_print ( const uint8_t * msg,
uint32_t len )
static

Emit a byte run on the SCI8 console.

Definition at line 268 of file main.c.

References ra8_board_uart_console_write().

Referenced by main(), wd_fail_halt(), wd_print_banner(), wd_print_banner(), wd_print_hex(), and wd_print_uint().

◆ wd_print_banner()

void wd_print_banner ( uint32_t lib_crc,
uint32_t rdr_crc )
static

Emit the PASS banner once the self-check holds.

Definition at line 876 of file main.c.

References k_wd_msg_lib, k_wd_msg_pass, k_wd_msg_pre, k_wd_msg_rdr, k_wd_msg_route, ra8_app_count(), s_reg, wd_print(), wd_print_hex(), and wd_print_uint().

Referenced by main().

◆ wd_print_hex()

void wd_print_hex ( uint32_t value)
static

Print value as 8 uppercase hex digits.

Definition at line 283 of file main.c.

References k_wd_dec_ten, k_wd_hex_nibbles, k_wd_nibble_bits, k_wd_nibble_mask, and wd_print().

Referenced by wd_print_banner(), and wd_print_banner().

◆ wd_print_uint()

void wd_print_uint ( uint32_t value)
static

Print a small unsigned integer in decimal.

Definition at line 295 of file main.c.

References k_wd_dec_ten, and wd_print().

Referenced by wd_print_banner(), and wd_print_banner().

◆ wd_register_apps()

bool wd_register_apps ( ra8_app_t * library,
ra8_app_t * reader,
ra8_app_t * settings )
static

◆ wd_render_active()

void wd_render_active ( void )
static

Render the focused app and flush the whole panel.

Definition at line 633 of file main.c.

References ra8_app_render(), s_reg, and wd_flush_full().

Referenced by main(), and wd_service_request().

◆ wd_route_button()

void wd_route_button ( wd_btn_t btn)
static

Route a navigation button through the focused app (#146).

Definition at line 655 of file main.c.

References k_ra8_widget_ev_button, ra8_app_route_input(), and s_reg.

Referenced by wd_poll_buttons().

◆ wd_selfcheck()

bool wd_selfcheck ( uint32_t * out_lib,
uint32_t * out_rdr )
static

Run the whole deterministic surface; return the two composites' hashes.

Definition at line 813 of file main.c.

References k_ra8_ok, k_wd_app_library, k_wd_app_reader, ra8_app_launch(), ra8_app_render(), s_library, s_reader, s_reg, wd_check_damage(), wd_check_touch_dispatch(), and wd_framebuffer_hash().

Referenced by main().

◆ wd_service_request()

void wd_service_request ( void )
static

Apply a pending app-switch request: launch + re-composite if changed.

Definition at line 694 of file main.c.

References g_wd_request, k_ra8_app_none, k_ra8_ok, ra8_app_active(), ra8_app_launch(), s_reg, and wd_render_active().

Referenced by main().

◆ wd_setup_or_halt()

void wd_setup_or_halt ( void )
static

◆ wd_state_init()

void wd_state_init ( wa_app_state_t * st,
const char * title,
const char *const * lines,
uint16_t nlines,
uint32_t bg )
static

◆ wd_status_render()

void wd_status_render ( ra8_widget_t * w)
static

Status-bar render: fill + active app name + the button hint.

Definition at line 344 of file main.c.

References k_wd_col_dim, k_wd_col_status_bg, k_wd_col_text, k_wd_line_h, k_wd_pad, ra8_gfx_font_8x16, ra8_gfx_rect(), ra8_gfx_text_out(), wa_chrome_t::reg, and wd_active_name().

◆ wd_sw_pressed()

bool wd_sw_pressed ( ra8_port_pin_t pin)
static

Read a user switch (active-low); true == pressed.

Definition at line 645 of file main.c.

References k_ra8_level_high, k_ra8_level_low, k_ra8_ok, pin, and ra8_gpio_read().

Referenced by wd_poll_buttons().

◆ wd_tabbar_on_input()

bool wd_tabbar_on_input ( ra8_widget_t * w,
const ra8_widget_event_t * ev )
static

Tab-bar input: map a touch column to an app id (request a launch).

Definition at line 417 of file main.c.

References g_wd_request, k_ra8_ok, k_ra8_widget_ev_touch, ra8_widget_event_t::kind, ra8_app_at(), ra8_app_count(), wa_chrome_t::reg, and ra8_widget_event_t::x.

◆ wd_tabbar_render()

void wd_tabbar_render ( ra8_widget_t * w)
static

Variable Documentation

◆ g_wd_request

volatile int16_t g_wd_request = (int16_t)k_ra8_app_none
static

App id an input handler asked to focus, or k_ra8_app_none.

Note
Set by a widget/app on_input; consumed by the main loop.
Warning
Written from input handlers only.
Since
0.1.0

Definition at line 220 of file main.c.

Referenced by main(), wd_app_on_input(), wd_check_touch_dispatch(), wd_service_request(), and wd_tabbar_on_input().

◆ k_wd_app_vt

const ra8_app_vtable_t k_wd_app_vt
static
Initial value:
= {
.init = nullptr,
.on_enter = wd_app_enter,
.tick = nullptr,
.render = wd_app_render,
.on_input = wd_app_on_input,
.on_leave = wd_app_leave,
.deinit = nullptr,
}
static void wd_app_enter(ra8_app_t *a)
Definition main.c:531
static void wd_app_render(const ra8_app_t *a)
App render: clear, lay out the tree, mark all dirty, composite.
Definition main.c:511
static bool wd_app_on_input(ra8_app_t *a, const ra8_widget_event_t *ev)
App input: SW button -> neighbour app; touch -> widget dispatch.
Definition main.c:488
static void wd_app_leave(ra8_app_t *a)
Definition main.c:536

Shared app lifecycle vtable (every app behaves the same way).

Definition at line 542 of file main.c.

Referenced by wd_register_apps().

◆ k_wd_content_vt

const ra8_widget_vtable_t k_wd_content_vt
static
Initial value:
= {.measure = nullptr,
.render = wd_content_render,
.on_input = nullptr}
static void wd_content_render(ra8_widget_t *w)
Content render: fill + title over the app's body lines.
Definition main.c:365

Definition at line 453 of file main.c.

Referenced by wd_state_init().

◆ k_wd_display_cfg

const display_cfg_t k_wd_display_cfg
static
Initial value:
= {
.framebuffer = s_framebuffer,
.framebuffer_bytes = sizeof(s_framebuffer),
.width_px = (uint16_t)k_wd_fb_w,
.height_px = (uint16_t)k_wd_fb_h,
.panel_timing = &s_ra8_panel_ek_ra8d2_timing,
}
static uint16_t s_framebuffer[(size_t) k_panel_height_px *(size_t) k_panel_width_px]
1024x600 RGB565 framebuffer in external SDRAM (GLCDC scans this).
Definition main.c:67
@ k_wd_fb_h
Framebuffer height, pixels.
Definition main.c:83
@ k_wd_fb_w
Framebuffer width, pixels.
Definition main.c:82
@ k_display_pixfmt_rgb565
16 bpp, 5/6/5 packed.
const display_backend_iface_t k_display_backend_lcd_ra8_glcdc
LCD backend vtable – pass its address through display_cfg_t.iface to drive the EK-RA8D2 panel.
static const ra8_glcdc_timing_t s_ra8_panel_ek_ra8d2_timing
EK-RA8D2 ER-TFT070-6 RGB timing for ra8_glcdc_init / the LCD backend.

Display PAL config: GLCDC LCD backend bound to the SRAM framebuffer.

Definition at line 591 of file main.c.

Referenced by wd_panel_up().

◆ k_wd_lib_lines

const char* const k_wd_lib_lines[]
static
Initial value:
= {
"The Time Machine H. G. Wells",
"Frankenstein M. Shelley",
"Pride and Prejudice J. Austen",
"Open with SW2; browse with SW1/SW2.",
}

Definition at line 229 of file main.c.

Referenced by wd_register_apps().

◆ k_wd_msg_boot

const uint8_t k_wd_msg_boot[] = "widget-app-demo: boot\r\n"
static

Definition at line 251 of file main.c.

Referenced by main().

◆ k_wd_msg_fchk

const uint8_t k_wd_msg_fchk[] = "widget-app-demo: FAIL selfcheck\r\n"
static

Definition at line 255 of file main.c.

Referenced by main().

◆ k_wd_msg_finit

const uint8_t k_wd_msg_finit[] = "widget-app-demo: FAIL init\r\n"
static

Definition at line 252 of file main.c.

Referenced by wd_setup_or_halt().

◆ k_wd_msg_fpanl

const uint8_t k_wd_msg_fpanl[] = "widget-app-demo: FAIL panel\r\n"
static

Definition at line 253 of file main.c.

Referenced by main().

◆ k_wd_msg_freg

const uint8_t k_wd_msg_freg[] = "widget-app-demo: FAIL register\r\n"
static

Definition at line 254 of file main.c.

Referenced by main().

◆ k_wd_msg_lib

const uint8_t k_wd_msg_lib[] = " lib="
static

Definition at line 257 of file main.c.

Referenced by wd_print_banner().

◆ k_wd_msg_pass

const uint8_t k_wd_msg_pass[] = " PASS\r\n"
static

Definition at line 260 of file main.c.

Referenced by wd_print_banner(), and wd_print_banner().

◆ k_wd_msg_pre

const uint8_t k_wd_msg_pre[] = "widget-app-demo: apps="
static

Definition at line 256 of file main.c.

Referenced by wd_print_banner(), and wd_print_banner().

◆ k_wd_msg_rdr

const uint8_t k_wd_msg_rdr[] = " rdr="
static

Definition at line 258 of file main.c.

Referenced by wd_print_banner().

◆ k_wd_msg_route

const uint8_t k_wd_msg_route[] = " route=ok flush=512x44 hint=fast"
static

Definition at line 259 of file main.c.

Referenced by wd_print_banner().

◆ k_wd_rdr_lines

const char* const k_wd_rdr_lines[]
static
Initial value:
= {
"Chapter 1",
"The Time Traveller (for so it will be",
"convenient to speak of him) was",
"expounding a recondite matter to us.",
" page 1/214",
}

Definition at line 235 of file main.c.

Referenced by wd_register_apps().

◆ k_wd_set_lines

const char* const k_wd_set_lines[]
static
Initial value:
= {
"Refresh cadence fast (A2)",
"Margins normal",
"Font 8x16 mono",
"This app is removable (WA_APP_SETTINGS).",
}

Definition at line 243 of file main.c.

Referenced by wd_register_apps().

◆ k_wd_status_vt

const ra8_widget_vtable_t k_wd_status_vt
static
Initial value:
= {.measure = nullptr,
.render = wd_status_render,
.on_input = nullptr}
static void wd_status_render(ra8_widget_t *w)
Status-bar render: fill + active app name + the button hint.
Definition main.c:344

Status / content widgets ignore input (NULL handler never consumes).

Definition at line 450 of file main.c.

Referenced by wd_state_init().

◆ k_wd_tabbar_vt

const ra8_widget_vtable_t k_wd_tabbar_vt
static
Initial value:
= {.measure = nullptr,
.render = wd_tabbar_render,
.on_input = wd_tabbar_on_input}
static bool wd_tabbar_on_input(ra8_widget_t *w, const ra8_widget_event_t *ev)
Tab-bar input: map a touch column to an app id (request a launch).
Definition main.c:417
static void wd_tabbar_render(ra8_widget_t *w)
Tab-bar render: one cell per app, the active one highlighted.
Definition main.c:380

Definition at line 456 of file main.c.

Referenced by wd_state_init().

◆ s_chrome

wa_chrome_t s_chrome = {.reg = &s_reg}
static

Shared chrome state.

Definition at line 206 of file main.c.

◆ s_display

display_handle_t* s_display = nullptr
static

Live display handle once the GLCDC panel is up.

Definition at line 222 of file main.c.

◆ s_framebuffer

uint16_t s_framebuffer[(uint32_t) k_wd_fb_w *(uint32_t) k_wd_fb_h]
static

GLCDC-scanned render target in SRAM, AXI-burst aligned.

Since
0.1.0

Definition at line 169 of file main.c.

◆ s_library

wa_app_state_t s_library
static

Library app state.

Definition at line 207 of file main.c.

◆ s_reader

wa_app_state_t s_reader
static

Reader app state.

Definition at line 208 of file main.c.

◆ s_reg

ra8_app_registry_t s_reg
static

The app registry.

Definition at line 204 of file main.c.

◆ s_settings

wa_app_state_t s_settings
static

Settings app state (optional).

Definition at line 210 of file main.c.

Referenced by wd_register_apps().

◆ s_slots

ra8_app_t* s_slots[k_wd_app_settings]
static

Registry storage (<=3).

Definition at line 205 of file main.c.

◆ s_was_sw1

bool s_was_sw1
static

Debounce latch: true while SW1 is held (fire once per press).

Definition at line 224 of file main.c.

◆ s_was_sw2

bool s_was_sw2
static

Debounce latch: true while SW2 is held.

See also
s_was_sw1

Definition at line 226 of file main.c.

◆ s_wd_sw1_pin

ra8_port_pin_t s_wd_sw1_pin = k_ra8_pin_none
static

SW1 (previous app) port pin, sourced from the board layer at init.

Definition at line 160 of file main.c.

Referenced by wd_poll_buttons(), and wd_setup_or_halt().

◆ s_wd_sw2_pin

ra8_port_pin_t s_wd_sw2_pin = k_ra8_pin_none
static

SW2 (next app) port pin, sourced from the board layer at init.

Definition at line 162 of file main.c.

Referenced by wd_poll_buttons(), and wd_setup_or_halt().