Created
June 23, 2020 18:34
-
-
Save JeremySCook/58cfac2cd9474313ea778c5b1a21e278 to your computer and use it in GitHub Desktop.
Simplified image display routine for Waveshare 2.7 inch 3-color eInk display
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# @filename : main.cpp | |
# @brief : 2.9inch e-paper display (B) demo | |
# @author : Yehui from Waveshare | |
# | |
# Copyright (C) Waveshare July 31 2017 | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documnetation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in | |
# all copies or substantial portions of the Software. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
# THE SOFTWARE. | |
## | |
import epd2in7b | |
from PIL import Image | |
from PIL import ImageFont | |
from PIL import ImageDraw | |
import time | |
#import imagedata | |
COLORED = 1 | |
UNCOLORED = 0 | |
def main(): | |
epd = epd2in7b.EPD() | |
epd.init() | |
# clear the frame buffer | |
frame_black = [0] * (epd.width * epd.height / 8) | |
frame_red = [0] * (epd.width * epd.height / 8) | |
# display images | |
frame_black = epd.get_frame_buffer(Image.open('black.bmp')) | |
frame_red = epd.get_frame_buffer(Image.open('red.bmp')) | |
epd.display_frame(frame_black, frame_red) | |
time.sleep(5) | |
# clear display | |
frame_black = [0] * (epd.width * epd.height / 8) | |
frame_red = [0] * (epd.width * epd.height / 8) | |
epd.display_frame(frame_black, frame_red) | |
# You can get frame buffer from an image or import the buffer directly: | |
#epd.display_frame(imagedata.IMAGE_BLACK, imagedata.IMAGE_RED) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment