Beispiel #1
0
lcd = SMemLCD(args.device)

img = PIL.Image.new('1', (WIDTH, HEIGHT))
draw = PIL.ImageDraw.Draw(img)
if args.font:
    font = PIL.ImageFont.truetype(args.font[0], size=30)
else:
    font = PIL.ImageFont.load_default()

for i in range(60, -1, -1):
    img.paste(0)

    center(draw, 60, 'smemlcd library demo', font)

    s = 'closing in {:02d}...'.format(i)
    center(draw, 100, s, font)

    draw.arc(((180, 180), (220, 220)), 0, 360, fill='white')
    draw.pieslice(((180, 180), (220, 220)),
                  -90, (60 - i) * 6 - 90,
                  outline='white')

    t1 = time.time()
    lcd.write(img.tobytes())
    print('lcd writing time', round(time.time() - t1, 4))

    time.sleep(1)

# vim: sw=4:et:ai
Beispiel #2
0
    # View Loop
    stream.seek(0)
    for foo in camera.capture_continuous(stream,
                                         format='jpeg',
                                         use_video_port=True,
                                         resize=(S_WIDTH, S_HEIGHT),
                                         splitter_port=1):
        t1 = time.time()
        stream.seek(
            0
        )  # "Rewind" the stream to the beginning so we can read its content
        image_source = Image.open(stream)
        imageInverted = ImageOps.invert(image_source)

        # convert image to black or white and send to LCD
        lcd.write(imageInverted.convert('1').tobytes())
        stream.seek(0)
        #         print('Live view : capture and display time: %f' % (time.time() - t1))

        if GPIO.event_detected(SHOT_PIN):
            liveViewThread.takeAshot = True
            break
        if GPIO.event_detected(PRINT_PIN):
            liveViewThread.exitNOshot = True
            break

    # Wait the picture is taken
    liveViewThread.join(5)

    # Set current file number if not set yet
    if currentFileNumber == -1:
lcd = SMemLCD('/dev/spidev0.0')

try:
    t1 = time.time()
    camera.capture(stream, format='jpeg', use_video_port=True)
    t2 = time.time()
    stream.seek(0) # "Rewind" the stream to the beginning so we can read its content
    image_source = Image.open(stream)
    imageResized = image_source.resize((WIDTH, HEIGHT), Image.ANTIALIAS)
    imageEnancer = ImageEnhance.Contrast(imageResized)
    imageContrasted = imageEnancer.enhance(2)
    imageInverted = PIL.ImageOps.invert(imageContrasted)
    imagedithered = imageInverted.convert('1') # convert image to black or white
    
#    GPIO.output(22, 1)
    lcd.write(imagedithered.tobytes())
#    GPIO.output(22, 0)
    
    stream.seek(0) # "Rewind" the stream to the beginning so we can read its content
    
    print('capture time: %f, process time %f' % (t1 - t2, time.time() - t2))
    t1 = time.time()
    
    imageRotated = image_source.rotate(90)
    printer = Adafruit_Thermal("/dev/ttyAMA0", 115200, timeout=0, rtscts=True)
    printer.printImage(imageRotated, False)
    printer.feed(3)

finally:
    GPIO.cleanup()
    camera.close()
Beispiel #4
0
camera.start_preview()
camera.contrast = 25
time.sleep(2)

lcd = SMemLCD('/dev/spidev0.0')

for i in range(100, -1, -1):
    t1 = time.time()

    camera.capture(stream,
                   format='jpeg',
                   use_video_port=True,
                   resize=(WIDTH, HEIGHT))
    stream.seek(
        0)  # "Rewind" the stream to the beginning so we can read its content
    image = Image.open(stream)
    image = image.convert('L')  # convert image to black and white
    image = PIL.ImageOps.invert(image)
    image = image.convert('1')  # convert image to black and white
    GPIO.output(22, 1)
    lcd.write(image.tobytes())
    GPIO.output(22, 0)
    stream.seek(
        0)  # "Rewind" the stream to the beginning so we can read its content

    print('lcd writing time: %f' % (round(time.time() - t1, 4)))

GPIO.cleanup()

if __name__ == '__main__':
    pass
Beispiel #5
0
img = PIL.Image.new('1', (WIDTH, HEIGHT))
draw = PIL.ImageDraw.Draw(img)
if args.font:
    font = PIL.ImageFont.truetype(args.font[0], size=30)
else:
    font = PIL.ImageFont.load_default()

for i in range(60, -1, -1):
    start = time.monotonic()
    img.paste(0)

    center(draw, 60, 'smemlcd library demo', font)

    s = 'closing in {:02d}...'.format(i)
    center(draw, 100, s, font)

    draw.rectangle((5, 120, 395, 140), outline='white')
    draw.rectangle((6, 121, 6 + 393 * (60 - i) / 60, 139), outline='white', fill='white')

    sw = time.monotonic()
    lcd.write(img.tobytes())
    end = time.monotonic()
    print('time: process={:.4f}, write={:.4f}'.format(end - start, end - sw))

    time.sleep(0.2)

lcd.close()

# vim: sw=4:et:ai