1+ import time
2+
13import machine
24from lib .i2c_lcd import I2cLcd
35
@@ -20,9 +22,10 @@ def __init__(self, sda_pin: int, scl_pin: int):
2022 self .__lcd = I2cLcd (self .__i2c , 0x27 , 2 , 16 )
2123 self .__init_symbols ()
2224
23- def print (self , text : str , line : int = 1 , position : int = 1 , clear_line : bool = False , clear_full : bool = False ):
25+ def print (self , text : str , line : int = 1 , position : int = 1 , clear_line : bool = False , clear_full : bool = False , trim : bool = True ):
2426 self .__validate_inputs (line , position )
25- text = self .__trim_text (text )
27+ if trim :
28+ text = self .__trim_text (text )
2629
2730 if clear_full :
2831 self .clear ()
@@ -49,6 +52,17 @@ def clear(self, line: int = None):
4952 else :
5053 self .__lcd .clear ()
5154
55+ def print_scroll_text (self , text : str , line : int = 1 , delay : float = 0 ):
56+ self .__validate_inputs (line )
57+ if len (text ) <= 16 :
58+ self .print (text , line )
59+ return
60+
61+ padded_text = text + " " * 16
62+ for start in range (len (padded_text ) - 15 ):
63+ self .print (padded_text [start :start + 16 ], line , clear_line = True )
64+ time .sleep (delay )
65+
5266 def __init_symbols (self ):
5367 for symbol in Symbols .__dict__ .values ():
5468 if isinstance (symbol , Symbol ):
0 commit comments