46typedef enum : int32_t {
70typedef enum : uint32_t {
84 switch (
s_kb.keys[idx].kind) {
103static void er_round_rect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t c)
111 (void)
ra8_gfx_circle((x + w - r) - 1, (y + h - r) - 1, r, c,
true);
115static void er_tri_up(int32_t cx, int32_t ay, int32_t by, int32_t hw, uint32_t c)
117 const int32_t span = by - ay;
118 for (int32_t y = ay; y <= by; ++y) {
119 const int32_t half = (span > 0) ? ((hw * (y - ay)) / span) : hw;
141 const int32_t tx = (cx - w) + h;
149 (void)
ra8_gfx_line((cx + xo) - xe, cy - xe, cx + xo + xe, cy + xe, c);
150 (void)
ra8_gfx_line(cx + xo + xe, cy - xe, (cx + xo) - xe, cy + xe, c);
160 (void)
ra8_gfx_line(cx - w, cy, (cx - w) + a, cy - a, c);
161 (void)
ra8_gfx_line(cx - w, cy, (cx - w) + a, cy + a, c);
177 const int32_t lx = kx + ((kw - lw) / 2);
192 const int32_t kx = r.
x + g;
193 const int32_t ky = r.
y + g;
194 const int32_t kw = r.
w - (2 * g);
195 const int32_t kh = r.
h - (2 * g);
203 const int32_t cx = kx + (kw / 2);
204 const int32_t cy = ky + (kh / 2);
239 (int32_t)
s_fb.width_px,
240 (int32_t)
s_fb.height_px - band_y,
252 for (uint8_t i = 0U; i <
s_kb.count; i++) {
274 bands[0].visible =
true;
277 bands[1].visible =
true;
280 for (uint16_t i = 0U; i < 2U; ++i) {
299 if (out ==
nullptr) {
313 if ((soc ==
nullptr) || (charging ==
nullptr)) {
317 uint8_t crate_hi = 0U;
343 for (uint32_t i = 0U; (i < n) && (*pos < (cap - 1U)); i++) {
344 buf[*pos] = tmp[n - 1U - i];
347 if (*pos < (cap - 1U)) {
355static void er_append_str(
char* buf, uint32_t cap, uint32_t* pos,
const char* s)
358 for (uint32_t i = 0U; (i < (uint32_t)
k_er_nag_line_max) && (s[i] !=
'\0') && (*pos < (cap - 1U));
371 return (x >= bx) && (x < (bx + bw)) && (y >= (int32_t)
k_er_nag_top) &&
519#ifdef RA8_APP_SETTINGS
528#ifdef RA8_APP_SETTINGS
565 const bool touching = (got > 0U);
631 static uint32_t s_skip = 0U;
Pure page-turn + input-region decisions for the e-reader (#78).
static er_dir_t er_buttons_to_dir(bool sw1_pressed, bool sw2_pressed)
Decide a page-turn direction from the two user-button states.
static er_dir_t er_tap_to_dir(int32_t x, int32_t width)
Decide a page-turn direction from a touch X coordinate (edge taps).
E-reader UI chrome – shared contract between main.c and the per-aspect helper translation units (scre...
@ k_er_paper
Page background (g15).
@ k_er_ink
Primary text / glyphs (g0).
@ k_er_ink_muted
Secondary text / metadata (g5).
const char k_er_search_hint[]
Search placeholder.
ra8_ui_target_t s_targets[]
Tap targets for the current screen.
ra8_kbd_layout_t s_kb
On-screen keyboard grid.
ra8_kbd_text_t s_query
Live search query.
uint32_t s_chapter_idx
Reading chapter index.
uint16_t s_target_count
Tap targets currently populated.
bool s_nag_region_only
True when a tap only toggled the nag.
@ k_er_fg_reg_crate
CRATE register (sign = charge dir).
@ k_er_fg_addr
Fuel gauge 7-bit I2C address.
@ k_er_fg_sign
CRATE high-byte sign bit (discharge).
@ k_er_fg_reg_soc
SOC register (high byte = percent).
@ k_er_back_w
Reading back-region width (px).
@ k_er_max_targets
Max collected tap targets.
@ k_er_pad_ui
Side padding for bands / grid.
@ k_er_text_pad
Inset for text inside a box.
@ k_er_toolbar_h
Library toolbar band height.
@ k_er_statusbar_h
Top status-bar band height.
@ k_er_touch_channel
The board's GT911 bus.
@ k_er_touch_max_points
One contact = one tap.
display_turn_event_t s_pending_event
Pending refresh event for next flush.
void er_flush_event(display_turn_event_t event)
Flush the panel for a refresh event through the cadence policy (#78).
ra8_batt_monitor_t s_batt_mon
Low-battery nag policy state.
@ k_er_nag_margin
Banner inset from the screen sides.
@ k_er_nag_h
Banner height (px).
@ k_er_nag_top
Banner top y (clear of the status bar).
@ k_er_nag_dec_max
Scratch for a "NNN%" decimal tail.
@ k_er_nag_text_dy
Text inset from the banner top.
@ k_er_nag_line_max
Banner text buffer size (bounds copy).
@ k_er_nag_text_dx
Text inset from the banner left.
@ k_er_nag_dec_ten
Decimal base.
@ k_er_batt_every
Poll the gauge every Nth frame (~1/s).
uint32_t s_loc_back_count
Entries used in s_loc_back.
er_loc_t s_loc_back[]
Reading back-stack for link jumps.
ra8_batt_nag_t s_batt_nag
Nag currently shown over the chrome.
uint32_t s_reading_page
Reading current reflow page.
void er_render_current(void)
Render whichever screen is on top of the navigation stack.
@ k_er_act_none
Not a tap target.
@ k_er_act_open_book
Library card -> open the reading view.
@ k_er_act_settings
Bottom-nav Settings -> Settings app.
@ k_er_act_search
Toolbar Search -> open the keyboard.
@ k_er_act_key_base
Keyboard key i -> base + i.
void er_text_left(int32_t x, int32_t y, const char *str, uint32_t color)
Draw a left-anchored text run in the bundled font.
bool er_reading_link_tap(int32_t x, int32_t y)
Follow an in-content <a> tap in the Reading body (#110).
@ k_er_screen_reading
Reading view.
@ k_er_screen_keyboard
On-screen keyboard (search entry).
@ k_er_screen_library
Library / home grid.
@ k_er_screen_settings
Settings (optional app, if RA8_APP_SETTINGS).
bool er_apply_pageturn(er_dir_t dir)
Apply a page turn to the reading location (touch + button shared path).
uint8_t s_batt_soc
Last fuel-gauge SOC percent.
void er_render_nag_region(void)
Repaint only the low-battery banner rect (dirty-region update).
@ k_er_nag_low_bg
Low-battery banner fill (g5).
@ k_er_nag_text
Banner text (paper on the fill).
@ k_er_nag_crit_bg
Critical banner fill (g0 ink).
static bool s_was_touching
Debounce: true while a contact is held (fire once per press).
static bool s_was_sw1
Edge-detect: was SW1 held on the previous button poll.
static bool s_was_sw2
Edge-detect: was SW2 held on the previous button poll.
static ra8_app_nav_t s_nav
Navigation back-stack layered over s_reg.
@ k_ra8_batt_low_pct
Low-battery threshold (inclusive).
@ k_ra8_batt_rearm_margin
Hysteresis above a band to re-arm it.
ra8_err_t ra8_batt_update(ra8_batt_monitor_t *mon, uint8_t soc_pct, bool charging, ra8_batt_nag_t *out_nag)
Fold one SOC reading into the monitor and report the nag to raise.
ra8_batt_nag_t
The low-battery warning a single ra8_batt_update step raises.
@ k_ra8_batt_nag_none
No new warning this step.
@ k_ra8_batt_nag_critical
SOC fell to the critical band (<=10%).
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
ra8_err_t ra8_board_sw_pin(ra8_board_sw_id_t sw, ra8_port_pin_t *out_pin)
Translate a board switch id into its underlying ra8_port_pin_t.
@ k_ra8_board_sw1
SW1, P009, IRQ13-DS (jumper E31).
@ k_ra8_board_sw2
SW2, P008, IRQ12-DS (jumper E32).
ra8_board_eth_pin_t pin
Pin.
Display Platform Abstraction Layer for the RA8D2.
@ k_display_event_chapter
Chapter-boundary turn – wants a clean refresh.
@ k_display_event_open
Book/first page opened – wants a clean INIT.
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
size_t strlen(const char *s)
Calculate string length.
Software 2D graphics primitives layered on top of a caller-ownedframebuffer (DRW / D/AVE 2D / GLCDC r...
ra8_err_t ra8_gfx_circle(int32_t cx, int32_t cy, int32_t r, uint32_t color, bool filled)
Draw a circle using midpoint algorithm.
ra8_err_t ra8_gfx_line(int32_t x0, int32_t y0, int32_t x1, int32_t y1, uint32_t color)
Draw a line from (x0,y0) to (x1,y1) with Bresenham's algorithm.
ra8_err_t ra8_gfx_clear(uint32_t color)
Fill the bound framebuffer's clip region with a single colour.
ra8_err_t ra8_gfx_text_out(int32_t x, int32_t y, const char *str, const ra8_gfx_font_t *font, uint32_t fg_color, uint32_t bg_color)
Render a NUL-terminated ASCII string.
ra8_err_t ra8_gfx_rect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color, bool filled)
Draw an axis-aligned rectangle.
Bitmap font descriptor + bundled font handles for ra8_gfx.
const ra8_gfx_font_t ra8_gfx_font_8x16
Bundled 8x16 IBM PC VGA bitmap font, ASCII 0x20..0x7E.
I3C Bus Interface driver – unified native-I3C + I2C-compat modes.
ra8_err_t ra8_i3c_read(uint8_t channel, uint8_t addr, uint8_t *buf, uint32_t len, bool restart)
Read len bytes from addr.
ra8_err_t ra8_i3c_write(uint8_t channel, uint8_t addr, const uint8_t *data, uint32_t len, bool restart)
Write len bytes to addr.
On-screen keyboard widget – iOS-style layers, shift, hit-test.
ra8_err_t ra8_kbd_text_init(ra8_kbd_text_t *t)
Reset a text buffer to empty / uncommitted.
ra8_err_t ra8_kbd_apply(ra8_kbd_text_t *t, ra8_kbd_layout_t *kb, uint8_t key_idx)
Apply key key_idx to the text buffer, SHIFT, and active layer.
ra8_kbd_key_kind_t
What a key does when tapped.
@ k_ra8_kbd_key_space
Append a space.
@ k_ra8_kbd_key_layer
Switch to the layer in aux.
@ k_ra8_kbd_key_enter
Commit the query (RETURN).
@ k_ra8_kbd_key_char
Append the shift-correct char.
@ k_ra8_kbd_key_shift
Toggle the one-shot SHIFT.
@ k_ra8_kbd_key_backspace
Delete the last char.
ra8_err_t ra8_kbd_layout_init(ra8_kbd_layout_t *kb, const ra8_ui_rect_t *frame)
Lay the letters layer into frame; clear SHIFT.
char ra8_kbd_key_glyph(const ra8_kbd_layout_t *kb, uint8_t key_idx)
Effective character a char key emits given the live SHIFT state.
@ k_ra8_kbd_layer_symbols
Brackets / math symbols (#+=).
@ k_ra8_kbd_layer_numbers
Digits + common symbols (123).
Typed Port / Pin Constants for the RA8D2 IOPORT Module.
ra8_port_pin_t
Packed (port << 8) | pin pin identifier.
@ k_ra8_pin_none
Sentinel: no pin selected.
ra8_level_t
Digital output / input level.
@ k_ra8_level_high
Drive or read 1.
@ k_ra8_level_low
Drive or read 0.
High-level GPIO helpers on top of the PORT + PFS register layer.
ra8_err_t ra8_gpio_read(ra8_port_pin_t pin, ra8_level_t *out_level)
Read a previously-configured input.
Multi-touch input driver – GoodIX GT911 backend.
ra8_err_t ra8_touch_read(ra8_touch_point_t *out_points, uint8_t max_count, uint8_t *got_count)
Drain the current touch frame.
Bounded UI interaction core: hit-testing, screen stack, paging.
ra8_err_t ra8_ui_nav_push(ra8_ui_nav_t *nav, uint16_t screen)
Push a new screen onto the stack.
ra8_err_t ra8_ui_nav_pop(ra8_ui_nav_t *nav, uint16_t *out_screen)
Pop the top screen, revealing the one beneath.
bool ra8_ui_rect_contains(const ra8_ui_rect_t *r, int32_t px, int32_t py)
Test whether a point lies inside a rectangle.
ra8_err_t ra8_ui_nav_top(const ra8_ui_nav_t *nav, uint16_t *out_screen)
Read the current (top) screen id.
ra8_err_t ra8_ui_hit_test(const ra8_ui_target_t *targets, uint16_t count, int32_t px, int32_t py, uint16_t *out_action, bool *out_hit)
Find the first tap target containing a point.
One node in a box tree (caller-owned).
One decoded touch contact.
uint16_t x
Panel X coordinate.
uint16_t y
Panel Y coordinate.
Axis-aligned rectangle in framebuffer pixel coordinates.
int32_t w
Width (pixels, >= 0).
int32_t h
Height (pixels, >= 0).
int32_t x
Left edge (pixels).
int32_t y
Top edge (pixels).