Skip to content

Instantly share code, notes, and snippets.

@libbymiller libbymiller/screenshot.py
Last active Apr 19, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.