|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Pure page-turn + input-region decisions for the e-reader (#78). More...
#include <stdint.h>Go to the source code of this file.
Enumerations | |
| enum | er_dir_t : int8_t { k_er_dir_prev = -1 , k_er_dir_none = 0 , k_er_dir_next = 1 } |
| Page-turn direction produced by an input decision. More... | |
| enum | er_pageturn_const_t : uint32_t { k_er_pt_thirds = 3U , k_er_page_last = 0xFFFFFFFFU } |
| Constants for the page-turn decisions (no magic numbers). More... | |
Functions | |
| 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). | |
| 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 bool | er_pageturn_step (uint32_t chapter, uint32_t page, uint32_t pages, uint32_t ch_count, er_dir_t dir, uint32_t *out_chap, uint32_t *out_page, bool *out_crossed) |
| Advance/retreat the reading location by one page, crossing chapters. | |
Pure page-turn + input-region decisions for the e-reader (#78).
The reading view turns pages from two inputs – touch edge taps and the two user buttons – and crosses chapter boundaries. The DECISIONS (which way a tap or button means, how a turn advances across pages and chapters, where it clamps) are factored into the small pure functions here so they are unit- and MC/DC-testable without the GLCDC / touch / GPIO stack. main.c calls them and applies the result to its file-scope reading-location state; the host test apps/board/stand_alone/ereader/tests/src/test_ereader_pageturn.c exercises them directly.
Header-only static inline (no TU to link): both the app and the test include it and get their own copies. Pure logic – no MMIO, no heap, no globals.
[Ring 7 / App] {World: NS}
Definition in file er_pageturn.h.
| enum er_dir_t : int8_t |
Page-turn direction produced by an input decision.
| Enumerator | |
|---|---|
| k_er_dir_prev | Go to the previous page. |
| k_er_dir_none | No page turn. |
| k_er_dir_next | Go to the next page. |
Definition at line 34 of file er_pageturn.h.
| enum er_pageturn_const_t : uint32_t |
Constants for the page-turn decisions (no magic numbers).
| Enumerator | |
|---|---|
| k_er_pt_thirds | Screen split into thirds for edge taps. |
| k_er_page_last | Sentinel: "last page of this chapter". |
Definition at line 45 of file er_pageturn.h.
|
inlinestatic |
Decide a page-turn direction from the two user-button states.
SW1 = previous page, SW2 = next page. If both are pressed, previous wins (deterministic). Inputs are the logical "pressed" states (the caller maps the active-low GPIO levels to booleans).
| [in] | sw1_pressed | true if SW1 (P009) is held. |
| [in] | sw2_pressed | true if SW2 (P008) is held. |
Definition at line 98 of file er_pageturn.h.
References k_er_dir_next, k_er_dir_none, and k_er_dir_prev.
Referenced by er_poll_buttons().
|
inlinestatic |
Advance/retreat the reading location by one page, crossing chapters.
Within a chapter, moves page by one in dir. At a chapter edge it crosses: NEXT past the last page goes to page 0 of the next chapter; PREV before page 0 goes to k_er_page_last of the previous chapter (the caller's render clamps that sentinel to the real last page once the new chapter is laid out, since the page count is not known here). Clamps at the book ends (no change). A cross is reported in out_crossed so the caller can pick a clean chapter-boundary refresh.
| [in] | chapter | Current chapter index. |
| [in] | page | Current page within chapter. |
| [in] | pages | Page count of chapter (>= 1). |
| [in] | ch_count | Number of chapters in the spine (>= 1). |
| [in] | dir | er_dir_t direction. |
| [out] | out_chap | Receives the new chapter index. |
| [out] | out_page | Receives the new page (or k_er_page_last on PREV cross). |
| [out] | out_crossed | Receives true iff a chapter boundary was crossed. |
pages >= 1 and ch_count >= 1. out_chap, out_page) is the new location. Definition at line 141 of file er_pageturn.h.
References k_er_dir_next, k_er_dir_prev, and k_er_page_last.
Referenced by er_apply_pageturn().
|
inlinestatic |
Decide a page-turn direction from a touch X coordinate (edge taps).
Right third of the screen = next page, left third = previous, and the middle third is neutral (reserved for in-content links / future menus). The boundaries use integer thirds of width.
| [in] | x | Tap X in panel pixels. |
| [in] | width | Panel width in pixels (> 0). |
width == 0). width is the live framebuffer width. x is a panel-space coordinate. Definition at line 67 of file er_pageturn.h.
References k_er_dir_next, k_er_dir_none, k_er_dir_prev, and k_er_pt_thirds.
Referenced by er_handle_reading_tap().