Jul-13-2018, 03:11 PM
>Hi All,
I am trying to build a function to write text to a 20X4 LCD.
I have imported the appropriate driver and defined the name of the lcd.
Side can be BB (port) or SB (starbord).
i now do:
Apparently i can not substitute the pre-defined 'lcdBB' by the constructed string dspy=('lcd'+side).
Can anyone advise if there is a way to do what i want (if possible at all).
Rgds Steffen
I am trying to build a function to write text to a 20X4 LCD.
I have imported the appropriate driver and defined the name of the lcd.
lcdBB=I2C_LCD_driver_twoLCD.lcd(0x26)Now i want to use a variable that is given as a parameter in the def of the function: side.
Side can be BB (port) or SB (starbord).
i now do:
dspy='lcd'+sidewhich results in:
>>> dspy 'lcdSB'To write a line to the lcd i do:
>>> lcdBB.lcd_display_string(boord+' pomp OFF',4)that works fine so i thought, can i construct the 'lcdBB" from the parameters of the function and thus i did:
>>> dspy.lcd_display_string(boord+' pomp OFF',4)
Error:Traceback (most recent call last):
File "<pyshell>", line 1, in <module>
AttributeError: 'str' object has no attribute 'lcd_display_string'
With the above AttributeError as result.Apparently i can not substitute the pre-defined 'lcdBB' by the constructed string dspy=('lcd'+side).
Can anyone advise if there is a way to do what i want (if possible at all).
Rgds Steffen