MCPcopy Create free account
hub / github.com/RetiredWizard/PyDOS / lcdScroll

Function lcdScroll

lcdscroll.py:15–141  ·  view source on GitHub ↗
(argv)

Source from the content-addressed store, hash-verified

13 import lcd2004
14
15def lcdScroll(argv):
16
17 if argv == "":
18 if envVars.get("stopthread","") == "":
19 argv = input("Say what?: ")
20 else:
21 print('\nUse "passedIn" environment variable to define text for threaded run.')
22
23 # The PCF8574 has a jumper selectable address: 0x20 - 0x27
24 DEFAULT_I2C_ADDR = 0x27
25 foundLCD = False
26
27 i2c = None
28 for i2cNo in range(3):
29 try:
30 i2c = Pydos_hw.I2C(i2cNo)
31 except:
32 pass
33 if i2c:
34 if sys.implementation.name.upper() == "CIRCUITPYTHON":
35 # circuitpython seems to require locking the i2c bus
36 while not i2c.try_lock():
37 pass
38
39 if DEFAULT_I2C_ADDR in i2c.scan():
40 foundLCD = True
41 break
42
43 if sys.implementation.name.upper() == 'CIRCUITPYTHON':
44 i2c.unlock()
45
46 if not foundLCD:
47 print("LCD not found at address: ",hex(DEFAULT_I2C_ADDR))
48 return
49
50 if sys.implementation.name.upper() == "CIRCUITPYTHON":
51
52 # 2 lines, 16 characters per line
53 lcd = I2cLcd(i2c, DEFAULT_I2C_ADDR, 2, 16)
54
55 # smiley faces as custom characters
56 happy = bytearray([0x00,0x0A,0x00,0x04,0x00,0x11,0x0E,0x00])
57 heart = bytearray([0x00,0x00,0x0A,0X15,0X11,0X0A,0X04,0X00])
58 grin = bytearray([0x00,0x00,0x0A,0x00,0x1F,0x11,0x0E,0x00])
59 lcd.custom_char(0, happy)
60 lcd.custom_char(1, heart)
61 lcd.custom_char(2, grin)
62
63 else:
64
65 ID=1
66 lcd=lcd2004.lcd(DEFAULT_I2C_ADDR,i2c)
67 lcd.lcd_backlight(True)
68 lcd.lcd_clear()
69
70 if argv == "":
71 if sys.implementation.name.upper() == "CIRCUITPYTHON":
72 lcd.backlight_off()

Callers 1

lcdscroll.pyFile · 0.85

Calls 15

hal_write_commandMethod · 0.95
inputFunction · 0.90
I2cLcdClass · 0.90
getMethod · 0.80
I2CMethod · 0.80
custom_charMethod · 0.80
lcd_backlightMethod · 0.80
lcd_clearMethod · 0.80
backlight_offMethod · 0.80
move_toMethod · 0.80
putstrMethod · 0.80
lcd_printMethod · 0.80

Tested by

no test coverage detected