Cardputer question - how to build text strings from user key strokes?
-
In UiFlow 2, how to use coding blocks to simply get keystrokes from a user and form into a string, ended by the Enter key? It would seem that this should be something simple, in the Text category of blocks. A List doesn't seem to be an answer. Nor does a ByteArray. Am I missing something? The "Prompt for User Input" block in Text category does nothing. Thanks.
-
@bigal2301 Unfortunately there isn't a built-in keyboard buffer handler block.
There is a keypress event handler which is good, but it seems designed so you can't both get a key code and the key string at the same time. This makes it tricky to handle 'special' keys.
I just threw together an example called "Example Keyboard Buffer" in the project zone.
It handles enter with a function, handles the delete key, and filters out tab/escape.
Much of the code is comments explaining things as well as a small scroll buffer on screen. -
@dissy
Hello dissy, thank you very much for your keyboard script. I have just spent a few hours trying to bring the Cardputer keyboard to life. Your program got me on the right track.
I am currently writing a manual on how to use the cardputer with micropython in German. I would like to use your script as a Micropython module and make it available for download on my website, with your authorship of course. Do you agree with this?
My website: https://micropython.aundz.net/index.php?title=M5CardComputer is still a work in progress.
Thank you very much. -
@peter Yes, that is perfectly OK with me. I'm glad you found it useful! Creating a module sounds like a wonderful idea
-
I will inform you when it is available on the internet. What should I write as a copyright notice?
-
@peter None needed. It is public domain
-
@dissy OK
-
Hi,
my Micropython Modul ist ready to use: http://micropython.aundz.net/index.php?title=M5CardComputer_Keyboard#Ein_Modul_zur_Keyboardabfrage
It is to use with Micropython (Thonny) not with UIFlow!
M5Stack uses 2 spaces for indentation, I used 4 spaces as it is standard in Micropython.