Negative number from keypad

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Bobw
Posts: 157
Joined: Sat Jan 22, 2011 10:39 pm
Location: Michigan
Has thanked: 6 times
Been thanked: 27 times
Contact:

Negative number from keypad

Postby Bobw » Tue Apr 24, 2012 11:11 pm

I am playing around with the keypad trying to figure out how to pass a negative symbol to a variable.
IE: User wants to input -60. This should equal 3 key presses from the keypad. -, 6, 0
I am using a 4x4 key pad, and figuring the F key would be labeled - or (15) when pressed.
I think I figured out how to read a key press and pass it to one variable, and read a second key press and pass it to a second variable. But the negative symbol is kicking my brain.

I have found most of the examples for the key locks/door locks that have been posted on here.

Any Ideas?

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 381 times
Been thanked: 715 times
Contact:

Re: Negative number from keypad

Postby JohnCrow » Wed Apr 25, 2012 8:53 am

Hi Bob

Just a quick though, could you program it to use the ascii code for "-"
1 in 10 people understand binary, the other one doesn't !

Bobw
Posts: 157
Joined: Sat Jan 22, 2011 10:39 pm
Location: Michigan
Has thanked: 6 times
Been thanked: 27 times
Contact:

Re: Negative number from keypad

Postby Bobw » Wed Apr 25, 2012 2:31 pm

John,

I thought about that last night.
Need to input from -90 to 450.
Won't be able to play around with it till this weekend.
To bad there is not a FC app so I could play with it on my tablet.

Bob

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 381 times
Been thanked: 715 times
Contact:

Re: Negative number from keypad

Postby JohnCrow » Wed Apr 25, 2012 3:04 pm

Now thats a good idea
Flowcode for Android :wink: :D
1 in 10 people understand binary, the other one doesn't !

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 514 times
Been thanked: 467 times
Contact:

Re: Negative number from keypad

Postby dazz » Wed Apr 25, 2012 3:16 pm

Try this should give you enough to get started use the f key in sim to get your symbol

a very quick way to get the decimal number for a key press, is to open a flowchart add a loop with a keypad macro in it, add a variable as the return byte in the macro, then in build option select 100 as a speed, then simulate simple add the variable you created then everytime you press a hey the number associated with that key is diplayed, to change say the f key use a decision branch as in my flowchrt , to get the hex value for the symbol you want displayed open windows calculater and set it to programmer mode (a good tip from either john crow or medelec was either or both) then looking at the ascii chart in the help files, simply type in the binary number for the symbol you want, click on the hex box incalc and use that number hth
Attachments
quick -ve input.fcf
(10 KiB) Downloaded 87 times
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

Bobw
Posts: 157
Joined: Sat Jan 22, 2011 10:39 pm
Location: Michigan
Has thanked: 6 times
Been thanked: 27 times
Contact:

Re: Negative number from keypad

Postby Bobw » Wed Apr 25, 2012 6:32 pm

Dazz,

Played around with your example a bit.
That may work.
Will have another go at it this weekend.
I thought about using go to satements in case the input needed to be erased (wrong key pressed)
Would give you an easy way to back up a step.

Thanks

Bob

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 514 times
Been thanked: 467 times
Contact:

Re: Negative number from keypad

Postby dazz » Wed Apr 25, 2012 9:08 pm

Hi if you look at one of medelecs door lock flowcharts theres one somewhere which shows how to deal with incorrect inputs. the one i posted is just a quick way to make a specific key show a - on a display, you could also map another key say the A key to maybe act as a backspace key for incorrect input hth
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8420
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2405 times
Been thanked: 3437 times
Contact:

Re: Negative number from keypad

Postby medelec35 » Wed Apr 25, 2012 10:06 pm

Hi Bob,
I have adapted a flowchart to allow you to enter -negative or positive numbers.
You can enter between 1 and 3 digits and minus can be used at any time. E.g
1
67
-4
-890
46-7
1-23
Take the last example.
If you enter 1-23 then result variable = -123
Neg Nums.png
Neg Nums.png (156.93 KiB) Viewed 4406 times


E is to enter digits
C is to clear last entry

If I can think of a way to simplify it then I will.

Martin
Attachments
Neg Num).fcf
(17.09 KiB) Downloaded 106 times
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 514 times
Been thanked: 467 times
Contact:

Re: Negative number from keypad

Postby dazz » Thu Apr 26, 2012 12:23 pm

Martin silly question time, whats the reason for taking 48 from the keypad number
These users thanked the author dazz for the post:
medelec35 (Fri Apr 27, 2012 4:15 pm)
Rating: 5.26%
 
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

wayne millard
Posts: 224
Joined: Thu May 31, 2007 2:18 pm
Has thanked: 6 times
Been thanked: 11 times
Contact:

Re: Negative number from keypad

Postby wayne millard » Thu Apr 26, 2012 12:45 pm

Hi

I is because when you press the button 0 = 48 1 = 49 and so on so you need to take 48 from the result you get to get the number of the button you have pressed.

wayne
These users thanked the author wayne millard for the post:
dazz (Thu Apr 26, 2012 12:55 pm)
Rating: 5.26%
 

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 514 times
Been thanked: 467 times
Contact:

Re: Negative number from keypad

Postby dazz » Thu Apr 26, 2012 12:54 pm

cheers wayne
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8420
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2405 times
Been thanked: 3437 times
Contact:

Re: Negative number from keypad

Postby medelec35 » Thu Apr 26, 2012 1:10 pm

Not a silly question at all. In fact that is a good question!
I have not got V3 to check, but I believe it was Bert Van dam who did it that way.
the -48 just converted ASCII into the relevant number.
E.g number 1 is ASCII 49.
so 49-48 =1
I just kept it like that for people with FC3 load flowchart with free V5 and create their own V3.
Since I don't believe FC3 has GetKeypadNumber??
Will find out tonight :lol:
If I am wrong then there is no need to have used -48 at all.
However since V3 is years old now I will be stopping that method and just use GetKeypadNumber instead of
GetKeypadAscii

Martin

Edit: Just noticed a new post has been posted, so sorry if repeating any information.

Edit2, My memory is getting poor (Dam old age :lol: ) Flowcode3 does have GetKeypadNumber, so GetKeypadAscii could of been used
to send ASCII via rs232.
Anyway from now on I will revert to GetKeypadNumber!
Thanks Daz :)
These users thanked the author medelec35 for the post:
dazz (Thu Apr 26, 2012 1:25 pm)
Rating: 5.26%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 514 times
Been thanked: 467 times
Contact:

Re: Negative number from keypad

Postby dazz » Thu Apr 26, 2012 1:24 pm

Ah got it as i used getkeypad number and didnt notice you used get ascii, but glad i asked as its good to know the differences between the two
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php