Skip to content

v1.1 - KOReader Physical Page Sync

Choose a tag to compare

@yanllsama yanllsama released this 30 Jun 07:22
f996e55

📝 Physical Page Sync (Ninja Engine) - Changelog
Module: KOReader Statistics Plugin (statistics.koplugin) - Physical Page Sync Module

🚀 New Features & Improvements (v1.1)
Increased Mathematical Ratio Precision:

The math.ceil() function previously used for ratio calculation has been replaced with exact floating-point division.
Example: In the old system, for a book with 500 physical pages rendered across 850 KOReader screens, the ratio was calculated as math.ceil(850 / 500) = 2. This meant the engine waited for 2 screen turns to increment 1 physical page. By the end of the 850 screens, it would only record 425 pages instead of 500 (a significant margin of error).
In the new system, this ratio is precisely calculated and rounded to two decimal places (e.g., 1.70). The engine now knows exactly how to distribute the pages.
Transition to a Fractional Accumulator:

The page turn counter (cre_screen_counter) has been entirely rewritten to use a fractional accumulator (cre_fractional_counter) instead of an integer counter.
Thanks to this new system, the engine accumulates decimal values silently in the background (e.g., +1.0 per turn) and compares it against the precise float ratio (e.g., 1.70). Any leftover fractions are carried over to the next turn to ensure perfectly smooth distribution.
Result: By the time you reach the end of the book, the discrepancy between the recorded page count and the target physical page count has been reduced to absolutely 0%.
Updated UI Notifications:

The InfoMessage dialogs that appear when a ratio is calculated have been updated from integer (%d) to float format (%.2f).
When the module is enabled, instead of seeing "Ratio: 2 taps per page", you will now see an exact reading like "Ratio: 1.70 taps per page" for complete transparency.
State Saving Revision:

When the device goes to sleep or the book is closed (onCloseDocument, onReaderReady), the exact fractional state of the counter (e.g., 0.40) is now preserved and saved identically into the book's sidecar file. When you resume reading, the sync continues seamlessly from the exact millimeter you left off.
🐛 Bug Fixes
Fixed a "premature rounding" issue where the counter would unnecessarily halve the reading speed for books where the physical page count was very close to, but not exactly equal to, the screen count (Thanks to the community feedback on Reddit for pointing this out!).