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

Post Reply
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

Post by Bobw »

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: 364 times
Been thanked: 716 times
Contact:

Re: Negative number from keypad

Post by JohnCrow »

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

Post by Bobw »

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: 364 times
Been thanked: 716 times
Contact:

Re: Negative number from keypad

Post by JohnCrow »

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: 474 times
Been thanked: 458 times
Contact:

Re: Negative number from keypad

Post by dazz »

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 277 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

Post by Bobw »

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: 474 times
Been thanked: 458 times
Contact:

Re: Negative number from keypad

Post by dazz »

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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Negative number from keypad

Post by medelec35 »

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
(156.93 KiB) Downloaded 5239 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 291 times
Martin

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

Re: Negative number from keypad

Post by dazz »

Martin silly question time, whats the reason for taking 48 from the keypad number
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

wayne millard
Posts: 234
Joined: Thu May 31, 2007 2:18 pm
Has thanked: 7 times
Been thanked: 12 times
Contact:

Re: Negative number from keypad

Post by wayne millard »

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

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

Re: Negative number from keypad

Post by dazz »

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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Negative number from keypad

Post by medelec35 »

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

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

Re: Negative number from keypad

Post by dazz »

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

Post Reply