Strange behavior with Pyboard and ssd1306 display over I2C
Posted: Sun Apr 14, 2019 12:33 am
I've been experimenting with a pyboard (running uPy 1.9.3) and a 128x32 OLED display controlled by an SSD1306. I used the 1.9.3 version of the ssd1306.py driver from the MicroPython github.
I've managed to connect to the display using I2C, and I can do some operations successfully. For example I can draw text to the screen or draw lines as I'd expect. However it seems like something goes off the rails if I try to do a fill or a blit to the display outside a certain range of pixels. Here's how I've been making the display object:
[code]
import ssd1306
from machine import I2C, Pin
def make_display():
sda = Pin.board.Y10
scl = Pin.board.Y9
bus = I2C (sda=sda, scl =scl)
display = ssd1306.SSD1306_I2C(128,32, bus)
[/code]
and here's something that works:
[code]
d = make_display()
d.poweron()
d.fill_rect (0,0,7,7,1)
d.show()
# shows an 8-pixel rectangle in the upper left corner of the display
[/code]
However this does not work as expected:
[code]
d = make_display()
d.poweron()
d.fill_rect (0,0,31,31,1)
d.show()
# should be a 32x32 block -- but the screen goes dark instead
[/code]
cycling poweroff() and poweron() calls will cause the larger rectangle to flicker visibly on the display for a moment, but then the display goes dark again. Once I'm in this mode I can't get the display to permanently reappear. Sometimes the
Somewhat related, the brightness of the display seems to diminish markedly if I'm using the entire addressable space: the 8x8 pixel block in my example above is nice and bright -- however if I do this:
[code]
d = make_display()
d.poweron()
d.rect (0,0,127,31,1)
d.show()
# 1-pixel line around display border
[/code]
The resulting image is so dim it's hard to make out in daylight.
I'm not clear where i could be off the rails here. Any suggestions for possible problems? I'm powering the OLED using the 3.3 out of the pyboard, which itself is 5v in from a USB (that i'm also using to control the board over a TTY). I tried rolling forward to the uPy 1.9.4 (the current github version) but that fails: the latest version of the SSD1306 driver inherits directly from FrameBuffer and my pyboard does not like that.
The hardware is here: https://vetco.net/products/0-91-128x32- ... ic-arduino
I've managed to connect to the display using I2C, and I can do some operations successfully. For example I can draw text to the screen or draw lines as I'd expect. However it seems like something goes off the rails if I try to do a fill or a blit to the display outside a certain range of pixels. Here's how I've been making the display object:
[code]
import ssd1306
from machine import I2C, Pin
def make_display():
sda = Pin.board.Y10
scl = Pin.board.Y9
bus = I2C (sda=sda, scl =scl)
display = ssd1306.SSD1306_I2C(128,32, bus)
[/code]
and here's something that works:
[code]
d = make_display()
d.poweron()
d.fill_rect (0,0,7,7,1)
d.show()
# shows an 8-pixel rectangle in the upper left corner of the display
[/code]
However this does not work as expected:
[code]
d = make_display()
d.poweron()
d.fill_rect (0,0,31,31,1)
d.show()
# should be a 32x32 block -- but the screen goes dark instead
[/code]
cycling poweroff() and poweron() calls will cause the larger rectangle to flicker visibly on the display for a moment, but then the display goes dark again. Once I'm in this mode I can't get the display to permanently reappear. Sometimes the
Somewhat related, the brightness of the display seems to diminish markedly if I'm using the entire addressable space: the 8x8 pixel block in my example above is nice and bright -- however if I do this:
[code]
d = make_display()
d.poweron()
d.rect (0,0,127,31,1)
d.show()
# 1-pixel line around display border
[/code]
The resulting image is so dim it's hard to make out in daylight.
I'm not clear where i could be off the rails here. Any suggestions for possible problems? I'm powering the OLED using the 3.3 out of the pyboard, which itself is 5v in from a USB (that i'm also using to control the board over a TTY). I tried rolling forward to the uPy 1.9.4 (the current github version) but that fails: the latest version of the SSD1306 driver inherits directly from FrameBuffer and my pyboard does not like that.
The hardware is here: https://vetco.net/products/0-91-128x32- ... ic-arduino