Skip to content

Commit aefb639

Browse files
committed
bare eink guide examples
1 parent ecc17f1 commit aefb639

File tree

30 files changed

+1616
-0
lines changed

30 files changed

+1616
-0
lines changed

Bare_eInk_Guide/212x104_flex_monochrome_arduino/.uno.test.only

Whitespace-only changes.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/***************************************************
2+
Adafruit invests time and resources providing this open source code,
3+
please support Adafruit and open-source hardware by purchasing
4+
products from Adafruit!
5+
6+
Written by Limor Fried/Ladyada for Adafruit Industries.
7+
MIT license, all text above must be included in any redistribution
8+
****************************************************/
9+
10+
#include "Adafruit_ThinkInk.h"
11+
12+
#ifdef ARDUINO_ADAFRUIT_FEATHER_RP2040_THINKINK // detects if compiling for
13+
// Feather RP2040 ThinkInk
14+
#define EPD_DC PIN_EPD_DC // ThinkInk 24-pin connector DC
15+
#define EPD_CS PIN_EPD_CS // ThinkInk 24-pin connector CS
16+
#define EPD_BUSY PIN_EPD_BUSY // ThinkInk 24-pin connector Busy
17+
#define SRAM_CS -1 // use onboard RAM
18+
#define EPD_RESET PIN_EPD_RESET // ThinkInk 24-pin connector Reset
19+
#define EPD_SPI &SPI1 // secondary SPI for ThinkInk
20+
#else
21+
#define EPD_DC 10
22+
#define EPD_CS 9
23+
#define EPD_BUSY 7 // can set to -1 to not use a pin (will wait a fixed delay)
24+
#define SRAM_CS 6
25+
#define EPD_RESET 8 // can set to -1 and share with microcontroller Reset!
26+
#define EPD_SPI &SPI // primary SPI
27+
#endif
28+
29+
// 2.13" 212x104 Flexible Monochrome and IL0373 chipset
30+
ThinkInk_213_Grayscale4_T5 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY, EPD_SPI);
31+
32+
void setup() {
33+
Serial.begin(115200);
34+
while (!Serial) {
35+
delay(10);
36+
}
37+
Serial.println("Adafruit EPD full update test in mono");
38+
Serial.println("2.13 Monochrome EPD with IL0373 chipset");
39+
display.begin(THINKINK_MONO);
40+
}
41+
42+
void loop() {
43+
Serial.println("Banner demo");
44+
display.clearBuffer();
45+
display.setTextSize(3);
46+
display.setCursor((display.width() - 180) / 2, (display.height() - 24) / 2);
47+
display.setTextColor(EPD_BLACK);
48+
display.print("Monochrome");
49+
display.display();
50+
51+
delay(2000);
52+
53+
Serial.println("B/W rectangle demo");
54+
display.clearBuffer();
55+
display.fillRect(display.width() / 2, 0, display.width() / 2,
56+
display.height(), EPD_BLACK);
57+
display.display();
58+
59+
delay(2000);
60+
61+
Serial.println("Text demo");
62+
// large block of text
63+
display.clearBuffer();
64+
display.setTextSize(1);
65+
testdrawtext(
66+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur "
67+
"adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, "
68+
"fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor "
69+
"neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet "
70+
"ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a "
71+
"tortor imperdiet posuere. ",
72+
EPD_BLACK);
73+
display.display();
74+
75+
delay(2000);
76+
77+
display.clearBuffer();
78+
for (int16_t i = 0; i < display.width(); i += 4) {
79+
display.drawLine(0, 0, i, display.height() - 1, EPD_BLACK);
80+
}
81+
82+
for (int16_t i = 0; i < display.height(); i += 4) {
83+
display.drawLine(display.width() - 1, 0, 0, i, EPD_BLACK);
84+
}
85+
display.display();
86+
87+
delay(2000);
88+
}
89+
90+
void testdrawtext(const char *text, uint16_t color) {
91+
display.setCursor(0, 0);
92+
display.setTextColor(color);
93+
display.setTextWrap(true);
94+
display.print(text);
95+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# SPDX-FileCopyrightText: 2025 Scott Shawcroft, written for Adafruit Industries
2+
# SPDX-FileCopyrightText: Copyright (c) 2021 Melissa LeBlanc-Williams for Adafruit Industries
3+
#
4+
# SPDX-License-Identifier: MIT
5+
6+
"""Simple test for 2.13" 212x104 Flexible Monochrome eInk display."""
7+
8+
import time
9+
10+
import board
11+
import busio
12+
import displayio
13+
from fourwire import FourWire
14+
15+
import adafruit_il0373
16+
17+
displayio.release_displays()
18+
19+
if "EPD_MOSI" in dir(board): # Feather RP2040 ThinkInk
20+
spi = busio.SPI(board.EPD_SCK, MOSI=board.EPD_MOSI, MISO=None)
21+
epd_cs = board.EPD_CS
22+
epd_dc = board.EPD_DC
23+
epd_reset = board.EPD_RESET
24+
epd_busy = board.EPD_BUSY
25+
else:
26+
spi = board.SPI() # Uses SCK and MOSI
27+
epd_cs = board.D9
28+
epd_dc = board.D10
29+
epd_reset = board.D8 # Set to None for FeatherWing
30+
epd_busy = board.D7 # Set to None for FeatherWing
31+
32+
display_bus = FourWire(spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000)
33+
time.sleep(1)
34+
35+
display = adafruit_il0373.IL0373(
36+
display_bus, width=212, height=104, rotation=90, busy_pin=epd_busy,
37+
black_bits_inverted=False, color_bits_inverted=True, swap_rams=True
38+
)
39+
40+
g = displayio.Group()
41+
42+
pic = displayio.OnDiskBitmap("/display-ruler-640x360.bmp")
43+
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
44+
g.append(t)
45+
46+
display.root_group = g
47+
48+
display.refresh()
49+
50+
print("refreshed")
51+
52+
time.sleep(display.time_to_refresh + 5)
53+
print("waited correct time")
54+
55+
# Keep the display the same
56+
while True:
57+
time.sleep(10)
Binary file not shown.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# SPDX-FileCopyrightText: 2019 Melissa LeBlanc-Williams for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
4+
"""
5+
ePaper Display Shapes and Text demo using the Pillow Library.
6+
2.13" 212x104 Flexible Monochrome
7+
https://www.adafruit.com/product/4243
8+
"""
9+
10+
import board
11+
import busio
12+
import digitalio
13+
from PIL import Image, ImageDraw, ImageFont
14+
15+
from adafruit_epd.il0373 import Adafruit_IL0373
16+
17+
# First define some color constants
18+
WHITE = (0xFF, 0xFF, 0xFF)
19+
BLACK = (0x00, 0x00, 0x00)
20+
21+
# Next define some constants to allow easy resizing of shapes and colors
22+
BORDER = 20
23+
FONTSIZE = 24
24+
BACKGROUND_COLOR = BLACK
25+
FOREGROUND_COLOR = WHITE
26+
TEXT_COLOR = BLACK
27+
28+
# create the spi device and pins we will need
29+
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
30+
ecs = digitalio.DigitalInOut(board.CE0)
31+
dc = digitalio.DigitalInOut(board.D22)
32+
srcs = None
33+
rst = digitalio.DigitalInOut(board.D27)
34+
busy = digitalio.DigitalInOut(board.D17)
35+
36+
# give them all to our driver
37+
display = Adafruit_IL0373(104, 212,
38+
spi,
39+
cs_pin=ecs,
40+
dc_pin=dc,
41+
sramcs_pin=srcs,
42+
rst_pin=rst,
43+
busy_pin=busy,
44+
pid=4243 # special arg to use different power up
45+
)
46+
47+
display.set_black_buffer(1, True)
48+
display.set_color_buffer(0, True)
49+
display.rotation = 3
50+
width = display.width
51+
height = display.height
52+
image = Image.new("RGB", (width, height))
53+
54+
# clear the buffer
55+
display.fill(WHITE)
56+
57+
# Get drawing object to draw on image.
58+
draw = ImageDraw.Draw(image)
59+
# empty it
60+
draw.rectangle((0, 0, width, height), fill=WHITE)
61+
62+
# Draw an outline box
63+
draw.rectangle((1, 1, width - 2, height - 2), outline=BLACK, fill=WHITE)
64+
65+
# Draw some shapes.
66+
# First define some constants to allow easy resizing of shapes.
67+
padding = 5
68+
shape_width = 30
69+
top = padding
70+
bottom = height - padding
71+
# Move left to right keeping track of the current x position for drawing shapes.
72+
x = padding
73+
# Draw an ellipse.
74+
draw.ellipse((x, top, x + shape_width, bottom), outline=BLACK, fill=WHITE)
75+
x += shape_width + padding
76+
# Draw a rectangle.
77+
draw.rectangle((x, top, x + shape_width, bottom), outline=BLACK, fill=BLACK)
78+
x += shape_width + padding
79+
# Draw a triangle.
80+
draw.polygon(
81+
[(x, bottom), (x + shape_width / 2, top), (x + shape_width, bottom)],
82+
outline=BLACK,
83+
fill=BLACK,
84+
)
85+
x += shape_width + padding
86+
# Draw an X.
87+
draw.line((x, bottom, x + shape_width, top), fill=BLACK)
88+
draw.line((x, top, x + shape_width, bottom), fill=BLACK)
89+
x += shape_width + padding
90+
91+
# Load default font.
92+
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 20)
93+
94+
draw.text((x, top), "Hello", font=font, fill=BLACK)
95+
draw.text((x, top + 20), "World!", font=font, fill=BLACK)
96+
97+
# Display image.
98+
display.image(image)
99+
100+
display.display()

