STM32F407Disc : Write data on LCD

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
User avatar
pythoncoder
Posts: 3312
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: STM32F407Disc : Write data on LCD

Post by pythoncoder » Tue Jan 02, 2018 2:02 pm

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.
Peter Hinch

nikhiledutech
Posts: 118
Joined: Wed Dec 27, 2017 8:52 am

Re: STM32F407Disc : Write data on LCD

Post by nikhiledutech » Wed Jan 03, 2018 5:20 am

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 :)

User avatar
Roberthh
Posts: 1320
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: STM32F407Disc : Write data on LCD

Post by Roberthh » Wed Jan 03, 2018 6:41 am

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

nikhiledutech
Posts: 118
Joined: Wed Dec 27, 2017 8:52 am

Re: STM32F407Disc : Write data on LCD

Post by nikhiledutech » Wed Jan 03, 2018 7:03 am

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 :)

Post Reply