Page 2 of 2

Re: STM32F407Disc : Write data on LCD

Posted: Tue Jan 02, 2018 2:02 pm
by pythoncoder
nikhiledutech wrote:
Tue Jan 02, 2018 4:59 am
I think this is the same problem which you too faced while py board...
Sure, a year ago I was pretty confused about this myself, which was why I tried to document it in my installation guide. But I made an unwarranted assumption. I omitted to document sufficiently clearly the need to install the Unix build of MicroPython, which is necessary to run upip. I'll remedy this.

Re: STM32F407Disc : Write data on LCD

Posted: Wed Jan 03, 2018 5:20 am
by nikhiledutech
Yeah. Currently i want to print a variable whose value is changing continuously, like say ADC O/P. If i want to print this variable on LCD, how can i print it using your code. Or what changes i need to do , to print it on LCD.
import uasyncio as asyncio
import utime as time
from alcd import LCD, PINLIST

lcd = LCD(PINLIST, cols = 16)
x =1234
async def lcd_task():
for secs in range(20, -1, -1):
lcd[0] = 'x'.format(secs)
lcd[1] = "Solutions ".format(secs)
await asyncio.sleep(1)


loop = asyncio.get_event_loop()
loop.run_until_complete(lcd_task())
lcd[0] = 'x'.format(secs)
But as variable is in quotes it takes it as string. Can you help me in displaying variable on LCD.

Thanks :)

Re: STM32F407Disc : Write data on LCD

Posted: Wed Jan 03, 2018 6:41 am
by Roberthh
in 'x'.format(secs) x is the format specifier. Try '{}'.format(secs), or if you like a fixed width, '{:3}'.format(secs). For all details of Format specifiers, look into the Python manuals. https://pyformat.info/ or https://docs.python.org/3.1/library/string.html

Re: STM32F407Disc : Write data on LCD

Posted: Wed Jan 03, 2018 7:03 am
by nikhiledutech
Yeah. Thanks. Got it.
Now i have modified the code little bit to print a variable.
lcd = LCD(PINLIST, cols = 16)

async def lcd_task():
A = 1234
lcd[0] = 'A {}'.format(A)
lcd[1] = "Solution"
await asyncio.sleep(1)

loop = asyncio.get_event_loop()
loop.run_until_complete(lcd_task())

Now the variable gets printed on LCD as A 1234. I guess its the right way.
Thanks :)