OLED mini-display for ESP32

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: OLED mini-display for ESP32

Post by deshipu » Tue Sep 12, 2017 8:11 am

loboris wrote:What makes MicroPython "MicroPython" is the core of the Python language implementation, at least it is my understanding...
Tell that to someone who downloads a library or driver "for MicroPython" and gets errors like these. Look at Adafruit's CircuitPython — it is still the same language, but they changed the name to avoid confusion, because they have different API for the peripherals. I'm not saying you have to change the name, but it would make it much easier to also write libraries for your version, and clearly mark them as running on your version — by using the name of the runtime in the library's name. Right now how I would do that? "loboris' MicroPython"?

loboris
Posts: 344
Joined: Fri Oct 02, 2015 6:19 pm

Re: OLED mini-display for ESP32

Post by loboris » Tue Sep 12, 2017 8:46 am

@deshipu

What you say makes sense. I'll try to maintain the compatibility with MicroPython.
At the moment I'm writting the documentation for all the changes and new/modified modules specific to this port. I'm aware that at this time it is hard to use/test it without knowing what exactly has been added/changed and why.
Thank you for your comments.

ttmetro
Posts: 104
Joined: Mon Jul 31, 2017 12:44 am

Re: OLED mini-display for ESP32

Post by ttmetro » Thu Oct 19, 2017 5:03 am

Ran into the next problem (with "loboris' MicroPython" - rest works very well):

Code: Select all

   File "ssd1306.py", line 1198, in write_data
AttributeError: 'I2C' object has no attribute 'write'
dir(i2c) indeed only lists writeto and writeto_mem.

scan shows the device ([60]) as expected, and I also can communicate with other I2C devices (tried MPU9250).
Bernhard Boser

loboris
Posts: 344
Joined: Fri Oct 02, 2015 6:19 pm

Re: OLED mini-display for ESP32

Post by loboris » Thu Oct 19, 2017 11:40 am

ttmetro wrote:
Thu Oct 19, 2017 5:03 am
Ran into the next problem (with "loboris' MicroPython" - rest works very well):

Code: Select all

   File "ssd1306.py", line 1198, in write_data
AttributeError: 'I2C' object has no attribute 'write'
dir(i2c) indeed only lists writeto and writeto_mem.

scan shows the device ([60]) as expected, and I also can communicate with other I2C devices (tried MPU9250).
There is a bug in frozen module ssd1306.py.
Please edit components/micropython/esp32/modules/ssd1306.py and change:

Code: Select all

    def write_data(self, buf):
        self.temp[0] = self.addr << 1
        self.temp[1] = 0x40 # Co=0, D/C#=1
        self.i2c.write(self.temp)
        self.i2c.write(buf)
to:

Code: Select all

    def write_data(self, buf):
        temp1 = bytearray(1)
        temp1[0] = 0x40 # Co=0, D/C#=1
        self.i2c.writeto(self.addr, temp1+buf)
The fix will be pushed to GitHub today or tomorrow.

I'm working on implementation of primitive I2C functions start, stop, write, readinto for ESP32 hardware I2C.
It will be available soon.

Post Reply