Skip to content
Merged
Show file tree
Hide file tree
Changes from 128 commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
cc3f0a6
Switching from navigate&preview to navigate_to&preview_to, relative t…
samuelclay Aug 16, 2025
d35f441
Committing clang-format/clang-tidy changes
Aug 16, 2025
d615e26
Merge branch 'main' into sam/kindle-navigate-to
samuelclay Aug 27, 2025
709923c
Committing clang-format/clang-tidy changes
Aug 27, 2025
b7a71ce
Preventing infinite loop if position hasn't changed while loading mor…
samuelclay Aug 28, 2025
5f857e2
Committing clang-format/clang-tidy changes
Aug 28, 2025
2441e0a
More logging, better adherence to previewed pages consistency.
samuelclay Aug 28, 2025
1c5b77c
Better page turning logic, but we're now advancing the navigate_to wa…
samuelclay Aug 28, 2025
9fc7907
Committing clang-format/clang-tidy changes
Sep 3, 2025
324e0a9
Adding navigate retries to fully take advantage of idempotency. Also …
samuelclay Sep 3, 2025
47ec7df
Committing clang-format/clang-tidy changes
Sep 3, 2025
e141dd5
Fixing kindle test images.
samuelclay Sep 3, 2025
9124117
Committing clang-format/clang-tidy changes
Sep 3, 2025
374a37e
Fixing build
samuelclay Sep 3, 2025
8a6e1ab
Committing clang-format/clang-tidy changes
Sep 3, 2025
9f56009
Adding make lint instructions to CLAUDE.md
samuelclay Sep 3, 2025
27d5657
Fixing tests
samuelclay Sep 3, 2025
0cd2407
Clang tidy clean
samuelclay Sep 5, 2025
bf4a041
Ignore kindle tests on normal `make test` run
samuelclay Sep 5, 2025
59b614e
Remove some verbose logs
samuelclay Sep 5, 2025
3e28a3e
Refactoring to keep it DRY
samuelclay Sep 6, 2025
24f283e
Committing clang-format/clang-tidy changes
Sep 6, 2025
df055ab
Goodbye green flash (#1143)
samuelclay Sep 5, 2025
8548ff5
Merge branch 'main' into sam/kindle-navigate-to
samuelclay Sep 6, 2025
be7920d
Fixing kindle test image for connecting.
samuelclay Sep 8, 2025
4411b17
Simplifying updatePage logic.
samuelclay Sep 8, 2025
f6c7338
More test images
samuelclay Sep 8, 2025
b6bb010
Skip the connecting state, too transient.
samuelclay Sep 8, 2025
145fcff
Using new book_session_key to help the server know when to adjust its…
samuelclay Sep 8, 2025
4f61214
Code review, cleaning up updatePlace, ensuring non-preview navigates …
samuelclay Sep 9, 2025
64f4cba
Committing clang-format/clang-tidy changes
Sep 9, 2025
c0b1e0b
Simplifying updatePlace
samuelclay Sep 9, 2025
12e6d4e
Adding telemetry, retrying book opening, even more simplification of …
samuelclay Sep 10, 2025
8e69fb2
Showing Table of Contents and choosing chapters. Needs page numbers a…
samuelclay Sep 10, 2025
59c1ec8
Update src/Models/KindlePageFlipper.cpp
samuelclay Sep 10, 2025
91191fd
Committing clang-format/clang-tidy changes
Sep 10, 2025
42aa812
Adding KindleError to better manage errors as they propagate between …
samuelclay Sep 11, 2025
6ad3ba8
Adding more kindle tests to tests previewing nad navigating in a long…
samuelclay Sep 11, 2025
76278df
Opening a book sets the navigate_to to 0 so we don't immediately make…
samuelclay Sep 11, 2025
98aeebf
Splitting lastRenderedPlace_ and lastServerSyncPlace_.
samuelclay Sep 11, 2025
e65394f
Looping and fetching up to 6 pages to fill out content.
samuelclay Sep 11, 2025
44a3bbd
Adding short pages test, regenerating all kindle images to purge unused
samuelclay Sep 11, 2025
37efe4a
Committing clang-format/clang-tidy changes
Sep 11, 2025
9bcf626
Skip the visual kindle test, run it as part of [kindle]
samuelclay Sep 11, 2025
cd3c29e
Update src/UI/KindleReadableScreen.cpp
samuelclay Sep 11, 2025
952bde9
Removing unnecessary onPositionChanged
samuelclay Sep 11, 2025
b5e3c55
Handling session key mismatch by resetting navigate_to page position …
samuelclay Sep 11, 2025
e0fb879
Adding back in a StopFreeRtos so the test can finish
samuelclay Sep 11, 2025
24a8c4a
Now expect a book_session_key.
samuelclay Sep 10, 2025
1c3b287
Merge branch 'sam/kindle-navigate-to' into sam/kindle-toc
samuelclay Sep 12, 2025
8bab936
Committing clang-format/clang-tidy changes
Sep 12, 2025
994e584
Don't used cache navigateTo, recalculate it every time. Also moving s…
samuelclay Sep 12, 2025
5173360
Committing clang-format/clang-tidy changes
Sep 12, 2025
320d8f2
Replacing missing params
samuelclay Sep 12, 2025
9c2be1a
Don't used cache navigateTo, recalculate it every time. Also moving s…
samuelclay Sep 12, 2025
0a5f6d8
Merge branch 'sam/kindle-navigate-to' into sam/kindle-toc
samuelclay Sep 12, 2025
30881dc
Fixing ToC redraws and navigation when landing.
samuelclay Sep 13, 2025
b694b42
Attempting to fix overlay woes.
samuelclay Sep 15, 2025
719f2d5
Revert "Attempting to fix overlay woes."
samuelclay Sep 15, 2025
5230843
Adding a background view to hide the status message.
samuelclay Sep 15, 2025
7aebff9
Page numbers in their right place
samuelclay Sep 15, 2025
df5c5c7
Fix EOF for both tutorial and release notes (#1144)
samuelclay Sep 15, 2025
e705414
KindleError -> std::shared_ptr<KindleError>
samuelclay Sep 16, 2025
2b15f04
session_key_mismatch magic string
samuelclay Sep 16, 2025
d6b50c9
Consolidating errors, cleaning retry loop to make it clear what's the…
samuelclay Sep 16, 2025
f915f7a
When we're at the end of the buffered content, fall back to the last …
samuelclay Sep 16, 2025
5c2c5a8
Flattened control flow. Not auto-accepting visual changes.
samuelclay Sep 16, 2025
eb0732d
KindleErrorType -> KindleError::Type
samuelclay Sep 16, 2025
ca6196d
Hard failure on missing session key.
samuelclay Sep 16, 2025
cc3897e
DispatchGetCore0BackgroundQueue -> dispatchQueue
samuelclay Sep 16, 2025
67d822e
Short-page kindle test in CI
samuelclay Sep 16, 2025
ff4f896
Committing clang-format/clang-tidy changes
Sep 16, 2025
6bd574a
Now that we require book_session_key, we need to generate it in the m…
samuelclay Sep 16, 2025
9d44e84
No need to run network synchronously.
samuelclay Sep 16, 2025
aeed3ca
Stop freertos at end of test to cleanup
samuelclay Sep 16, 2025
03a2c65
Refactored fetchAdditionalPagesIfNeeded into syncPagesWithServer so t…
samuelclay Sep 16, 2025
f8c452b
Stop HTTP server before stopping FreeRTOS to avoid deadlock
samuelclay Sep 16, 2025
9b37c6b
Committing clang-format/clang-tidy changes
Sep 16, 2025
c8206fa
gotContentFunction -> onNavigationComplete
samuelclay Sep 16, 2025
953320a
Merge branch 'sam/kindle-navigate-to' into sam/kindle-toc
samuelclay Sep 16, 2025
9ec0c84
Committing clang-format/clang-tidy changes
Sep 16, 2025
97ced68
Committing clang-format/clang-tidy changes
Sep 16, 2025
53b1bca
Adding sleep to try and fix kindle short pages test (which runs fine …
samuelclay Sep 17, 2025
84ec25f
Adding sleep to try and fix kindle short pages test (which runs fine …
samuelclay Sep 17, 2025
98a12d7
Merge branch 'sam/kindle-navigate-to' into sam/kindle-toc
samuelclay Sep 17, 2025
8805ec8
Storing kindle reading progress in kindle.json so the menu is correct.
samuelclay Sep 18, 2025
2f669ff
Committing clang-format/clang-tidy changes
Sep 18, 2025
5f9a7b4
Optimistically update kindle progress on ToC chapter choice.
samuelclay Sep 18, 2025
dff126a
Committing clang-format/clang-tidy changes
Sep 18, 2025
77d08e0
Code review
samuelclay Sep 18, 2025
1f5f8b3
Kindle progress in test fixture.
samuelclay Sep 18, 2025
6bc70d3
Review
samuelclay Sep 18, 2025
30056d5
onContentReady
samuelclay Sep 19, 2025
44989af
onTestContentReady
samuelclay Sep 19, 2025
bd401af
Handling last read dialog, adding test with new screenshots.
samuelclay Sep 20, 2025
3a76ee4
Checking for last read dialog before book session key validation.
samuelclay Sep 20, 2025
675b765
Merge branch 'sam/kindle-navigate-to' into sam/kindle-toc
samuelclay Sep 20, 2025
4664c27
Adding test-only callbacks to capture last read dialogs.
samuelclay Sep 22, 2025
14f9c17
Removing WAIT_FOR_CONTENT_RENDER and switching to using the new TEST-…
samuelclay Sep 22, 2025
10d8d72
Apply suggestion from @johnboiles
samuelclay Sep 22, 2025
fe542e0
Apply suggestion from @johnboiles
samuelclay Sep 22, 2025
1c26f71
Apply suggestion from @johnboiles
samuelclay Sep 22, 2025
1273e39
Apply suggestion from @johnboiles
samuelclay Sep 22, 2025
bf9fce8
Adding test-only callbacks to capture last read dialogs.
samuelclay Sep 22, 2025
d1e1891
Removing WAIT_FOR_CONTENT_RENDER and switching to using the new TEST-…
samuelclay Sep 22, 2025
53f8233
Polling for screens
samuelclay Sep 22, 2025
47eae66
Expanding wait targets
samuelclay Sep 22, 2025
798d307
Correcting github's substitutions
samuelclay Sep 22, 2025
b4977ea
Rewriting short pages kindle test, now passes and has perfect screens…
samuelclay Sep 23, 2025
1399aeb
Removing slop from tests
samuelclay Sep 23, 2025
a51c4d0
Committing clang-format/clang-tidy changes
Sep 23, 2025
8f4f4ae
Consolidating network calls, adding conventions to CLAUDE.md.
samuelclay Sep 23, 2025
3839b7c
Removing currentPosition_, only currentPage_ should be used.
samuelclay Sep 23, 2025
f6ccb53
Allocate enough toc json space.
samuelclay Sep 23, 2025
5457df4
Committing clang-format/clang-tidy changes
Sep 23, 2025
9f3aa5a
Early return convention
samuelclay Sep 25, 2025
a91fe3f
Testing retries, showing error message and popup menu in the right pl…
samuelclay Sep 25, 2025
19ca31c
Committing clang-format/clang-tidy changes
Sep 25, 2025
1465ec1
Adding staging support for kindle. Also moving kindle current page to…
samuelclay Sep 25, 2025
c58431e
Committing clang-format/clang-tidy changes
Sep 25, 2025
1512c92
Don't bother showing the Connecting view on Kindle since it's not mea…
samuelclay Sep 25, 2025
7a53c25
Cleaning up test's kindle.json to remove unused fields.
samuelclay Sep 25, 2025
d1a6c24
Removing percentage from the server, now calculating on the fly. Much…
samuelclay Sep 25, 2025
ceb1cc0
Committing clang-format/clang-tidy changes
Sep 25, 2025
3582d2e
Kindle pages are 1-indexed because they are human readable.
samuelclay Sep 25, 2025
b5cf5a8
Page numbers in the Kindle popup.
samuelclay Sep 26, 2025
7cce14c
Renames
samuelclay Sep 26, 2025
8e8b73c
Committing clang-format/clang-tidy changes
Sep 26, 2025
62deddd
Removing nested #if TESTS.
samuelclay Sep 29, 2025
365d7cb
Merge branch 'main' into sam/kindle-page-numbers
samuelclay Sep 29, 2025
3aa31b2
Only 2 network tries
samuelclay Sep 29, 2025
a2096fc
Merge branch 'main' into sam/kindle-page-numbers
samuelclay Sep 30, 2025
592fb28
Shipped, can turn off KINDLE_USE_STAGING
samuelclay Sep 30, 2025
d5a129c
hasExplicitPageNumbers_ -> hasExplicitPageNumbers()
samuelclay Sep 30, 2025
34501de
Committing clang-format/clang-tidy changes
Sep 30, 2025
933df49
Merge branch 'main' into sam/kindle-page-numbers
samuelclay Oct 8, 2025
e04d34e
Commenting out two kindle short page images, both the "Syncing to las…
samuelclay Oct 8, 2025
b526a05
Merge remote-tracking branch 'origin/main' into sam/kindle-page-numbers
johnboiles Oct 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ jobs:
run: |
./scripts/test_watchdog.sh './test/CatchTests/build/tests [kindle] --reporter console --reporter junit::out=catch-results-kindle.xml' 60

- name: Run kindle short pages tests
run: |
./scripts/test_watchdog.sh './test/CatchTests/build/tests [kindle-short-pages] --reporter console --reporter junit::out=catch-results-kindle-short-pages.xml' 60

- name: Test Report
uses: dorny/test-reporter@v1
# run this step even if previous step failed
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ build-log.txt
test_kindle_*.ini

# Claude makes docs for sharing with other repos
docs/*
docs/*

# Log files
logs/*
38 changes: 38 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Repository Guidelines

This guide aligns contributors on how to build, test, and submit changes for the Sol Reader glasses firmware.

## Project Structure & Module Organization
- `src/`: C/C++ app code (entry: `src/main.cpp`). Key areas: `Communications/`, `Displays/`, `EPub/`, `Inputs/`, `Models/`, `Renderers/`, `Sensors/`, `Storage/`, `UI/`, `Ulp/`.
- `include/`: generated or shared headers. `components/` and `lib/`: external components and Simulator code.
- `test/CatchTests/`: Catch2 tests; images under `Images/Accepted/` (baselines) and `Images/TestRun/` (diffs).
- `scripts/`: helper tools; `docs/`, `data/`: assets and docs. Build output goes to `build*/`.

## Build, Test, and Development Commands
- Build firmware: `. ~/esp/esp-idf/export.sh && make build`
- Flash + monitor: `make flash monitor` (set serial ports automatically). Stop reset-only monitor with `make monitor`.
- Target profiles: `TARGET=glasses-release make build` (see `sdkconfig.defaults.*`).
- Simulator: `make sim` (or `sim8`, `sim16`, `sim24`); logs in `logs/`.
- Tests: `make test` (or focused: `make test-kindle`, `make test-content-sync`).
- Lint/format: `make clang-format` or `make tidy`; clean: `make clean`.

## Coding Style & Naming Conventions
- C++ style: LLVM base, 4-space indent, 100-col limit (`.clang-format`).
- Includes: group/regroup system `<...>` before local "...".
- Naming (`.clang-tidy`): namespaces `lower_case`; classes/structs `CamelCase`; functions `camelBack`; variables `camelBack`; constants `UPPER_CASE`; private/protected members end with `_`.
- Run `make tidy` before pushing. Python files are auto-formatted in CI via `black` and `isort`.

## Testing Guidelines
- Framework: Catch2 in `test/CatchTests`. Add files as `Test*.cpp` or `<Feature>Test.cpp`.
- Tags: use category tags (e.g., `[epub]`, `[content-sync]`, `[telemetry]`, `[kindle]`).
- Visual baselines: when a baseline is missing or mismatches, tests write new images to `.../TestRun/` and also copy them into the matching `.../Accepted/` location—but the run still fails (by design) so CI flags it.
- Local acceptance: run `make test`, review diffs, then leave the updated baselines in Accepted/ unstaged to accept them, then rerun.

## Commit & Pull Request Guidelines
- Messages: imperative, concise; reference issues/PRs with `#1234`. Example: `Fix: prevent green flash (#1143)`.
- PRs: include a summary, linked issues, test plan (commands run), and screenshots or updated baselines for UI changes.
- CI must pass: Catch2 tests, clang-tidy/format, and Python formatting workflows run on PRs. Run `make test` and `make tidy` locally first.

## Security & Configuration Tips
- Do not commit secrets or local prefs (e.g., `simprefs.ini`, logs, `TestRun/` outputs are gitignored).
- Set up ESP-IDF per README; export the environment before building. For Simulator cloud access, keep tokens in `simprefs.ini` locally.
26 changes: 22 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Sol Reader Embedded App - Development Guide

## Tips
- **Visual Test Generation**: When tests use `ASSERT_VIEW_UNCHANGED`, they automatically generate accepted images on first run if they don't exist. The test will fail initially and show you the copy command to create the accepted image from the generated TestRun image.

## Test Screenshots
- Never copy TestRun images to Accepted folder - the test runner auto-accepts them when tests fail
- The test framework automatically updates accepted screenshots when they change
Expand All @@ -12,10 +15,16 @@
- Monitor serial logs: `make monitor`
- Run simulator: `make sim` (or `make sim8`, `make sim16`, `make sim24` for different display modes)
- No need to run export.sh for simulator
- Simulator output is logged to `logs/sim.log` (or `logs/sim8.log`, `logs/sim16.log`, `logs/sim24.log`)
- Watch logs in real-time: `tail -f logs/sim.log`
- Log file is cleared on each run
- Run tests: `make test`
- Run single test: `./test/CatchTests/build/tests '[test-tag]'` (e.g. `'[epub]'`, `'[content-sync]'`)
- Format code: `make clang-format`
- Static analysis: `make clang-tidy`
- Build tests: `make test-build`
- Run single test: `make test-build && ./test/CatchTests/build/tests '[test-tag]'` (e.g. `'[epub]'`, `'[content-sync]'`)
- Always rebuild before running tests to ensure changes are included
- Format code: `make clang-tidy`
- **IMPORTANT**: Always run `. $IDF_PATH/export.sh && make clang-tidy` after making code changes
- Full linting (format + static analysis): `make clang-format` (can be slow)

## Code Style Guidelines
- Format: Use clang-format with LLVM-based style (ColumnLimit: 100, IndentWidth: 4)
Expand All @@ -24,8 +33,17 @@
- Logging: Use log_d/log_i/log_w/log_e with descriptive messages
- Memory: Manage heap allocations carefully, use HEAP_PROFILE macros to track
- Naming: camelCase for variables/methods, PascalCase for classes, ALL_CAPS for constants/macros
- Comments: Use `//` for line comments, `/* */` for block comments
- Comments: Use `//` for line comments and for block comments
- Stack usage: Monitor stack usage with watermarks (SHOW_WATERMARK macro)
- Threading: Use DispatchQueue for most async operations
- Comments: Only include comments if they add context that's not readily apparent in the next line of code or if the code block has some complexity
- Comments: Don't add comments that are simply addressing the prompt, only add them if the comments clear up confusion

## Architecture Conventions
- **Network/API requests**: All network requests must go through SindarinAPI (never direct HTTP calls from UI screens)
- **Kindle navigation**: Kindle-specific logic and state management should be delegated to KindlePageFlipper, not handled in UI screens
- **Async operations**: Use DispatchQueue for background operations; UI screens coordinate but don't implement async logic directly
- **State management**: Business logic classes (like KindlePageFlipper) encapsulate state changes; UI screens handle callbacks and visual updates
- **Error handling**: Use assertions (`assert()`) for programming errors; return structured error types for recoverable operations
- **Data persistence**: UI screens use LocalStore and PreferencesStore for data access; avoid direct file system operations in UI
- **Telemetry**: Use centralized Telemetry class with structured fields; log meaningful events at appropriate levels (log_d/log_i/log_w/log_e)
31 changes: 26 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
all: build

# Use all but 1 core for building
NUM_CORES := $(shell nproc)
NUM_CORES := $(shell nproc 2>/dev/null || sysctl -n hw.ncpu)
NUM_CORES := $(shell echo $$(( $(NUM_CORES) - 1 )))
NUM_CORES := $(shell [ $(NUM_CORES) -lt 1 ] && echo 1 || echo $(NUM_CORES))

Expand Down Expand Up @@ -51,7 +51,11 @@ sim-build:

.PHONY: sim-run
sim: sim-build
./lib/Simulator/build/simulator
@mkdir -p logs
@echo "Starting simulator with logging to logs/sim.log"
@echo "You can watch the log with: tail -f logs/sim.log"
@> logs/sim.log
@./lib/Simulator/build/simulator 2>&1 | tee logs/sim.log

.PHONY: sim8-build
sim8-build:
Expand All @@ -60,7 +64,11 @@ sim8-build:

.PHONY: sim-run8
sim8: sim8-build
./lib/Simulator/build8/simulator
@mkdir -p logs
@echo "Starting simulator with logging to logs/sim8.log"
@echo "You can watch the log with: tail -f logs/sim8.log"
@> logs/sim8.log
@./lib/Simulator/build8/simulator 2>&1 | tee logs/sim8.log

.PHONY: sim16-build
sim16-build:
Expand All @@ -69,7 +77,11 @@ sim16-build:

.PHONY: sim-run16
sim16: sim16-build
./lib/Simulator/build16/simulator
@mkdir -p logs
@echo "Starting simulator with logging to logs/sim16.log"
@echo "You can watch the log with: tail -f logs/sim16.log"
@> logs/sim16.log
@./lib/Simulator/build16/simulator 2>&1 | tee logs/sim16.log

.PHONY: sim24-build
sim24-build:
Expand All @@ -78,7 +90,11 @@ sim24-build:

.PHONY: sim-run24
sim24: sim24-build
./lib/Simulator/build24/simulator
@mkdir -p logs
@echo "Starting simulator with logging to logs/sim24.log"
@echo "You can watch the log with: tail -f logs/sim24.log"
@> logs/sim24.log
@./lib/Simulator/build24/simulator 2>&1 | tee logs/sim24.log

.PHONY: lldb
lldb: sim-build
Expand All @@ -100,6 +116,7 @@ test: test-build
./test/CatchTests/build/tests '[content-sync]'
./test/CatchTests/build/tests '[telemetry]'
./test/CatchTests/build/tests '[kindle]'
./test/CatchTests/build/tests '[kindle-short-pages]'

.PHONY: test-content-sync
test-content-sync: test-build
Expand All @@ -115,6 +132,10 @@ test-epub-lldb: test-build

test-kindle: test-build
./test/CatchTests/build/tests '[kindle]'
./test/CatchTests/build/tests '[kindle-short-pages]'

test-kindle-short: test-build
./test/CatchTests/build/tests '[kindle-short-pages]'

test-kindle-lldb: test-build
lldb ./test/CatchTests/build/tests '[kindle]'
Expand Down
Loading