ssd1306 using I2C on the esp8266
Re: ssd1306 using I2C on the esp8266
If its just frozen python source - then yes it won't save any RAM.
I was thinking about frozen bytecode, and with that I'm not sure whether data would be able to come from flash or not.
With C you could definitely have the data accessible directly from flash.
Even with python, there might be some clever tricks to get access to raw data (not using the usual python methods).
I was thinking about frozen bytecode, and with that I'm not sure whether data would be able to come from flash or not.
With C you could definitely have the data accessible directly from flash.
Even with python, there might be some clever tricks to get access to raw data (not using the usual python methods).
Re: ssd1306 using I2C on the esp8266
Just the same as with Python. And depending on what exactly you mean. Looks like you hint at accessing flash in memory-mapped way, but that's inherently device-specific. For example, ESP8266 has memory-mapped access, but only for the portion of flash. Otherwise, you need to treat flash as a storage device and access it correspondingly, and that's exactly what pythoncoder did above.With C you could definitely have the data accessible directly from flash.
So, the "ultimate" solution to this problem would be to develop a C module which would take a char code and returned bytes-like object with font data. (Of course, the real ultimate solution is to have good graphics API (including font rendering) backed by C implementation. As a sneak peek, u8g integration as a stretch goal for ESP8266 didn't get enough votes, so we'll leave it to you guys to decide what works best in different cases.)
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Re: ssd1306 using I2C on the esp8266
Speaking of which, will you disclose the voting results? It would be interesting to see what people are most interested in.pfalcon wrote:As a sneak peek, u8g integration as a stretch goal for ESP8266 didn't get enough votes, so we'll leave it to you guys to decide what works best in different cases.)
Re: ssd1306 using I2C on the esp8266
Of course, please expect a KS update soon. P.S. let's keep individual topics on topic .
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: ssd1306 using I2C on the esp8266
In my testing it works. I have a utility which converts multiple C font files into a single Python sourcefile. This declares a (large) bytes instance for each font and instantiates a PyFont object from each bytes object. Compiled as frozen bytecode I can import the module and access the PyFonts with minimal RAM usage.dhylands wrote:...I was thinking about frozen bytecode, and with that I'm not sure whether data would be able to come from flash or not...
Frozen bytecode is a great way to access large data structures at RAM-like speed.
Sounds interesting!dhylands wrote:Even with python, there might be some clever tricks to get access to raw data (not using the usual python methods).
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: ssd1306 using I2C on the esp8266
I was thinking that the code that Damien gave me to extract the bytecode (See post http://forum.micropython.org/viewtopic. ... 7913#p7901) might be modified to get access to variables stored in flash or something. I haven't really thought this through, and given that you've got things working with frozen bytecode, then that seems like the way to go.pythoncoder wrote:Sounds interesting!dhylands wrote:Even with python, there might be some clever tricks to get access to raw data (not using the usual python methods).
Re: ssd1306 using I2C on the esp8266
Perhaps it would make sense to put some standard font somewhere inside the micropython, so that it could then be used by various user libraries?
Re: ssd1306 using I2C on the esp8266
I just tested a small I²C SSD1306 display with the driver that is now included in drivers/display, and it works flawlessly:
This is the result of the following code:
This is the result of the following code:
Code: Select all
import ssd1306
from machine import I2C, Pin
import math
i2c = I2C(sda=Pin(4), scl=Pin(5))
display = ssd1306.SSD1306_I2C(32, i2c, 60)
display.fill(0)
for x in range(0, 96):
display.pixel(x, 16+int(math.sin(x/32*math.pi)*7 + 8), 1)
display.show()
Re: ssd1306 using I2C on the esp8266
By the way, has anybody managed to get the SSD1306 driver to work with the SPI displays? I took a stab at rewriting it to use the new hardware API, but I haven't been able to get it to display anything.
Re: ssd1306 using I2C on the esp8266
Replying to myself, because I managed to get it to work. The trick is to initialize the MOSI and SCK pins to OUT when passing them to the SPI constructor, otherwise they will stay high-impedance forever. Example:
Code: Select all
>>> from machine import Pin, SPI
>>> spi = SPI(miso=Pin(12), mosi=Pin(13, Pin.OUT), sck=Pin(14, Pin.OUT))