55 if ((memory ==
nullptr) || (memory->
pixels ==
nullptr)) {
58 for (uint16_t row = 0U; row < height; row++) {
59 uint16_t*
const begin =
60 &memory->
pixels[((size_t)(y + row) * (size_t)memory->
stride) + (
size_t)x];
61 for (uint16_t column = 0U; column < width; column++) {
62 begin[column] = color;
145 char buf[k_run_row_cap];
147 (void)snprintf(buf,
sizeof(buf),
"0x%08X", st->
pc);
149 (void)snprintf(buf,
sizeof(buf),
"%s chunk %u", st->
running ?
"RUNNING" :
"parked", st->
chunks);
183 char buf[k_io_row_cap];
192 snprintf(buf,
sizeof(buf),
"%u total IRQ0 x%u IRQ1 x%u", st->
irq_total, st->
irq0, st->
irq1);
195 (void)snprintf(buf,
sizeof(buf),
"%u, %u", st->
touch_x, st->
touch_y);
197 (void)snprintf(buf,
sizeof(buf),
"-");
201 const unsigned long sd_sz =
204 const char* sd_u = sd_gb ?
"GB" :
"MB";
206 (void)snprintf(buf,
sizeof(buf),
"-");
216 (void)snprintf(buf,
sizeof(buf),
"%lu %s (image)", sd_sz, sd_u);
251 if ((uint32_t)per > count) {
252 per = (int32_t)count;
254 return (uint32_t)per;
281 return (count + per_row - 1U) / per_row;
316 const uint32_t row = idx / per_row;
317 const uint32_t col = idx % per_row;
318 const int32_t pitch = panel_w / (int32_t)per_row;
319 r[0] = panel_x + ((int32_t)col * pitch);
365 for (uint32_t i = 0U; i < count; i++) {
366 int32_t rect[4] = {0, 0, 0, 0};
380 k_tab_caption_cap = 24U,
382 char cap[k_tab_caption_cap];
418 k_console_head_cap = 80U,
420 char buf[k_console_head_cap];
426 "CONSOLE PAUSED -%u/%u click=follow",
431 (void)snprintf(buf,
sizeof(buf),
"CONSOLE LIVE (UART %u B, wheel=scroll)", st->
uart_tx_total);
472 if (rows > max_rows) {
475 for (int32_t i = 0; i < rows; i++) {
498 const int32_t panel_x = x;
513 const int32_t tab_band = tab_rows * (int32_t)
k_con_tab_h;
514 const int32_t body_y = (int32_t)
k_con_y + tab_band;
515 const int32_t body_h = panel_h - tab_band;
656 (void)snprintf(buf,
sizeof(buf),
"%u%%", (
unsigned)soc);
727 if ((surface ==
nullptr) || !surface->
ok || (surface->
fill ==
nullptr) || (panel_w == 0U) ||
747 const int32_t x = (int32_t)panel_w + (int32_t)
k_pad_x;
751 (int32_t)panel_w + 3,
780 const uint16_t* panel,
785 if ((out ==
nullptr) || (panel_w == 0U)) {
802 const int32_t cx = (int32_t)x;
803 const int32_t cy = (int32_t)y;
804 const int32_t side_lo = (int32_t)panel_w;
806 const bool in_sidex = (cx >= side_lo) && (cx < side_hi);
809 const int32_t bx1 = (int32_t)panel_w + (int32_t)
k_btn_x_dx;
810 if ((cx >= bx1) && (cx < (bx1 + (int32_t)
k_btn_w))) {
814 if ((cx >= bx2) && (cx < (bx2 + (int32_t)
k_btn_w))) {
820 const int32_t sx = (int32_t)panel_w + (int32_t)
k_pwr_x_dx;
825 if ((cx >= cgx) && (cx < (cgx + (int32_t)
k_pwr_chg_w))) {
832 if ((cx >= lx) && (cx < (lx + (int32_t)
k_core_lp_w))) {
846 if (out_pct ==
nullptr) {
849 const int32_t cx = (int32_t)x;
850 const int32_t sx = (int32_t)panel_w + (int32_t)
k_pwr_x_dx;
867 if (out_idx ==
nullptr) {
870 if (tab_count == 0U) {
873 uint32_t count = tab_count;
877 const int32_t cx = (int32_t)x;
878 const int32_t cy = (int32_t)y;
879 const int32_t origin_x = (int32_t)panel_w + (int32_t)
k_pad_x;
885 for (uint32_t i = 0U; i < count; i++) {
886 int32_t rect[4] = {0, 0, 0, 0};
891 if (cx >= (rect[0] + rect[2])) {
897 if (cy >= (rect[1] + rect[3])) {
static void internal_draw_console(board_overlay_surface_t *surface, int32_t x, const board_status_t *st)
Perform draw console for the board overlay model.
static void internal_draw_button(board_overlay_surface_t *surface, int32_t x, const char *label, bool pressed)
Draw one labelled push-button face at x (green when pressed).
static uint32_t internal_console_tabs_per_row(int32_t panel_w, uint32_t count)
Tabs drawn per row for a wrapping tab grid of count cells.
static uint32_t internal_console_tab_row_count(int32_t panel_w, uint32_t count)
Number of rows a wrapping tab grid of count cells occupies.
static int32_t internal_draw_run_stats(board_overlay_surface_t *surface, int32_t x, int32_t y, const board_status_t *st)
Paint the run-stats block (PC / chunks / MMIO / state); next free y.
bool board_overlay_draw_sidebar(board_overlay_surface_t *surface, uint16_t panel_w, const board_status_t *st)
Paint the sidebar background, divider, title and all status sections.
board_overlay_btn_t board_overlay_hit_button(uint16_t x, uint16_t y, uint16_t panel_w)
Classify a composite-space click against the sidebar's on-screen buttons.
static uint16_t internal_battery_fill_color(uint8_t soc, bool charging)
Pick the battery gauge fill colour: green charging, else red/amber/green by level.
static void internal_console_tab_rect(int32_t panel_x, int32_t panel_w, uint32_t idx, uint32_t count, int32_t *r)
Compute one console tab's cell rectangle in the wrapping grid.
static void internal_draw_led(board_overlay_surface_t *surface, int32_t x, int32_t y, const board_led_status_t *led)
Draw one LED indicator dot (filled when on) plus its caption.
bool board_overlay_hit_console_tab(uint16_t x, uint16_t y, uint16_t panel_w, uint32_t tab_count, uint32_t *out_idx)
Map a composite-space click on the console tab bar to a tab index.
static void internal_draw_buttons(board_overlay_surface_t *surface, int32_t x, const board_status_t *st)
Paint the "BUTTONS" heading and the clickable SW1 / SW2 buttons.
static void internal_draw_console_tabs(board_overlay_surface_t *surface, int32_t panel_x, int32_t panel_w, const board_status_t *st)
Draw the wrapping console tab bar at the top of the console panel.
void board_overlay_compose(uint16_t *out, const uint16_t *panel, uint16_t panel_w, uint16_t panel_h, const board_status_t *st)
Render the full composite (panel region + status sidebar) into out.
static void internal_draw_console_heading(board_overlay_surface_t *surface, int32_t x, const board_status_t *st)
Draw the console heading line and its rule.
static bool internal_memory_fill(void *context, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color)
Fill one already-clipped rectangle in a contiguous RGB565 surface.
static int32_t internal_draw_leds(board_overlay_surface_t *surface, int32_t x, int32_t y, const board_status_t *st)
Paint the three LED indicators in a row; returns the next free y.
static uint8_t internal_battery_clamp(uint8_t soc)
Clamp a SOC value to 0..100 for display.
static void internal_draw_core(board_overlay_surface_t *surface, int32_t x, const board_status_t *st)
Paint the primary-core / low-power toggle on the right of the BUTTONS row.
static void internal_draw_console_body(board_overlay_surface_t *surface, int32_t panel_x, int32_t body_y, int32_t body_h, const board_status_t *st)
Draw the scrolling console body below the tab bar.
static void internal_draw_power(board_overlay_surface_t *surface, int32_t x, const board_status_t *st)
Paint the POWER section: a drag-to-set battery slider and a CHG toggle.
static int32_t internal_draw_io_block(board_overlay_surface_t *surface, int32_t x, int32_t y, const board_status_t *st)
Paint the I/O block (USB / IRQ / touch / SD); returns next free y.
bool board_overlay_battery_pct_at(uint16_t x, uint16_t panel_w, uint8_t *out_pct)
Map a click column on the battery slider track to a 0..100 SOC percent.
Composite board-view renderer: panel framebuffer + a status sidebar.
uint16_t board_overlay_total_width(uint16_t panel_w)
Total composite width for a panel of width panel_w.
board_overlay_btn_t
On-screen sidebar control a click landed on.
@ k_board_overlay_btn_sw2
On-screen SW2 (P008) push-button.
@ k_board_overlay_btn_console
Console panel: toggle autoscroll.
@ k_board_overlay_btn_battery
Battery slider track: set SOC.
@ k_board_overlay_btn_batt_chg
Battery CHG button: toggle charge.
@ k_board_overlay_btn_none
Click did not land on a control.
@ k_board_overlay_btn_lowpower
CORE low-power toggle button.
@ k_board_overlay_btn_sw1
On-screen SW1 (P009) push-button.
@ k_overlay_console_tabs_max
Tab-bar capacity (channels = tabs).
uint16_t board_overlay_total_height(uint16_t panel_h)
Total composite height for a panel of height panel_h.
@ k_overlay_led_count
LED1 / LED2 / LED3 (mirrors the BSP).
Module-private layout constants + draw primitives for the overlay.
int32_t priv_draw_text(board_overlay_surface_t *surface, int32_t x, int32_t y, const char *s, uint16_t color, int32_t sc)
Draw a NUL-terminated string; returns the x after the last glyph.
@ k_btn_head_y
"BUTTONS" heading row.
@ k_btn_gap
Horizontal gap between SW1 and SW2.
@ k_btn_y
Button face top.
@ k_btn_w
Button face width.
@ k_btn_label_y
Caption top inset within the button face.
@ k_btn_x_dx
Button column inset from the sidebar origin.
@ k_btn_label_x
Caption inset within the button face.
@ k_btn_h
Button face height.
@ k_sd_unit_div
Bytes per KiB step (KiB->MiB->GiB ladder).
@ k_con_tab_h
Tab-bar row height (one row of the grid).
@ k_con_pad
Inner padding inside the console panel.
@ k_con_line_h
Vertical step between console text lines.
@ k_con_head_y
"CONSOLE" heading row.
@ k_con_tab_cap_y
Caption y-offset within a tab row.
@ k_con_tab_gap
Gap between adjacent tab cells.
@ k_con_y
Console panel top.
@ k_con_tab_txt
Caption inset within a tab cell.
@ k_con_tab_min_w
Minimum tab-cell pitch; sets tabs-per-row.
@ k_con_bottom
Bottom margin below the console panel.
@ k_title_bar_h
Title-bar band height (board name at 2x).
@ k_section_gap
Gap above a section heading.
@ k_rule_dy
Heading baseline to its underline rule.
@ k_led_col_dx
Horizontal spacing between LEDs.
@ k_led_row_h
LED row height (advance to next block).
@ k_title_gap
Title line to the app-name line.
@ k_sidebar_top
Sidebar top margin.
@ k_led_label_dy
LED label vertical offset within its dot.
@ k_pad_x
Left padding inside the sidebar.
@ k_ovl_tab_empty_txt
Inactive empty tab.
@ k_ovl_rule
Thin horizontal section rule.
@ k_ovl_tab_off_bg
Inactive tab background.
@ k_ovl_btn_up
Button face, released.
@ k_ovl_btn_border
On-screen button outline.
@ k_ovl_ok
Green "running / ok" indicator.
@ k_ovl_amber
Amber attention indicator.
@ k_ovl_console_txt
Console text (terminal green).
@ k_ovl_console_bg
Near-black console background.
@ k_ovl_text
Light-grey body text.
@ k_ovl_divider
Panel/sidebar divider.
@ k_ovl_heading
White heading text.
@ k_ovl_tab_off_txt
Inactive tab with traffic.
@ k_ovl_bg
Dark slate sidebar background.
@ k_ovl_btn_label
Button caption text.
@ k_ovl_accent
Cyan title accent.
@ k_ovl_console_new
Newest line (white).
@ k_ovl_bg_alt
Lighter section band.
@ k_ovl_led_off
Unlit LED dot.
@ k_ovl_tab_on_bg
Active tab background.
@ k_ovl_led_ring
LED dot outline.
@ k_ovl_btn_down
Button face, pressed (green).
@ k_ovl_sidebar_w
Sidebar width.
@ k_ovl_red
Low-SOC red gauge.
@ k_ovl_tab_on_txt
Active tab caption.
@ k_ovl_dim
Dim label text (field names).
@ k_io_head_y
"I/O" section heading row (clear of the LEDs).
@ k_pwr_head_y
"POWER" heading row.
@ k_pwr_soc_full
SOC clamp / percent denominator.
@ k_pwr_x_dx
POWER column inset from the sidebar origin.
@ k_pwr_chg_w
CHG toggle face width.
@ k_core_lp_off
Low-power toggle x offset (right of SW1/SW2).
@ k_pwr_h
Slider track height.
@ k_pwr_track_w
Slider track width (the full drag range).
@ k_pwr_soc_low
SOC at or below this draws the gauge red.
@ k_pwr_soc_mid
SOC at or below this draws the gauge amber.
@ k_pwr_chg_off
CHG toggle x offset from the track origin.
@ k_core_lp_w
Low-power toggle face width.
@ k_pwr_y
Battery slider track top.
@ k_pwr_label_y
Caption top inset within a POWER face.
void priv_blit_panel(uint16_t *out, uint16_t w, uint16_t h, const uint16_t *panel, uint16_t panel_w, uint16_t panel_h)
Blit the rendered panel into the composite's panel region.
int32_t priv_section_head(board_overlay_surface_t *surface, int32_t x, int32_t y, const char *title)
Draw a section heading (accent colour) with a thin rule beneath it.
void priv_fill_rect(board_overlay_surface_t *surface, int32_t x, int32_t y, int32_t rw, int32_t rh, uint16_t color)
Fill a clipped rectangle in the composite (draw primitive).
int32_t priv_kv_row(board_overlay_surface_t *surface, int32_t x, int32_t y, const char *label, const char *value, uint16_t val_color)
Draw a "label value" row: dim label, coloured value; returns next y.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
One board LED's live state for the status sidebar.
const char * label
Short ASCII caption (e.g.
uint16_t color
RGB565 lit colour (blue / green / red).
bool on
True when the GPIO pin is driven high.
Non-owning drawing surface used by memory and raw-fd compositors.
board_overlay_fill_fn fill
Clipped solid-rectangle writer.
bool ok
Sticky false after a sink write fault.
uint16_t width
Complete composite width in pixels.
uint16_t height
Complete composite height in pixels.
Live peripheral snapshot the status sidebar renders each frame.
uint16_t touch_y
Last touch Y (if any).
char console[k_overlay_console_rows][k_overlay_line_cap]
Visible lines (active tab).
const char * app_name
App / window title.
uint32_t console_ch_count
Tabs to draw (<= max).
bool battery_charging
Fuel gauge reports charge.
uint32_t irq1
IRQ1 taken count.
uint32_t mmio_writes
Modelled-peripheral MMIO writes served.
uint16_t touch_x
Last touch X (if any).
uint8_t battery_soc
Fuel-gauge SOC percent.
bool core_is_m33
Primary core is the M33.
uint32_t console_active_ch
Active tab index.
bool console_autoscroll
True = following live tail; false=paused.
board_led_status_t leds[k_overlay_led_count]
Per-LED indicator state.
uint32_t console_total
Total lines in the active channel ring.
uint32_t console_ch_count_lines[k_overlay_console_tabs_max]
Per-tab line count.
uint32_t uart_tx_total
Total UART TX bytes the firmware emitted.
uint32_t irq0
IRQ0 taken count.
uint64_t sd_bytes
SD card size in bytes (>4GB).
bool sw1_pressed
On-screen SW1 held down.
bool sd_attached
A microSD card is attached.
uint32_t console_count
Visible lines populated (<= rows).
const char * console_ch_name[k_overlay_console_tabs_max]
Per-tab caption.
const char * sd_label
SD volume label (–sd-new).
bool low_power
Low-power (M33 4:1 clock) on.
uint32_t console_scroll
Lines scrolled back from newest (0=live).
uint8_t sd_fat_bits
12/16/32 if –sd-new, else 0.
uint32_t chunks
Emulation chunks run so far.
bool running
True while the run loop is live (not parked).
uint32_t pc
Current emulated program counter.
const char * usb_state
USB device state string.
uint32_t mmio_reads
Modelled-peripheral MMIO reads served.
bool has_touch
A touch has been drained.
bool sw2_pressed
On-screen SW2 held down.
uint32_t irq_total
Total NVIC IRQs taken.
Context adapting the legacy contiguous composite to a fill surface.
uint16_t * pixels
Caller-owned row-major RGB565 pixels.
uint16_t stride
Complete composite row width.