@@ -173,6 +173,7 @@ def __init__(self, rs, en, d4, d5, d6, d7, columns, lines
173
173
# itialize to 0,0
174
174
self .row = 0
175
175
self .column = 0
176
+ self ._column_align = False
176
177
# pylint: enable-msg=too-many-arguments
177
178
178
179
def home (self ):
@@ -201,6 +202,17 @@ def clear(self):
201
202
"""
202
203
self ._write8 (_LCD_CLEARDISPLAY )
203
204
time .sleep (0.003 )
205
+
206
+ @property
207
+ def column_align (self ):
208
+ """If True, message text after '\n ' starts directly below start of first
209
+ character in message. If False, text after '\n ' starts at column zero.
210
+ """
211
+ return self ._column_align
212
+
213
+ @column_align .setter
214
+ def column_align (self , enable ):
215
+ self ._column_align = enable
204
216
205
217
@property
206
218
def cursor (self ):
@@ -234,8 +246,9 @@ def cursor(self, show):
234
246
self ._write8 (_LCD_DISPLAYCONTROL | self .displaycontrol )
235
247
236
248
def cursor_position (self , column , row ):
237
- """Move the cursor to position ``column``, ``row``
238
-
249
+ """Move the cursor to position ``column``, ``row`` for the next
250
+ message only. Displaying a message resets the cursor position to (0, 0).
251
+
239
252
:param column: column location
240
253
:param row: row location
241
254
"""
@@ -369,6 +382,13 @@ def message(self, message):
369
382
# which case start on the opposite side of the display if cursor_position
370
383
# is (0,0) or not set. Start second line at same column as first line when
371
384
# cursor_position is set
385
+ if self .displaymode & _LCD_ENTRYLEFT > 0 :
386
+ col = self .column * self ._column_align
387
+ else :
388
+ if self ._column_align :
389
+ col = self .column
390
+ else :
391
+ col = self .columns - 1
372
392
self .cursor_position (col , line )
373
393
# Write string to display
374
394
else :
0 commit comments