OLED Displays SSD1306
Re: OLED Displays SSD1306
Following the initial trial and error with the source code provided in the Github repository above i did some tweaks to the code which i of course will commit back to a fork on Github.
What i would like to mention and ask before doing this is that i also did start to port more basic drawing operations to uPy for use on this device (lines, rectangles and the old-school 5x7 pixel font in different scales).
These drawing primitives are operating on a 1-bit frame-buffer (the only hint to the used monochrome display) which by itself is hardware independent. Based on this it possibly could receive some performance boost by "hand-optimizing" it or by using some code-emitter decorators.
The code works but has not been tested that extensively. Status is something about "alpha, but works as intended". Some open ends are still present. E.g. i would like it to respect the frame-buffer boundaries. It currently still draws characters, which "hang out off the display on side" over into the opposite side. In general there are still some quirks i would like to be hunted down, before considering it really usable.
I did base my implementation on the algorithms found in the Adafruit GFX library for Arduino, so i should at least check their licenses before we do commit this back to Github under the MIT license.
Should we pull such an module out of this context or is there no other need for this?
What i would like to mention and ask before doing this is that i also did start to port more basic drawing operations to uPy for use on this device (lines, rectangles and the old-school 5x7 pixel font in different scales).
These drawing primitives are operating on a 1-bit frame-buffer (the only hint to the used monochrome display) which by itself is hardware independent. Based on this it possibly could receive some performance boost by "hand-optimizing" it or by using some code-emitter decorators.
The code works but has not been tested that extensively. Status is something about "alpha, but works as intended". Some open ends are still present. E.g. i would like it to respect the frame-buffer boundaries. It currently still draws characters, which "hang out off the display on side" over into the opposite side. In general there are still some quirks i would like to be hunted down, before considering it really usable.
I did base my implementation on the algorithms found in the Adafruit GFX library for Arduino, so i should at least check their licenses before we do commit this back to Github under the MIT license.
Should we pull such an module out of this context or is there no other need for this?
Re: OLED Displays SSD1306
Hello,
I want to use the SSD1306 with I2C, too.
But it do not run.
I connectet SDA to Y10, and SCL to Y9, VIN to 5V and GND to GND. so far ok?
than I kopied the main and the ssd1306 file from GitHub, and uncommand the line for I2C in the main file. OK?
But now I get an error
Thank you for all ideas!
I want to use the SSD1306 with I2C, too.
But it do not run.
I connectet SDA to Y10, and SCL to Y9, VIN to 5V and GND to GND. so far ok?
than I kopied the main and the ssd1306 file from GitHub, and uncommand the line for I2C in the main file. OK?
Code: Select all
import pyb
from ssd1306 import SSD1306
# SPI
#display = SSD1306(pinout={'dc': 'Y3',
# 'res': 'Y4'},
# height=64,
# external_vcc=False)
# I2C connected to Y9, Y10 (I2C bus 2)
display = SSD1306(pinout={'sda': 'Y10',
'scl': 'Y9'},
height=64,
external_vcc=False)
led_red = pyb.LED(1)
led_red.off()
....
Code: Select all
PYB: sync filesystems
PYB: soft reboot
Unexpected error: bytearray index out of range
Micro Python v1.3.9-59-g99bcaa2 on 2015-02-11; PYBv1.0 with STM32F405RG
Thank you for all ideas!
Re: OLED Displays SSD1306
Since you didn't get a traceback (which seems peculiar), I'd look for try/catch blocks.
I generally add print statements to the code to try and narrow down where the error is coming from.
I generally add print statements to the code to try and narrow down where the error is coming from.
Re: OLED Displays SSD1306
Thank you, yes, this was the first problem, you are so fast
Re: OLED Displays SSD1306
Hello,
this runs now,
But how I can wirte a Text message to the display.
I tried
But this is unexpected indent
Can I get an example?
Thank you
this runs now,
But how I can wirte a Text message to the display.
I tried
Code: Select all
display.write_command('123')
Can I get an example?
Thank you
Re: OLED Displays SSD1306
The display library from the Github repository does not support text display. But there is a fork with added text rendering.
The method you are calling is used for communicating on the SPI or I2C bus. Do not use it externally, it should be kept private to the module.
As for examples... i have none at hand. Simply check the code for the method called "draw_text(x, y, string, size=1, space=1)". You should also keep that font module (font.py) around!
Additionally this library might soon need an update for all MicroPython platforms. It does rely on the "pyb" module which is only available on the official pyboard!
The method you are calling is used for communicating on the SPI or I2C bus. Do not use it externally, it should be kept private to the module.
As for examples... i have none at hand. Simply check the code for the method called "draw_text(x, y, string, size=1, space=1)". You should also keep that font module (font.py) around!
Additionally this library might soon need an update for all MicroPython platforms. It does rely on the "pyb" module which is only available on the official pyboard!
Re: OLED Displays SSD1306
Coming back to the display...
I've tried to use the latest code... https://github.com/khenderick/micropython-drivers
I'm using a stock AdaFruit 64X128 display... https://www.adafruit.com/product/938
When I attempt to use the example, I get. I know the display works (tested it under with Arduino Uno)
Any ideas where I can go next to try and find out the issue?
Thanks
Dom
I've tried to use the latest code... https://github.com/khenderick/micropython-drivers
I'm using a stock AdaFruit 64X128 display... https://www.adafruit.com/product/938
When I attempt to use the example, I get. I know the display works (tested it under with Arduino Uno)
Code: Select all
PYB: sync filesystems
PYB: soft reboot
Unexpected error: 116
Traceback (most recent call last):
File "main.py", line 94, in <module>
File "main.py", line 94, in <module>
File "ssd1306.py", line 183, in poweroff
File "ssd1306.py", line 116, in write_command
OSError: 116
MicroPython v1.5.1-158-g0a4eb4d on 2015-12-20; PYBv1.0 with STM32F405RG
Type "help()" for more information.
Thanks
Dom
Re: OLED Displays SSD1306
I have similar problem, the OSError: 116 seems to be related to ACK byte that some displays don't handle.. for arduino i had to use the U8G_I2C_OPT_NO_ACK) option on u8glib to work. Seems to be another controller than SSD1306, like the SH1106. I don't figure out how to solve it yet...domgiles wrote:Coming back to the display...
I've tried to use the latest code... https://github.com/khenderick/micropython-drivers
I'm using a stock AdaFruit 64X128 display... https://www.adafruit.com/product/938
When I attempt to use the example, I get. I know the display works (tested it under with Arduino Uno)
Any ideas where I can go next to try and find out the issue?Code: Select all
PYB: sync filesystems PYB: soft reboot Unexpected error: 116 Traceback (most recent call last): File "main.py", line 94, in <module> File "main.py", line 94, in <module> File "ssd1306.py", line 183, in poweroff File "ssd1306.py", line 116, in write_command OSError: 116 MicroPython v1.5.1-158-g0a4eb4d on 2015-12-20; PYBv1.0 with STM32F405RG Type "help()" for more information.
Thanks
Dom
Re: OLED Displays SSD1306
Code: Select all
self.spi.init(baudrate=self.rate, polarity=0, phase=0)
Re: OLED Displays SSD1306
Because you might have more than one device on the SPI bus, and those other devices might be using different mode/speed. So you never know if the mode/speed have been changed. So you have to set them to the correct values each time. That was the reasoning when I was asked to add it, anyways.