wms Posted January 14, 2005 Report Posted January 14, 2005 Hi Peter, Is it possible to programme a joystick button so that it cycles through a series of key combinations?. I am thinking specifically of the PSS A320 where there are separate key combinations for the three different Speed Brake settings, ie LOW, MED, MAX. I would like to be able to either press a single key and hold it until the required setting is set, or repeatedly press the same key until the required setting is set. Is this possible? Many Thanks
Pete Dowson Posted January 14, 2005 Report Posted January 14, 2005 Is it possible to programme a joystick button so that it cycles through a series of key combinations?. I am thinking specifically of the PSS A320 where there are separate key combinations for the three different Speed Brake settings, ie LOW, MED, MAX. I would like to be able to either press a single key and hold it until the required setting is set, or repeatedly press the same key until the required setting is set. Is this possible? Yes. You will have to do this by editing in the FSUIPC.INI file. You can do it by using the facilities for setting and clearing flags and having conditional actions. Check out the Advanced User's documentation. You could also do it by using FSUIPC offsets - incrementing one and making other actions on the same key dependent upon the value. But for that you need some publically available offsets. I will be releasing a batch of those soon, mainly aimed at making it easier to use my GFdisplay (Go Flight display control program), but they could be used for anything, providing that it's for private use (so avoiding clashes between different products). Look at flags first though. Regards, Pete
wms Posted January 14, 2005 Author Report Posted January 14, 2005 Pete, Thanks for that. I'll try programming the buttons using the Advanced User Guide. If there are any users who have already done this and are willing to give some help, it would be very much appreciated. Many Thanks
hm Posted January 15, 2005 Report Posted January 15, 2005 Hi, This is some programming I did to test some ideas I had. It is working! Of coarse you can make it in your application much simpler if you use the 1-3 of the counter directly to set your instructions. My programming is for a 8 button Microsoft Sidewinder. hm [buttons] PollInterval=20 ; 0=CP(F-10)(-0,7)0,6,C1003,20 1=CP(F-10)(-0,6)0,7,C1003,20 ; ; Flag 10 follows key (-6 & -7) ; 2=CU(-0,7)0,6,C1003,10 3=CU(-0,6)0,7,C1003,10 ; ; Flag 11 follows key (+6 & -7) ; 4=CP(-0,7)0,6,C1004,10 5=CP(-0,7)0,6,C1003,11 6=CU(F+0,11)0,6,C1004,11 ; ; Flag 12 follows key (-6 & +7) ; 7=CP(-0,6)0,7,C1004,10 8=CP(-0,6)0,7,C1003,12 9=CU(F+0,12)0,7,C1004,12 ; ; Flag 13 follows key (+6 & +7) ; 10=CP(F+0,11)0,7,C1004,11 11=CP(+0,6)0,7,C1003,13 12=CU(F+0,13)0,7,C1004,13 ; 13=CP(F+0,12)0,6,C1004,12 14=CP(+0,7)0,6,C1003,13 15=CU(F+0,13)0,6,C1004,13 ;------------------------------------------------------------------- ; 8 state up/down counter :------------------------------------------------------------------- ; Count up ;------------------------------------------------------------------- 16=CP(F+0,13)0,3,C1005,14 17=CP(F+0,13)(F-0,14)0,3,C1005,15 18=CP(F+0,13)(F-0,14)(F-0,15)0,3,C1005,16 ; 19=CP(F+0,20)(F+0,14)0,3,C1004,20 20=CP(F+0,20)(F+0,15)0,3,C1004,20 21=CP(F+0,20)(F+0,16)0,3,C1004,20 22=CP(F+0,13)(F-0,14)(F-0,15)(F-0,16)0,3,C1003,20 ; 23=CP(F+0,21)(F-0,14)0,3,C1004,21 24=CP(F+0,21)(F+0,15)0,3,C1004,21 25=CP(F+0,21)(F+0,16)0,3,C1004,21 26=CP(F+0,13)(F+0,14)(F-0,15)(F-0,16)0,3,C1003,21 ; 27=CP(F+0,22)(F+0,14)0,3,C1004,22 28=CP(F+0,22)(F-0,15)0,3,C1004,22 29=CP(F+0,22)(F+0,16)0,3,C1004,22 30=CP(F+0,13)(F-0,14)(F+0,15)(F-0,16)0,3,C1003,22 ; 31=CP(F+0,23)(F-0,14)0,3,C1004,23 32=CP(F+0,23)(F-0,15)0,3,C1004,23 33=CP(F+0,23)(F+0,16)0,3,C1004,23 34=CP(F+0,13)(F+0,14)(F+0,15)(F-0,16)0,3,C1003,23 ; 35=CP(F+0,24)(F+0,14)0,3,C1004,24 36=CP(F+0,24)(F+0,15)0,3,C1004,24 37=CP(F+0,24)(F-0,16)0,3,C1004,24 38=CP(F+0,13)(F-0,14)(F-0,15)(F+0,16)0,3,C1003,24 ; 39=CP(F+0,25)(F-0,14)0,3,C1004,25 40=CP(F+0,25)(F+0,15)0,3,C1004,25 41=CP(F+0,25)(F-0,16)0,3,C1004,25 42=CP(F+0,13)(F+0,14)(F-0,15)(F+0,16)0,3,C1003,25 ; 43=CP(F+0,26)(F+0,14)0,3,C1004,26 44=CP(F+0,26)(F-0,15)0,3,C1004,26 45=CP(F+0,26)(F-0,16)0,3,C1004,26 46=CP(F+0,13)(F-0,14)(F+0,15)(F+0,16)0,3,C1003,26 ; 47=CP(F+0,27)(F-0,14)0,3,C1004,27 48=CP(F+0,27)(F-0,15)0,3,C1004,27 49=CP(F+0,27)(F-0,14)0,3,C1004,27 50=CP(F+0,13)(F+0,14)(F+0,15)(F+0,16)0,3,C1003,27 ;----------------------------------------------------- ; Count down ;----------------------------------------------------- 51=CP(F+0,13)0,2,C1005,14 52=CP(F+0,13)(F+0,14)0,2,C1005,15 53=CP(F+0,13)(F+0,14)(F+0,15)0,2,C1005,16 ; 54=CP(F+0,20)(F+0,14)0,2,C1004,20 55=CP(F+0,20)(F+0,15)0,2,C1004,20 56=CP(F+0,20)(F+0,16)0,2,C1004,20 57=CP(F+0,13)(F-0,14)(F-0,15)(F-0,16)0,2,C1003,20 ; 58=CP(F+0,21)(F-0,14)0,2,C1004,21 59=CP(F+0,21)(F+0,15)0,2,C1004,21 60=CP(F+0,21)(F+0,16)0,2,C1004,21 61=CP(F+0,13)(F+0,14)(F-0,15)(F-0,16)0,2,C1003,21 ; 62=CP(F+0,22)(F+0,14)0,2,C1004,22 63=CP(F+0,22)(F-0,15)0,2,C1004,22 64=CP(F+0,22)(F+0,16)0,2,C1004,22 65=CP(F+0,13)(F-0,14)(F+0,15)(F-0,16)0,2,C1003,22 ; 66=CP(F+0,23)(F-0,14)0,2,C1004,23 67=CP(F+0,23)(F-0,15)0,2,C1004,23 68=CP(F+0,23)(F+0,16)0,2,C1004,23 69=CP(F+0,13)(F+0,14)(F+0,15)(F-0,16)0,2,C1003,23 ; 70=CP(F+0,24)(F+0,14)0,2,C1004,24 71=CP(F+0,24)(F+0,15)0,2,C1004,24 72=CP(F+0,24)(F-0,16)0,2,C1004,24 73=CP(F+0,13)(F-0,14)(F-0,15)(F+0,16)0,2,C1003,24 ; 74=CP(F+0,25)(F-0,14)0,2,C1004,25 75=CP(F+0,25)(F+0,15)0,2,C1004,25 76=CP(F+0,25)(F-0,16)0,2,C1004,25 77=CP(F+0,13)(F+0,14)(F-0,15)(F+0,16)0,2,C1003,25 ; 78=CP(F+0,26)(F+0,14)0,2,C1004,26 79=CP(F+0,26)(F-0,15)0,2,C1004,26 80=CP(F+0,26)(F-0,16)0,2,C1004,26 81=CP(F+0,13)(F-0,14)(F+0,15)(F+0,16)0,2,C1003,26 ; 82=CP(F+0,27)(F-0,14)0,2,C1004,27 83=CP(F+0,27)(F-0,15)0,2,C1004,27 84=CP(F+0,27)(F-0,14)0,2,C1004,27 85=CP(F+0,13)(F+0,14)(F+0,15)(F+0,16)0,2,C1003,27 ; ;------------------------------------------------------------- ; Here are the commands for FS9 ;------------------------------------------------------------- ;if -6 & -7 (Flag 10) ; 86=CR(F+0,10)0,0,C65588,0 ;Break Repeat 87=CP(F+0,20)(F+0,10)0,1,C65570,0 ;State 0 :Gear Toggle 88=CR(F+0,20)(F+0,10)0,2,C65607,0 ;State 0 :Trim down Repeat 89=CR(F+0,20)(F+0,10)0,3,C65615,0 ;State 0 :Trim up Repeat 90=CP(F+0,10)0,4,C65758,0 ;Flaps Incr 91=CP(F+0,10)0,5,C65759,0 ;Flaps Decr ; ; if +6 & -7 (Flag 11) ; 92=CP(F+0,20)(F+0,11)0,0,C65752,1 ;Parking breaks toggle 93=CP(F+0,20)(F+0,11)0,1,C65751,0 ;State 0 :Landing Lights Toggle 94=CR(F+0,20)(F+0,11)0,2,C65771,0 ;State 0 :Propeller Pitch Decr 95=CR(F+0,20)(F+0,11)0,3,C65769,0 ;State 0 :Propeller Pitch Incr 96=CP(F+0,20)(F+0,11)0,4,C66390,0 ;Wing fold (Dragchute) toggle 97=CP(F+0,20)(F+0,11)0,5,C65589,0 ;Spoilers toggle ; ; if -6 & +7 (Flag 12) ; 98=CP(F+0,12)0,0,K192,1 ;~ for CS727 99=CP(F+0,20)(F+0,12)0,1,C65858,0 ;State 0 :Pitot Heat Toggle 100=CR(F+0,20)(F+0,12)0,2,C65777,0 ;State 0 :Mixture Decr 101=CR(F+0,20)(F+0,12)0,3,C65775,0 ;State 0 :Mixture Incr 102=CP(F+0,12)0,4,K83,8 ;Next view 103=CP(F+0,12)0,5,K83,9 ;Previous view ; ; if +7 & +8 (Flag 13) ; 104=CP(F+0,20)(F+0,13)(F-0,31)0,0,C66224,0 ;State 0 :Autostart Engines 105=CP(F+0,20)(F+0,13)(F+0,31)0,0,K112,11 ;State 0 :Engine shut down (CTRL+SHFT+F1) 106=CU(F+0,20)(F+0,13)0,0,C1005,31 ;State 0 :Toggle Engine Flag 107=CP(F+0,20)(F+0,13)0,1,C66293,0 ;State 0 :Toggle Avionics Master 108=CP(F+0,20)(F+0,13)0,2,C66244,0 ;State 0 :Decrement Cowl Flaps 109=CP(F+0,20)(F+0,13)0,3,C66243,0 ;State 0 :Increment Cowl flaps ; ;------------------------------------------------------------- ; Here with the 8 state machine ;------------------------------------------------------------- ; State 1: COM1 radio ;------------------------------------------------------------- ; 110=CP(F+0,21)(F+0,11)0,1,C66372,0 ;Toggle Standby/COM 1 111=CR(F+0,21)(F+0,11)0,2,C65636,0 ;COM 1 units (-1) 112=CR(F+0,21)(F+0,11)0,3,C65637,0 ;COM 1 units (+1) 113=CR(F+0,21)(F+0,12)0,2,C66434,0 ;COM 1 fractions (-1+C) 114=CR(F+0,21)(F+0,12)0,3,C66435,0 ;COM 1 fractions (+1+C) ; ;------------------------------------------------------------- ; State 2: COM2 radio ;------------------------------------------------------------- ; 115=CP(F+0,22)(F+0,11)0,1,C66444,0 ;Toggle Standby/COM 2 116=CR(F+0,22)(F+0,11)0,2,C66436,0 ;COM 2 units (-1) 117=CR(F+0,22)(F+0,11)0,3,C66437,0 ;COM 2 units (+1) 118=CR(F+0,22)(F+0,12)0,2,C66439,0 ;COM 2 fractions (-1) 119=CR(F+0,22)(F+0,12)0,3,C66441,0 ;COM 2 fractions (+1) ; ;------------------------------------------------------------- ; State 3: Heading Bug ;------------------------------------------------------------- ; 120=CP(F+0,23)(F+0,11)0,2,C65880,0 ;Heading Bug (-1) 121=CP(F+0,23)(F+0,11)0,3,C65879,0 ;Heading Bug (+1) 122=CR(F+0,23)(F+0,12)0,2,C1024,0 ;Heading Bug (-10) 123=CR(F+0,23)(F+0,12)0,3,C1025,0 ;Heading Bug (+10) ; ;------------------------------------------------------------- ; State 4: NAV1 Frequence ;------------------------------------------------------------- ; 124=CP(F+0,22)(F+0,11)0,1,C65640,0 ;Toggle Standby/NAV 1 125=CR(F+0,22)(F+0,11)0,2,C65640,0 ;NAV 1 units (-1) 126=CR(F+0,22)(F+0,11)0,3,C65641,0 ;NAV 1 units (+1) 127=CR(F+0,22)(F+0,12)0,2,C66445,0 ;NAV 1 fractions (-1) 128=CR(F+0,22)(F+0,12)0,3,C66446,0 ;NAV 1 fractions (+1) ; ;------------------------------------------------------------- ; State 5: VOR1 OBI ;------------------------------------------------------------- ; 129=CP(F+0,24)(F+0,11)0,2,C65662,0 ;VOR1 OBI (-1) 130=CP(F+0,24)(F+0,11)0,3,C65663,0 ;VOR1 OBI (+1) 131=CR(F+0,24)(F+0,12)0,2,C1024,0 ;VOR1 OBI (-10) 132=CR(F+0,24)(F+0,12)0,3,C1025,0 ;VOR1 OBI (+10) ; ;------------------------------------------------------------- ; State 6: NAV2 Frequence ;------------------------------------------------------------- ; 133=CP(F+0,22)(F+0,11)0,1,C66452,0 ;Toggle Standby/NAV 2 134=CR(F+0,22)(F+0,11)0,2,C65644,0 ;NAV 2 units (-1) 135=CR(F+0,22)(F+0,11)0,3,C65645,0 ;NAV 2 units (+1) 136=CR(F+0,22)(F+0,12)0,2,C66449,0 ;NAV 2 fractions (-1) 137=CR(F+0,22)(F+0,12)0,3,C66450,0 ;NAV 2 fractions (+1) ; ;------------------------------------------------------------- ; State 7: VOR2 OBI ;------------------------------------------------------------- ; 138=CP(F+0,25)(F+0,11)0,2,C65664,0 ;VOR2 OBI (-1) 139=CP(F+0,25)(F+0,11)0,3,C65665,0 ;VOR2 OBI (+1) 140=CR(F+0,25)(F+0,12)0,2,C1024,0 ;VOR2 OBI (-10) 141=CR(F+0,25)(F+0,12)0,3,C1025,0 ;VOR2 OBI (+10)
wms Posted January 17, 2005 Author Report Posted January 17, 2005 Thanks for that. It all looks awfully complicated so I think I'll just go back to the simpler method of having three separate buttons programmed for each of the three separate functions. Many Thanks for your response.
Pete Dowson Posted January 17, 2005 Report Posted January 17, 2005 Thanks for that. It all looks awfully complicated so I think I'll just go back to the simpler method of having three separate buttons programmed for each of the three separate functions. I think that ambitious project put you off, eh? It certainly doesn't need to be anywhere near as complex just for three states. Did you look at the business about flags and conditions in the Advanced User's documentation? I can help, but I'd rather not simply work out solutions -- helping folks reach their own solutions is better because then they understand and can go on to do more. Ask specific questions instead and we'll get there. What you are looking for is simply something like this: if in "state 1" this button should do X and change the state to 2 if in "state 2" this button should do Y and change the state to 3 if in "state 3" this button should do Z and change the state to 1 Now the Flags offered by FSUIPC are either on or off, so you cannot get 3 different states from only 1 of them -- you'd need 2. So, choose 2 arbitrary flags -- these are really button numbers for buttons you haven't got -- FSUIPC provides one flag for each possible button (0-31) on joysticks 0-15, so there are plenty which you won't (cannot) be using for "real" buttons. So, to make the arithmetic easy, say you choose flags on joystick 10, buttons 0 and 1. These have numbers 256*10 + 0 and 256*10 + 1, or 2560 and 2561 respectively. Your "if" lines above (conditionals) will be: if button pressed and not flag 2560 and not Flag 2561, do X, and set Flag 2560 if button pressed and flag 2560 but not Flag 2561, do Y, and set Flag 2561 if button pressed and flag 2560 and Flag 2561, do Z, and clear Flag 2560 and clear Flag 2561 Now, because, in FSUIPC, each parameter line can only do one thing, this amounts not to 3 entries in the INI, but 7: if button pressed and not Flag 2560 and not Flag 2561, do X if button pressed and not Flag 2560 and not Flag 2561, set Flag 2560 if button pressed and Flag 2560 but not Flag 2561, do Y if button pressed and Flag 2560 but not Flag 2561, set Flag 2561 if button pressed and Flag 2560 and Flag 2561, do Z if button pressed and Flag 2560 and Flag 2561, clear Flag 2560 if button pressed and not Flag 2560 and Flag 2561 clear Flag 2561 Note that the very last line looks wrong as it is conditional on "not Flag 2560", but it has to be this way because the line before cleared that Flag. Without this the logic would break down -- FSUIPC executes ALL the lines it finds for that one button press, not just the first one it finds applicable. This also brings up another point. For each of the three little groups the lines need to be defined in this order because FSUIPC processes them in order (actually in the order of the left-hand line number in the [buttons] section). If they got out of order, then the Flags would be changed in the wrong order. Phew ....looks like I've done most of the work after all. I hope I've made it understandable. All you need to do is convert that to the parametric format laid down in the documentation. Do you think you can do that? If not ask questions. Regards, Pete
wms Posted January 17, 2005 Author Report Posted January 17, 2005 OK. I,ll give it a go and come back to you if (when) I need some help. Many Thanks
hm Posted January 17, 2005 Report Posted January 17, 2005 Well here is my (shorter :wink: )solution: 01= P0,3,C1005,11 02= CP(F-0,11)0,3,C1005,12 03=CP(F-0,11)(F-0,12)0,3, do this 04=CP(F+0,11)(F-0,12)0,3, do that 05=CP(FF+0,11)(F+0,12)0,3, do the third thing How does it work, line 3 to 5 are a binary decoding of the possible combinations of the states of two flags 11 and 12 (states 00, 10 and 11) line 1 and 2 are forming a binary 3 counter: 01 the first line toggles flag 11: if you push the button (here 3) flag 11 changes his state from 0 to 1 or from 0 to 1 so this flag cycles trough 0 - 1 - 0 - 1 - 0 - 1 - 0 - 1 - .... by each pusch of the button. in rule 2 however flag 12, which has also a toggle command, can only be toggled when flag 11 is zero and as such this flag changes his state as follows by each puch of the button: 0 - 0 - 1 - 1 - 0 - 0 - 1 - 1 - ...... in combination with flag 11 : a binary 3 state counter which is decoded in the three following rules. My previous example was of course very complicated but it contains the rules of above (16, 17) and it shows you how you can assign a lot of commands to a few joystick buttons. hm
Pete Dowson Posted January 17, 2005 Report Posted January 17, 2005 Well here is my (shorter :wink: )solution:.... in combination with flag 11 : a binary 3 state counter which is decoded in the three following rules. Very clever, but I'm glad you had to explain it rather than me, and you did it so very well too! Thanks. Just one typo to correct -- there's an FF in line 5 which should be just F of course. Thanks again, Pete
hm Posted January 17, 2005 Report Posted January 17, 2005 Sorry I made a few typo's, this is the correction: Well here is my (shorter icon_wink.gif )solution: 01= P0,3,C1005,11 02= CP(F-0,11)0,3,C1005,12 03=CP(F+0,11)(F-0,12)0,3, do this 04=CP(F+0,11)(F+0,12)0,3, do that 05=CP(F-0,11)(F-0,12)0,3, do the third thing How does it work, line 3 to 5 are a binary decoding of the possible combinations of the states of two flags 11 and 12 (states 00, 10 and 11) line 1 and 2 are forming a binary 3 counter: the first line toggles flag 11: if you push the button (here 3) flag 11 changes his state from 0 to 1 or from 0 to 1 so this flag cycles trough 0 - 1 - 0 - 1 - 0 - 1 - 0 - 1 - .... by each push of the button. in rule 2 however flag 12, which has also a toggle command, can only be toggled when flag 11 is zero and as such this flag changes his state as follows by each push of the button: 0 - 0 - 1 - 1 - 0 - 0 - 1 - 1 - ...... in combination with flag 11 : a binary 3 state counter which is decoded in the three following rules. I changed the order because the first count detected will be 1. My previous example was of course very complicated but it contains the rules of above (16, 17) and it shows you how you can assign a lot of commands to a few joystick buttons. hm
wms Posted January 17, 2005 Author Report Posted January 17, 2005 Hi Guys, Let me just get this straight: 1 When you first press the button, Flag11 is toggled from 0 to 1, with Flag12 left as 0 (because Flag11 is not 0) 2 When you press the button a second time, Flag11 is toggled to 0 and Flag12 is toggled to 1 (because Flag11 is now 1) 3 When pressed for a third time, Flag11 is toggled to 1 , with Flag12 left as 1 (because Flag11 is not 0) This gives the following unique combinations for Flag11/Flag12: 1/0 0/1 1/1 My questions are, at what point are the flags reset to 0/0 ? and , how can you be sure they start at 0/0 ? Also, I've just realised I will need a fourth state where the flags are set to 0/0 to switch off the SpeedBrake. Cheers
Pete Dowson Posted January 17, 2005 Report Posted January 17, 2005 My questions are, at what point are the flags reset to 0/0 ? and , how can you be sure they start at 0/0 ? Also, I've just realised I will need a fourth state where the flags are set to 0/0 to switch off the SpeedBrake. Actually, as far as I can see, there are 4 states. Extracting the state changes from hm's message: 0 - 1 - 0 - 1 - 0 - 1 - 0 - 1 0 - 0 - 1 - 1 - 0 - 0 - 1 - 1 you can see that they actually run through the 4 possible combinations: 00, 10, 01, 11 ... So, it seems to me that in the original, there's a "spare" button press which doesn't do anything. Adding: 06=CP(F-0,11)(F+0,12)0,3, do the fourth thing might therefore meet your needs, eh? As to how it starts, well, both flags will be off when you first load FS, but after that you are in that 4 state cycle till you close FS. If you want a reset you'd need another button! Regards, Pete Regards, Pete
wms Posted January 17, 2005 Author Report Posted January 17, 2005 Pete, Thanks for that. I think I am well on my way now so I'll trysome actual programming later tonight. Cheers
hm Posted January 18, 2005 Report Posted January 18, 2005 Hi, You are right, Pete, there are indeed 4 states :oops: but like you said in this case 4 states are probably needed: no brakes -> low brakes -> medium brakes -> max brakes. But the counter in my example, however, will overflow by the next push after "Max brakes" to "No brakes". Therefore IMHO it is better that in this application uses a binary up/down counter with two buttons. In that case you can step up and down to higher or lower break forces. This is my proposal: ; Up counting ; 01=CP(F-0,11)0,3,C1005,11 02=CP(F-0,12)0,3,C1005,11 03=CP(F-0,11)(F-0,12)0,3,C1005,12 ; 04=CP(F+0,11)0,3,C1004,20 05=CP(F+0,12)0,3,C1004,20 06=CP(F-0,11)(F-0,12)0,3,C1003,20 ; 07=CP(F-0,11)0,3,C1004,21 08=CP(F+0,12)0,3,C1004,21 09=CP(F+0,11)(F-0,12)0,3,C1003,21 ; 10=CP(F+0,11)0,3,C1004,22 11=CP(F-0,12)0,3,C1004,22 12=CP(F-0,11)(F+0,12)0,3,C1003,22 ; 13=CP(F-0,11)0,3,C1004,23 14=CP(F-0,12)0,3,C1004,23 15=CP(F+0,11)(F+0,12)0,3,C1003,23 ; ; Down counting ; 16=CP(F+0,11)0,2,C1005,11 17=CP(F+0,12)0,2,C1005,11 18=CP(F+0,11)(F+0,12)0,2,C1005,12 ; 19=CP(F+0,11)0,2,C1004,20 20=CP(F+0,12)0,2,C1004,20 21=CP(F-0,11)(F-0,12)0,2,C1003,20 ; 22=CP(F-0,11)0,2,C1004,21 23=CP(F+0,12)0,2,C1004,21 24=CP(F+0,11)(F-0,12)0,2,C1003,21 ; 25=CP(F+0,11)0,2,C1004,22 26=CP(F-0,12)0,2,C1004,22 27=CP(F-0,11)(F+0,12)0,2,C1003,22 ; 28=CP(F-0,11)0,2,C1004,23 29=CP(F-0,12)0,2,C1004,23 30=CP(F+0,11)(F+0,12)0,2,C1003,23 ; 29=CP(F+0,20)0,3,do no brakes 30=CP(F+0,20)0,2,do no brakes 30=CP(F+0,21)0,3,do low brakes 31=CP(F+0,21)0,2,do low brakes 32=CP(F+0,22)0,3,do medium brakes 33=CP(F+0,22)0,2,do medium brakes 34=CP(F+0,23)0,3,do max brakes 35=CP(F+0,23)0,2,do max brakes It is less complicated then it looks, but some tricks are necessary: lines 01 to 03 are the counter, counting up with button 3, precautions are taken to not allow overflow (behind 1/1): flag 11 can only be toggled when flag 11 or flag 12 is not set, and flag 11 can only be toggled in counts (0/0, 1/0, 0/1), flag 12 can only be toggled once in count 1/0 to 0/1. lines 04 - 15 are again the binary decoding of the counter but this time to intermediate flags and therefore the additional instructions to reset the flag, if the conditions aren't met, are necessary. The following lines are counting down with button 2. Again precautions are taken to not underflow the counter (below zero). This time the decoding is in combination with button 2. And so this way you can cycle up/down trough the states: No brakes <--> Low brakes <--> Medium brakes <--> Max brakes hm
wms Posted January 18, 2005 Author Report Posted January 18, 2005 Hi Guys, I've managed to get the button programming to work (sort of). I've assigned Control/Shift/F8, F9 and F10 to sellect LOW, MED and MAX Speedbrakes respectively by using the following code: [buttons] 1=P1,27,C1005,11 2=CP(F-0,11)1,27,C1005,12 3=CP(F+0,11)(F-0,12)1,27,K119,11 4=CP(F+0,11)(F+0,12)1,27,K120,11 5=CP(F-0,11)(F-0,12)1,27,K121,11 and this works perfectly. I then thought I would add: 6=CP(F-0,11)(F+0,12)1,27,K121,11 to perform a final Control/Shift F10 and switch off the MAX setting. If I use the keyboard, this works perfectly, but if I use the joystick button the sequence I get is MAX, MED, MAX, LOW......repeating. The Speedbrake never switches off. Any ideas why this is happening? I really appreciate your help so far and I am learning from it.
wms Posted January 18, 2005 Author Report Posted January 18, 2005 Hi Guys, Sorted! This now works perfectly: 6=P1,27,C1005,11 7=CP(F-0,11)1,27,C1005,12 8=CP(F+0,11)(F-0,12)1,27,K119,11 9=CP(F-0,11)(F+0,12)1,27,K120,11 10=CP(F+0,11)(F+0,12)1,27,K121,11 11=CP(F-0,11)(F-0,12)1,27,K121,11 Many Thanks for your help. It was much appreciated.
Pete Dowson Posted January 19, 2005 Report Posted January 19, 2005 Hi Guys,I've managed to get the button programming to work (sort of). I've assigned Control/Shift/F8, F9 and F10 to sellect LOW, MED and MAX Speedbrakes respectively by using the following code: [buttons] 1=P1,27,C1005,11 2=CP(F-0,11)1,27,C1005,12 3=CP(F+0,11)(F-0,12)1,27,K119,11 4=CP(F+0,11)(F+0,12)1,27,K120,11 5=CP(F-0,11)(F-0,12)1,27,K121,11 and this works perfectly. I then thought I would add: 6=CP(F-0,11)(F+0,12)1,27,K121,11 to perform a final Control/Shift F10 and switch off the MAX setting. If I use the keyboard, this works perfectly, but if I use the joystick button the sequence I get is MAX, MED, MAX, LOW......repeating. The Speedbrake never switches off. Looking at this very closely: The sequence of flag 11 is 1 0 1 0 ... The sequence of Flag 12 is 0 1 1 0 ... So the sequence of the active lines executed above is Flags: Result: 1 0 line 3 0 1 line 6 1 1 line 4 0 0 line 5 Since your lines 5 and 6 (presumably toggling the same PSS keyboard command) are never sequenced next to each other, I assume they are just doing the same thing, i.e. setting MAX. Note that without line 6 the order was as you wanted: 3, 4, 5. If you renumber the lines and put them in the order they will be sequenced in, maybe you can see what happens? i.e. Here's what I think you meant: 3=CP(F+0,11)(F-0,12)1,27,K119,11 4=CP(F-0,11)(F+0,12)1,27,K120,11 5=CP(F+0,11)(F+0,12)1,27,K121,11 6=CP(F-0,11)(F-0,12)1,27,K121,11 Regards, Pete
hm Posted January 19, 2005 Report Posted January 19, 2005 Hi, Here is why: The first 2 rules are forming a binary counter, the begin state is for flag 11 and 12 both 0. This state isn't detected as long as the button wasn't pushed. The first time you hit the button , the state of flag 11 becomes "on", flag 12 stays "off". This is the very first state that is detected. At the second push flag 11 changes his state and becomes "off", but flag 12 becomes "on". At the third push flag "11" changes his state again to be "on" and flag 12 stays "on". At the fourth push, however, both flags are becoming "off". (In computer terms: you have an overflow, if you had a third flag, this flag would become "on" and it would change his state every fourth push) Next the cycle restarts at the fifth push: flag 11 changes his state to "on", flag 12 stays off ... Therefore the correction is in the sequence order: [buttons] 1=P1,27,C1005,11 2=CP(F-0,11)1,27,C1005,12 3=CP(F+0,11)(F-0,12)1,27,K119,11 4=CP(F-0,11)(F+0,12)1,27,K120,11 5=CP(F+0,11)(F+0,12)1,27,K121,11 6=CP(F-0,11)(F-0,12)1,27,K121,11 I suppose that the brake settings are working like a real old antique array radio buttons where only one button could be active; you could switch from one button to an other ( to select the wave lengths (long, short, very short, and FM) :), at the same time the radio was switched on but if you pushed the active button again, the whole array buttons and the radio was switched off :). Therefore the same command is executed in state 3 (1/1) and 4 (0/0). hm
hm Posted January 19, 2005 Report Posted January 19, 2005 hi Pete, I am not typing as fast as you are, so I seem to be a parrot :lol: hm
wms Posted January 19, 2005 Author Report Posted January 19, 2005 Hi Guys, See my earlier post where I explained that I finally got it working perfectly. I'm now going to look at similarly programming some other buttons. Many Thanks for your help.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now