aboutsummaryrefslogtreecommitdiff

go-epd7in3e

A small Go driver for the Waveshare 7.3" e-Paper (E) "Spectra 6" panel (epd7in3e, 800x480, 6 colours) over SPI on a Raspberry Pi.

This was written by referencing the original c driver provided by waveshare at https://github.com/waveshareteam/e-Paper

Wiring

Default Waveshare HAT wiring, BCM numbers:

Signal BCM pin Direction Notes
RST GPIO17 out active low
DC GPIO25 out low = command, high = data
CS GPIO8 (CE0) - driven by the kernel spidev driver
BUSY GPIO24 in LOW = busy, HIGH = idle
PWR GPIO27 out driven HIGH before anything else
MOSI GPIO10 - SPI0
SCLK GPIO11 - SPI0, 4 MHz, mode 0, 8 bits

Enabling SPI

On a Raspberry Pi with the HAT fitted:

  1. sudo raspi-config -> Interface Options -> SPI -> Yes.
  2. sudo reboot, then confirm /dev/spidev0.0 exists.
  3. Build with the Makefile, on the Pi or cross-compiled on a PC/server:
make build      # on the Pi, produces ./epdctl
make arm64      # Pi 4/5 64-bit, produces ./epdctl-arm64
make arm        # 32-bit, produces ./epdctl-arm
make clean      # remove the built binaries

CLI usage

epdctl always initialises the panel, draws, then puts it to deep sleep. -dry-run out.png writes the quantised 800x480 frame to a PNG instead of touching the hardware. -v logs every command, data write and busy-wait duration to stderr for bring-up diagnostics.

epdctl clear                 # fill the panel white
epdctl clear blue            # any of black|white|yellow|red|blue|green
epdctl bars                  # six vertical colour bars
epdctl show photo.jpg        # letterbox, dither, display
epdctl show photo.png -dry-run /tmp/preview.png

Library Usage

d, err := epd7in3e.NewHAT(nil)   // SPI0.0 + default HAT pins, defaults
// or &epd7in3e.Opts{Verbose: true} to log every command to stderr
if err != nil { log.Fatal(err) }
ctx := context.Background()
if err := d.Init(ctx); err != nil { log.Fatal(err) }
img, _, err := image.Decode(file) // 800x480 or 480x800 (rotated)
if err != nil { log.Fatal(err) }
if err := d.Display(ctx, img); err != nil { log.Fatal(err) }
if err := d.Sleep(ctx); err != nil { log.Fatal(err) }
d.Halt()                          // power the board rail off