KE0158 keyes 电子墨水屏 1.54寸 200*200分辨率 红色环保

KE0158-1

说明

当我们在DIY实验时,经常需要用到显示屏。keyes 电子墨水屏模块上带有一个1.54寸的显示屏,显示颜色为黑白色,分辨率为200*200。模块通过SPI通讯,可动态显示图案。

为了方便你使用,我们还提供显示屏模块和arduino单片机、树莓派搭配使用的详细方法。同时,为了方便将模块固定在其他设备上,模块自带4个直径为3mm的定位孔。

特别注意:测试时,我们使用的是1.8.9版本的IDE软件测试,如果使用其他版本IDE,

代码可能出现不兼容现象。

技术参数

工作电压: DC 5V

工作电流:150mA

最大功率:0.75W

显示屏颜色:黑白色

显示屏大小:1.54寸

显示屏分辨率:200*200

接口类型:间距为2.54mm的8pin排针

工作温度范围:-20℃到+60℃

定位孔大小:直径3mm

尺寸:56*45*7mm

重量:15.2g

  1. 接线方法

UNO板连接方法

KE0158

树莓派连接方法

KE0158

  1. 测试代码链接

Arduino代码

#include <SPI.h>

#include “epd1in54_V2.h”

#include “imagedata.h”

Epd epd;

void setup()

{

// put your setup code here, to run once:

Serial.begin(9600);

if (epd.Init() != 0) {

Serial.println(“e-Paper init failed”);

return;

}

/*

Serial.println(“e-Paper clear”);

epd.Clear();

Serial.println(“e-Paper show pic”);

epd.Display(IMAGE_DATA);

Serial.println(“e-Paper clear and sleep”);

epd.Clear();

epd.Sleep();

*/

}

void loop()

{

epd.Display(IMAGE_DATA);

delay(1000);

epd.Display(IMAGE_DATA1);

delay(1000);

}

树莓派代码(python)

#!/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 epd1in54_V2

import time

from PIL import Image,ImageDraw,ImageFont

import traceback

logging.basicConfig(level=logging.DEBUG)

try:

logging.info(“epd1in54_V2 Demo”)

epd = epd1in54_V2.EPD()

logging.info(“init and Clear”)

epd.init()

epd.Clear(0xFF)

time.sleep(1)

# Drawing on the image

logging.info(“1.Drawing on the image…”)

image = Image.new(‘1’, (epd.width, epd.height), 255) # 255: clear the frame

draw = ImageDraw.Draw(image)

font = ImageFont.truetype(os.path.join(picdir, ‘Font.ttc’), 24)

draw.rectangle((0, 10, 200, 34), fill = 0)

draw.text((8, 12), ‘hello world’, font = font, fill = 255)

draw.text((8, 36), u’keyestudio’, font = font, fill = 0)

draw.line((16, 60, 56, 60), fill = 0)

draw.line((56, 60, 56, 110), fill = 0)

draw.line((16, 110, 56, 110), fill = 0)

draw.line((16, 110, 16, 60), fill = 0)

draw.line((16, 60, 56, 110), fill = 0)

draw.line((56, 60, 16, 110), fill = 0)

draw.arc((90, 60, 150, 120), 0, 360, fill = 0)

draw.rectangle((16, 130, 56, 180), fill = 0)

draw.chord((90, 130, 150, 190), 0, 360, fill = 0)

epd.display(epd.getbuffer(image.rotate(90)))

time.sleep(2)

# read bmp file

logging.info(“2.read bmp file…”)

image = Image.open(os.path.join(picdir, ‘1in54.bmp’))

epd.display(epd.getbuffer(image))

time.sleep(2)

# read bmp file on window

# logging.info(“3.read bmp file on window…”)

# epd.Clear(0xFF)

# image1 = Image.new(‘1’, (epd.width, epd.height), 255) # 255: clear the frame

# bmp = Image.open(os.path.join(picdir, ‘100×100.bmp’))

# image1.paste(bmp, (50,50))

# epd.display(epd.getbuffer(image1))

# time.sleep(2)

# partial update

logging.info(“4.show time…”)

time_image = Image.new(‘1’, (epd.width, epd.height), 255)

epd.displayPartBaseImage(epd.getbuffer(time_image))

time_draw = ImageDraw.Draw(time_image)

num = 0

while (True):

time_draw.rectangle((10, 10, 120, 50), fill = 255)

time_draw.text((10, 10), time.strftime(‘%H:%M:%S’), font = font, fill = 0)

newimage = time_image.crop([10, 10, 120, 50])

time_image.paste(newimage, (10,10))

epd.displayPart(epd.getbuffer(time_image))

num = num + 1

if(num == 10):

break

logging.info(“Clear…”)

epd.init()

epd.Clear(0xFF)

logging.info(“Goto Sleep…”)

epd.sleep()

except IOError as e:

logging.info(e)

except KeyboardInterrupt:

logging.info(“ctrl + c:”)

epd1in54_V2.epdconfig.module_exit()

exit()

  1. Arduino代码设置方法
  2. 设置时,我们需要安装Image2Lcd取模软件,安装后,利用注册码注册。
  3. 利用画图软件,画出你需要的图案,导出设置为黑白色,像素设置为200*200。
  4. 打开取模软件,设置如下图。

  1. 点击打开,选择你导出的图案,如下图。

正显(白底黑字),则“颜色反转”打钩;负显(黑底白字)则不需要打钩。

  1. 点击 ,即可生成对应的C语言代码,如下图。

  1. 将生成的C语言代码,复制到代码中的const unsigned char IMAGE_DATA[] PROGMEM位置,如下图。

  1. 树莓派设置方法
  2. 按照树莓派接线方法,将模块接到树莓派上(我的是树莓派4B)
  3. 打开树莓派终端,输入以下指令进入配置界面,开启SPI接口功能。

sudo raspi-config

Interfacing Options -> SPI -> Yes

然后重启树莓派。

sudo reboot

  1. 在树莓派终端,并运行以下指令,安装BCM2835库文件。

wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.60.tar.gz

tar zxvf bcm2835-1.60.tar.gz

cd bcm2835-1.60/

sudo ./configure

sudo make

sudo make check

sudo make install

  1. 安装完驱动后,在pi文件夹内可以看到bcm2835-1.60文件夹。

  1. 将keyestudio-e-Paper压缩包,复制到bcm2835-1.60文件夹。并解压到bcm2835-1.60文件夹。生成的keyestudio-e-Paper文件夹带有测试代码和相关设置文件。

  1. 通过以下指令,控制水墨屏显示不同图案。

cd bcm2835-1.60/keyestudio-e-Paper/python/examples/

ls

Sudo python epd_1in54_V2_test.py

  1. 特别注意,在实验中,设置代码时,我们需要调用显示图案。显示图案的路径为/home/pi/bcm2835-1.60/keyestudio-e-Paper/python/pic

图案的像素是200*200。

  1. 测试结果

按照接线图接线,上传测试代码成功,上电后,显示屏会循环显示各种图案。

  1. 相关资料链接

https://pan.baidu.com/s/1dSinjzt0MrR2xqqAbb_xkQ

提取码:3d67