Skip to content

Instantly share code, notes, and snippets.

@libbymiller
Last active April 19, 2018 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save libbymiller/8fe783397e342ce6f2747964158c899d to your computer and use it in GitHub Desktop.
Save libbymiller/8fe783397e342ce6f2747964158c899d to your computer and use it in GitHub Desktop.
e-ink chromium waveshare
import epd7in5
import Image
import ImageDraw
import ImageFont
EPD_WIDTH = 640
EPD_HEIGHT = 384
def main():
epd = epd7in5.EPD()
epd.init()
# For simplicity, the arguments are explicit numerical coordinates
image = Image.new('1', (EPD_WIDTH, EPD_HEIGHT), 1) # 1: clear the frame
draw = ImageDraw.Draw(image)
image = Image.open('screenshot.png')
epd.display_frame(epd.get_frame_buffer(image))
if __name__ == '__main__':
main()
# this is lightly edited version of @andrewn's work: https://github.com/andrewn/resin-epaper to work with the waveshare 7.5"
import epd7in5
import Image
import ImageDraw
import ImageFont
EPD_WIDTH = 640
EPD_HEIGHT = 384
def main():
epd = epd7in5.EPD()
epd.init()
# For simplicity, the arguments are explicit numerical coordinates
image = Image.new('1', (EPD_WIDTH, EPD_HEIGHT), 1) # 1: clear the frame
draw = ImageDraw.Draw(image)
image = Image.open('screenshot.png')
epd.display_frame(epd.get_frame_buffer(image))
if __name__ == '__main__':
main()
echo "Running at $(date -R)"
echo "Timezone is $TZ"
# Take a screenshot
chromium-browser --headless --disable-gpu --no-sandbox --hide-scrollbars --screenshot --window-size=640,384 https://www.bbc.co.uk/
# xargs trims surrounding whitespace
nextFileHash=$(sha1sum screenshot.png | xargs)
lastFileHash=$(cat last-file-hash.txt | xargs)
echo "Comparing hashes"
echo $lastFileHash
echo $nextFileHash
if [ "$nextFileHash" == "$lastFileHash" ]; then
echo "screenshot is the same, exiting"
exit 0
fi
echo $nextFileHash > last-file-hash.txt
# Rotate screenshot
# Because the output from chromium gets messed up when
# the display rotates it
##convert screenshot.png -colorspace gray +matte -depth 2 -rotate -90 screenshot.png
convert screenshot.png -colorspace gray +matte -depth 2 screenshot.png
# Draw nice logo
python screenshot.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment