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