Skip to content

Commit

Permalink
Merge pull request #85 from waynedyck/fix-pillow-10-errors
Browse files Browse the repository at this point in the history
Fix Pillow 10 errors when running example files
  • Loading branch information
FoamyGuy committed Mar 11, 2024
2 parents 9e77061 + 97e4c54 commit a990c87
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 11 deletions.
9 changes: 6 additions & 3 deletions examples/ssd1306_pillow_animate.py
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
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
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
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
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
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
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

0 comments on commit a990c87

Please sign in to comment.