45typedef enum : uint32_t {
84typedef enum : uint32_t {
97typedef enum : uint32_t {
115typedef enum : uint8_t {
242void sh_image_blit_gray8(
const uint8_t* src, int32_t w, int32_t h, int32_t dst_x, int32_t dst_y);
331void sh_fit(
char* dst,
size_t cap,
const char* src, int32_t max_chars);
334size_t sh_fmt_uint(
char* dst,
size_t pos, uint32_t v);
340void sh_titlebar(
const char* title,
const char* right);
446typedef enum : uint8_t {
500ra8_err_t sh_inflate(
const void* src,
size_t src_len,
void* dst,
size_t dst_cap,
size_t* out_len);
Flat, execute-in-place container for a build-time "compiled" e-book.
Paged (demand-fetched) accessor mode for book over ra8_vmem (#163).
@generated by tools/epub_compile/src/bake_library.py – do not edit by hand.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Active display-panel descriptor for the EK-RA8D2 (ER-TFT070-6).
Bounded UI interaction core: hit-testing, screen stack, paging.
Virtual-memory object sources – the page-cache storage seam (Layer 1, #147).
ra8_err_t(* ra8_vsource_read_fn)(void *ctx, uint64_t offset, uint8_t *buf, uint32_t len)
Read len bytes at offset from a paged object's backing.
void sh_book_cover_fullscreen(int32_t x, int32_t y, int32_t w, int32_t h)
Draw the open book's cover full-size, aspect-fit into the box.
int32_t sh_cells(int32_t pixels)
Cells of the 8px bitmap font that fit in pixels.
bool sh_reader_turn(int32_t dir)
Turn the reader page by dir (-1/+1) across chapters; returns changed.
bool sh_comic_tap(int32_t x, bool header)
Handle a comic-screen tap: header returns to the shelf, else page-turn.
void sh_decode_cover(uint16_t idx, const book_src_t *src)
Decode the open rabook source's 4bpp cover into thumbnail slot idx.
bool sh_paged_open(ra8_vsource_read_fn file_read, void *file_ctx, uint64_t file_len)
Open a chunked .rabook container as the demand-paged book source.
void sh_comic_render(void)
Render the current comic page full-screen (title bar + fitted image).
uint32_t sh_reader_first_content(void)
First chapter with substantial prose (skips title/imprint front matter).
void sh_reader_load_chapter(uint32_t chapter)
Load + wrap a chapter into the reader working set.
void sh_shelf_build_thumbs(void)
Copy the baked books' pre-decoded covers into sh_state_t::thumb at boot.
void sh_toc_scroll(int32_t dir)
Scroll the TOC list by dir pages (-1 up / +1 down), clamped.
bool sh_paged_open_mram(const uint8_t *blob, uint32_t blob_len)
Open a memory-mapped (baked MRAM) RBKC container as the paged source.
bool sh_sd_open_epub(const char *name, void *out_book)
Stream-open SD file name as an EPUB via epub_open_streamed_fs.
ra8_err_t sh_image_blit_cover(const book_src_t *src, uint32_t img_idx, int32_t dst_x, int32_t dst_y, int32_t box_w, int32_t box_h, int32_t *out_w, int32_t *out_h)
Decode + aspect-fit a 4bpp image straight into the framebuffer box.
bool sh_book_open(uint16_t idx)
Open shelf entry idx by its format; sets g_sh.open_fmt + chapter count, and (for SD books on first op...
ra8_err_t sh_image_decode_gray8(const book_src_t *src, uint32_t img_idx, uint8_t *out, int32_t box_w, int32_t box_h, int32_t *out_w, int32_t *out_h)
Decode a 4bpp grayscale image, aspect-fit-scale it into box, and write the result into a gray8 buffer...
void sh_border(ra8_ui_rect_t r, uint32_t colour, int32_t width)
Draw a width-thick rectangle outline in colour.
int32_t sh_shelf_hit(int32_t x, int32_t y)
Hit-test a shelf tap; returns the book index or -1.
void sh_book_chapter_label(uint32_t chapter, char *out, size_t cap)
Resolve a chapter's TOC label (or "Chapter N") into out.
void sh_comic_selfcheck(sh_comic_probe_t *cbz, sh_comic_probe_t *cbr, bool *rtl_ok)
Headless boot self-check: decode the baked CBZ + CBR page 0, verify RTL.
bool sh_comic_turn(int32_t dir)
Turn the comic page by dir in reading order, clamped to the ends.
sh_screen_t
The active screen in sh_state_t.
@ k_sh_screen_shelf
Book grid with cover thumbnails.
@ k_sh_screen_comic
Full-page image reader (CBZ / CBR).
@ k_sh_screen_reader
Reading a book.
@ k_sh_screen_cover
One book's cover / title page.
@ k_sh_screen_toc
Chapter list.
void sh_sd_scan(void)
Append every root *.RBK file on the card as an SD shelf entry.
bool sh_sd_book_open(const char *name, uint32_t *out_len)
Open SD file name and hold it as the paged book backing.
bool sh_book_decode_thumb(uint16_t idx)
Decode the open book's cover into thumbnail slot idx; returns ok.
void sh_titlebar(const char *title, const char *right)
Fill the header bar and draw title left + optional right text.
sh_loupe_const_t
Press-and-hold magnifier-loupe geometry + gesture threshold (#211).
@ k_sh_loupe_w
Lens window width in framebuffer pixels.
@ k_sh_loupe_zoom
Integer magnification of the sampled window.
@ k_sh_loupe_h
Lens window height in framebuffer pixels.
@ k_sh_loupe_border
Lens chrome (frame) thickness in pixels.
@ k_sh_loupe_hold_ms
Press-hold duration that opens the lens (ms).
size_t sh_sd_comic_read(void *ctx, uint64_t offset, void *buf, size_t len)
comic_read_fn over the held-open SD book file (seek + clamped read).
ra8_err_t sh_book_chapter_text(uint32_t chapter, char *out, size_t cap, size_t *out_len)
Extract one chapter's plain text from the open book (either backend).
ra8_err_t sh_inflate(const void *src, size_t src_len, void *dst, size_t dst_cap, size_t *out_len)
Heap-free zlib inflater matching book_inflate_fn (miniz; main.c).
void sh_comic_close(void)
Close any open comic and release its backing (idempotent).
bool sh_image_loupe_map(const book_src_t *src, uint32_t img_idx, int32_t box_x, int32_t box_y, int32_t box_w, int32_t box_h, int32_t px, int32_t py, int32_t *out_cx, int32_t *out_cy)
Map a framebuffer touch point over an aspect-fit image box to full-resolution source coordinates (lou...
sh_const_t
Panel geometry, layout, font, and reader sizing constants.
@ k_sh_title_cap
Entry title buffer bytes.
@ k_sh_text_cap
Per-chapter plain-text buffer bytes.
@ k_sh_uart_baud
Console baud.
@ k_sh_gap
Gap between shelf cards.
@ k_sh_thumb_h
Shelf cover-thumbnail box height.
@ k_sh_line_h
Reader text line height.
@ k_sh_glyph_h
Bitmap font cell height.
@ k_sh_fb_h
Panel height in pixels.
@ k_sh_poll_ms
Input poll period in ms.
@ k_sh_glyph_w
Bitmap font cell width.
@ k_sh_pad
Outer margin / content inset.
@ k_sh_thumb_bytes
gray8 bytes per cached thumbnail.
@ k_sh_name_cap
SD file-name buffer bytes (VFAT long).
@ k_sh_thumb_w
Shelf cover-thumbnail box width.
@ k_sh_bar_h
Header / title-bar height.
@ k_sh_linebuf
Per-line draw buffer bytes.
@ k_sh_toc_row_h
TOC list row height.
@ k_sh_poll_pts
Touch points polled per read.
@ k_sh_uart_chan
SCI8 J-Link OB console channel.
@ k_sh_max_lines
Max wrapped reader lines per chapter.
@ k_sh_fb_w
Panel width in pixels.
@ k_sh_dec_base
Decimal formatting base.
@ k_sh_grid_cols
Shelf grid columns.
@ k_sh_author_cap
Entry author buffer bytes.
@ k_sh_card_pad
Inner card inset.
@ k_sh_max_books
Shelf / thumbnail-cache capacity.
void sh_cover_loupe_render(void)
Draw the magnifier loupe over the cover at the current pan centre.
ra8_err_t sh_image_loupe(const book_src_t *src, uint32_t img_idx, int32_t src_cx, int32_t src_cy, int32_t dst_x, int32_t dst_y)
Draw the magnifier loupe: a k_sh_loupe_zoom-magnified 1:1 window of a full-resolution 4bpp source ima...
sh_cover_act_t
Result of a tap on the cover screen.
@ k_sh_cover_read
Open the reader at chapter 0.
@ k_sh_cover_none
Tap hit nothing actionable.
@ k_sh_cover_toc
Open the table of contents.
void sh_sd_close_epub(void *book)
Close a streamed EPUB opened by sh_sd_open_epub and its source file.
void sh_toc_render(void)
Render the open book's chapter list (TOC).
void sh_comic_toggle_rtl(void)
Flip the comic reading direction (LTR <-> RTL); page index unchanged.
bool sh_cover_loupe_map(int32_t px, int32_t py, int32_t *out_cx, int32_t *out_cy)
Map a cover-screen touch to full-res source coordinates for the loupe.
void sh_reader_render(void)
Render the current reader page.
int32_t sh_comic_edge_dir(int32_t x)
Map a comic-screen edge tap to a reading-order page delta (RTL-aware).
void sh_image_blit_gray8(const uint8_t *src, int32_t w, int32_t h, int32_t dst_x, int32_t dst_y)
Blit a gray8 bitmap to the bound framebuffer at dst_x, dst_y.
void sh_comic_append_banner(char *b, size_t *pos, const sh_comic_probe_t *cbz, const sh_comic_probe_t *cbr, bool rtl_ok)
Append " cbz=P:WxH:CRC cbr=P:WxH:CRC rtl=OK" to the boot banner buffer.
void sh_reader_prefetch_adjacent(void)
Read-ahead warm the adjacent chapters into the page cache (#207).
size_t sh_fmt_uint(char *dst, size_t pos, uint32_t v)
Append unsigned v as decimal into dst at pos; returns new pos.
bool sh_sd_mount(void)
Bring up the Pmod2 microSD over ra8_sdmmc_spi and mount its FAT volume.
void sh_sd_book_close(void)
Close the held SD book file (idempotent).
void sh_shelf_render(void)
Render the shelf grid (cover cards) into the framebuffer.
sh_state_t g_sh
The single whole-app state instance (defined in main.c).
uint16_t * sh_fb_pixels(void)
The live RGB565 framebuffer ra8_gfx scans (defined in main.c).
ra8_err_t sh_sd_book_read(void *ctx, uint64_t offset, uint8_t *buf, uint32_t len)
ra8_vsource_read_fn over the held-open SD book file (seek + read).
void sh_fit(char *dst, size_t cap, const char *src, int32_t max_chars)
Copy src into dst (cap bytes), truncating past max_chars with "..".
sh_cover_act_t sh_cover_action(int32_t x, int32_t y)
Classify a cover-screen tap into a sh_cover_act_t.
int32_t sh_toc_hit(int32_t x, int32_t y)
Hit-test a TOC tap; returns the chapter index or -1.
void sh_paged_close(void)
Unbind the paged book source and release its SD backing (idempotent).
sh_color_t
0x00RRGGBB palette shared by every screen.
@ k_sh_col_edge
Card / image border.
@ k_sh_col_barfg
Text on the bar.
@ k_sh_col_card_hi
Selected card fill.
@ k_sh_col_bg
App background (dark wood).
@ k_sh_col_rowhi
TOC selected-row fill.
@ k_sh_col_card
Card / page fill (paper).
@ k_sh_col_sub
Secondary ink (author / hints).
@ k_sh_col_sel
Selection accent (amber).
@ k_sh_col_bar
Header / title-bar fill.
void sh_cover_render(void)
Render the selected book's cover / title page.
bool sh_comic_open(uint16_t idx)
Open shelf entry idx as a comic archive (CBZ / CBR) for page reading.
Book-format classification by file extension (long-name aware, #633).
sh_book_fmt_t
Book container format behind a shelf entry / the open book.
A book data source: resident (zero-copy) or paged (demand-fetched).
Axis-aligned rectangle in framebuffer pixel coordinates.
One container's headless self-check result (page 0 decode digest).
uint32_t pages
Page count parsed from the archive.
bool ok
true if page 0 opened + decoded successfully.
int32_t w
Blitted (fitted) page width in pixels.
int32_t h
Blitted (fitted) page height in pixels.
uint32_t crc
FNV-1a-32 over the decoded scratch framebuffer.
One shelf book, sourced from MRAM (baked) or the SD card, in either the .rabook or ....
bool from_sd
true: read sd_name from SD; false: use blob.
const uint8_t * blob
Baked RBKC bytes (MRAM), or NULL when SD.
uint16_t thumb_w
Pre-baked thumbnail width.
uint16_t thumb_h
Pre-baked thumbnail height.
const uint8_t * thumb
Pre-baked gray8 cover thumbnail, or NULL.
uint32_t blob_len
Baked length, or SD file size in bytes.
char sd_name[k_sh_name_cap]
SD file name, e.g.
sh_book_fmt_t fmt
Container format (rabook / epub).
char title[k_sh_title_cap]
Display title.
char author[k_sh_author_cap]
Display author.
One wrapped reader line: a byte slice of sh_state_t::text.
uint16_t len
Length in bytes.
uint32_t off
Start offset into the chapter text buffer.
Whole-app UI + reader state (single instance g_sh).
uint16_t thumb_h[k_sh_max_books]
Drawn thumbnail height.
uint32_t line_count
Wrapped lines in the chapter.
uint16_t thumb_w[k_sh_max_books]
Drawn thumbnail width.
int32_t toc_scroll
TOC: first visible row index.
uint16_t book_count
Shelf entries in use (baked + SD).
uint32_t comic_count
Comic reader: open comic page count (0 = none).
uint32_t touch_down_ms
ra8_time_ms() timestamp at the current press start.
book_src_t book_src
Paged source over the open rabook.
size_t text_len
Bytes of valid chapter text.
bool sd_ready
true once an SD volume mounted.
uint32_t page
Reader: current page within the chapter.
bool comic_rtl
Comic reader: right-to-left (manga) reading order.
uint32_t chapter
Reader: current chapter index.
int32_t touch_down_y
Press-start Y in framebuffer pixels.
sh_entry_t entry[k_sh_max_books]
Unified baked+SD book table.
ra8_ui_rect_t card_rect[k_sh_max_books]
Cached shelf card rects.
sh_screen_t screen
Active screen.
int32_t loupe_cy
Loupe pan centre Y in full-res source pixels.
uint8_t thumb[k_sh_max_books][k_sh_thumb_bytes]
gray8 covers.
sh_line_t lines[k_sh_max_lines]
Wrapped line slices.
int32_t loupe_cx
Loupe pan centre X in full-res source pixels.
uint16_t selected
Highlighted shelf book index.
uint32_t chap_pages
Reader: pages in the current chapter.
uint32_t chapter_count
Open book chapter count.
bool loupe_active
Press-hold magnifier loupe currently open (#211).
uint32_t comic_page
Comic reader: current page index (0-based).
sh_book_fmt_t open_fmt
Format of the currently open book.
int32_t touch_down_x
Press-start X in framebuffer pixels.
char text[k_sh_text_cap]
Current chapter plain text.