A library and app to display text and images on an Raspberry Pi eInk display
  • C 65.8%
  • Kotlin 33.9%
  • Makefile 0.3%
Find a file
2026-01-26 10:06:05 +00:00
.idea Removed harcoded code and tokens from spotify service. Now requires a REFRESH_TOKEN environment variable. 2026-01-26 09:23:13 +00:00
gradle/wrapper Gradle version bump 2025-02-23 08:09:52 +00:00
src Implemented a basic ellipsis mode for displaying text, and using it for displaying song titles. 2026-01-26 10:05:16 +00:00
.gitignore Initial commit - project can compile an arm64 linux binary 2024-09-05 08:42:45 +01:00
build.gradle.kts Initial commit for fetching spotify data. 2024-09-16 12:39:39 +01:00
gradle.properties Initial commit - project can compile an arm64 linux binary 2024-09-05 08:42:45 +01:00
gradlew Gradle version bump 2025-02-23 08:09:52 +00:00
gradlew.bat Gradle version bump 2025-02-23 08:09:52 +00:00
README.md Removed harcoded code and tokens from spotify service. Now requires a REFRESH_TOKEN environment variable. 2026-01-26 09:23:13 +00:00
settings.gradle.kts How to add JVM unit tests? 2024-09-07 10:19:46 +01:00

Khartoum

Experimenting with Waveshare ePaper for the Raspberry Pi

Writing code in Kotlin Native to control and display images and text on a Waveshare ePaper HAT for the Raspbery Pi.

It is not possible to build this application on a Raspberry Pi, as Jetbrains do not support the Raspberry as a build platform (despite it having the same core architecture as the M-series ARM processors used on Macs).

Makes use of the bcm2835 C library for hardware control. It recreates some of the Waveshare GUI C example functions, in Kotlin, in a library I am calling Khartoum. So far, the following functions are available:

The Khartoum binary must be run as root (sudo -E ./Khartoum.kexe) on the Raspberry Pi.

Libraries used

  • Kotlinx serialization
  • Kotlinx datetime
  • Native c-libraries:

Spotify

Requires two environment variables to be set:

  • SPOTIFY_CLIENT
  • SPOTIFY_SECRET
  • SPOTIFY_REFRESH_TOKEN

To create a client ID, register a new application through the developer dashboard. You'll also find the secret here.

To authorize the application, I should be requesting the authorization through the code flow mechanism. But this application runs headless and in the background. Instead, I need to get a code from:

https://accounts.spotify.com/authorize?response_type=code&client_id=<<CLIENT_ID>>&scope=user-read-currently-playing&redirect_uri=https://www.liamjd.org/spotCallback

Which redirects to https://www.liamjd.org/spotCallback?code=<<CODE>>

And from that code, I can request a refresh token from the URL:

curl -d client_id=<<CLIENT>> -d client_secret=<<SECRET>> -d grant_type=authorization_code -d code=<<CODE>> -d redirect_uri=https%3A%2F%2Fwww.liamjd.org%2FspotCallback https://accounts.spotify.com/api/token

That refresh token can then be used to request a new access token and is stored as an environment variable.

Need the -E option to be passed to sudo for them to be available. Run the command with nohup to ensure it keeps running even after logging out (sudo -E nohup ./Khartoum.kexe &).