@@ -260,6 +260,7 @@ def write(self, value, char_mode=False):
260
260
def begin (self , cols , lines ):
261
261
self .currline = 0
262
262
self .numlines = lines
263
+ self .numcols = cols
263
264
self .clear ()
264
265
265
266
@@ -404,13 +405,35 @@ def createChar(self, location, bitmap):
404
405
self .write (self .LCD_SETDDRAMADDR )
405
406
406
407
407
- def message (self , text ):
408
- """ Send string to LCD. Newline wraps to second line"""
409
- lines = str (text ).split ('\n ' ) # Split at newline(s)
410
- for i , line in enumerate (lines ): # For each substring...
411
- if i > 0 : # If newline(s),
412
- self .write (0xC0 ) # set DDRAM address to 2nd line
413
- self .write (line , True ) # Issue substring
408
+ def message (self , text , limitMode = 0 ):
409
+ """ Send string to LCD. Newline wraps to next line"""
410
+ lines = str (text ).split ('\n ' ) # Split at newline(s)
411
+ for i , line in enumerate (lines ): # For each substring...
412
+ if i == 1 : # If newline(s),
413
+ self .write (0xC0 ) # set DDRAM address to 2nd line
414
+ elif i == 2 :
415
+ self .write (0x94 )
416
+ elif i >= 3 :
417
+ self .write (0xD4 )
418
+ """Now depending on the limit mode set by the function call this will handle """
419
+ lineLength = len (line )
420
+ limit = self .numcols
421
+ if limitMode <= 0 :
422
+ self .write (line , True )
423
+ elif lineLength >= limit and limitMode == 1 :
424
+ '''With the limit mode set to 1 the line is truncated
425
+ at the number of columns available on the display'''
426
+ limitedLine = line [0 :self .numcols ]
427
+ self .write (limitedLine , True )
428
+ elif lineLength >= limit and limitMode == 2 :
429
+ '''With the limit mode set to 2 the line is truncated
430
+ at the number of columns minus 3 to add in an elipse'''
431
+ limitedLine = line [0 :self .numcols - 3 ]+ '...'
432
+ self .write (limitedLine , True )
433
+ elif lineLength >= limit and limitMode >= 3 :
434
+ '''Future todo, add in proper, "line after line" cariage return'''
435
+ else :
436
+ self .write (line , True )
414
437
415
438
416
439
def backlight (self , color ):
0 commit comments