Brings ~55 mod-exclusive files to the upstream-based mod/master-resync branch: Activities (migrated to new ActivityManager pattern): - Clock/Time: SetTimeActivity, SetTimezoneOffsetActivity, NtpSyncActivity - Dictionary: DictionaryDefinitionActivity, DictionarySuggestionsActivity, DictionaryWordSelectActivity, LookedUpWordsActivity - Bookmark: EpubReaderBookmarkSelectionActivity - Book management: BookManageMenuActivity, EndOfBookMenuActivity - OPDS: OpdsServerListActivity, OpdsSettingsActivity - Utility: DirectoryPickerActivity, NumericStepperActivity Utilities (unchanged): - BookManager, BookSettings, BookmarkStore, BootNtpSync - Dictionary, LookupHistory, TimeSync, OpdsServerStore Libraries: PlaceholderCover, TableData, ChapterXPathIndexer Scripts: inject_mod_version, generate_book_icon, preview_placeholder_cover Docs: KOReader sync XPath mapping Migration changes: - ActivityWithSubactivity -> Activity base class - Callback constructors -> finish()/setResult() pattern - enterNewActivity() -> startActivityForResult() - Activity::RenderLock&& -> RenderLock&& These files won't compile yet - they reference mod settings and I18n strings that will be added in subsequent phases. Made-with: Cursor
7.1 KiB
Session Context Dump (2026-02-09)
Everything below is a snapshot of the conversation context at the time of writing. It captures what was explored, what was read, what was produced, and what the current state of work is. Use this to resume without re-exploring.
Branch State
- Current branch:
mod/sleep-screen-tweaks - Git status:
.gitignoremodified (unstaged). No other tracked changes. Allmod/docs/files are new/untracked (themod/directory is gitignored).
What Was Done This Session
-
Explored the entire project structure using parallel agents. Mapped every directory, identified all source files, read key headers and configs.
-
Created 3 documentation files in
mod/docs/:hardware.md-- Full hardware capabilities (CPU, flash partitions, display specs with GPIO pins, buttons with indices, SD card, battery, WiFi, USB, power management, SDK libraries)file-structure.md-- Complete directory tree with descriptions of every file group (src/ activities, components, network; lib/ HAL, EPUB engine, fonts, supporting libs; scripts, tests, docs, .github CI)ci-build-and-code-style.md-- Build system (3 PlatformIO environments), all 4 CI workflows with triggers and steps, release process, clang-format rules table, cppcheck config, PR requirements, contribution guidelines
-
Created
project-summary.md-- condensed reference consolidating all three docs plus architecture patterns, caching behavior, and constraints.
Files Read During Exploration
The following files were read in full and their contents informed the documentation:
Config/root:
platformio.ini-- all build environments, flags, dependencies, SDK symlinkspartitions.csv-- flash partition table (6 rows).clang-format-- 332 lines of formatting rules.clangd-- C++2a standard setting.gitmodules-- open-x4-sdk submodule referenceREADME.md-- project overview, features checklist, install instructions, internals (caching), contributingSCOPE.md-- in-scope/out-of-scope feature boundariesGOVERNANCE.md-- community principles, moderation
HAL layer:
lib/hal/HalDisplay.h-- display constants (480x800, buffer size 48000), refresh modes enum, grayscale buffer methodslib/hal/HalGPIO.h-- GPIO pin defines (EPD_SCLK=8, EPD_MOSI=10, EPD_CS=21, EPD_DC=4, EPD_RST=5, EPD_BUSY=6, SPI_MISO=7, BAT_GPIO0=0, UART0_RXD=20), button indices (0-6), WakeupReason enumlib/hal/HalStorage.h-- Storage singleton, file ops API, SDCardManager wrapper
Application:
src/main.cpp-- 413 lines: setup/loop, activity routing (onGoHome, onGoToReader, etc.), font initialization (Bookerly 12/14/16/18, NotoSans 12/14/16/18, OpenDyslexic 8/10/12/14, Ubuntu 10/12), power button verification, deep sleep entry, auto-sleep timeout, memory loggingsrc/MappedInputManager.h-- Button enum (Back, Confirm, Left, Right, Up, Down, Power, PageBack, PageForward), Labels struct, mapLabels()src/Battery.h-- globalBatteryMonitor battery(BAT_GPIO0)instance
CI/GitHub:
.github/workflows/ci.yml-- 4 jobs (clang-format, cppcheck, build, test-status), triggers, steps.github/workflows/release.yml-- tag trigger, gh_release env, 5 artifact files.github/workflows/release_candidate.yml-- workflow_dispatch, release/* branch gate, SHORT_SHA extraction.github/workflows/pr-formatting-check.yml-- semantic PR title check.github/PULL_REQUEST_TEMPLATE.md-- summary, context, AI usage disclosure
Scripts:
bin/clang-format-fix-- bash script, git ls-files, grep for C/C++ extensions, excludes builtinFonts/, -g flag for modified-only
Directory listings obtained:
- Root,
src/,src/Activities/(full recursive),lib/(all subdirectories),lib/Epub/(full recursive),docs/,scripts/,test/
Current Mod Work Context
From mod/docs/todo.md, two tasks are planned for the sleep screen on branch mod/sleep-screen-tweaks:
Task 1 -- Gradient fill for letterboxed images: When a sleep screen image doesn't match the 480x800 display aspect ratio, void/letterbox areas should be filled with a gradient sampled from the nearest ~20 pixels of the image edge. Relevant files:
src/activities/boot_sleep/SleepActivity.cpp/.h-- sleep screen rendering logiclib/GfxRenderer/BitmapHelpers.cpp/.h-- bitmap manipulation utilitieslib/GfxRenderer/Bitmap.cpp/.h-- bitmap data structurelib/hal/HalDisplay.h-- display dimensions (480x800), buffer operations
Task 2 -- Fix "Fit" mode for small images: In "Fit" mode, images smaller than the display should be scaled UP to fit (maintaining aspect ratio). The current implementation only scales down larger images. Same relevant files as Task 1.
Neither task has been started yet -- only documentation/exploration was done this session.
Key Architectural Details Observed in Source
Activity lifecycle (from main.cpp):
exitActivity()callsonExit()thendeleteon the current activityenterNewActivity()setscurrentActivityand callsonEnter()- Activities receive
GfxRenderer&andMappedInputManager&in constructors ReaderActivityalso receives the epub path and callback functions for navigation
Boot sequence (from main.cpp setup()):
gpio.begin()-- init GPIO/SPI- Serial init only if USB connected
Storage.begin()-- SD card init (shows error screen on failure)- Load settings, KOReader store, UI theme
- Check wakeup reason: PowerButton verifies hold duration, AfterUSBPower goes back to sleep, AfterFlash/Other proceed
- Display + font setup
- Show BootActivity (splash)
- Load app state + recent books
- Route to HomeActivity or ReaderActivity based on saved state
Main loop (from main.cpp loop()):
- Poll GPIO
- Apply fadingFix setting to renderer
- Log memory every 10s (when serial active)
- Track activity timer, auto-sleep on configurable timeout
- Check power button hold for manual sleep
- Run
currentActivity->loop() - Delay 10ms normally, or
yield()if activity requests fast response (e.g. web server)
Settings system:
CrossPointSettingsloaded from SD at boot viaSETTINGSmacro- Includes:
shortPwrBtnbehavior,getPowerButtonDuration(),getSleepTimeoutMs(),fadingFix CrossPointState(APP_STATE) tracks:openEpubPath,lastSleepFromReader,readerActivityLoadCount
Display details (from HalDisplay.h):
DISPLAY_WIDTHandDISPLAY_HEIGHTareconstexprsourced fromEInkDisplayDISPLAY_WIDTH_BYTES = DISPLAY_WIDTH / 8(480/8 = 60)BUFFER_SIZE = DISPLAY_WIDTH_BYTES * DISPLAY_HEIGHT(60 * 800 = 48000)- Grayscale uses separate LSB/MSB buffers
displayBuffer()andrefreshDisplay()takeRefreshModeand optionalturnOffScreendrawImage()supports PROGMEM source flag
Companion Documentation Files
All in mod/docs/:
todo.md-- active mod task list (sleep screen tweaks)hardware.md-- full hardware reference (175 lines)file-structure.md-- complete file tree with descriptions (307 lines)ci-build-and-code-style.md-- build/CI/style reference (281 lines)project-summary.md-- condensed project reference (217 lines)session-summary.md-- this file