Skip to content

Commit a25be36

Browse files
authored
Merge pull request #3135 from adafruit/eink_uber_guide
bare eink guide examples
2 parents 693b455 + f3940cb commit a25be36

File tree

55 files changed

+2931
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2931
-0
lines changed

Bare_eInk_Guide/212x104_flexible_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" 212x104 Flexible Monochrome and IL0373 chipset
34+
ThinkInk_213_Grayscale4_T5 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 IL0373 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+
}
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: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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_213_Flex_Mono
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_213_Flex_Mono(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+
)
45+
46+
display.rotation = 3
47+
width = display.width
48+
height = display.height
49+
image = Image.new("RGB", (width, height))
50+
51+
# clear the buffer
52+
display.fill(WHITE)
53+
54+
# Get drawing object to draw on image.
55+
draw = ImageDraw.Draw(image)
56+
# empty it
57+
draw.rectangle((0, 0, width, height), fill=WHITE)
58+
59+
# Draw an outline box
60+
draw.rectangle((1, 1, width - 2, height - 2), outline=BLACK, fill=WHITE)
61+
62+
# Draw some shapes.
63+
# First define some constants to allow easy resizing of shapes.
64+
padding = 5
65+
shape_width = 30
66+
top = padding
67+
bottom = height - padding
68+
# Move left to right keeping track of the current x position for drawing shapes.
69+
x = padding
70+
# Draw an ellipse.
71+
draw.ellipse((x, top, x + shape_width, bottom), outline=BLACK, fill=WHITE)
72+
x += shape_width + padding
73+
# Draw a rectangle.
74+
draw.rectangle((x, top, x + shape_width, bottom), outline=BLACK, fill=BLACK)
75+
x += shape_width + padding
76+
# Draw a triangle.
77+
draw.polygon(
78+
[(x, bottom), (x + shape_width / 2, top), (x + shape_width, bottom)],
79+
outline=BLACK,
80+
fill=BLACK,
81+
)
82+
x += shape_width + padding
83+
# Draw an X.
84+
draw.line((x, bottom, x + shape_width, top), fill=BLACK)
85+
draw.line((x, top, x + shape_width, bottom), fill=BLACK)
86+
x += shape_width + padding
87+
88+
# Load default font.
89+
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 20)
90+
91+
draw.text((x, top), "Hello", font=font, fill=BLACK)
92+
draw.text((x, top + 20), "World!", font=font, fill=BLACK)
93+
94+
# Display image.
95+
display.image(image)
96+
97+
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)