Skip to content

Commit 706a097

Browse files
authored
Merge pull request #20 from kattni/cursor-position-fix
cursor_position fix, add column check
2 parents 32570d2 + 6b34402 commit 706a097

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

adafruit_character_lcd/character_lcd.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,11 @@ def cursor_position(self, column, row):
236236
:param row: row location
237237
"""
238238
# Clamp row to the last row of the display
239-
if row > self.lines:
239+
if row >= self.lines:
240240
row = self.lines - 1
241+
# Clamp to last column of display
242+
if column >= self.columns:
243+
column = self.columns - 1
241244
# Set location
242245
self._write8(_LCD_SETDDRAMADDR | (column + _LCD_ROW_OFFSETS[row]))
243246

0 commit comments

Comments
 (0)