Imagegeneration for Kindle 4

Task: Generate images displayable on a Kindle 4.

Example code using Python and Pillow:

# -*- coding: utf-8 -*-
from PIL import Image, ImageDraw, ImageFont

image = Image.new("P", (600,800), 255)

# generate a 8 bit greyscale palette
def palette():
  for i in range(0,256):
    yield i;yield i; yield i

image.putpalette(
  list(palette())
)

draw = ImageDraw.Draw(image)

# needs a TrueType font
font_name = "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-Bold.ttf"
font = ImageFont.truetype(font_name, 100)
# set some text including some unicode
txt = u"TEXT \u2600 \u2602 \u2603"

draw.text((10, 0), txt, 0, font=font)
image.convert('L').save("kindle-image.png", "png")

ESP8266 Learnings

  • reducing voltage with resistors can interfere with the PULLUP of your GPIO -> don't pullup

  • a 1€ USB powerplug is crap. you get a lot of interference on your analog signal (i.e. PPD42NS)

  • always cross-check with an oscilloscope. you may be surprised how bad your sensor signal is.