Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advice on luma.oled examples #289

Closed
peterbmckinley opened this issue Jun 29, 2020 · 10 comments
Closed

Advice on luma.oled examples #289

peterbmckinley opened this issue Jun 29, 2020 · 10 comments

Comments

@peterbmckinley
Copy link

peterbmckinley commented Jun 29, 2020

Hi All,

Bear with me but I'm trying to get my head around the minefield of i2c, v SPI v luma.oled v ssd1306 v sh1106 v PIL v Pillow v Python v Python3 v pip v pip3 (etc. ad nauseum).

Long story short, I have my 1.3" monochrome I2C OLED working fine using the method and examples here:

https://github.com/codelectron/ssd1306.git

All I want to do, mainly as a fun learning exercise, is get some of the luma.oled examples also working.

Rather than boring everyone with ALL the details, my question is are all the examples in luma.oled for an SPI display? (mine is I2C). I tried the first 5 and none of them work, yet for example maze.py from codelectron displays fine (after I edited to text to select SH1106 instead of the default SSD1306, the inevitable issue with larger 1.3" displays).

I'm hoping the answer will help some other newbies in the same frustrating boat.

FYI platform is the latest Armbian. "Welcome to Armbian buster with Linux 5.4.45-sunxi" running on an Orange Pi Zero

@peterbmckinley
Copy link
Author

peterbmckinley commented Jun 29, 2020

Perhaps I should point out, I followed the instructions to the letter from this page onwards, resolving all dependencies and errors:

https://luma-oled.readthedocs.io/en/latest/hardware.html

then applied the fixes discussed here, with no errors:

rm-hull/luma.led_matrix#151

and finally cloned the luma.oled examples from here:

https://github.com/rm-hull/luma.examples.

As I said, is the issue I'm using an i2c display and the examples are all for SPI? Or what :)

@rm-hull
Copy link
Owner

rm-hull commented Jun 29, 2020

From what I can gather https://github.com/codelectron/ssd1306.git is a fork of this project made to work with orange pi, and it hasn’t been updated for many years.

When you run the examples, are you supplying any command line arguments, and what do the examples print out?

I have a feeling that orange pi has its i2c on a different bus to that on the raspberry pi .... so you would be looking for a value of “3c” somewhere in the output when you run the “i2cdetect -y 1” command. If you don’t see anything try 0 or 2 instead of 1. Once you do see “3c”, you will have identified the correct bus, so if you run “python examples/demo.py --help” You’ll see there is an option “--i2c-port” where you can override with the correct bus number.

@peterbmckinley
Copy link
Author

peterbmckinley commented Jun 29, 2020 via email

@peterbmckinley
Copy link
Author

Oops dont ask why I put Ian!!

Is there a particular example you want me to try, which is the simplest? Bear in mind I'm using i2c. I have SSD1306 and SH1106 displays so it doesn't matter which the example is set up for.

Peter

@rm-hull
Copy link
Owner

rm-hull commented Jun 29, 2020

It should (and does) work on orange pi ... here is an app I wrote some time back: https://github.com/rm-hull/weatherstation targeting orange pi zero. Other folks have got it working on other sbc’s too.

The default for all the examples is ssd1306 on i2c, so it doesn’t matter which you choose.

The important thing is to determine the correct bus first and foremost

@peterbmckinley
Copy link
Author

peterbmckinley commented Jun 29, 2020 via email

@peterbmckinley
Copy link
Author

0_96 inch working
1_3 inch corrupt

@peterbmckinley
Copy link
Author

Just to further clarify, the Orange Pi Zero has two i2c bus connections, TWI0 and TWI1. Needless to say when I switch over to TWI1 the examples run without any arguments.

Happy days :)

@peterbmckinley
Copy link
Author

I've edited demo_opts.py in the old codelectron ssd1306 folder to default to Bus 1 as well, so all the examples are now harmonised.

import argparse

parser = argparse.ArgumentParser(description='oled arguments')
parser.add_argument(
'--port', '-p',
type=int,
default=1,
help='i2c bus number',

The only thing that doesn't work is the 1.3" display with the luma.oled examples.........

Here is demo_opts.py in its entirety, if that helps:

import argparse

parser = argparse.ArgumentParser(description='oled arguments')
parser.add_argument(
'--port', '-p',
type=int,
default=1,
help='i2c bus number',
)
parser.add_argument(
'--address', '-a',
type=str,
default='0x3c',
help='i2c display address',
)
parser.add_argument(
'--display', '-d',
type=str,
default='sh1106',
help='display type, one of ssd1306 or sh1106',
)

args = parser.parse_args()
if args.display not in ('ssd1306', 'sh1106'):
parser.error('unknown display %s' % args.display)
try:
args.address = int(args.address, 0)
except ValueError:
parser.error('invalid address %s' % args.address)

import oled.device
Device = getattr(oled.device, args.display)
device = Device(port=args.port, address=args.address)

@peterbmckinley
Copy link
Author

--display sh1106

duh...............

LOVE IT, great experience and great examples. Good work Richard thank you so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants