Negative number from keypad
Moderator: Benj
-
- 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
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?
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?
- JohnCrow
- 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
Hi Bob
Just a quick though, could you program it to use the ascii code for "-"
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 !
-
- 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
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
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
- JohnCrow
- 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
Now thats a good idea
Flowcode for Android
Flowcode for Android
1 in 10 people understand binary, the other one doesn't !
-
- Posts: 1314
- Joined: Sun Jan 15, 2012 3:15 pm
- Has thanked: 474 times
- Been thanked: 458 times
- Contact:
Re: Negative number from keypad
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
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 278 times
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php
-
- 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
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
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
-
- Posts: 1314
- Joined: Sun Jan 15, 2012 3:15 pm
- Has thanked: 474 times
- Been thanked: 458 times
- Contact:
Re: Negative number from keypad
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
-
- 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
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 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
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 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 293 times
Martin
-
- Posts: 1314
- Joined: Sun Jan 15, 2012 3:15 pm
- Has thanked: 474 times
- Been thanked: 458 times
- Contact:
Re: Negative number from keypad
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
-
- Posts: 234
- Joined: Thu May 31, 2007 2:18 pm
- Has thanked: 7 times
- Been thanked: 12 times
- Contact:
Re: Negative number from keypad
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
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
-
- Posts: 1314
- Joined: Sun Jan 15, 2012 3:15 pm
- Has thanked: 474 times
- Been thanked: 458 times
- Contact:
Re: Negative number from keypad
cheers wayne
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php
-
- 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
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
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 ) 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
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
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 ) 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
-
- Posts: 1314
- Joined: Sun Jan 15, 2012 3:15 pm
- Has thanked: 474 times
- Been thanked: 458 times
- Contact:
Re: Negative number from keypad
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