Closed attilagyorffy closed 4 years ago
interesting error message..
@attilagyorffy can you git clone the repository for luma.core and run the unit tests there? We should start at the core and go from there..
git clone https://github.com/rm-hull/luma.core.git
cd luma.core
pip install -e .
pip install tox coverage
tox
@thijstriemstra Here you go, this output is a bit meaningless to me but I hope you may be able to shed some light. Thanks in advance.
https://gist.github.com/attilagyorffy/a74c833172b0106781cedcebced03255
The error stack trace points to the RPi.GPIO library not accepting the value of 201 when trying to set up the data/command pin. What lead you to selecting that value of 201? Is there a board pin reference for nanopi that you used? Can you share a link?
If 201 is definitely correct, it could be that the examples are passing through the pin as a string when a number is required (or vise-versa)
I would start by writing a small test program just to exercise the GPIO to try and isolate the problem
@rm-hull 201 is the right GPIO pin according to the Nano Pi NEO Air layout diagram
I've also tested this by manually exporting, setting the direction and the value of the pin via dev:
echo "201" >/sys/class/gpio/export
echo "out" >/sys/class/gpio/gpio201/direction
echo "1" > /sys/class/gpio/gpio201/value
The right physical pin is now turned on. (Measured the voltage with an actual device).
What I don't understand is how luma.core interacting with the pin itself. Is it sending the same data via the linux /dev/
device?
OK, so first of all the part that I did not get right was that I used the linux GPIO pin numbering scheme over the physical header numbers. (Which means 201 should have been 18 and 1 should have been 22. See the NanoPI Neo Air layout).
Now I have an example program that I can run without any error messages, yet the display is blank and shows no output. (I've validated the connections, these should be just fine. I can turn on the display outside of the context of the luma project):
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
from luma.core.interface.serial import spi
from luma.core.render import canvas
from luma.oled.device import ssd1322
from PIL import ImageDraw
serial = spi(port=0, gpio=GPIO, gpio_DC=18, gpio_RST=22, bus_speed_hz=16000000)
device = ssd1322(serial)
with canvas(device) as draw:
draw.rectangle(device.bounding_box, outline="white", fill="white")
Important: I'm passing in an RPI.GPIO implementation that has been previously instructed to use the board numbering, otherwise the code fails upon setting the spi connection.
Now that I think the GPIO connection is fine, I am looking for a way to further debug the code.
From what I've seen in a previous issue, the bus speed etc should be fine unless you tell me otherwise. https://github.com/rm-hull/luma.oled/issues/90
@attilagyorffy not sure using BOARD mode is a good idea since we hardcode it to BCM: https://github.com/rm-hull/luma.core/blob/master/luma/core/lib.py#L24 But maybe I misunderstand.
FYI... Changing to: GPIO.setmode(GPIO.BCM)
fixed it for me. Cheers
@attilagyorffy did you solve this issue? Im going to close this ticket. Please re-open if you need further assistance
@attilagyorffy did you solve this issue? Im going to close this ticket. Please re-open if you need further assistance To be honest I gave up on the project and don't remember honestly where I've left it off, sorry and thanks anyway.
Hi,
I'm trying to run the example project using a SSD1322 display on a FriendlyCore OS on a NanoPi NEO Air.
Running
sudo python examples/sys_info.py -f conf/myconfig.cfg
I'm getting an error:I have the following config defined:
I believe the FriendlyARM OS comes with the RPI.GPIO python package preinstalled which should have the right physical/gpio pin mappings. During the
luma.examples
pip install I was keeping an eye on the install output and have seen no output that would suggest that the RPI.GPIO module was overwritten.I think I have the wiring set up correctly, using the NHD-2.8-25664UCB2 display.
I wonder what the error message really means and what I could do to debug the problem forward. Any help would be appreciated, thanks.
PS: I did try this on an Armbian OS too (not the FriendlyARM Ubuntu, which doesn't have the RPi.GPIO module preinstalled, I got a similar error there too, only it said
ValueError: The channel sent is invalid on a Raspberry Pi
(this makes me believe that the RPI.GPIO library should be working fine?)