Dependancies
🌳 An outdoor LoRa-GPS tracker with an E-Ink display 🔑
Display demo sample code with V2.1 E-Ink hardware version
Dependancies
Check the E-Ink display module for the version number. Here, version 2.1 is used and the number is marked on the module.
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 Zero / SAMD21G are defined as following:
SAMD21G Pin | I/O Pin | SERCOM-ALT | Name |
---|---|---|---|
19 |
PB10 |
SERCOM4/PAD[2] |
COPI |
20 |
PB11 |
SERCOM4/PAD[3] |
SCK |
Schematic label | Arduino Zero pin name | SAMD21G pin name |
---|---|---|
EINK_BUSY | D7 | PA21 |
EINK_RST | D8 | PA06 |
EINK_DC | D9 | PA07 |
EINK_CS | D10 | PA18 |
COPI | ICSP_COPI | PB10 |
CLK | ICSP_SCK | PB11 |
CIPO | ICSP_CIPO | PA12 |
ls -al /dev/cu.usbmodem
and arduino-cli board list
. Run make
to compile and upload the code to the board.
#include <SPI.h>
#include "epd1in54_V2.h"
#include "epdpaint.h"
Epd epd;
unsigned char image[1024];
Paint paint(image, 0, 0);
#define COLORED 0
#define UNCOLORED 1
int count = 0;
char count_string[] = {'0', '0', '0', '\0'};
void setup() {
SerialUSB.begin(9600);
SerialUSB.println("e-Paper init");
initEink();
delay(1000);
}
void loop() {
displayOnEink();
delay(2000);
}
bool initEink() {
epd.LDirInit();
epd.Clear();
return true;
}
void displayOnEink() {
sprintf(count_string, "%d", ++count);
paint.SetWidth(200);
paint.SetHeight(24);
paint.SetRotate(ROTATE_0);
paint.Clear(COLORED);
paint.DrawStringAt(10, 4, "Lat Long!", &Font16, UNCOLORED);
epd.SetFrameMemory(
paint.GetImage(), 0, 10, paint.GetWidth(), paint.GetHeight());
paint.Clear(UNCOLORED);
paint.DrawStringAt(10, 4, "at ", &Font16, COLORED);
paint.DrawStringAt(40, 4, "00:00", &Font16, COLORED);
epd.SetFrameMemory(
paint.GetImage(), 0, 30, paint.GetWidth(), paint.GetHeight());
paint.SetWidth(50);
paint.SetHeight(120);
paint.SetRotate(ROTATE_270);
paint.Clear(COLORED);
paint.DrawStringAt(12, 10, count_string, &Font16, UNCOLORED);
paint.DrawStringAt(12, 32, count_string, &Font16, UNCOLORED);
epd.SetFrameMemory(
paint.GetImage(), 80, 72, paint.GetWidth(), paint.GetHeight());
epd.DisplayFrame();
SerialUSB.println("e-Paper print " + String(count_string));
}
BOARD?=hutscape:samd:oak
PORT := $(shell ls /dev/cu.usbmodem*)
BUILD=build
.PHONY: default lint all flash clean
default: all flash clean
all:
arduino-cli compile --fqbn $(BOARD) --output-dir $(BUILD) ./
flash:
arduino-cli upload -p $(PORT) --fqbn $(BOARD) --input-dir $(BUILD) --verbose
clean:
rm -r build