Use the e-paper module as a to-do list

Trigger

I "Can I use it for something like an electronic paper module?" I "I'm going to forget a lot of things to do lately, so let's use it as a to-do list (something like a memo)"

What you have prepared

・ Raspberry Pi 3 model B + ・ Electronic paper module (4.2inch e-Paper Module) ・ Spacer (if you like)

procedure

Image of something like this ・ Itemize and save what to do (characters) in an appropriate text file (text.txt) -Read a text file with Python and write it to e-Paper

Write python source code

write.py


#!/usr/bin/python
# -*- coding:utf-8 -*-
import sys
import os
picdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic')
libdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib')
if os.path.exists(libdir):
    sys.path.append(libdir)

import logging
from waveshare_epd import epd4in2bc
import time
from PIL import Image,ImageDraw,ImageFont
import traceback
import RPi.GPIO as GPIO
logging.basicConfig(level=logging.DEBUG)




try:
    #erase e-paper
    logging.info("epd4in2bc Demo")
    epd = epd4in2bc.EPD()
    logging.info("init and Clear")
    epd.init()
    epd.Clear()
    time.sleep(1)
    
    #read text file
    f = open('text.txt', 'r')
    memo_text = []
    for line in f:
        memo_text.append(line)
    f.close()
    #print(memo_text)

    
    #make text figure
    im = Image.new("RGB",(400,300),"white")
    draw = ImageDraw.Draw(im)
    fig1 = Image.open('fig.png').convert("RGBA") #Load the image of Irasutoya
    draw.rectangle((0, 0, 399, 299), fill=(255, 255, 255), outline=(0, 0, 0), width=3) #Outer frame rectangle
    draw.rectangle((0, 0, 399, 50), fill=(0, 0, 0), outline=(0, 0, 0)) #Filled rectangle in the to-do list
    im.paste(fig1, (200, 150),fig1.split()[3])    

    font_path = ImageFont.truetype('/usr/share/fonts/opentype/noto/NotoSansCJK-Light.ttc',30)
    text1 = "To Do List\n"
    draw.text((10, 10), text1 , fill=(255, 255, 255), font=font_path)
   
    
    font_path = ImageFont.truetype('/usr/share/fonts/opentype/noto/NotoSansCJK-Light.ttc',24)
    i = 0
    w = 0
    while i in range(len(memo_text)):
        draw.text((10, 50 + w), "・" + memo_text[i] , fill=(0, 0, 0), font=font_path)
        w = w + 35
        i = i + 1

    im.save("./../pic/hoge.bmp")


    # Drawing on the image
    logging.info("3.read bmp file")
    HBlackimage = Image.open(os.path.join(picdir, 'hoge.bmp'))
    HRYimage = Image.open(os.path.join(picdir, 'hoge.bmp'))
    epd.display(epd.getbuffer(HBlackimage), epd.getbuffer(HRYimage))
    time.sleep(2)

    logging.info("Goto Sleep...")
    epd.sleep()
    

except IOError as e:
    logging.info(e)

except KeyboardInterrupt:
    logging.info("ctrl + c:")
    epd4in2bc.epdconfig.module_exit()
    exit()

Edit the text file as follows and place it in the same directory as write.py

text.txt


Master's thesis
Proceedings
Contact real estate agent
Drinking party tomorrow

I tried it

I felt surreal when I added the illustration of Irasutoya. IMG_3433.jpg

If you want to change the displayed item, rewrite text.text and then run the Python code again to update to the changed item.

Recommended Posts

Use the e-paper module as a to-do list
Use Remotte as a user
Extract the value of dict or list as a string
Use DynamoDB as a lock manager
Use pymol as a python library
How to use the optparse module
How to use the ConfigParser module
Precautions when using a list or dictionary as the default argument
Use youtube_dl as a python module. appendix) Nico Nico Douga HTTP 403 error
Create a graph using the Sympy module
Change the list in a for statement
Push the hash list into VT and receive the detection result as a list
Use BMFont as the font for pyglet
I want to see a list of WebDAV files in the Requests module
A note on customizing the dict list class
Make a copy of the list in Python
Write a TCP server using the SocketServer module
Get only the subclass elements in a list
Use the Kaggle API inside a Docker container
[Python] A rough understanding of the logging module
A simple to-do list created with Python + Django
A python amateur tries to summarize the list ②
Use the nghttp2 Python module from Homebrew from pyenv's Python
As a beginner, I searched the / proc directory
Use Flask as the next step for SimpleHTTPServer
Tips for Python beginners to use the Scikit-image example for themselves 7 How to make a module
use go module
Get the variable name of the variable as a character string.
How to use the Raspberry Pi relay module Python
[python] Get the list of classes defined in the module
Create a Todo app with the Django REST framework
Make a note of the list of basic Pandas usage
Create a Todo app with Django ③ Create a task list page
[Blender] Use the text drawing module from within the script
Let's use the Python version of the Confluence API module.
Specify MinGW as the compiler to use with Python
Output the output result of sklearn.metrics.classification_report as a CSV file
Creating a list when the nomenclature is a fixed time
Use KNP as a Universal Dependency parser with spaCy