Skip to content

Commit

Permalink
Check invalid cursor position only when auto_linebreaks enabled (#109)
Browse files Browse the repository at this point in the history
* Check invalid cursor position only when auto_linebreaks enabled
* Fixed too long line
  • Loading branch information
007hacky007 committed Mar 24, 2023
1 parent e651d9c commit 21fcead
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion RPLCD/lcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ def _get_cursor_pos(self):
def _set_cursor_pos(self, value):
if not hasattr(value, '__getitem__') or len(value) != 2:
raise ValueError('Cursor position should be determined by a 2-tuple.')
if value[0] not in range(self.lcd.rows) or value[1] not in range(self.lcd.cols):
if self.auto_linebreaks and \
(value[0] not in range(self.lcd.rows) or value[1] not in range(self.lcd.cols)):
msg = 'Cursor position {pos!r} invalid on a {lcd.rows}x{lcd.cols} LCD.'
raise ValueError(msg.format(pos=value, lcd=self.lcd))
row_offsets = [0x00, 0x40, self.lcd.cols, 0x40 + self.lcd.cols]
Expand Down

0 comments on commit 21fcead

Please sign in to comment.