Skip to content

Commit f3940cb

Browse files
committed
last couple
1 parent 7040a65 commit f3940cb

File tree

12 files changed

+527
-0
lines changed

12 files changed

+527
-0
lines changed

Bare_eInk_Guide/416x240_monochrome_arduino/.uno.test.only

Whitespace-only changes.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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+
// 3.7" Monochrome Display with 420x240 pixels and UC8253 chipset
34+
ThinkInk_370_Mono_BAAMFGN display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS,
35+
EPD_BUSY, EPD_SPI);
36+
37+
void setup() {
38+
Serial.begin(115200);
39+
while (!Serial) {
40+
delay(10);
41+
}
42+
Serial.println("Adafruit EPD full update test in mono");
43+
Serial.println("3.7 Monochrome EPD with UC8253 chipset");
44+
display.begin(THINKINK_MONO);
45+
}
46+
47+
void loop() {
48+
Serial.println("Banner demo");
49+
display.clearBuffer();
50+
display.setTextSize(3);
51+
display.setCursor((display.width() - 180) / 2, (display.height() - 24) / 2);
52+
display.setTextColor(EPD_BLACK);
53+
display.print("Monochrome");
54+
display.display();
55+
56+
delay(2000);
57+
58+
Serial.println("B/W rectangle demo");
59+
display.clearBuffer();
60+
display.fillRect(display.width() / 2, 0, display.width() / 2,
61+
display.height(), EPD_BLACK);
62+
display.display();
63+
64+
delay(2000);
65+
66+
Serial.println("Text demo");
67+
// large block of text
68+
display.clearBuffer();
69+
display.setTextSize(1);
70+
testdrawtext(
71+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur "
72+
"adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, "
73+
"fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor "
74+
"neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet "
75+
"ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a "
76+
"tortor imperdiet posuere. ",
77+
EPD_BLACK);
78+
display.display();
79+
80+
delay(2000);
81+
82+
display.clearBuffer();
83+
for (int16_t i = 0; i < display.width(); i += 4) {
84+
display.drawLine(0, 0, i, display.height() - 1, EPD_BLACK);
85+
}
86+
87+
for (int16_t i = 0; i < display.height(); i += 4) {
88+
display.drawLine(display.width() - 1, 0, 0, i, EPD_BLACK);
89+
}
90+
display.display();
91+
92+
delay(2000);
93+
}
94+
95+
void testdrawtext(const char *text, uint16_t color) {
96+
display.setCursor(0, 0);
97+
display.setTextColor(color);
98+
display.setTextWrap(true);
99+
display.print(text);
100+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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: Unlicense
5+
6+
"""Simple test script for 3.7" 240x416 monochrome display (ThinkInk_370_Mono_BAAMFGN)."""
7+
8+
import time
9+
10+
import board
11+
import busio
12+
import displayio
13+
from fourwire import FourWire
14+
15+
import adafruit_uc8253
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_uc8253.UC8253(
36+
display_bus,
37+
width=416,
38+
height=240,
39+
busy_pin=epd_busy,
40+
rotation=270,
41+
vcom_cdi=0x97,
42+
)
43+
44+
g = displayio.Group()
45+
46+
pic = displayio.OnDiskBitmap("/display-ruler-1280x720.bmp")
47+
t = displayio.TileGrid(pic, pixel_shader=pic.pixel_shader)
48+
g.append(t)
49+
50+
display.root_group = g
51+
52+
display.refresh()
53+
54+
print("refreshed")
55+
56+
time.sleep(display.time_to_refresh + 5)
57+
print("waited correct time")
58+
59+
# Keep the display the same
60+
while True:
61+
time.sleep(10)
Binary file not shown.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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+
3.7" Monochrome 416x240 display
7+
https://www.adafruit.com/product/6395
8+
"""
9+
10+
import board
11+
import busio
12+
import digitalio
13+
from PIL import Image, ImageDraw, ImageFont
14+
15+
from adafruit_epd.uc8253 import Adafruit_UC8253_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+
display = Adafruit_UC8253_Mono(240, 416,
37+
spi,
38+
cs_pin=ecs,
39+
dc_pin=dc,
40+
sramcs_pin=srcs,
41+
rst_pin=rst,
42+
busy_pin=busy
43+
)
44+
45+
display.set_black_buffer(1, True)
46+
display.set_color_buffer(1, True)
47+
display.rotation = 3
48+
49+
width = display.width
50+
height = display.height
51+
image = Image.new("RGB", (width, height))
52+
53+
# clear the buffer
54+
display.fill(WHITE)
55+
56+
# Get drawing object to draw on image.
57+
draw = ImageDraw.Draw(image)
58+
# empty it
59+
draw.rectangle((0, 0, width, height), fill=WHITE)
60+
61+
# Draw an outline box
62+
draw.rectangle((1, 1, width - 2, height - 2), outline=BLACK, fill=WHITE)
63+
64+
# Draw some shapes.
65+
# First define some constants to allow easy resizing of shapes.
66+
padding = 15
67+
shape_width = 45
68+
top = padding
69+
bottom = height - padding
70+
# Move left to right keeping track of the current x position for drawing shapes.
71+
x = padding
72+
# Draw an ellipse.
73+
draw.ellipse((x, top, x + shape_width, bottom), outline=BLACK, fill=WHITE)
74+
x += shape_width + padding
75+
# Draw a rectangle.
76+
draw.rectangle((x, top, x + shape_width, bottom), outline=BLACK, fill=BLACK)
77+
x += shape_width + padding
78+
# Draw a triangle.
79+
draw.polygon(
80+
[(x, bottom), (x + shape_width / 2, top), (x + shape_width, bottom)],
81+
outline=BLACK,
82+
fill=BLACK,
83+
)
84+
x += shape_width + padding
85+
# Draw an X.
86+
draw.line((x, bottom, x + shape_width, top), fill=BLACK)
87+
draw.line((x, top, x + shape_width, bottom), fill=BLACK)
88+
x += shape_width + padding
89+
90+
# Load default font.
91+
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 30)
92+
93+
draw.text((x, top), "Hello", font=font, fill=BLACK)
94+
draw.text((x, top + 30), "World!", font=font, fill=BLACK)
95+
96+
# Display image.
97+
display.image(image)
98+
99+
display.display()

Bare_eInk_Guide/416x240_tricolor_arduino/.uno.test.only

Whitespace-only changes.
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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+
// 3.7" Tricolor Display with 417x240 pixels and UC8253 chipset
34+
ThinkInk_370_Tricolor_BABMFGNR display(EPD_DC, EPD_RESET, EPD_CS, SRAM_CS,
35+
EPD_BUSY, EPD_SPI);
36+
37+
void setup() {
38+
Serial.begin(115200);
39+
while (!Serial) {
40+
delay(10);
41+
}
42+
Serial.println("Adafruit EPD full update test in red/black/white");
43+
Serial.println("3.7 Tri-Color EPD with UC8253 chipset");
44+
display.begin(THINKINK_TRICOLOR);
45+
}
46+
47+
void loop() {
48+
Serial.println("Banner demo");
49+
display.clearBuffer();
50+
display.setTextSize(3);
51+
display.setCursor((display.width() - 144) / 2, (display.height() - 24) / 2);
52+
display.setTextColor(EPD_BLACK);
53+
display.print("Tri");
54+
display.setTextColor(EPD_RED);
55+
display.print("Color");
56+
display.display();
57+
58+
delay(15000);
59+
60+
Serial.println("Color rectangle demo");
61+
display.clearBuffer();
62+
display.fillRect(display.width() / 3, 0, display.width() / 3,
63+
display.height(), EPD_BLACK);
64+
display.fillRect((display.width() * 2) / 3, 0, display.width() / 3,
65+
display.height(), EPD_RED);
66+
display.display();
67+
68+
delay(15000);
69+
70+
Serial.println("Text demo");
71+
// large block of text
72+
display.clearBuffer();
73+
display.setTextSize(1);
74+
testdrawtext(
75+
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur "
76+
"adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, "
77+
"fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor "
78+
"neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet "
79+
"ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a "
80+
"tortor imperdiet posuere. ",
81+
EPD_BLACK);
82+
display.display();
83+
84+
delay(15000);
85+
86+
display.clearBuffer();
87+
for (int16_t i = 0; i < display.width(); i += 4) {
88+
display.drawLine(0, 0, i, display.height() - 1, EPD_BLACK);
89+
}
90+
91+
for (int16_t i = 0; i < display.height(); i += 4) {
92+
display.drawLine(display.width() - 1, 0, 0, i, EPD_RED);
93+
}
94+
display.display();
95+
96+
delay(15000);
97+
}
98+
99+
void testdrawtext(const char *text, uint16_t color) {
100+
display.setCursor(0, 0);
101+
display.setTextColor(color);
102+
display.setTextWrap(true);
103+
display.print(text);
104+
}

0 commit comments

Comments
 (0)