Braeden108 Posted December 30, 2016 Posted December 30, 2016 I feel like this is a common question round here. What's the best way to simulate an On-On switch with an On-Off? I'd prefer a way to do this with MMJoy, so the arduino is programmed with it. That would make the whole thing plug and play. Light the tires kick the fires! [sIGPIC][/sIGPIC]
Goblin Posted December 30, 2016 Posted December 30, 2016 You can set MMJoy up to send a button press signal for both on and off, but I think it will be the same button.
Braeden108 Posted December 30, 2016 Author Posted December 30, 2016 Well actually the switch series I'm targeting doesn't have an On-Off version. But hell I could still wire an on-on like an On-Off Light the tires kick the fires! [sIGPIC][/sIGPIC]
Goblin Posted December 30, 2016 Posted December 30, 2016 Are they just ON-ON? That could be wired like a ON-OFF by just not using one of the poles. But, you could still wire them like ON-ON, and then set up MMJoy to send momentary signals when the switch is turned on and then again when turne off (not on). So each switch will be able to control two different buttons, but you decide which one you map, if you know what I mean... If it's a toggle function, you just map one switch direction and use it as a on/off switch for that toggle. I.e. 'BTN22' for gear up or down. Or if it's a two way function, you map both switch directions. I.e. 'BTN22'' for gear up and 'BTN23' for gear down.
Sokol1_br Posted December 30, 2016 Posted December 30, 2016 (edited) He has ON-OFF switch and wants make it work as ON-ON. Will be difficult if this switch has only 2 poles, as normally had. Some models has 3 (DPST). Think the "easy way" by hardware is use a optcoupler circuit in between switch and controller, send a momentarily contact in ON and OFF state. If I remember has one in this topic: https://forums.eagle.ru/showthread.php?t=65998 Not sure but maybe EasyJoy32One firmware allow this natively. Lynx controller will do - don't know if is available standalone. Other way is customizing Arduino code - look at DCS BIOS. Or rest use a keymapper software with "on press" and "on release" ability, or for DCSW editing LUA... and again in next patch. :) Edited December 31, 2016 by Sokol1_br
Braeden108 Posted December 31, 2016 Author Posted December 31, 2016 (edited) I'm planning on ordering On-On switches (like I said the E-switch 100 series doesn't have on-off)but it would save me a lot of wiring and matrixing to have one pair of wires going to the switches. The hardware way to do it would be to split a buttons output into switch one and switch one not using an inverter. That way when switch one is on switch one not will be off. Then when switch one is off switch one not will be on. If I were building 1000 joysticks and was making a PCB that's how I would do it. But I'm not (unless like 1000 of you want one?) I was merely hoping that there was an easy software way. I hear, I always forget his name, he makes the warthog boxes and other sim goodies. He has software that will do it, but it might be proprietary. Edited December 31, 2016 by Braeden108 Light the tires kick the fires! [sIGPIC][/sIGPIC]
Goblin Posted December 31, 2016 Posted December 31, 2016 He has ON-OFF switch and wants make it work as ON-ON. Yes and no... ;) That's what he asks at first, but then changes it to having only on-on switches.
CrashO Posted December 31, 2016 Posted December 31, 2016 (edited) So if I understand you correctly, you just want 2 joystick buttons (ingame) using a normal off-on toggle switch? Not sure on how to do it with MMJoy (I don't use it). But to do so with ArduinoJoystickLibrary is pretty easy. I imagine MMJoy allows you to do it pretty much the same way. Just keep track of the buttonState (is it on or off) and set a joy button to 1 while the other one is 0. When the state changes, flip it. I do it like this (to use on-off-on switches as 3 joybuttons, but you can just rip out the stuff for the second pin to use for on-off) // toggleIndex = location inside the array where all info about this switch is stored // rowIndex = pin for the row (common of the switch) // col_1 = first pin for switch // col_2 = second pin for the switch // button_1 = joy number for 1st position // button_2 = joy number for 2nd position // button_3 = joy number for 3rd position void readThreewayToggle(int toggleIndex, int rowIndex, int col_1, int col_2, int button_1, int button_2, int button_3) { pinMode(row[rowIndex], OUTPUT); // Set row to output digitalWrite(row[rowIndex], LOW); // Set row to GND int currentButtonState = 0; //column currentButtonState = !digitalRead(col_1); if (currentButtonState != lastButtonStateToggle[toggleIndex][0]) { Joystick.setButton(button_1, currentButtonState); lastButtonStateToggle[toggleIndex][0] = currentButtonState; Joystick.setButton(button_3, 0); lastButtonStateToggle[toggleIndex][2] = 0; } currentButtonState = !digitalRead(col_2); if (currentButtonState != lastButtonStateToggle[toggleIndex][1]) { Joystick.setButton(button_2, currentButtonState); lastButtonStateToggle[toggleIndex][1] = currentButtonState; Joystick.setButton(button_3, 0); lastButtonStateToggle[toggleIndex][2] = 0; } if (lastButtonStateToggle[toggleIndex][0] == lastButtonStateToggle[toggleIndex][1] && lastButtonStateToggle[toggleIndex][2] == 0) { Joystick.setButton(button_3, 1); lastButtonStateToggle[toggleIndex][2] = 1; } pinMode(row[rowIndex], INPUT); // Set row to float again } So to use it, I would just call this from inside void loop(): readThreewayToggle(0, 1, column[3], column[4], 1, 2, 3); for the following hardware wiring: *Note, values in the call are -1 from the hardware schematic because of zero based arrays :) Edited December 31, 2016 by CrashO pressed submit instead of preview.. 1
Sokol1_br Posted December 31, 2016 Posted December 31, 2016 (edited) E-Switch 100 use 3 pole - most simple version. Can be ON-NONE-ON - think in this case the pole jump from 1 to 3 - don't stop in the middle and central pins is the return. Or ON-OFF-ON, pole stop in the middle. Central pin is common, outside return. In both cases, if want only ON-OFF wire only 2 pins. Thing is, games rarely looks for a always ON switch (in old games this even cause problems), the ideal is like Lynx will do, send a momentary contact in ON and OFF positions, but this is firmware function, not the switch. Consider before buy switches figure how the used USB card handle then, and for what game function will be used. In some case the ideal is buy a DPDT, for example, the last IL-2 controls is done with "keyboard players" mentality, most commands is done for momentary key press only (press to ON, press to OFF), what result awkward handle with ON-OFF lever switch if is 2 pins models. A DPST, DPDT will handle better - still the out synch issue. Edited January 1, 2017 by Sokol1_br , OU
Activity Posted January 1, 2017 Posted January 1, 2017 You can achieve this behaviour in MMjoy by configuring two buttons for the same H/W button, one like you would normally (switch ON). For the second one, set mode to switch OFF.
LynxDK Posted January 4, 2017 Posted January 4, 2017 Since its been mentioned a couple of time here now, i will just confirm that the Arduino firmware code for our CUB Buttons Boxes will be released soon on our website. For free of course. This Code is made for Arduino Leonardo, and has some really nice features, one of them being able to choose if normal On-Off Switches should be On-Off or On-On... and likewise the On-Off-On, can also be made On-On-On. But it is only momentary switch inputs, like Sokol1_br said, not holding switch functions. The code is of course set up for the CUB, which means it also has a function of saving 4 switch settings to the unit, that you can load in if you switch to another plane / Game. But eveyone can download the code, and adjust it for their needs. we will problaly release different firmwares on our web in time, since you can just buy the Backplate and the Panels for the CUB in our shop, and mount it with our DZUS Rails, or simply screw them into a frame wherever you want. And then use your own Arduino Leonardo to make a custom button box. then people can make their own switch setup, which recalls for different firmwares. :) Anyway, this wasnt suppose to be a commercial input, but simply state that the function you seek might be found in our Coding. :) Regards. LynxDK [sIGPIC][/sIGPIC] Instagram
Braeden108 Posted January 4, 2017 Author Posted January 4, 2017 Since its been mentioned a couple of time here now, i will just confirm that the Arduino firmware code for our CUB Buttons Boxes will be released soon on our website. For free of course. This Code is made for Arduino Leonardo, and has some really nice features, one of them being able to choose if normal On-Off Switches should be On-Off or On-On... and likewise the On-Off-On, can also be made On-On-On. But it is only momentary switch inputs, like Sokol1_br said, not holding switch functions. The code is of course set up for the CUB, which means it also has a function of saving 4 switch settings to the unit, that you can load in if you switch to another plane / Game. But eveyone can download the code, and adjust it for their needs. we will problaly release different firmwares on our web in time, since you can just buy the Backplate and the Panels for the CUB in our shop, and mount it with our DZUS Rails, or simply screw them into a frame wherever you want. And then use your own Arduino Leonardo to make a custom button box. then people can make their own switch setup, which recalls for different firmwares. :) Anyway, this wasnt suppose to be a commercial input, but simply state that the function you seek might be found in our Coding. :) LynxDK, I'm sorry I always forget your username. BUt I was hoping you'd post your software is what I was hoping to find. I'll probably just wire up this project with on-on switches but my other projects will have your code on them hopefully. And I hope you'll have a donate section for that code. Light the tires kick the fires! [sIGPIC][/sIGPIC]
LynxDK Posted January 4, 2017 Posted January 4, 2017 LynxDK, I'm sorry I always forget your username. BUt I was hoping you'd post your software is what I was hoping to find. I'll probably just wire up this project with on-on switches but my other projects will have your code on them hopefully. And I hope you'll have a donate section for that code. We have Finalized the CUB 1 Firmware V.1.0 and will release it very soon. We have no plan on taking donations for this... Like our Blueprints and Drawings we release for free, we do it because we think its fun, and its our Hobby. Plus we wouldnt take money for something made for Arduino that is Open Source :) Regards. LynxDK [sIGPIC][/sIGPIC] Instagram
LynxDK Posted January 4, 2017 Posted January 4, 2017 The CUB1 Code is available for downloade here: http://lynx.dk/cub-firmware/ And a guide to install also follows. the Code is free for anyone to edit to suit their needs, and if you guys make a new version of the code that you think other should benefit from, we can easily put it for download on our website. Regards. LynxDK [sIGPIC][/sIGPIC] Instagram
Recommended Posts