SSD1306 with SPI on LoPy4? (/topic/1541/solved-ssd1306-with-spi on WiPy)
flexypepo last edited by
RE: SSD1306 with SPI?](/topic/1541/solved-ssd1306-with-spi)
Using the ssd1306 driver (https://github.com/micropython/micropython/blob/master/drivers/display/ssd1306.py), I'll try to get the Adafruit 128x32 OLED SSD1306-SPI working with LoPy4. No luck thusfar.
The OLED display is wired to my LoP4 (via Expansion board 3.0) as follows:
SSD1306 -> LoPy4 -> Exp.bord
Vin -> 3.3V
GND -> GND
DATA -> MOSI,P11 -> G22
CLK -> CLK,P10 -> G17
DC -> P9 -> G16
RST -> P8 -> G15
CS -> P12 -> G28
This is the code I'm using to test, and for which I got error
'TypeError: function expected at most 5 arguments, got 6'
from machine import Pin, SPI
from ssd1306 import SSD1306_SPI as ssd
spi = SPI(0, mode=SPI.MASTER, baudrate=1000000, polarity=0, phase=0)
dc = Pin('P9', mode=Pin.OUT) # G16
rst = Pin('P8', mode=Pin.OUT) # G15
cs = Pin('P12', mode=Pin.OUT) # G28
oled = ssd(128, 32, spi, dc, rst, cs)
Is it wired correctly?
Is the ssd130 module from micropython.org correct to use for LoPy4? There are 6, and not 5, arguments needed for the SSD1306_SPI constructor.
When I leave out any of the pin-arguments (dc or rst), I'll got following error:
'TypeError: object with buffer protocol required'
Does anyone has a tip or pointer how to get the display working with the LoPy4?
Pycom MicroPython 1.18.0.r1 [v1.8.6-849-9569a73] on 2018-07-20
robert-hh last edited by
@flexypepo Yes, that's rigth. The API for Pin changed a while ago from pin.high() to pin.value(1) or just pin(1). The latter is, what the genuine driver at https://github.com/micropython/micropython/tree/master/drivers/display uses.
flexypepo last edited by
@robert-hh Thanks for your information. I've tried the change to 'framebuf.MVLSB', but it did not helped. Neither connecting the Vin of OLED-display to +5V instead of +3V on Expansion board.
However, using a two-year old 'ssd1306' module of Tony DiCola (https://github.com/adafruit/micropython-adafruit-ssd1306), the OLED came to life! Only change in ssd1306 module, was to use 'aPin'.value(1) instead of 'aPin'.high(). Idemdito for 'aPin'.low()..
I've not yet investigated what the differences are in the drivers, especially related to the 'strange' error message about the number of arguments. For the moment, I continue with this (slightly modified) ssd1306 driver, and will see what will happen.
Thanks for the pointer about the P8-pin. I'll change it when I'm start to use the SD-card. I'm new to LoPy4 development, and found the P- and G-names very confusing. I have some experiences with micropython on a couple of ESP32 boards. Its a challenge (or pity?) to handle the various flavours of Micopython (Adafruit, Loboris, Pycom, vanilla micropython). Sigh.
Best regards, Peter
robert-hh last edited by robert-hh
@flexypepo I would not expect it to work right away, but the differences should be small. One I stumbled over is in line 35 of ssd1306.py, which reads:
super().__init__(self.buffer, self.width, self.height, framebuf.MONO_VLSB)
The last argument should be framebuf.MVLSB with Pycom's flavor of micropython.
The other thing I noticed is the use of Pins. P8 is used for the SD card data. So if you use the SD card, you must not use P8 for other purposes.
And yes, you need all 6 arguments, since the signals mentioned by them are needed.
Edit: I do not know why this error you mention is flagged. I would expect something else.