shreddersa Posted August 12, 2018 Share Posted August 12, 2018 I have just started using DCS-BIOS and am very grateful for this fantastic tool. I have set a test panel to include ON-ON and ON-OFF switches, RotaryEncoders and pushbuttons. It is all working great. My question comes in for a specific application in the Spitfire. I have rigged the starter button cover with a little magnet in the cover and a Hall Effect non-latching switch in the base. As a result the Hall Effect switch switches ON when the cover is closed and OFF when the cover is opened, ie. the magnet is removed. This has the opposite effect to that which is desired in-cockpit. Is it possible to add code in the Arduino sketch which will reverse this effect? It currently reads as follows: DcsBios::Switch2Pos starterCover("STARTER_COVER", 3); The full sketch is as follows: /* Tell DCS-BIOS to use a serial connection and use interrupt-driven communication. The main program will be interrupted to prioritize processing incoming data. This should work on any Arduino that has an ATMega328 controller (Uno, Pro Mini, many others). */ #define DCSBIOS_IRQ_SERIAL #include "DcsBios.h" /* paste code snippets from the reference documentation here */ DcsBios::Switch2Pos starter("STARTER", 2); DcsBios::Switch2Pos starterCover("STARTER_COVER", 3); const byte flapsPins[2] = {4, 5}; DcsBios::SwitchMultiPos flaps("FLAPS", flapsPins, 2); DcsBios::Switch2Pos magneto0("MAGNETO0", 6); DcsBios::LED ucDownC(0x5412, 0x4000, 7); DcsBios::Switch2Pos buttonCan("BUTTON_CAN", 8); DcsBios::Switch2Pos buttonMg("BUTTON_MG", 9); DcsBios::Switch2Pos iffCover("IFF_COVER", 10); DcsBios::Potentiometer pitliteLh("PITLITE_LH", A0); DcsBios::RotaryEncoder clkPinion("CLK_PINION", "-3200", "+3200", 11, 12); DcsBios::Switch2Pos clkPinionPull("CLK_PINION_PULL", 13); void setup() { DcsBios::setup(); } Link to comment Share on other sites More sharing options...
Tekkx Posted August 12, 2018 Share Posted August 12, 2018 (edited) What if you multiplicate your value by -1? I'm away of a PC so I can't check out by myself. Good idea with magnet and Hall sensor. I would have used a reed contact. Gesendet von meinem K4000_PRO mit Tapatalk Edited August 12, 2018 by Tekkx Manual for my version of RS485-Hardware, contact: tekkx@dresi.de Please do not PM me with DCS-BIOS-related questions. If the answer might also be useful to someone else, it belongs in a public thread where it can be discovered by everyone using the search function. Thank You. Link to comment Share on other sites More sharing options...
shreddersa Posted August 12, 2018 Author Share Posted August 12, 2018 What if you multiplicate your value by -1? I'm away of a PC so I can't check out by myself. Good idea with magnet and Hall sensor. I would have used a reed contact. Gesendet von meinem K4000_PRO mit Tapatalk Thanks Tekkx, not sure which value you would be referring to? The only value given is that of the pin number. The magnet and Hall sensor work great, just the wrong way round. My understanding is that reed switches may not be terribly robust? Link to comment Share on other sites More sharing options...
Tekkx Posted August 12, 2018 Share Posted August 12, 2018 DcsBios::Switch2Pos starterCover("STARTER_COVER", 3); This sends either "1" or "0" if something has changed - if opened or closed the Cover. Somehow you could "catch" this and convertt it to your preferred value. Look in your dcs-bios control-reference for further details. I have right now no acces to a running system. And my "DCS-BIOS speaking" isn't that fluent. ;) Manual for my version of RS485-Hardware, contact: tekkx@dresi.de Please do not PM me with DCS-BIOS-related questions. If the answer might also be useful to someone else, it belongs in a public thread where it can be discovered by everyone using the search function. Thank You. Link to comment Share on other sites More sharing options...
draken152 Posted August 12, 2018 Share Posted August 12, 2018 For effect what Tekkx mentioned you need to edit spitfire.lua in dcs bios directory. I don't have it (it is not part of my DCS bios) so as example here is line from fw190D.lua for same function: defineTumb("STARTER_CVR",2, 3006, 104, 1, {0,1}, nil, false, "Cockpit", "Starter Switch Cover") {0,1} - you need to change, my estimation is {1,0} but I am not sure Aditional info here Try it and let us know.... [sIGPIC][/sIGPIC] Building FW190D pit ,,To Dora with love" http://forums.eagle.ru/showthread.php?t=132743 Link to comment Share on other sites More sharing options...
TechRoss Posted August 13, 2018 Share Posted August 13, 2018 Are you basically saying you just want to 'reverse' the switch? I am not sure about the hall sensor etc etc, but for a normal toggle, if you add a third parameter you can do this. DcsBios::Switch2Pos starterCover("STARTER_COVER", 3, true); (Assuming this is a default DCS BIOS command. I might be completely wrong here) Link to comment Share on other sites More sharing options...
shreddersa Posted August 13, 2018 Author Share Posted August 13, 2018 Gentlemen, I am extremely grateful for your help and responses. I have no doubt that it will be valuable for others too. Tekkx, you were on the right path that this could be solved programmatically, thank you.:thumbup: Draken152, fantastic info, thank you. This will be extremely useful in understanding the underlying programming to DCS-BIOS, and I have no doubt your suggestion would work. Great work on the Dora by the way, I will be following your build with interest! :thumbup: TechRoss, yours presented the simplest potential solution, so I tried that first :) DcsBios::Switch2Pos starterCover("STARTER_COVER", 3, true); Very pleased to say that IT WORKS!!! :thumbup: I am so happy and excited! Thank you all again! I will post a little video of my testwork, hopefully it helps others too.:pilotfly: For details on my design/build, check out my website: heritageflightsim.com Link to comment Share on other sites More sharing options...
Ranma13 Posted August 13, 2018 Share Posted August 13, 2018 If you run into something that DCS BIOS doesn't seem to support based on its documentation, have a look at the source code first: https://github.com/dcs-bios/dcs-bios-arduino-library There's a bunch of stuff that it supports, but is undocumented. In addition to the reverse flag for ON-OFF switches, there's also things like setting how many steps equals a detent for rotary encoders so that you can speed them up or slow them down. Link to comment Share on other sites More sharing options...
shreddersa Posted August 13, 2018 Author Share Posted August 13, 2018 If you run into something that DCS BIOS doesn't seem to support based on its documentation, have a look at the source code first: https://github.com/dcs-bios/dcs-bios-arduino-library There's a bunch of stuff that it supports, but is undocumented. In addition to the reverse flag for ON-OFF switches, there's also things like setting how many steps equals a detent for rotary encoders so that you can speed them up or slow them down. Thanks for pointing that out Ranma. Very useful info. :thumbup: Link to comment Share on other sites More sharing options...
TechRoss Posted August 14, 2018 Share Posted August 14, 2018 Very pleased to say that IT WORKS!!! :thumbup: Great, glad you can now move forward. Link to comment Share on other sites More sharing options...
Recommended Posts