A Time Timer on my Kindle, in Lua

On this page

In my last post about my Kindle I jailbroke it and wrote a bit of Lua for KOReader: bookmaxxing, a sort order that keeps the shortest unread book on top. That went well enough that the Kindle stopped feeling like a sealed box and started feeling like something I could add to.

Which brings me to a recent micro-obsession: the Time Timer. If you have not seen one, it is a clock face with a coloured disc on it. You turn the disc to the number of minutes you want, and as time passes the disc shrinks back towards twelve. That is all it does.

Jan Rogers made the first one, by her company's account out of paper plates, because her young daughter kept asking how long fifteen minutes was and pointing at a clock did not help.1 That is the whole pitch. A clock tells you what time it is. A Time Timer shows you how much is left, as a shape, and you can read it from across the room without thinking about numbers.

People who like them, like them a lot. They show up in classrooms, in therapy offices and all over ADHD forums, where "time blindness", the trouble of sensing how much time has passed, is a common complaint.2 The research on visual timers is thinner than the enthusiasm, but the idea is easy to believe: you stop estimating and start looking.

And I want one. I also know myself. I would use it hard for four days, then it would sit on a shelf next to the other things I bought to fix my focus. So I have been trying with all my might not to buy one.

Then I looked at the Kindle on my desk, already jailbroken, already running a reader I can program, with a screen that costs nothing to keep showing the same picture. I wanted to see if I could build one.

What I needed

I called it dialtimer, since Time Timer is somebody's trademark.

  • The disc. A wedge that starts at twelve and shrinks back towards it, the way the real thing does: fifteen minutes is the top-left quarter, not the top-right.

  • Presets. 5, 10, 15, 25, 45 and 60 minutes, one tap each.

  • Pomodoro. 25 minutes of focus, 5 minutes of break, a longer break after every fourth round. The technique is named after the tomato-shaped kitchen timer Francesco Cirillo used as a student,3 so it felt right to have it here.

  • Tap the dial to start and pause. Nothing else on the screen should need explaining.

  • Stay awake. A Kindle that falls asleep halfway through a focus block is worse than no timer.

  • Be kind to the battery. This one needed actual thinking.

E-ink wants you to leave it alone

An e-ink screen uses no power to hold an image. It only uses power to change one. So the honest e-ink timer redraws as rarely as possible, and the honest Time Timer moves continuously. Those two pull in opposite directions.

The numbers helped. On my Paperwhite's 300 dpi screen, the edge of the disc moves about 43 pixels a minute, roughly 3.6 mm. Redrawing every 5 seconds moves it a third of a millimetre at a time, which you can barely see. Once a minute, it jumps. Every 15 seconds it moves about a millimetre, and you can watch it tick down.

How the redraw happens matters as much as how often. E-ink panels have several ways of changing pixels. The full one is slow, flashes the screen and handles every shade of grey. A fast one called A2 only does black and white, and only touches the pixels that change, but it leaves faint ghosts behind that pile up until a full refresh clears them.4 So the disc is solid black instead of grey, and the timer works like this:

What changesHow oftenHow it is drawn
The discevery 15 secondsA2, only the dial's square
The minutes textonce a minutea normal partial refresh
The last two minutesevery 5 secondsA2, only the dial
Everything, to clear ghostsevery 5 minutesfull refresh

That is the Balanced setting. There is also Smooth, every 5 seconds, and Frugal, once a minute. I do not have battery numbers yet. The plan is to run an hour on each from a full charge and write down what KOReader reports.

Building it on the desktop

The part that made this pleasant is that KOReader has a desktop build. The same Lua code, with the same widgets, runs in a window on Linux, and three environment variables make the window pretend to be a given device:

EMULATE_READER_W=618 EMULATE_READER_H=824 EMULATE_READER_DPI=150 ./luajit reader.lua

That is my Paperwhite at half size: same proportions, same layout, small enough to fit on a monitor. A fourth variable, KO_HOME, gives the test copy its own settings folder, so it never mixes with anything else.

KOReader runs on LuaJIT, so the plugin can draw straight onto the screen buffer. The wedge is a polygon, the centre plus a point for every degree along the arc, filled one row of pixels at a time:

for y = floor(min_y), floor(max_y) do
    local sy = y + 0.5
    local count = 0
    for i = 1, n do
        local j = i % n + 1
        local x1, y1 = pts[2 * i - 1], pts[2 * i]
        local x2, y2 = pts[2 * j - 1], pts[2 * j]
        if (y1 <= sy and y2 > sy) or (y2 <= sy and y1 > sy) then
            count = count + 1
            xs[count] = x1 + (sy - y1) * (x2 - x1) / (y2 - y1)
        end
    end
    table.sort(xs)
    for k = 1, count - 1, 2 do
        bb:paintRect(floor(xs[k] + 0.5), y, floor(xs[k + 1] + 0.5) - floor(xs[k] + 0.5), 1, color)
    end
end

For each row it finds where the row crosses the polygon's edges, sorts the crossings and fills between them in pairs. At the Kindle's full resolution that takes two or three milliseconds on my desktop.

The ticking is the other half. Instead of a timer that fires every 15 seconds from whenever it started, it counts backwards from the end time and wakes on the next step:

local left = self:secondsLeft()
local every = self:interval(left)   -- 15, or 5 in the last two minutes
local wait = left % every
if wait == 0 then wait = math.min(every, left) end
UIManager:scheduleIn(math.max(1, wait), self.tick)

Every interval divides 60, so the moments the minutes text changes always land on a step, and a pause or a slow wake-up never drifts the dial. On each step it checks whether the text changed: if not, it repaints only the dial with A2.

I tested it the way I would test anything else: a three-minute timer, run headless with no window at all, logging every screen refresh with its type and size. The log was the table above, line for line, down to the full refresh when the time ran out.

Putting it on the Kindle

This assumes a jailbroken Kindle with KOReader on it, started with --framework_stop as in the jailbreak post.

  1. Exit KOReader. Tap the top edge, go to the last menu tab and choose Exit. While KOReader runs with Amazon's interface stopped, the Kindle doesn't show up as a drive at all; plugged in, mine reported zero bytes of storage until I exited.

  2. Plug it in and wait for the Kindle's USB drive screen.

  3. Copy the plugin folder to koreader/plugins/dialtimer.koplugin. Only _meta.lua, main.lua and dialtimer_disc.lua are needed; the rest is the README and the desktop test setup.

  4. Eject it properly, unplug, and start KOReader again from the search bar:

;kpm launch koreader --framework_stop
  1. Open it from the Tools menu: Dial timer. It can also be bound to a gesture, so a swipe gets you from a book to a timer.

On my Paperwhite, on KOReader v2026.07.1, it did what the desktop said it would. The dial moves every 15 seconds without the whole screen flashing, the Kindle stays awake through a timer, and it goes back to sleep as usual once I close it.

So far it has cost me nothing but an evening. Ask me in a month whether I still use it.

The code is on GitHub as dotMavriQ/dialtimer.koplugin, MIT licensed, with the desktop test setup included.

Footnotes

  1. Time Timer, From Paper Plates to a Global Tool: The Origin Story of the Time Timer. The company's own account; it dates the first one to 1994. ↩

  2. Simply Psychology, ADHD & Time Blindness. ↩

  3. Pomodoro Technique, Wikipedia. ↩

  4. EPD Rendering, unofficial documentation of e-ink refresh modes. ↩

dotmavriq.life

Scan to open the site on another device.