Dependancies
Pre-requisites
Buy the components
waveshare-1in54-e-paper-samd21g.ino
#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) {
SerialUSB.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();
}
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
Check the version of the Waveshare module and use the example code for version 1 and version 2 accordingly.
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 |
Arduino Zero | Waveshare E-Ink module | SAMD21G |
---|---|---|
D7 | BUSY | PA21 |
D8 | RST | PA06 |
D9 | DC | PA07 |
D10 | CS | PA18 |
CLK | SCK on ICSP connector | PB11 |
DIN | COPI on ISCP connector | PB10 |