Close

Another screen

A project log for PolaPi-Zero

Yet another Polaroid-like camera. Now with flavor! RapsberryPi Zero, Python, Memory-LCD, less wiring. It's all about monochrome.

MuthMuth 03/29/2017 at 16:420 Comments

As said, the memory LCD choice was mainly because it was already lying on a box somewhere in the possibly-will-be-useful pile of stuff. However it's not easy to find and not easy to solder.

I had a bit of time to quickly test what could be the result with a cheap oled screen. The 128x64 monochome OLED based on the SSD1305 /6 are quite common.

I used the Adafruit python SSD1306 library and the python picamera one. It gives funny results (too bad PIL library not implements ordered dithering instead of Floydsteinberg) but it's really at the lower resolution limit for a useful viewfinder :

Preview code is quick and dirty :

'''
Created on March 13, 2017
@author: muth
'''
from __future__ import print_function
from io import BytesIO
from time import sleep
import picamera
from PIL import Image
from time import sleep
import time
import Adafruit_SSD1306

S_WIDTH = 128
S_HEIGHT = 64
S_SIZE = (S_WIDTH, S_HEIGHT)
P_WIDTH = 768
P_HEIGHT = 384
P_SIZE = (P_WIDTH, P_HEIGHT)

class MyOutput(object):
    def __init__(self):
        self.size = 0

    def write(self, s):
        global oled
        
        image = Image.frombuffer('L', P_SIZE, s, "raw", 'L', 0, 1)
        image.thumbnail(S_SIZE, Image.NEAREST)
        image = image.convert('1', dither=Image.FLOYDSTEINBERG)
#         image = image.convert('1', dither=Image.NONE)
        oled.image(image)
        oled.display()

# Initialize oled.
oled = Adafruit_SSD1306.SSD1306_128_64(rst=24)
oled.begin()
oled.clear()
oled.display()
oled.set_contrast(2)

with picamera.PiCamera() as camera:
    camera.rotation = 180
    camera.resolution = P_SIZE
    camera.framerate = 60
    camera.contrast = 50
#     camera.start_preview()
    camera.start_recording(MyOutput(), format='yuv', resize=P_SIZE)
    sleep(30)
    camera.stop_recording()
    sleep(1)

Discussions