Skip to content

Commit 1e7c6b6

Browse files
authored
Merge pull request #18 from mikeysklar/128x64-spi-col-offset
screen offset, font warning
2 parents 1beba27 + 8f5cb6f commit 1e7c6b6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

examples/ssd1305_pillow_demo.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,18 @@
2424
WIDTH = 128
2525
HEIGHT = 64 # Change to 32 if needed
2626
BORDER = 8
27+
COL = 0 # If you see static, change 0 --> 4, fixes alignment
2728

2829
# Use for SPI
2930
spi = board.SPI()
3031
oled_cs = digitalio.DigitalInOut(board.D5)
3132
oled_dc = digitalio.DigitalInOut(board.D6)
32-
oled = adafruit_ssd1305.SSD1305_SPI(WIDTH, HEIGHT, spi, oled_dc, oled_reset, oled_cs)
33+
oled = adafruit_ssd1305.SSD1305_SPI(WIDTH, HEIGHT, spi, oled_dc, oled_reset, oled_cs, col=COL)
3334

3435
# Use for I2C.
3536
# i2c = board.I2C() # uses board.SCL and board.SDA
3637
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
37-
# oled = adafruit_ssd1305.SSD1305_I2C(WIDTH, HEIGHT, i2c, addr=0x3c, reset=oled_reset)
38+
# oled = adafruit_ssd1305.SSD1305_I2C(WIDTH, HEIGHT, i2c, addr=0x3c, reset=oled_reset, col=COL)
3839

3940
# Clear display.
4041
oled.fill(0)
@@ -62,7 +63,9 @@
6263

6364
# Draw Some Text
6465
text = "Hello World!"
65-
(font_width, font_height) = font.getsize(text)
66+
bbox = font.getbbox(text)
67+
font_width = bbox[2] - bbox[0]
68+
font_height = bbox[3] - bbox[1]
6669
draw.text(
6770
(oled.width // 2 - font_width // 2, oled.height // 2 - font_height // 2),
6871
text,

0 commit comments

Comments
 (0)