Oak

🌳 An outdoor LoRa-GPS tracker with an E-Ink display 🔑

power 18650
wireless LoRa,
sensor GPS, E-Ink
mcu SAMD21G18
bom items 82
bom cost USD $78.93
vendors 6
completed July 2022

E-Ink rotated

e-ink e-paper waveshare display e-paper version 1 medium

Display lat-long and Haversine distance


Before starting

Dependancies

waveshare

Pre-requisites

E-Ink hello world

Details

Display rotated information on the E-Ink as an example to display the various information such as latitude, longitude, Haversine distance and last timestamp.

This example uses Version 1 of WaveShare 1.54inch E-Ink module.

Steps

  1. Plug in the Oak PCB to the computer
  2. (Option A) Ensure the PCB can be detected with ls -al /dev/cu.usbmodem and arduino-cli board list. Run make to compile and upload the code to the board. (Option A) Ensure the PCB can be detected with <code>ls -al /dev/cu.usbmodem</code> and <code>arduino-cli board list</code>. Run <code>make</code> to compile and upload the code to the board.
  3. (Option B) Ensure the board can be detected with Arduino IDE. Compile and upload the code to the board. (Option B) Ensure the board can be detected with Arduino IDE. Compile and upload the code to the board.

Serial console

Serial output from the firmware.

Code

Download code
#include <SPI.h>

#include "epd1in54.h"
#include "epdpaint.h"

#define COLORED 0
#define UNCOLORED 1

const char latlong[] = "1.40N, 103.91E";
const char haversine[] = "300m";
const char last_timestamp[] = "00:10 ago";

unsigned char image[1024];
Paint paint(image, 0, 0);
Epd epd;
unsigned long time_start_ms;
unsigned long time_now_s;

void setup() {
  SerialUSB.begin(9600);

  SerialUSB.println("E-Ink rotated information example... \n");
  if (epd.Init(lut_full_update) != 0) {
    SerialUSB.println("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(COLORED);
  paint.DrawStringAt(10, 4, "Current position", &Font16, UNCOLORED);
  epd.SetFrameMemory(
    paint.GetImage(), 0, 10, paint.GetWidth(), paint.GetHeight());

  paint.Clear(UNCOLORED);
  paint.DrawStringAt(20, 4, latlong, &Font16, COLORED);
  epd.SetFrameMemory(
    paint.GetImage(), 0, 30, paint.GetWidth(), paint.GetHeight());
  SerialUSB.println("Displayed sample lat-long");

  paint.SetWidth(50);
  paint.SetHeight(120);
  paint.SetRotate(ROTATE_270);

  paint.Clear(COLORED);
  paint.DrawStringAt(15, 6, haversine, &Font24, UNCOLORED);
  paint.DrawStringAt(15, 34, last_timestamp, &Font16, UNCOLORED);
  epd.SetFrameMemory(paint.GetImage(),
    80, 72, paint.GetWidth(), paint.GetHeight());
  SerialUSB.println("Displayed sample Haversine distance and last timestamp");

  epd.DisplayFrame();
  delay(1000);
}

void loop() {}

Makefile

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

References