Skip to content

Commit 4a4ecfc

Browse files
mcauserdhylands
authored andcommitted
Move the cursor after putting a char (dhylands#7)
Looks good to me. I tested it on a 4x20 LCD and it works the same both before and after the patch.
1 parent 4944b8f commit 4a4ecfc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lcd/lcd_api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ def putchar(self, char):
134134
"""Writes the indicated character to the LCD at the current cursor
135135
position, and advances the cursor by one position.
136136
"""
137+
if char != '\n':
138+
self.hal_write_data(ord(char))
139+
self.cursor_x += 1
137140
if self.cursor_x >= self.num_columns or char == '\n':
138141
self.cursor_x = 0
139142
self.cursor_y += 1
140143
if self.cursor_y >= self.num_lines:
141144
self.cursor_y = 0
142145
self.move_to(self.cursor_x, self.cursor_y)
143-
if char != '\n':
144-
self.hal_write_data(ord(char))
145-
self.cursor_x += 1
146146

147147
def putstr(self, string):
148148
"""Write the indicated string to the LCD at the current cursor

0 commit comments

Comments
 (0)