Object with buffer protocol required
-
Hello,
I am new with Pycom and using a Sipy board for a project (which I am programming with Atom and the Pymakr consol). I want to display messages on a OLED screen (which is a RiT display). Thus, I was thinking about using the SSD1306 library which seems approriate (here is the one I am using https://github.com/micropython/micropython/blob/master/drivers/display/ssd1306.py). I also need to use a framebuffer, thus I imported the framebuf library at the beginning of my code. However, when I run the code, I get this message : TypeError: object with buffer protocol required. I have no idea why I get this so I would really appreciate your help. You can find below the block of code which causes this problem.scl=Pin('P10',mode=Pin.IN,pull=None,alt=-1)
sda=Pin('P9',mode=Pin.IN,pull=None,alt=-1)
i2c=I2C(0,pins=('P9','P10'))
fbuf = FrameBuffer(bytearray(10 * 100 * 2), 10, 100, framebuf.RGB565) (apparently, this line provokes the error)
oled=SSD1306_I2C(128,32,i2c,0x3c)Thanks for your help and do not hesitate to ask if you need further information
-
@Eric73 Thank you, it works much better now!
-
@brossingo So, it seem that pycom micropython doesn't include framebuffer module, so you cant create one.
But i use SSD1306 one a projet from
https://github.com/dmitryelj/LoPyI2CLCD/blob/master/lopy_lcd.pyFile is named SSD1306.py on my board
Here is sample of the code i use in my projet
from machine import I2C import SSD1306 as Screen i2c=I2C(0) i2c.init(I2C.MASTER,baudrate=400000) Screen.initialize(Screen.kDisplayI2C128x64,i2c) Screen.set_contrast(128) # 1-255 Screen.clearBuffer() Screen.addString(0, 0,"SSD1306 running") Screen.displayOn() Screen.drawBuffer()