Yokan / rebuild
Course 1 8624561

DbEinkPreset.kt

composeApp/src/commonMain/kotlin/eu/friedcutlet/yokan/database/DbEinkPreset.kt

implementation35 lines
1package eu.friedcutlet.yokan.database23import kotlinx.serialization.Serializable45/**6 * E-ink screens Yokan targets in e-ink display mode. [width] x [height] is the portrait panel7 * resolution; optimized downloads keep each page's short side at most [width].8 */9@Serializable10enum class DbEinkPreset(val label: String, val width: Int, val height: Int) {11    KindleBasic("Kindle (basic)", 1072, 1448),12    KindlePaperwhite("Kindle Paperwhite", 1264, 1680),13    KindleOasis("Kindle Oasis", 1264, 1680),14    KindleScribe("Kindle Scribe", 1860, 2480),15    KoboClara("Kobo Clara", 1072, 1448),16    KoboLibra("Kobo Libra", 1264, 1680),17    KoboSage("Kobo Sage", 1440, 1920),18    KoboElipsa("Kobo Elipsa", 1404, 1872),19    BooxPage("Boox Page / Leaf (7\")", 1264, 1680),20    BooxNoteAir("Boox Note Air / generic 10\"", 1404, 1872),21}2223/** Pages turned between full-screen refreshes; 0 disables the refresh flash. */24val EinkRefreshIntervals = listOf(0, 1, 3, 6, 10, 20)2526/** Size that keeps [width] x [height]'s short side at most [maxShortSide]; never upscales. */27fun einkScaledSize(width: Int, height: Int, maxShortSide: Int): Pair<Int, Int> {28    val shortSide = minOf(width, height)29    if (shortSide <= maxShortSide) return width to height30    val scale = maxShortSide.toDouble() / shortSide31    return maxOf(1, kotlin.math.round(width * scale).toInt()) to maxOf(1, kotlin.math.round(height * scale).toInt())32}3334/** True on the page turns that should flash a full refresh to clear e-ink ghosting. */35fun einkFullRefreshDue(pageTurns: Int, every: Int): Boolean = every > 0 && pageTurns > 0 && pageTurns % every == 036

Search chapters, reference and source filenames.