Bare_eInk_Guide/250x122_monochrome_arduino/.uno.test.only

Whitespace-only changes.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// SPDX-FileCopyrightText: 2025 Ladyada for Adafruit Industries
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
/***************************************************
6+
Adafruit invests time and resources providing this open source code,
7+
please support Adafruit and open-source hardware by purchasing
8+
products from Adafruit!
9+
10+
Written by Limor Fried/Ladyada for Adafruit Industries.
11+
MIT license, all text above must be included in any redistribution
12+
****************************************************/
13+
14+
#include "Adafruit_ThinkInk.h"
15+
16+
#ifdef ARDUINO_ADAFRUIT_FEATHER_RP2040_THINKINK // detects if compiling for
17+
// Feather RP2040 ThinkInk
18+
#define EPD_DC PIN_EPD_DC // ThinkInk 24-pin connector DC
19+
#define EPD_CS PIN_EPD_CS // ThinkInk 24-pin connector CS
20+
#define EPD_BUSY PIN_EPD_BUSY // ThinkInk 24-pin connector Busy
21+
#define SRAM_CS -1 // use onboard RAM
22+
#define EPD_RESET PIN_EPD_RESET // ThinkInk 24-pin connector Reset
23+
#define EPD_SPI &SPI1 // secondary SPI for ThinkInk
24+
#else
25+
#define EPD_DC 10
26+
#define EPD_CS 9
27+
#define EPD_BUSY 7 // can set to -1 to not use a pin (will wait a fixed delay)
28+
#define SRAM_CS 6
29+
#define EPD_RESET 8 // can set to -1 and share with microcontroller Reset!
30+
#define EPD_SPI &SPI // primary SPI
31+
#endif
32+
33+
// 2.13" Monochrome displays with 250x122 pixels and SSD1680Z chipset
34+
ThinkInk_213_Mono_GDEY0213B74 display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS, EPD_BUSY, EPD_SPI);
35+
36+
void setup() {
37+
Serial.begin(115200);
38+
while (!Serial) {
39+
delay(10);
40+
}
41+
Serial.println("Adafruit EPD full update test in mono");
42+
Serial.println("2.13 Monochrome EPD with SSD1680Z chipset");
43+
display.begin(THINKINK_MONO);
44+
}
45+
46+
void loop() {
47+
Serial.println("Banner demo");
48+
display.clearBuffer();
49+
display.setTextSize(3);
50+
display.setCursor((display.width() - 180) / 2, (display.height() - 24) / 2);
51+
display.setTextColor(EPD_BLACK);
52+
display.print("Monochrome");
53+
display.display();
54+
55+
delay(2000);
56+
57+
Serial.println("B/W rectangle demo");
58+
display.clearBuffer();
59+
display.fillRect(display.width() / 2, 0, display.width() / 2,
60+
display.height(), EPD_BLACK);
61+
display.display();
62+
63+
delay(2000);
64+
65+
Serial.println("Text demo");
66+
// large block of text
67+
display.clearBuffer();
68+
display.setTextSize(1);
69+
testdrawtext(
70+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur "
71+
"adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, "
72+
"fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor "
73+
"neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet "
74+
"ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a "
75+
"tortor imperdiet posuere. ",
76+
EPD_BLACK);
77+
display.display();
78+
79+
delay(2000);
80+
81+
display.clearBuffer();
82+
for (int16_t i = 0; i < display.width(); i += 4) {
83+
display.drawLine(0, 0, i, display.height() - 1, EPD_BLACK);
84+
}
85+
86+
for (int16_t i = 0; i < display.height(); i += 4) {
87+
display.drawLine(display.width() - 1, 0, 0, i, EPD_BLACK);
88+
}
89+
display.display();
90+
91+
delay(2000);
92+
}
93+
94+
void testdrawtext(const char *text, uint16_t color) {
95+
display.setCursor(0, 0);
96+
display.setTextColor(color);
97+
display.setTextWrap(true);
98+
display.print(text);
99+
}

0 commit comments

Comments
 (0)