[{"element_type":"text","content":"\n        \u003cp\u003eI oh so wanted to build Liz Clark's QTPy CH32V203 eInk / ePaper Daily Calendar \u0026amp; Clock but I didn't have much luck with booting and programming the CH32V203 board.\u0026nbsp; 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.\u0026nbsp; 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.\u0026nbsp; \u0026nbsp;Below is my parts list I used to make this calendar.\u0026nbsp;\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eThe code is fairly simple, and I just pieced it together from Adafruit web pages.\u0026nbsp; 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.\u0026nbsp; I've added the code here as well.\u0026nbsp; I am just a NOOB to programming and mostly hack at it to get it working.\u0026nbsp; If you find this helpful, great.\u0026nbsp; It was a fun little project.\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eHuz/zah ESP32 V2 Feather ID 5400\u003c/li\u003e\n\u003cli\u003eAdafruit EYSSPI Flex Cable 50mm ID 5462\u003c/li\u003e\n\u003cli\u003eAdafruit EYESPI Breakout Board 18 Pin Connector ID 5613\u003c/li\u003e\n\u003cli\u003eAdafruit 1.54\" Tri-Color eInk / ePaper Display 200x200 with EYESPI ID 4868\u003c/li\u003e\n\u003cli\u003eAdafruit DS3231 Precision RCT Breakout Board ID 3013\u003c/li\u003e\n\u003cli\u003eSTEMMA QT / Qwiic JST SH 4 pin Cable 50MM\u0026nbsp; ID 4399\u003c/li\u003e\n\u003cli\u003eRainbow Wire Wrap ID 4730\u003c/li\u003e\n\u003cli\u003eBlack Nylon Machine Screws and Stand offs M2.5 ID 3299\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003e\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eWire connection table\u003c/p\u003e\n\u003cp\u003eEYESPI connector\u0026nbsp; \u0026nbsp;--\u0026gt;\u0026nbsp; ESP32 V2\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eVIN\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; ---\u0026gt;\u0026nbsp; \u0026nbsp; 3v\u003c/li\u003e\n\u003cli\u003eGnd\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;---\u0026gt;\u0026nbsp; \u0026nbsp; Gnd\u003c/li\u003e\n\u003cli\u003eSCK\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;---\u0026gt;\u0026nbsp; \u0026nbsp; SCK\u003c/li\u003e\n\u003cli\u003eMOSI\u0026nbsp; \u0026nbsp; \u0026nbsp;---\u0026gt;\u0026nbsp; \u0026nbsp;MOSI\u003c/li\u003e\n\u003cli\u003eMISO\u0026nbsp; \u0026nbsp; \u0026nbsp;---\u0026gt;\u0026nbsp; \u0026nbsp;MISO\u003c/li\u003e\n\u003cli\u003eDC\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;---\u0026gt;\u0026nbsp; \u0026nbsp;TX\u003c/li\u003e\n\u003cli\u003eTCS\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;---\u0026gt;\u0026nbsp; \u0026nbsp;RX\u003c/li\u003e\n\u003cli\u003eSDCS\u0026nbsp; \u0026nbsp; ---\u0026gt;\u0026nbsp; \u0026nbsp;Pin 33 *\u003c/li\u003e\n\u003cli\u003eSDCS\u0026nbsp; \u0026nbsp; ---\u0026gt;\u0026nbsp; \u0026nbsp;Pin 27 *\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eNote: *\u0026nbsp; 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.\u0026nbsp; So I am guessing the pins are either floating or pulled to ground.\u003c/p\u003e\n\u003cp\u003e\u0026nbsp;\u003c/p\u003e\n\u003cp\u003e\u0026nbsp;\u003c/p\u003e\n      ","metadata":{}},{"element_type":"user_image","content":"https://cdn-learn.adafruit.com/user_assets/assets/000/001/460/original/17347163351764063439386209293384.jpg?1734716365","metadata":{"caption":""}},{"element_type":"user_image","content":"https://cdn-learn.adafruit.com/user_assets/assets/000/001/461/original/17347163768974205324365942582586.jpg?1734716416","metadata":{"caption":""}},{"element_type":"code","content":"# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries\n# SPDX-License-Identifier: MIT\n\n\"\"\"Simple test script for 1.54\" 200x200 Tri-Color display.\n\nSupported products:\n  * Adafruit 1.54\" Monochrome ePaper Display Breakout\n    * https://www.adafruit.com/product/4196 or 4668\n  \"\"\"\n\nimport time\nimport board\nimport displayio\nimport fourwire\nimport adafruit_ssd1681\nimport adafruit_ds3231\nfrom adafruit_display_text import label\nfrom adafruit_display_shapes.rect import Rect\nfrom adafruit_bitmap_font import bitmap_font\nimport terminalio\n\n#i2c = board.I2C()  # uses board.SCL and board.SDA\ni2c = board.STEMMA_I2C()  # For using the built-in STEMMA QT connector on a microcontroller\nrtc = adafruit_ds3231.DS3231(i2c)\n\nBLACK = 0x000000\nWHITE = 0xFFFFFF\nRED = 0xFF0000\n\n\nFOREGROUND_COLOR = BLACK\nBACKGROUND_COLOR = WHITE\nRED_FOREGROUND_COLOR = RED\n\nmonthsOfYear = (\"JAN\", \"FEB\", \"MAR\", \"APR\", \"MAY\", \"JUN\", \"JUL\", \"AUG\", \"SEP\", \"OCT\", \"NOV\", \"Dec\")\n\n# Lookup table for names of days (nicer printing).\ndays = (\"Mon\", \"Tue\", \"Wed\", \"Thur\", \"Fri\", \"Sat\", \"Sun\")\n#         0,     1,     2,     3,      4,     5,     6\n\n# pylint: disable-msg=using-constant-test\nif False:  # change to True if you want to set the time!\n    #                     year, mon, date, hour, min, sec, wday, yday, isdst\n    t = time.struct_time((2024, 12, 19, 08, 54, 13, 3, -1, -1))\n    # you must set year, mon, date, hour, min, sec and weekday\n    # yearday is not supported, isdst can be set but we don't do anything with it at this time\n    print(\"Setting time to:\", t)  # uncomment for debugging\n    rtc.datetime = t\n    print(t)\n\ndisplayio.release_displays()\n\n# This pinout works on a Feather M4 and may need to be altered for other boards.\nspi = board.SPI()  # Uses SCK and MOSI\nepd_cs = board.TX\nepd_dc = board.RX\nepd_reset = board.D15\nepd_busy = board.D32\n\n# Create the display object - the third color is red (0xff0000)\nDISPLAY_WIDTH = 200\nDISPLAY_HEIGHT = 200\n\n# Set up Place holder for display.\nd = rtc.datetime\ndayOfWeekStr_text = days[int(d.tm_wday)] # Display Week Day Name\nmonthStr_text = monthsOfYear[int(d.tm_mon)-1]\ndateStr_text = str(d.tm_mday) # Display Day\nyearStr_text = str(d.tm_year) # Display Year\ntimeStr_text = \"{:02}:{:02}:{:02}\".format(d.tm_hour, d.tm_min, d.tm_sec) # Display Time of Day\n\n# Set up fonts here\nfont = bitmap_font.load_font(\"Fonts/font_free_sans_12/font.pcf\")\nfont1 = bitmap_font.load_font(\"Fonts/font_free_serif_bold_18/font.pcf\")\nfont2 = bitmap_font.load_font(\"Fonts/font_free_sans_24/font.pcf\")\n\ndisplay_bus = fourwire.FourWire(\n    spi, command=epd_dc, chip_select=epd_cs, reset=epd_reset, baudrate=1000000\n)\n\ntime.sleep(10)\nprint(\"starting program\")\ndisplay = adafruit_ssd1681.SSD1681(\n    display_bus, width=DISPLAY_WIDTH, height=DISPLAY_HEIGHT, busy_pin=epd_busy, highlight_color=0xFF0000, rotation=180)\ndisplay_width = display.width\n\nmain_group = displayio.Group()\n\nbackground_bitmap = displayio.Bitmap(DISPLAY_WIDTH, DISPLAY_HEIGHT, 1)\n# Map colors in a palette\npalette = displayio.Palette(1)\npalette[0] = BACKGROUND_COLOR\n\n# Setup the Calendar Display\nscreen = displayio.TileGrid(background_bitmap, pixel_shader=palette)\n\n# Create a Tilegrid with the background and put in the displayio group\nmain_group.append(screen)\n\n# Create Black rectangle in display\nrect = Rect(0, 0, 200, 60, fill=RED_FOREGROUND_COLOR)\nmain_group.append(rect)\n\n# Create Black boader around display\nrect1 = Rect(0, 0, 200, 170, outline=FOREGROUND_COLOR, stroke=2)\nmain_group.append(rect1)\n\n# Display the Day of the Week Name in Black rectangle\ndayOfWeekStr = label.Label(font=font2, text=dayOfWeekStr_text, color=BACKGROUND_COLOR, scale=2) # Setup Day Name\ntext_width = dayOfWeekStr.bounding_box[2]\nx_position = (display_width - text_width) // 2 # Center position\ndayOfWeekStr.x = x_position - (text_width // 2)\ndayOfWeekStr.y = 28 # Adjust the y position as needed\nmain_group.append(dayOfWeekStr)\n\n# Display the Month\nmonthStr = label.Label(font=font1, text=monthStr_text, color=FOREGROUND_COLOR, scale=2) # x=60, y=75 # Setup Month\ntext_width = monthStr.bounding_box[2]\nx_position = (display_width - text_width) // 2 # Center position\nmonthStr.x = (x_position - (text_width // 2))\nmonthStr.y = 75 # Adjust the y position as needed\nmain_group.append(monthStr)\n\n# Display the Day\ndateStr = label.Label(font=font1, text=dateStr_text, color=FOREGROUND_COLOR, scale=2)# x=80, y=110 # Setup Day Number\ntext_width = dateStr.bounding_box[2]\nx_position = (display_width - text_width) // 2 # Center position\ndateStr.x = x_position  - (text_width // 2)\ndateStr.y = 110 # Adjust the y position as needed\nmain_group.append(dateStr)\n\n# Display the Year\nyearStr = label.Label(font=font1, text=yearStr_text, color=FOREGROUND_COLOR, scale=2) # x=62, y=145 # Setup Year\ntext_width = yearStr.bounding_box[2]\nx_position = (display_width - text_width) // 2 # Center position\nyearStr.x = x_position  - (text_width // 2)\nyearStr.y = 145 # Adjust the y position as needed\nmain_group.append(yearStr)\n\n# Display the time\ntimeStr = label.Label(font=font1, text=timeStr_text, color=FOREGROUND_COLOR, scale=1) # x=62, y=185 # Setup Time of Day\ntext_width = timeStr.bounding_box[2]\nx_position = (display_width - text_width) // 2 # Center position\ntimeStr.x = (x_position - (text_width // 2))\ntimeStr.y = 185 # Adjust the y position as needed\nmain_group.append(timeStr)\n\nprint(\"starting loop\")\nwhile True:\n    d = rtc.datetime\n    dayOfWeekStr.text = days[int(d.tm_wday)] # Display Week Day Name\n    monthStr.text = monthsOfYear[int(d.tm_mon)-1]\n    dateStr.text = str(d.tm_mday) # Display Day\n    yearStr.text = str(d.tm_year) # Display Year\n    timeStr.text = \"      {:02}:{:02}:{:02}\".format(d.tm_hour, d.tm_min, d.tm_sec) # Display Time of Day\n    time.sleep(1)  # wait a second\n    display.root_group = main_group\n    print(timeStr.text)\n    print(\"refreshing\")\n    display.refresh()\n    print(\"going to sleep now\")\n    time.sleep(3600) # Rest E-ink display before refreshing again\n    print(\"wake up time\")","metadata":{"language":"auto","linenums":false}}]