Open cubetastic33 opened 6 years ago
Hi, please try using the DebugBackend and see if this does anything. It won't actually control your display, but it helps locate the error. It might have to do with the GPIO setup. Unfortunately, I don't have access to a Pi 0 for testing.
Ok, I didn't understand that. What exactly should I do? Also, I had to install wiringpi2 for this, and it gives a deprecated warning.
I get the following output in the terminal:
pi@cubetastic:~ $ python /home/pi/Desktop/python_programs/lcd_test3.py
Inside main()
/usr/lib/python2.7/pylcd/backends.py:64: DeprecationWarning: The wiringpi2 module has been deprecated, please 'import wiringpi' instead.
and then everything stops.
Ohh okay, maybe that's the issue. I didn't do anything about this project in a while, so things probably have changed, yeah. Can you try editing backends.py line 64 to import wiringpi instead?
What I meant was that you could try using pylcd.DebugBackend
instead of pylcd.GPIOBackend
to see if the backend is causing the trouble or something else.
Ok, so I changed it to wiringpi in backends.py, and also changed it to pylcd.DebugBackend. Now, it does not give the deprecated warning, and gives me this output:
pi@cubetastic:~ $ python /home/pi/Desktop/python_programs/lcd_test3.py
Inside main()
Traceback (most recent call last):
File "/home/pi/Desktop/python_programs/lcd_test3.py", line 58, in <module>
main()
File "/home/pi/Desktop/python_programs/lcd_test3.py", line 44, in main
display = pylcd.ks0108.Display(backend = pylcd.DebugBackend, pinmap = PINMAP, debug = True)
File "/usr/lib/python2.7/pylcd/ks0108.py", line 30, in __init__
self.backend = backend(self, pinmap, *backend_args, **backend_kwargs)
File "/usr/lib/python2.7/pylcd/backends.py", line 177, in __init__
self.pinmap = dict([(key, [_key for _key, value in self.output_states].index(key)) for key, value in pinmap.iteritems()])
ValueError: 'RST' is not in list
Oh, my bad. Apparently the DebugBackend
was meant for Character LCDs only. Geez, I really don't know my own code anymore.
Can you try with the modified backends.py and the GPIOBackend
again?
I did that before trying DebugBackend, and it just output 'inside main()' and then got stuck :cry: I really don't know what to do...
Hmm okay, can you add some print statement below backends.py line 74? To see if the __init__
of the backend even completes.
The output seems to be kind of weird. I put a couple of marks (4, I think) with the last one at the end of the class. This is the output I got:
pi@cubetastic:~ $ python /home/pi/Desktop/python_programs/lcd_test3.py
crossed third mark
crossed final mark
Inside main()
crossed first mark
crossed second mark
crossed second mark
crossed second mark
crossed second mark
Okay, can you say where you put them? Then it might help.
This is the class:
class GPIOBackend:
def __init__(self, display, pinmap):
self.display = display
try:
import wiringpi as wiringpi
self.gpio = wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_GPIO)
except:
raise IOError("Could not export the GPIO pins. Make sure that you have the wiringpi library installed, run as root and$
print('crossed first mark')
self.reverse_pinmap = dict([(value, key) for key, value in pinmap.iteritems()])
for pin, output in pinmap.iteritems():
print('crossed second mark')
setattr(self, 'PIN_%s' % pin, output)
if pin == 'LED':
self.led_pwm = output == 18
self.gpio.pinMode(output, self.gpio.PWM_OUTPUT if pin == 'LED' and self.led_pwm else self.gpio.OUTPUT)
def high(self, output):
self.gpio.digitalWrite(output, True)
def low(self, output):
self.gpio.digitalWrite(output, False)
def pulse(self, output):
self.high(output)
time.sleep(0.001)
self.low(output)
print('crossed third mark')
def all_low(self):
for output in self.reverse_pinmap.keys():
self.low(output)
def write_nibble(self, nibble, data = True):
self.gpio.digitalWrite(self.PIN_RS, data)
self.gpio.digitalWrite(self.PIN_D4, nibble[3])
self.gpio.digitalWrite(self.PIN_D5, nibble[2])
self.gpio.digitalWrite(self.PIN_D6, nibble[1])
self.gpio.digitalWrite(self.PIN_D7, nibble[0])
def write_byte(self, byte, data = True):
self.gpio.digitalWrite(self.PIN_RS, data)
for i in range(8):
self.gpio.digitalWrite(getattr(self, "PIN_D%i" % i), byte[i])
def set_brightness(self, level):
assert level >= 0
assert level <= 1023
self.display.brightness = level
if self.led_pwm:
self.gpio.pwmWrite(self.PIN_LED, level)
else:
self.gpio.digitalWrite(self.PIN_LED, level > 0)
print('crossed final mark')
Okay, so the backend seems to work. You put some marks outside of the method definitions so they were executed before the main code.
Can you do some print statements in the __init__
of Display
in ks0108.py?
Ok, so it seems like the problem is here. The backlight didn't turn on for me, so I figured the error was before that place, and I was right. I put four marks like this:
class Display:
def __init__(self, backend, pinmap, auto_commit = False, backend_args = (), backend_kwargs = {}, skip_init = False, enable_backlight =$
print('started init()')
self.backend = backend(self, pinmap, *backend_args, **backend_kwargs)
self.auto_commit = auto_commit
self.brightness = 0
self.debug = debug
self.rows = 64
self.columns = 128
print('crossed second mark')
self.pages = self.rows / 8
self.content = [[[0 for z in range(8)] for x in range(self.pages)] for y in range(self.columns)]
self.old_content = deepcopy(self.content)
self.cursor_pos = [0, 0]
self.current_chip = 1
print('crossed third mark')
self.set_brightness = self.backend.set_brightness
self.write_byte = self.backend.write_byte
self.backend.all_low()
if enable_backlight:
self.set_brightness(1023)
print('crossed fourth mark')
if not skip_init:
And this is the output I got:
Inside main()
started init()
crossed second mark```
Okay, this is really weird. There's no hardware interfacing or any low-level stuff going on between the second and third mark... seems almost like the framebuffer init (self.content
) or the deepcopy
operation causes a serious exception that brings down the whole system. But why?
Can you connect a display via HDMI and see if you get a kernel panic or some signs of a crash?
ok... I'll try and then tell you.
Ok, it seems to be a completely different story when I connect a monitor. So, it looks like it has been giving more logs but I didn't recieve them because it disconnected from wifi. It printed 'crossed second mark' many times, and then the third and fourth marks, and then after the logs 'drew line' and 'committed to display' or something like that, it said 'bus error', and then after a while the wallpaper became all white and the taskbar disappeared.
EDIT: The program ended after the bus error
That sounds like a problem with your SD card then. Can you try a different one?
SD card? No, I don't have another one. What could be the problem with it? It is very new...
No idea, but googling "raspberry pi bus error" and knowing that Pis can be very picky with their sd cards it sounds reasonable...
This is the sd card I got: https://www.thingbits.net/products/8gb-microsd-card-with-noobs-2-0 It seems to be meant for the raspberry pi, so are you sure it is the sd card that is the problem?
Edit: I am using an RPi 0 W, in case it matters. I also completely formatted the sd card and directly installed the Raspbian image.
At this point I unfortunately don't know how to help you, maybe go to the Raspberry Pi Stack Exchange?
I already asked two questions there! One got severely downvoted and deleted, and the other didn't get any useful responses.
Well sorry but I can't help either, never had this problem, cannot reproduce it and don't know where to start looking...
Hey! I borrowed a micro sd card from my friend, and now I am trying to install pyLCD. However, I am getting an error: "No module name PIL found". I tried sudo pip install PIL
but it said no version found. How do I install pylcd?
nvm, I downloaded Pillow, but now, again, the program is stopping once it reaches "inside main()"... The led on the rpi goes off too... idk what to do! I don't think it's the sd card this time, because I couldn't find any samsung sd cards with 8 gb marked as not ok in the sd cards list...
ks0108
Hey, did you find a solution for this because currently i'm working on it and it shows error
I cannot help with that at the moment, unfortunately.
I am still unable to get any sort of output using this library with my 128x64 glcd (ks0108 driver). I tried using this really simple program:
However, I get the print statement of 'Inside main()', and then the entire RPi 0 gets stuck, it disconnects from wifi and ssh stops working, and the power led stops glowing. Please help me to at least get some sort of text/image on my lcd!