bnepethomas Posted August 31, 2024 Posted August 31, 2024 (edited) Hi Guys After scoring a coupe of real VHF radios, decided to try and build the radio using a rotary switch instead of an encoder. Thrown together a very rough prototype, and built out a test frame to prove the concept works. Now before I go and reinvent the wheel, has anyone else been down this road with DCS BIOS? Currently, as far as I can see, DCS BIOS only supports encoders, so my frame work compares the desired channel settings on the radio, and bangs away with INCs and DECs using DCS BIOS to align the radios. Anyone been there done that before I attempt to reinvent the wheel? thanks Peter Edited August 31, 2024 by bnepethomas
No1sonuk Posted August 31, 2024 Posted August 31, 2024 Most people use encoders and separate displays because it avoids switch synchronisation problems. But, to answer your question: You could try sendDcsBiosMessage. At the end of most of the Arduino controls is a call to sendDcsBiosMessage. What most users don't know is that you can invoke that yourself, and use the existing control reference to get the parameters. The syntax is sendDcsBiosMessage(message, value); Note that they're both strings, so value needs to be, for example, "1", not 1. To do with this original code line meant for an encoder, you can figure out the sendDcsBiosMessage code: DcsBios::RotaryEncoder vhfamFreq2("VHFAM_FREQ2", "DEC", "INC", PIN_A, PIN_B); "VHF_FREQ2" is the message that will be sent to DCS, followed by "DEC" or "INC". However, if you look at some other lines, they have "+3200" or "-3200". "INC" and "DEC" are essentially "+1" and "-1". But what does this mean? You can try this in your own switch-handling code: sendDcsBiosMessage("VHFAM_FREQ2", "0"); That should set the control to the first switch position. You just alter the "0" to whatever position is required. NOTE, though, that it's the switch position, NOT what the switch displays. e.g. The Frequency Selector 4 display values are "00", "25", "50", and "75", but the position values you'd need to send are "0", "1", "2", and "3". HOWEVER... There is another option that MIGHT work better. As implied earlier, DCS-BIOS is far less restrictive than most people know. Although the control reference lays down specific controls for functions, for the most part, these are just what the creators decided were the best fit for those functions. Most people will just use these and have no problems. BUT, others might also work. For example, this MIGHT work: const byte vhfamfreq2Pins[10] = {PIN_0, PIN_1, PIN_2, PIN_3, PIN_4, PIN_5, PIN_6, PIN_7, PIN_8, PIN_9}; DcsBios::SwitchMultiPos vhfamfreq2("VHFAM_FREQ2", vhfamfreq2Pins, 10); This was adapted from the UHF 1MHz frequency selector. That's worth a look as a good example of multiple control types for the type of function you need... Another thing most people don't know about DCS-BIOS is that in this line, for example: DcsBios::RotaryEncoder vhfamFreq2("VHFAM_FREQ2", "DEC", "INC", PIN_A, PIN_B); The green part can be pretty much anything you want, but it MUST be unique in each sketch. This is useful if, for example, you want multiple phyisical devices to alter the same control in DCS. So theoretically, both the 10-way switch AND rotary encoder code lines I shared above could alter the VHF AM freq 2 parameter because vhfamfreq2 is not the same as vhfamFreq2 (upper case "f" on "freq") as far as Arduino code is concerned. Another use could be driving two different pins with the same LED output: DcsBios::LED masterCaution(A_10C_MASTER_CAUTION_AM, PIN); // Original from control reference DcsBios::LED masterCautionA(A_10C_MASTER_CAUTION_AM, PIN_A); // Second one with altered label Both use the same basic function, but won't clash because I altered the label of the second one to make it unique. That may be of no use to you at all, but it's there as an explanation of how I could "make up" the labels for use with the 10-way switch code. That turned out more complex than I originally intended. Let me know if you need any clarification.
bnepethomas Posted August 31, 2024 Author Posted August 31, 2024 Thanks for the detailed reply - - I'm using the send message construct at the moment if (deltaPos > 0) { sendToDcsBiosMessage("VHFFM_FREQ1", "INC"); } else { sendToDcsBiosMessage("VHFFM_FREQ1", "DEC"); } I had no idea this sort of construct existed - so will check it out, whilst my test framework (sketch attached) was using individual pins, to cover all three radios I'm using a Matrix - but this gives me some pointers to go and check out 19 minutes ago, No1sonuk said: const byte vhfamfreq2Pins[10] = {PIN_0, PIN_1, PIN_2, PIN_3, PIN_4, PIN_5, PIN_6, PIN_7, PIN_8, PIN_9}; DcsBios::SwitchMultiPos vhfamfreq2("VHFAM_FREQ2", vhfamfreq2Pins, 10); A10_RADIO_SYNCH.ino
No1sonuk Posted August 31, 2024 Posted August 31, 2024 I only followed about 1/3 of that code. But I guess you just needed to know DCS-BIOS isn't as rigid as most people think.
bnepethomas Posted August 31, 2024 Author Posted August 31, 2024 Thanks - I really hadn't thought of tinkering with the innards of BIOS - but while poking around I found this at the end of the A10C lua -- A_10C:defineReadWriteRadio("UHF", 54, 7, 3, 1000, "UHF radio frequency") -- disabled - 4xx.xxx should be Axx.xxx - how do we accomplish this? -- A_10C:defineReadWriteRadio("VHF_AM", 55, 7, 3, 1000, "VHF AM radio frequency") -- disabled - last digit seems to sometimes be 1 greater (e.g. 124.001) -- A_10C:defineReadWriteRadio("VHF_FM", 56, 7, 3, 1000, "VHF FM radio frequency") -- disabled - last digit seems to sometimes be 1 greater (e.g. 30.076) Looks like the sort of thing that would be useful - found it was not commented out in the Mirage 2000, so will give it a go and see what happens
Recommended Posts