I oh so wanted to build Liz Clark's QTPy CH32V203 eInk / ePaper Daily Calendar & Clock but I didn't have much luck with booting and programming the CH32V203 board. I am no expert on how to do this. So I reversed engineered the code to Circuit Python and put in on the Huz/zah ESP32 V2 board. I also wanted some color and used the 1.54" 3 color e-ink display. I don't have a 3-D printer so I cut a strip of plexiglass and used a heat gun to put a 45-degree bend so it looks like a paper calendar. Below is my parts list I used to make this calendar.
The code is fairly simple, and I just pieced it together from Adafruit web pages. Granted I could have used WiFi to pull the time down and I may but for now I wanted to get used to playing around with DS3231 board. I used a wire wrap pen which you can get off of Amazon fairly cheap. I've added the code here as well. I am just a NOOB to programming and mostly hack at it to get it working. If you find this helpful, great. It was a fun little project.
- Huz/zah ESP32 V2 Feather ID 5400
- Adafruit EYSSPI Flex Cable 50mm ID 5462
- Adafruit EYESPI Breakout Board 18 Pin Connector ID 5613
- Adafruit 1.54" Tri-Color eInk / ePaper Display 200x200 with EYESPI ID 4868
- Adafruit DS3231 Precision RCT Breakout Board ID 3013
- STEMMA QT / Qwiic JST SH 4 pin Cable 50MM ID 4399
- Rainbow Wire Wrap ID 4730
- Black Nylon Machine Screws and Stand offs M2.5 ID 3299
Wire connection table
EYESPI connector --> ESP32 V2
- VIN ---> 3v
- Gnd ---> Gnd
- SCK ---> SCK
- MOSI ---> MOSI
- MISO ---> MISO
- DC ---> TX
- TCS ---> RX
- SDCS ---> Pin 33 *
- SDCS ---> Pin 27 *
Note: * I will comment, and maybe someone could tell why but Pin 22 and 37 are not in the code but without them the display would not update. So I am guessing the pins are either floating or pulled to ground.
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
"""Simple test script for 1.54" 200x200 Tri-Color display.
Supported products:
* Adafruit 1.54" Monochrome ePaper Display Breakout
* https://www.adafruit.com/product/4196 or 4668
"""
import time
import board
import displayio
import fourwire
import adafruit_ssd1681
import adafruit_ds3231
from adafruit_display_text import label
from adafruit_display_shapes.rect import Rect
from adafruit_bitmap_font import bitmap_font
import terminalio
#i2c = board.I2C() # uses board.SCL and board.SDA
i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
rtc = adafruit_ds3231.DS3231(i2c)
BLACK = 0x000000
WHITE = 0xFFFFFF
RED = 0xFF0000
FOREGROUND_COLOR = BLACK
BACKGROUND_COLOR = WHITE
RED_FOREGROUND_COLOR = RED
monthsOfYear = ("JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "Dec")
# Lookup table for names of days (nicer printing).
days = ("Mon", "Tue", "Wed", "Thur", "Fri", "Sat", "Sun")
# 0, 1, 2, 3, 4, 5, 6
# pylint: disable-msg=using-constant-test
if False: # change to True if you want to set the time!
# year, mon, date, hour, min, sec, wday, yday, isdst
t = time.struct_time((2024, 12, 19, 08, 54, 13, 3, -1, -1))
# you must set year, mon, date, hour, min, sec and weekday
# yearday is not supported, isdst can be set but we don't do anything with it at this time
print("Setting time to:", t) # uncomment for debugging
rtc.datetime = t
print(t)
displayio.release_displays()
# This pinout works on a Feather M4 and may need to be altered for other boards.
spi = board.SPI() # Uses SCK and MOSI
epd_cs = board.TX
epd_dc = board.RX
epd_reset = board.D15
epd_busy = board.D32
# Create the display object - the third color is red (0xff0000)
DISPLAY_WIDTH = 200
DISPLAY_HEIGHT = 200
# Set up Place holder for display.
d = rtc.datetime
dayOfWeekStr_text = days[int(d.tm_wday)] # Display Week Day Name
monthStr_text = monthsOfYear[int(d.tm_mon)-1]
dateStr_text = str(d.tm_mday) # Display Day
yearStr_text = str(d.tm_year) # Display Year
timeStr_text = "{:02}:{:02}:{:02}".format(d.tm_hour, d.tm_min, d.tm_sec) # Display Time of Day
# Set up fonts here
font = bitmap_font.load_font("Fonts/font_free_sans_12/font.pcf")
font1 = bitmap_font.load_font("Fonts/font_free_serif_bold_18/font.pcf")
font2 = bitmap_font.load_font("Fonts/font_free_sans_24/font.pcf")
display_bus = fourwire.FourWire(
spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000
)
time.sleep(10)
print("starting program")
display = adafruit_ssd1681.SSD1681(
display_bus, width=DISPLAY_WIDTH, height=DISPLAY_HEIGHT, busy_pin=epd_busy, highlight_color=0xFF0000, rotation=180)
display_width = display.width
main_group = displayio.Group()
background_bitmap = displayio.Bitmap(DISPLAY_WIDTH, DISPLAY_HEIGHT, 1)
# Map colors in a palette
palette = displayio.Palette(1)
palette[0] = BACKGROUND_COLOR
# Setup the Calendar Display
screen = displayio.TileGrid(background_bitmap, pixel_shader=palette)
# Create a Tilegrid with the background and put in the displayio group
main_group.append(screen)
# Create Black rectangle in display
rect = Rect(0, 0, 200, 60, fill=RED_FOREGROUND_COLOR)
main_group.append(rect)
# Create Black boader around display
rect1 = Rect(0, 0, 200, 170, outline=FOREGROUND_COLOR, stroke=2)
main_group.append(rect1)
# Display the Day of the Week Name in Black rectangle
dayOfWeekStr = label.Label(font=font2, text=dayOfWeekStr_text, color=BACKGROUND_COLOR, scale=2) # Setup Day Name
text_width = dayOfWeekStr.bounding_box[2]
x_position = (display_width - text_width) // 2 # Center position
dayOfWeekStr.x = x_position - (text_width // 2)
dayOfWeekStr.y = 28 # Adjust the y position as needed
main_group.append(dayOfWeekStr)
# Display the Month
monthStr = label.Label(font=font1, text=monthStr_text, color=FOREGROUND_COLOR, scale=2) # x=60, y=75 # Setup Month
text_width = monthStr.bounding_box[2]
x_position = (display_width - text_width) // 2 # Center position
monthStr.x = (x_position - (text_width // 2))
monthStr.y = 75 # Adjust the y position as needed
main_group.append(monthStr)
# Display the Day
dateStr = label.Label(font=font1, text=dateStr_text, color=FOREGROUND_COLOR, scale=2)# x=80, y=110 # Setup Day Number
text_width = dateStr.bounding_box[2]
x_position = (display_width - text_width) // 2 # Center position
dateStr.x = x_position - (text_width // 2)
dateStr.y = 110 # Adjust the y position as needed
main_group.append(dateStr)
# Display the Year
yearStr = label.Label(font=font1, text=yearStr_text, color=FOREGROUND_COLOR, scale=2) # x=62, y=145 # Setup Year
text_width = yearStr.bounding_box[2]
x_position = (display_width - text_width) // 2 # Center position
yearStr.x = x_position - (text_width // 2)
yearStr.y = 145 # Adjust the y position as needed
main_group.append(yearStr)
# Display the time
timeStr = label.Label(font=font1, text=timeStr_text, color=FOREGROUND_COLOR, scale=1) # x=62, y=185 # Setup Time of Day
text_width = timeStr.bounding_box[2]
x_position = (display_width - text_width) // 2 # Center position
timeStr.x = (x_position - (text_width // 2))
timeStr.y = 185 # Adjust the y position as needed
main_group.append(timeStr)
print("starting loop")
while True:
d = rtc.datetime
dayOfWeekStr.text = days[int(d.tm_wday)] # Display Week Day Name
monthStr.text = monthsOfYear[int(d.tm_mon)-1]
dateStr.text = str(d.tm_mday) # Display Day
yearStr.text = str(d.tm_year) # Display Year
timeStr.text = " {:02}:{:02}:{:02}".format(d.tm_hour, d.tm_min, d.tm_sec) # Display Time of Day
time.sleep(1) # wait a second
display.root_group = main_group
print(timeStr.text)
print("refreshing")
display.refresh()
print("going to sleep now")
time.sleep(3600) # Rest E-ink display before refreshing again
print("wake up time")
This page (EPS32 V2 eInk / ePaper Daily Calendar and Clock) was last updated on December 20, 2024.
Text editor powered by tinymce.