I'd like some simple examples of data entry using a keyboard, please.
ElectricAye
Posts: 4,561
I've never implemented a keyboard before and, though I know there are objects for it in the OBEX, I was hoping some of you fine folks wouldn't mind posting some simple examples of data entry using a keyboard. My lack of assembly knowledge combined with the usual lack of comments in the OBEX always makes it difficult for me to get started with things like this.
Ideally, what I would like to do is have a VGA screen that looks something like this:
And then I'd like to be able to click next to each colon with a mouse, type in the data, hit the Enter key and have those entered values be assigned to their respective variables without a whole lot of obscene dramas taking place.
Many thanks,
Mark
Ideally, what I would like to do is have a VGA screen that looks something like this:
VGA screen wrote:
Filename:
Date:
Test run:
And then I'd like to be able to click next to each colon with a mouse, type in the data, hit the Enter key and have those entered values be assigned to their respective variables without a whole lot of obscene dramas taking place.
Many thanks,
Mark
Comments
The input routine in PropDOS has served me repeatedly for keyboard input in various programs. Perhaps it would be of help? http://forums.parallaxinc.com/forums/default.aspx?f=25&m=224206
OBC
Jeff,
Wow, this PropDOS of yours is one major piece of work! Would you say line 773, PUB input(data, size) | keystroke,len is the best place to start looking, to educate myself on keyboard usage?
thanks!
On his website you can download the propterminal.exe and demos for how to use the keyboard or mouse.
The demos show basic techniques how you can do it. The website is german but the Propterminal manual and the spin-files are in english
http://insonix.ch/propeller/prop_term.html
best regards
Stefan
the mose-democode
OBC
I'm sure this stuff will make sense to me once my brain is out of its allergic Springtime fog. Even on a good day, my eyes glaze over when I have to read computer code. Especially coding masterpieces written by gurus. Frankly, today I was hoping for something on the level with Dr. Seuss.
BTW, the first known use of the word nerd was from Dr. Seuss in 1950.
I'm attaching the file in case anybody wants to wade through my horrible coding skills, unorthodox usage of Spin tag whatchamacallits, outlandishly long variable names, overly verbose commentary and other tidbits than invariably infuriate people who actually know what they're doing when it comes to microcontrollers. I'm sure it's still got a bunch of bugs in it somewhere.
Thanks again to Jeff and Stephan for helping me out of the total fog. Much appreciated. :-)
You should also limit the number of characters that can be entered. Otherwise you can have a buffer overflow which might cause any kind of problems in your program.
Then make the input routine a function that can be used in several parts of the program by passing the screen position and the length of the input field.
..
;o)
That's a good idea. I think I'll add that on as I build on this.
Well, maybe I didn't do it quite right, but I thought (FileNameCursorPosition < 8) took care of that. When I tested it, the program seemed to work in that regard.
Thanks for the comments and for taking the time to look at the code. I almost never post any code because I know it will freak out the code gurus on here. LOL.
Just one little point: what's the reason for having ByteArrayAddressPointer and FileNameCursorPosition?
Byte[ByteArrayAddressPointer] := PressedKey
if you replace that by
SDcardFileName[ Pointer ] := PressedKey
you only need one pointer.
You should post code ..
1. It's not bad at all
2. it propably helps others
3. gurus only want to give you wisdom ...
PS: But you don't check for >0 when hitting backspace.
Oh, good point! I'll have to fix that tonight. Thanks very much!
first of all a comment on this:
Just in case the quoted was not meant with a big selfironic smile on your face.
You are the person that has to stay together with yourself every day 24 hours. So you this person should think positive whenever possible about this person.
This includes from time to time to step away from yourself 2m left and 2m up to watch yourself what you are doing. Giving a positive or negative value to the doing - not to your person itself.
Your person itself has always the same big value in itself. If you keep this in mind it will be much easier to look at things that went wrong.
Anyway in case of your code my opinion is: it is good. I'm coding with the same length of variablenames to make things clear just by reading selfexplaining names.
So the basic comment is in the names itself. I'm using ctrl-shift cursor left/right to mark these names and then copy & paste them.
Saves time and avoids typos. So I'm pretty fast in writing code even with long variable names (and less debugging for typos).
Showing code means I'm willing to learn from comments.
The command repeat has various options including a "until" and a "while" which makes the repeating conditional
this is a variant which I personally prefer over using a "quit" as it makes the code more readable
could be a variant to code this.
About what MagIO2 wrote I prefer to test things not only quick with one example but to test with everything extreme I can think of
In this case hitting backspace a dozen times
1) slowly,
2) very fast
3) with varying speed to see what happens. I do this even if I "know" nothing bad can happen. Just to reassure that really nothing can happen and to catch up all the case where I only "thought" nothing bad could happen
Maybe I can call this systematic testing. This will assure that the code is working properly right while writing the code
and not doing strange things later on if I already forgot about the details how this piece of code works.
I would add a CON-section with constant names for cursor-controlcodes
best regards
Stefan
Wow, Stefan, these are all very great suggestions. I will definitely incorporate them as I work this keyboard capability into my next project. I think you are the only person on this forum (besides me) whom I've ever heard confess to using long self-explanatory variable names. When I first started using the Propeller a few years ago, I used to complain about how the OBEX was filled with code written in "electronic grunt" that was impossible for a newbie to follow, but I was always slapped down for being inefficient, a whiner or whatever. Personally, I'm not happy unless each of my variable names contains a built-in biography of the variable, including its place of birth, favorite color, hobbies and whether or not it uses tobacco products.
Thanks for the help!
Mark