Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Pillow 10 errors when running example files #85

Merged
merged 6 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
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
9 changes: 6 additions & 3 deletions examples/ssd1306_pillow_animate.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@
"SSD1306 ORGANIC LED DISPLAY. THIS IS AN OLD SCHOOL DEMO SCROLLER!!"
+ "GREETZ TO: LADYADA & THE ADAFRUIT CREW, TRIXTER, FUTURE CREW, AND FARBRAUSCH"
)
maxwidth, unused = draw.textsize(text, font=font)
bbox = draw.textbbox((0, 0), text, font=font)
maxwidth = bbox[2] - bbox[0]

# Set animation and sine wave parameters.
amplitude = height / 4
Expand All @@ -73,15 +74,17 @@
break
# Calculate width but skip drawing if off the left side of screen.
if x < -10:
char_width, char_height = draw.textsize(c, font=font)
bbox = draw.textbbox((0, 0), c, font=font)
char_width, char_height = bbox[2] - bbox[0], bbox[3] - bbox[1]
x += char_width
continue
# Calculate offset from sine wave.
y = offset + math.floor(amplitude * math.sin(x / float(width) * 2.0 * math.pi))
# Draw text.
draw.text((x, y), c, font=font, fill=255)
# Increment x position based on chacacter width.
char_width, char_height = draw.textsize(c, font=font)
bbox = draw.textbbox((0, 0), c, font=font)
char_width, char_height = bbox[2] - bbox[0], bbox[3] - bbox[1]
x += char_width

# Draw the image buffer.
Expand Down
9 changes: 8 additions & 1 deletion examples/ssd1306_pillow_clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@

i2c = board.I2C() # uses board.SCL and board.SDA
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c, addr=0x3D, reset=RESET_PIN)

# Create the SSD1306 OLED class.
# The first two parameters are the pixel width and pixel height.
# Change these to the right size for your display!
oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c)

# Note you can change the I2C address, or add a reset pin:
# oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c, addr=0x3D, reset=RESET_PIN)

# Clear display.
oled.fill(0)
Expand Down
3 changes: 2 additions & 1 deletion examples/ssd1306_pillow_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@

# Draw Some Text
text = "Hello World!"
(font_width, font_height) = font.getsize(text)
bbox = font.getbbox(text)
(font_width, font_height) = bbox[2] - bbox[0], bbox[3] - bbox[1]
draw.text(
(oled.width // 2 - font_width // 2, oled.height // 2 - font_height // 2),
text,
Expand Down
9 changes: 8 additions & 1 deletion examples/ssd1306_pillow_image_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@

i2c = board.I2C() # uses board.SCL and board.SDA
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c, addr=0x3D, reset=RESET_PIN)

# Create the SSD1306 OLED class.
# The first two parameters are the pixel width and pixel height.
# Change these to the right size for your display!
oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c)

# Note you can change the I2C address, or add a reset pin:
# oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c, addr=0x3D, reset=RESET_PIN)

# Clear display.
oled.fill(0)
Expand Down
9 changes: 8 additions & 1 deletion examples/ssd1306_pillow_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ def get_ip_address(ifname):
# Very important... This lets py-gaugette 'know' what pins to use in order to reset the display
i2c = board.I2C() # uses board.SCL and board.SDA
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c, addr=0x3D, reset=RESET_PIN)

# Create the SSD1306 OLED class.
# The first two parameters are the pixel width and pixel height.
# Change these to the right size for your display!
oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c)

# Note you can change the I2C address, or add a reset pin:
# oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c, addr=0x3D, reset=RESET_PIN)

# This sets TEXT equal to whatever your IP address is, or isn't
try:
Expand Down
9 changes: 8 additions & 1 deletion examples/ssd1306_pillow_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@
# Very important... This lets py-gaugette 'know' what pins to use in order to reset the display
i2c = board.I2C() # uses board.SCL and board.SDA
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c, addr=0x3D, reset=RESET_PIN)

# Create the SSD1306 OLED class.
# The first two parameters are the pixel width and pixel height.
# Change these to the right size for your display!
oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c)

# Note you can change the I2C address, or add a reset pin:
# oled = adafruit_ssd1306.SSD1306_I2C(128, 64, i2c, addr=0x3D, reset=RESET_PIN)

# Clear display.
oled.fill(0)
Expand Down
3 changes: 0 additions & 3 deletions examples/ssd1306_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
# This example and library is meant to work with Adafruit CircuitPython API.

import board
import displayio
import adafruit_ssd1306

displayio.release_displays()

# Create the I2C bus interface.
i2c = board.I2C() # uses board.SCL and board.SDA
# i2c = busio.I2C(board.GP1, board.GP0) # Pi Pico RP2040
Expand Down
Loading