From b59f46cb7caad5021a0a0d86cb5e0410ff551bdb Mon Sep 17 00:00:00 2001 From: Larry Bank Date: Mon, 9 Jun 2025 13:29:32 +0100 Subject: [PATCH] Added Pimoroni Inkyphat B/W 2.13 example --- rpi/examples/pimoroni_213/Makefile | 13 ++++++++++ rpi/examples/pimoroni_213/main.cpp | 39 ++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 rpi/examples/pimoroni_213/Makefile create mode 100644 rpi/examples/pimoroni_213/main.cpp diff --git a/rpi/examples/pimoroni_213/Makefile b/rpi/examples/pimoroni_213/Makefile new file mode 100644 index 0000000..f193195 --- /dev/null +++ b/rpi/examples/pimoroni_213/Makefile @@ -0,0 +1,13 @@ +CFLAGS=-D__LINUX__ -Wall -O2 -I../../ +LIBS=-lbb_epaper -lgpiod + +all: pimoroni_213 + +pimoroni_213: main.o + $(CXX) main.o $(LIBS) -o pimoroni_213 + +main.o: main.cpp + $(CXX) $(CFLAGS) -c main.cpp + +clean: + rm -rf *.o pimoroni_213 diff --git a/rpi/examples/pimoroni_213/main.cpp b/rpi/examples/pimoroni_213/main.cpp new file mode 100644 index 0000000..482ea0e --- /dev/null +++ b/rpi/examples/pimoroni_213/main.cpp @@ -0,0 +1,39 @@ +// +// C++ example for bb_epaper library +// written by Larry Bank (bitbank@pobox.com) +// Project started 9/23/2024 +// Copyright (c) 2024 BitBank Software, Inc. +// +#include +BBEPAPER bbep(EP213_122x250); +// BCM GPIO numbers used by Pimoroni e-paper "HATs" +#define PIN_DC 22 +#define PIN_RST 27 +#define PIN_BUSY 17 +#define PIN_CS 8 +#define SPI_BUS 0 + +int main(int argc, const char * argv[]) { + + bbep.initIO(PIN_DC, PIN_RST, PIN_BUSY, PIN_CS, SPI_BUS, 8000000); + bbep.allocBuffer(); // draw into RAM first + if (bbep.width() < bbep.height()) { // rotate to landscape mode + bbep.setRotation(90); + } + bbep.fillScreen(BBEP_WHITE); + bbep.setFont(FONT_12x16); + bbep.setTextColor(BBEP_BLACK); + bbep.setCursor(0,0); + bbep.println("arrrrrgh Pimoroni"); + bbep.println("Inkyphat is easy to"); + bbep.println("use in bb_epaper!"); + for (int i=20; i<50; i += 5) { + bbep.drawRoundRect(bbep.width()/2 - i, bbep.height()/2, i*2, i, 10, BBEP_BLACK); + } + bbep.writePlane(); // push the pixels from our RAM buffer to the e-epaper + bbep.refresh(REFRESH_FULL); // do a full refresh (only type possible on B/W/R) + bbep.sleep(DEEP_SLEEP); // turn off the epaper power circuit + return 0; +} /* main() */ + +