question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cursor position (0, 20) invalid on a 4x20 LCD

See original GitHub issue

When initializing an LCD with “auto_linebreaks=False”, then writing a 20 character string to position (0, 0) seems to fail.

Traceback (most recent call last):
  File "/usr/local/bin/lcd.py", line 60, in <module>
    main(controller, addr, cols, rows)
  File "/usr/local/bin/lcd.py", line 28, in main
    loop(lcd, unit)
  File "/usr/local/bin/lcd.py", line 48, in loop
    lcd.write_string(datestring.ljust(lcd.lcd.cols))
  File "/usr/local/lib/python3.5/dist-packages/RPLCD/lcd.py", line 279, in write_string
    self.write(char)
  File "/usr/local/lib/python3.5/dist-packages/RPLCD/lcd.py", line 406, in write
    self.cursor_pos = newpos
  File "/usr/local/lib/python3.5/dist-packages/RPLCD/lcd.py", line 151, in _set_cursor_pos
    raise ValueError(msg.format(pos=value, lcd=self.lcd))
ValueError: Cursor position (0, 20) invalid on a 4x20 LCD.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
dbrgncommented, Mar 24, 2019

I’m not sure. My preferred solution would be to simply continue writing to the memory. If you turn off auto linebreaks, then you’re on your own and any logic should be disabled.

This means that we’d have to disable bounds checks in that case.

1reaction
JsBergbaucommented, Apr 5, 2020

Anything new when this issue will be fixed in the official release you install with pip? Even resetting the Cursorposition doesn’t help. Second write leads to an exception. Since I return the Cursorposition to the beginning, this shouldn’t happen. If you wriite “ab” in the second write, display shows “ab3456789abcdefghijk”, so moving the cursor seems to work.

lcd.write_string("123456789abcdefghijk")
lcd.home()
lcd.cursor_pos=(0,0)
lcd.write_string("123456789abcdefghijk") #Exception
Read more comments on GitHub >

github_iconTop Results From Across the Web

Using a 4x20 LCD with Arduino - Interfacing
Here I am back, trying to test my new setup of Arduino using a 4x20 LCD as output. The idea is to monitor...
Read more >
facing problem to display number on lcd - Keil forum
Hi, i am working on 4X20 LCD ....i wrote code for that this code is working but when trying to reset my board...
Read more >
View topic - LCD truble!!! is not possible but
I have a problem whit a 4x20 LCD Display whit ks0073 controller . ... what is wrong? ... To set the cursor at...
Read more >
Moving cursor to lower line on LCD
I FINALLY have the XLCD library working with a 4x20 LCD. I used the PutrsXLCD function to write a string to the first...
Read more >
Why won't the 3rd line of my 4x20 LCD work? It just ... - Quora
Hello, yes I have had a similar problem with the line numbers on 4x20 LCD displays. ... WriteLCDCommand( 0x80 ); // Sets cursor...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found