I Made a Calendar with an E-Paper Display

April 13, 2023

Background

  • Friend: I have a Raspberry Pi 3B here, wanna play with it?
  • Me: OK

Then it sat in my dorm gathering dust for ages.

Anyway, this Linux development board is ARM-based; letting it gather dust seems like a waste. So, I made this thing.

What Did I Actually Make?

First, you have a screen, specifically an E-ink (aka e-paper) display. These screens have one major advantage: they can maintain the displayed content even after power is disconnected.

A broken e-paper screen

But these screens also have a disadvantage: the refresh rate is quite low, around 0.05Hz.

I thought about drawing something on it—like putting a webpage on it—but that might not be very friendly to this kind of screen. So, I wrote a UI library specifically for generating static content.

EPUI

Introducing E-Paper User Interface, the most awesome, fully customizable drawing library I designed for e-paper displays.

zhufucdev/epui

via GitHub

How should I put it… draw some weather?

from ui import *
from weather import *

canvas = Image.new('L', CANVAS_SIZE, 255)
context = Context(ImageDraw.Draw(canvas), CANVAS_SIZE)
weather_api_provider = CaiYunAPIProvider(
    api_key='you will never know',
    location=Location(
        latitude=3.1415926,
        longitude=2.7182818
    )
)
weather_provider = CaiYunWeatherProvider(
    weather_api_provider
)

context.root_group.add_view(
    LargeWeatherView(
        context,
        provider=weather_provider
    )
)

context.redraw_once()
canvas.show()

Introducing: Nanjing Weather

Drawing result

Introducing: Debug Mode

+ View.draw_bounds_box = True
canvas = Image.new('L', CANVAS_SIZE, 255)
context = Context(ImageDraw.Draw(canvas), CANVAS_SIZE)

See that? A compositional UI framework—it’s just awesome.

Technology

Not everyone cares about technology. If you’re a nerd, you can check out my repository. I’ll mention a few things here.

I abstracted the driver and the drawing separately so that the display could be anything, even a printer. Additionally, I used some APIs from CaiYun and Google Calendar to display useful information.

My own evaluation is that the entire codebase is highly abstracted and decoupled. You could say I’ve mastered Python.