Waveshare 1.54 inch with SAMD21G

arduino m0 samd21g waveshare e-paper e-ink

The 4 non-SPI pins are defined in epdif.h file:

#define RST_PIN         8
#define DC_PIN          9
#define CS_PIN          10
#define BUSY_PIN        7

The SPI pins for Arduino M0 / SAMD21G are defined as following:

SAMD21G Pin I/O Pin SERCOM-ALT Name
19 PB10 SERCOM4/PAD[2] MOSI
20 PB11 SERCOM4/PAD[3] SCK

Code

Download code
#include <Arduino.h>
#include <SPI.h>
#include "epd1in54.h"
#include "epdpaint.h"

#define COLORED     0
#define UNCOLORED   1

unsigned char image[1024];
Paint paint(image, 0, 0);
Epd epd;
int count = 0;
char count_string[] = {'0', '0', '0', '\0'};

void setup() {
  SerialUSB.begin(9600);
  while (!SerialUSB) { }
  SerialUSB.println("Start E-ink display...");
}

void loop() {
  sprintf(count_string, "%d", ++count);
  SerialUSB.println(count_string);

  if (epd.Init(lut_full_update) != 0) {
    Serial.print("e-Paper init failed");
    return;
  }

  epd.ClearFrameMemory(0xFF);
  epd.DisplayFrame();
  epd.ClearFrameMemory(0xFF);
  epd.DisplayFrame();

  paint.SetRotate(ROTATE_0);
  paint.SetWidth(200);
  paint.SetHeight(24);

  paint.Clear(UNCOLORED);
  paint.DrawStringAt(10, 4, count_string, &Font16, COLORED);
  epd.SetFrameMemory(paint.GetImage(), 0, 50, paint.GetWidth(), paint.GetHeight());

  epd.DisplayFrame();

  delay(2000);
  epd.Sleep();
}

Makefile

BOARD?=arduino:samd:mzero_bl
PORT := $(shell ls /dev/cu.usbmodem*)

.PHONY: default lint all flash clean

default: all flash clean

lint:
	cpplint --extensions=ino --filter=-legal/copyright *.ino

all:
	arduino-cli compile --fqbn $(BOARD) ./

flash:
	arduino-cli upload -p $(PORT) --fqbn $(BOARD)

clean:
	rm -r build

Serial console

Serial output from the firmware.

Waveshare 1.54 inch with SAMD21G serial console

Prototype

A photo of the actual setup.

Waveshare 1.54 inch with SAMD21G prototype

Schematic

Wire up the hardware accordingly

Waveshare 1.54 inch with SAMD21G schematic

References