Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions python-examples/OLEDimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

# Meant for use with the Raspberry Pi and an Adafruit monochrome OLED display!

# This program takes any image (recommended: landscape) and converts it into a black and white image which is then
# displayed on one of Adafruit's monochrome OLED displays.
# This program takes any image (recommended: landscape) and converts it into a black and white image which is then
# displayed on one of Adafruit's monochrome OLED displays.

# To run the code simply change directory to where it is saved and then type: sudo python OLEDimage.py <image name>
# For example: sudo python OLEDimage.py penguins900x600.jpg
# For example: sudo python OLEDimage.py penguins900x600.jpg
# The image penguins900x600.jpg is included in this repo as an example! Download any image that you want and simply change the
# image name!

# This program was created by The Raspberry Pi Guy

# Imports the necessary software - including PIL, an image processing library
import gaugette.ssd1306
import gaugette.platform
import gaugette.gpio
import time
import sys
from PIL import Image
Expand All @@ -26,10 +28,20 @@
DC_PIN = 16 # WiringPi pin 16 is GPIO15.
width = 128
height = 32
spi_bus = 0
spi_device = 0
gpio = gaugette.gpio.GPIO()
spi = gaugette.spi.SPI(spi_bus, spi_device)

led = gaugette.ssd1306.SSD1306(reset_pin=RESET_PIN, dc_pin=DC_PIN)
# Very important... This lets py-gaugette 'know' what pins to use in order to reset the display
led = gaugette.ssd1306.SSD1306(gpio, spi, reset_pin=RESET_PIN, dc_pin=DC_PIN, rows=32, cols=128) # Change rows & cols values depending on your display dimensions.
led.begin()
led.clear_display()
led.display()
led.invert_display()
time.sleep(0.5)
led.normal_display()
time.sleep(0.5)

# This bit converts our image into black and white and resizes it for the display

Expand All @@ -46,3 +58,4 @@
led.draw_pixel(x,y,bool(int(image_bw.getpixel((x,y)))))

led.display()