Vinc_Vega Posted September 22, 2021 Share Posted September 22, 2021 If touches can be programmed as a kind of dedicated arduino inputs, I could imagine that commands may be send to DCS-Bios. But I haven't done so yet. Regards, Vinc 1 Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
BlackLibrary Posted September 22, 2021 Share Posted September 22, 2021 (edited) not without "help". its an "Basic" program to communicate/interact with the Game. You need an software to "translate" it. As example - DCSFlightpanels = "converter" for StreamDeck and Saitek/Logitech Flight Panels Or with an Arduino library you can programm arduinos for your need Edited September 22, 2021 by BlackLibrary 1 aka WarLord DCSFlightpanels DCS-BIOS Fork DCSFlightpanels arduino-library DCSFlightpanels DCSFlightpanels-Profiles DCS FP / BIOS Discord Server Link to comment Share on other sites More sharing options...
BlackLibrary Posted September 24, 2021 Share Posted September 24, 2021 First version of Mosquito is uploaded to the Master Branch of Flightpanels Fork of DCS-BIOS. Ready for testers!! 1 aka WarLord DCSFlightpanels DCS-BIOS Fork DCSFlightpanels arduino-library DCSFlightpanels DCSFlightpanels-Profiles DCS FP / BIOS Discord Server Link to comment Share on other sites More sharing options...
No1sonuk Posted September 24, 2021 Share Posted September 24, 2021 (edited) 7 hours ago, BlackLibrary said: First version of Mosquito is uploaded to the Master Branch of Flightpanels Fork of DCS-BIOS. Ready for testers!! Thanks. Gun sight switch and Variometer (VVI) work well. WRT the bomb door switch: it doesn't self-reset when it reaches the end of the open or close sequence if the switch is still in position. I'm not sure that's an issue, though, as I'm likely to not use DCS-BIOS for those levers because I can program the locks on the landing gear and flap levers to move automatically in a Pro Micro set up as a HID. I've not tried anything else yet. About the airspeed indicator: Is the zero point straight down, and the end at "48" on the second rotation? BTW, is there an easy way to convert the Common Data Km H airspeed from a string to an integer? I want to use a common data heading and airspeed display, and it works better on integers. Plus, I can convert that to MPH or Kn easily. EDIT: Just noticed gauge for the Long range tank isn't separated into left and right. The cockpit gauges show them as split. Edited September 24, 2021 by No1sonuk Link to comment Share on other sites More sharing options...
BlackLibrary Posted September 25, 2021 Share Posted September 25, 2021 (edited) commondata has booth int and string. The speed indicator i programed like i find its valves in the lua. booth tanks are ther this gauge are the Central and longrange Fuel Gauges. i got my names from the lua. i dint even start the plane i tested switches that read strange (in the lua) but deep testing are mostly the users that fly the plane. They know the functions better and i dont have the time to learn that much planes If you find issues it would be great if you make issues via github Edited September 25, 2021 by BlackLibrary 1 aka WarLord DCSFlightpanels DCS-BIOS Fork DCSFlightpanels arduino-library DCSFlightpanels DCSFlightpanels-Profiles DCS FP / BIOS Discord Server Link to comment Share on other sites More sharing options...
No1sonuk Posted September 25, 2021 Share Posted September 25, 2021 3 hours ago, BlackLibrary said: commondata has booth int and string. Thanks. I didn't notice as the "simple" view shows a servo function by default. Link to comment Share on other sites More sharing options...
BlackLibrary Posted October 2, 2021 Share Posted October 2, 2021 (edited) new Release of Flightpanel BIOS Fork: https://github.com/DCSFlightpanels/dcs-bios/releases/tag/v0.7.42 +All planes stand 2.7.6.13436 +Add Mosquito -Hercules MOD still deactivated because send inputs not possible (under investigation) #CommonData - new Time readouts by neugy #A-10 - cleanup #A-4E - cleanup (v. 2.0 RC1), fix for #69 #BF-109 - fix for #67, add missing wheel brake command #F-5E - typo Fix #F-16 - cleanup #F-18 - remove spaces Typos, VSI fix #Harrier - UFC COMM Display fix #Hercules - some new lights #M-2000C - fix for #63 #Mi-24 - description changes, fix for #69 #Mi-8MT - All frequencys fixed by dslawek #P-51 - Airspeed Needle fix; Cleanup; #Spitfire - add missing lights, cleanup; #T-45 - fix for #68, #69 +Add dcs-bios-arduino-library-0.3.6 - https://github.com/talbotmcinnis/dcs-bios-arduino-library +Control-reference Page - Refresh button (auto restart the Live preview app) +Export module aliases to JSON file - This allows others using DCS-BIOS to determine which DCS aircraft names map to which BIOS module names. stored under doc/json ) Edited October 2, 2021 by BlackLibrary 1 aka WarLord DCSFlightpanels DCS-BIOS Fork DCSFlightpanels arduino-library DCSFlightpanels DCSFlightpanels-Profiles DCS FP / BIOS Discord Server Link to comment Share on other sites More sharing options...
jalfrezi Posted October 25, 2021 Share Posted October 25, 2021 Running into a strange issue with the F-14. I had lots of switches working through DCSFlightPanels, but since the last update most of these, but not all, have stopped working. All the other aircraft I have tried seem unaffected. Using the Chrome preview app it seems that the communication is only one way for a lot of these switches, the Chrome app can see the state of the switch, but it can't send a change to the F-14? I know lots of us lost key bindings in the update, is it possible Heatblur changed some other things that may have broken this too. Can anyone confirm what I'm seeing? Intel Core i9 9900K 5.0GHz · Gigabyte GeForce RTX 2080 SUPER · Gigabyte Z390 AORUS PRO · Alienware 34" AW3418DW · Corsair 2TB M.2 NVMe · 64Gb Corsair Vengeance 3200MHz DDR4 · Windows 10 · TM HOTAS Warthog · VPC ACE-2 Rudder Pedals · VPC V.F.X Grip · VPC MongoosT-50CM2 Grip · Virpil WarBRD base · HP Reverb Pro · 3x TM MFD · Buddy-Fox A-10 UFC · 2x LG Throttle Quadrants · LG Switch Panel · LG Multi Panel · LG Radio Panel · Buttkicker Gamer & JetSeat Link to comment Share on other sites More sharing options...
No1sonuk Posted October 25, 2021 Share Posted October 25, 2021 Was about to suggest going to the FlightPanels Fork Discord for notes on the update, but I see you've got your answer there. 1 Link to comment Share on other sites More sharing options...
BlackLibrary Posted November 4, 2021 Share Posted November 4, 2021 F-14 is updated in Hub to work with latest patch. Fork got a new update: 0.7.4.3 #A-10 - Cleanup #F-5E - UHF string convertion; Fix for #62 #F-16 - ADI trim fix; fix for #78; HMCS page added plus the Bullseye page by Matchsticks; Cleanup #F-14 - Cleanup, Pilot Tacan fix,; Fix for #75 and #77, Throttle and Wingsweep Handle Position as Float added; Indicator for Lantirn Panel installed #F-18 - Change some lights to Float; Pull request #80 from DeadMeatDCS (Throttle Position as Float) #Mi-24 - Fix for #76 #Mosquito - Naming fix for EXT-TAIL GEAR, Lever fixed #P-51 - Cleanup #Yak-52 - added Radio Freq as Float and String +Control-reference Page - improvements, new icons, Code upgraded +Add new socat version 1.7.4.1 +Installation and Setup Guide by OPEN HORNET Rerelease: 0.7.43a F-16 typo fix aka WarLord DCSFlightpanels DCS-BIOS Fork DCSFlightpanels arduino-library DCSFlightpanels DCSFlightpanels-Profiles DCS FP / BIOS Discord Server Link to comment Share on other sites More sharing options...
qq515616480 Posted December 12, 2021 Share Posted December 12, 2021 (edited) i work some times white a javascript decode script,it's canworker. //0-255 to hex function i2h(i){ var h = (i).toString(16); if (h.length==1){ h="0"+h; } return h; } var fbiosarr=new Array(); //所有未处理数据 var tmphex=new Array(); //正在处理数据 var da = new Array(65536); //数据存放缓冲区 var sync=0;//同步标识 function decodebios(hex) { //ka50雷达高度0-65525 console.log("get:1858|59>",da[0x1859]*256+da[0x1858]) // 把HEX数据放到fbiosarr数组,Uint16Array操作不便 var x1 = new Uint16Array(hex.match(/.{1,2}/g).map(byte => parseInt(byte, 16))); x1.forEach(e => { fbiosarr.push(e) }); // 开始处理fbiosarr数据 while (fbiosarr.length>5){ //如果是同步指令 if (fbiosarr[0]==0x55 && fbiosarr[1]==0x55 && fbiosarr[2]==0x55 && fbiosarr[3]==0x55){ sync=1; //删除0x55555555 fbiosarr.splice(0,4) }else{ //如果不同步, tmphex.push(fbiosarr.shift()) } if (sync==1){ //同步开始,处理之前收到的数据 while (tmphex.length>5){ var address = tmphex.splice(0,2); address.reverse(); address = eval("0x"+i2h(address[0])+i2h(address[1])) var count = tmphex.splice(0,2); count.reverse() count = eval("0x"+i2h(count[0])+i2h(count[1])) var data = tmphex.splice(0,count) //循环写入da数组 for (let i = 0; i < data.length; i++) { const h = data[i]; da[address+i]=h } } //复位同步记号 sync=0; tmphex.splice(0); } } } Edited December 12, 2021 by qq515616480 错别字 Link to comment Share on other sites More sharing options...
clayvt Posted December 31, 2021 Share Posted December 31, 2021 (edited) I got some Dog Fight Boss -18 levers today and I’m trying to wrap my brain around this bios stuff. I downloaded the “flightpanels” .zip but what do I do with it, is there an installer I need to get somewhere? I see mention of the hub, is that the original software that is no longer updated? many help would be appreciated. EDIT: Got the hub installed, and the dashboard shows connected with dcs and i can click the the "toggle" in the command library but the DFB levers arent being read. I looked up the board and its on COM 4 and is connected, but dont know what to do from here. Also, i just dropped the whole dcs-bios branch file into the scripts folder of the saved games folder, is that it? and i also already had an export file for simshaker and just added the do file command on the next line after the do file for simshaker. is that ok? Edited December 31, 2021 by clayvt Link to comment Share on other sites More sharing options...
Candiru89 Posted January 15, 2022 Share Posted January 15, 2022 Hello! I'm new to DCS-Bios, I'm just in the information gathering stage. My question is can I have output from a switch that have no feedback in the real cockpit? For example: in the ka-50 the I have a switch for short/medium/long bursts. Can I make a 3 LED indicator that shows the corresponding position? Or can I add an LED that lights up when the laser is switched on? Thanks! Link to comment Share on other sites More sharing options...
No1sonuk Posted January 16, 2022 Share Posted January 16, 2022 13 hours ago, Candiru89 said: For example: in the ka-50 the I have a switch for short/medium/long bursts. Can I make a 3 LED indicator that shows the corresponding position? Or can I add an LED that lights up when the laser is switched on? Thanks! A few ways to make the burst indicators: 1) "Open loop" in hardware: Use a double pole switch that uses one pole for the Arduino, and the other to switch on the LEDs. This would be easy to make 2 LEDs work with a DPDT, centre-off switch, but a bit trickier for 3 LEDs. 2) "Open loop" in software: Use a single pole switch for the Arduino and add a code routine that regularly checks the position of the switch and sets the LEDs accordingly. 3) "Closed loop" in software: If you set the control reference view to "Advanced", you'll see there's usually a set of code lines for output on controls that have only input in "Simple" view. You could use these lines to read the state of the control as DCS sees it. This would allow you to use the onscreen cockpit control, or any other bound control, and still have your LEDs work. Open loop means you set the LEDs without checking if DCS responded to the switch. Closed loop means you set the switch and read the feedback from DCS to set the LEDs. As for the laser: Is it any of these? DcsBios::LED lwrLaserRange(0x1810, 0x0010, PIN); DcsBios::LED lwrLaserTargeting(0x1810, 0x0020, PIN); 1 Link to comment Share on other sites More sharing options...
Candiru89 Posted January 16, 2022 Share Posted January 16, 2022 1 hour ago, No1sonuk said: A few ways to make the burst indicators: 1) "Open loop" in hardware: Use a double pole switch that uses one pole for the Arduino, and the other to switch on the LEDs. This would be easy to make 2 LEDs work with a DPDT, centre-off switch, but a bit trickier for 3 LEDs. 2) "Open loop" in software: Use a single pole switch for the Arduino and add a code routine that regularly checks the position of the switch and sets the LEDs accordingly. 3) "Closed loop" in software: If you set the control reference view to "Advanced", you'll see there's usually a set of code lines for output on controls that have only input in "Simple" view. You could use these lines to read the state of the control as DCS sees it. This would allow you to use the onscreen cockpit control, or any other bound control, and still have your LEDs work. Open loop means you set the LEDs without checking if DCS responded to the switch. Closed loop means you set the switch and read the feedback from DCS to set the LEDs. As for the laser: Is it any of these? DcsBios::LED lwrLaserRange(0x1810, 0x0010, PIN); DcsBios::LED lwrLaserTargeting(0x1810, 0x0020, PIN); Thank you for your response! I'm not yet programming, just gathering information whats possible. Basically my question is that can I get feedback of the state of a switch that is just a flip switch and gives no feedback irl by switching on a light or something? The laser part you pasted I think belongs to the "laser warning receiver" because "lwr" in the line, and thats gives feedback with lights in the cockpit too. The ka-50s own laser, that is used for lasing targets is just an on/off switch that gives no feedback, you have to check its position by looking at it. What I want to achieve is if I switch it on with a button on my hotas, then an led (on a led box) also switching on. Also Id like to achieve to put 3 leds under each other, and if the burst switch is on short, then on led is on, on medium an other, on long, the third led is on. Also while this switch don't have a feedback irl. Are these possible? Link to comment Share on other sites More sharing options...
No1sonuk Posted January 16, 2022 Share Posted January 16, 2022 9 hours ago, Candiru89 said: Thank you for your response! I'm not yet programming, just gathering information whats possible. Basically my question is that can I get feedback of the state of a switch that is just a flip switch and gives no feedback irl by switching on a light or something? A suggestion: Start a fresh thread in this forum (home cockpits) for this question so we can keep this announcement topic tidy and go into detail in a dedicated thread. I don't have the Ka50, so I don't know exactly which controls are used for the switches, but if you can give that info, or the DCS description of the switch, I might be able to find what you need. Also include which DCS-Bios version you're using - I know the Flightpanels version has some additional features on some aircraft that aren't available in the Hub version. Link to comment Share on other sites More sharing options...
tees Posted January 25, 2022 Share Posted January 25, 2022 Hi i have some issue maybe some one can help me i have this code : #include <Arduino.h> #include <U8g2lib.h> #include <Wire.h> #include <SPI.h> //#define DCSBIOS_IRQ_SERIAL //mega #define DCSBIOS_DEFAULT_SERIAL // eps #include "DcsBios.h" int count; //U8G2_SH1122_256X64_F_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 10, /* dc=*/ 5, /* reset=*/ 4); // mega scl pin52, sda pin U8G2_SH1122_256X64_F_4W_SW_SPI u8g2(U8G2_R2, /* clock=*/ 14, /* data=*/ 13, /* cs=*/ 15, /* dc=*/ 5, /* reset=*/ 4); //eps String comDisplay[3]; void setup() { count = 0; u8g2.begin(); Wire.begin(); u8g2.clearDisplay(); u8g2.clearBuffer(); u8g2.sendBuffer(); u8g2.setFont(Hornet_UFC); u8g2.setBusClock(850000); DcsBios::setup(); } void updateComDisplay(int changed,char* newValue) { comDisplay[changed] = cleanUpCom(newValue); u8g2.clearBuffer(); // clear the internal memory u8g2.setCursor(0, 45); u8g2.print(comDisplay[0]); u8g2.setCursor(57, 45); u8g2.print(comDisplay[1]); u8g2.setCursor(75, 45); u8g2.print(comDisplay[2]); u8g2.sendBuffer(); } char* cleanUpCom(char* newValue) { switch (newValue[0]) { case '`': newValue[0]='1'; break; case '~': newValue[0]='2'; break; } return newValue; } void onUfcScratchpadNumberDisplayChange(char* newValue) { updateComDisplay(2, newValue); } DcsBios::StringBuffer<8> ufcScratchpadNumberDisplayBuffer(0x7446, onUfcScratchpadNumberDisplayChange);/// main void onUfcScratchpadString2DisplayChange(char* newValue) { updateComDisplay(1, newValue); } DcsBios::StringBuffer<2> ufcScratchpadString2DisplayBuffer(0x7450, onUfcScratchpadString2DisplayChange);///mid void onUfcScratchpadString1DisplayChange(char* newValue) { updateComDisplay(0, newValue); } DcsBios::StringBuffer<2> ufcScratchpadString1DisplayBuffer(0x744e, onUfcScratchpadString1DisplayChange);///left //// updateComDisplay(2, newValue); void loop() { DcsBios::loop(); } OLED and DCS bios when using with mega 2560 its work correct but when i switch to ESP8266 NodeMCU i get strange artefacts 303 & Friends discord Hangar : JF-17 Thunder, F-16C Viper, I-16, Christen Eagle II, F-14 Tomcat, Supercarrier, WWII Assets Pack, F/A-18C Hornet, AJS-37 Viggen, Spitfire LF Mk. IX, F-5E Tiger II, M-2000C, MiG-15bis, Bf 109 K-4 Kurfürst, Fw 190 D-9 Dora, F-86F Sabre, Flaming Cliffs 3, P-51D Mustang, A-10C Warthog,SA342 Gazelle, UH-1H Huey, Mi-8MTV2 Magnificent Eight, Black Shark II, Persian Gulf Map, Normandy 1944 Map, Link to comment Share on other sites More sharing options...
byteman59 Posted January 27, 2022 Share Posted January 27, 2022 Does DCS-BIOS support the use of a PCF8575 Expansion Module for Arduino? Link to comment Share on other sites More sharing options...
atkinson Posted February 14, 2022 Share Posted February 14, 2022 Hey! I'm new to this, but I've had little success. In general, the thing is ... Is it possible how to implement data output from the FC3 module. Specifically, they are interested in the lamps for retracting / extending the landing gear, flaps, brake flaps. Link to comment Share on other sites More sharing options...
No1sonuk Posted February 14, 2022 Share Posted February 14, 2022 3 hours ago, atkinson said: Hey! I'm new to this, but I've had little success. In general, the thing is ... Is it possible how to implement data output from the FC3 module. Specifically, they are interested in the lamps for retracting / extending the landing gear, flaps, brake flaps. The FlightPanels Fork control reference only shows these: Gear status 0-1 Weight ON Wheels Left Gear 0-1 Weight ON Wheels Nose Gear 0-1 Weight ON Wheels Right Gear 0-1 Left Speed Brake 0-65535 Right Speed Brake 0-65535 The numbers are the possible values. There's no flaps value I can see. 1 Link to comment Share on other sites More sharing options...
Vinc_Vega Posted February 18, 2022 Share Posted February 18, 2022 (edited) On 1/27/2022 at 6:46 PM, byteman59 said: Does DCS-BIOS support the use of a PCF8575 Expansion Module for Arduino? DCS BIOS itself does not support port expanders. You have to create your own instances for checking the input states from an expander and than send the command to DCS. That`s how I plan to do the port extension on the VHF Radio Panel switches. I would apply the same logic to the PCF chips as I did for the MCP23017 expander. Spoiler // ---------- VHF FM radio panel ---------- #define DCSBIOS_IRQ_SERIAL #include "DcsBios.h" #include <Wire.h> // ----- 16 bit port expander connected @ IC2 address 0x27 #include "MCP23017.h" MCP23017 mcp; // Connect pin SCL of the expander to NANO/UNO pin A5 // Connect pin SDA of the expander to NANO/UNO pin A4 // MCP23017 connections // Physial Pin# PinName PinID // 21 GPA0 0 // 22 GPA1 1 // 23 GPA2 2 // 24 GPA3 3 // 25 GPA4 4 // 26 GPA5 5 // 27 GPA6 6 // 28 GPA7 7 // 1 GPB0 8 // 2 GPB1 9 // 3 GPB2 10 // 4 GPB3 11 // 5 GPB4 12 // 6 GPB5 13 // 7 GPB6 14 // 8 GPB7 15 // ----- declaration of variables long lastChangeTime = 0; const byte period = 10; // refresh and send switch positions regularily seconds (value to be multiplied by 1000 to make an integer) const byte debounce = 35; // debounce time, currently used for the preset selector (value to be multiplied by 10 to make an integer) byte VHFFM_FREQEMER = 0; byte prev_VHFFM_FREQEMER = 0; byte VHFFM_MODE = 0; byte prev_VHFFM_MODE = 0; byte VHFFM_PRESET = 0; byte prev_VHFFM_PRESET = 0; byte VHFFM_SQUELCH = 1; byte prev_VHFFM_SQUELCH = 1; // ---------- DCS content here below ---------- // ---------- SETUP Loop ---------- void setup() { DcsBios::setup(); // ----- initialize the 16 bit port expander mcp.begin(0x27); mcp.pinMode(0, INPUT); mcp.pullUp(0, HIGH); mcp.pinMode(1, INPUT); mcp.pullUp(1, HIGH); mcp.pinMode(2, INPUT); mcp.pullUp(2, HIGH); mcp.pinMode(3, INPUT); mcp.pullUp(3, HIGH); mcp.pinMode(4, INPUT); mcp.pullUp(4, HIGH); mcp.pinMode(5, INPUT); mcp.pullUp(5, HIGH); mcp.pinMode(6, INPUT); mcp.pullUp(6, HIGH); mcp.pinMode(7, INPUT); mcp.pullUp(7, HIGH); mcp.pinMode(8, INPUT); mcp.pullUp(8, HIGH); mcp.pinMode(9, INPUT); mcp.pullUp(9, HIGH); mcp.pinMode(10, INPUT); mcp.pullUp(10, HIGH); // ... continue to pin 15 if necessary // ----- first read the VHF FM radio switch positions and save to variables // Frequency Selection Dial FM/AM/MAN/PRE if (mcp.digitalRead(0) == 0) {VHFFM_FREQEMER = 0;} // Emergency FM if (mcp.digitalRead(1) == 0) {VHFFM_FREQEMER = 1;} // Emergency AM if (mcp.digitalRead(2) == 0) {VHFFM_FREQEMER = 2;} // Manual mode if (mcp.digitalRead(3) == 0) {VHFFM_FREQEMER = 3;} // preselected channel mode // Mode OFF/TR/DF if (mcp.digitalRead(4) == 0) {VHFFM_MODE = 0;} // OFF - disables the radio if (mcp.digitalRead(5) == 0) {VHFFM_MODE = 1;} // TR - Transmit and Recieve mode if (mcp.digitalRead(6) == 0) {VHFFM_MODE = 2;} // DF - Direction finding mode for the ADI and HSI // Preset Channel Selector if (mcp.digitalRead(7) == 0) {VHFFM_PRESET = 0;} // decrease channel selection if (mcp.digitalRead(8) == 0) {VHFFM_PRESET = 1;} // increase channel selection // Squelch if ((mcp.digitalRead(9) == 1) && (mcp.digitalRead(10) == 1)) {VHFFM_SQUELCH = 0;} // if no push botton is pressed if (mcp.digitalRead(9) == 0) {VHFFM_SQUELCH = 1;} // Squelch disabled if (mcp.digitalRead(10) == 0) {VHFFM_SQUELCH = 2;} // Squelch tone mode } // ---------- End of SETUP Loop ---------- // ---------- EXECUTION loop ---------- void loop() { DcsBios::loop(); readMCP(); // send switch positions on change // send switch positions regularily long now = millis(); if (now > lastChangeTime + (period*1000)) { readMCP(); lastChangeTime = now; } } // ---------- End of EXECUTION loop ---------- // ---------- FUNCTIONS declaration ---------- // read Inputs from MCP23017 and send switch positions only on change void readMCP() { // // Frequency Selection Dial FM/AM/MAN/PRE if (mcp.digitalRead(0) == 0) { VHFFM_FREQEMER = 0; if (prev_VHFFM_FREQEMER != 0) { DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "0"); // "tryToSendDcsBiosMessage" or "sendDcsBiosMessage" prev_VHFFM_FREQEMER = VHFFM_FREQEMER; } } if (mcp.digitalRead(1) == 0) { VHFFM_FREQEMER = 1; if (prev_VHFFM_FREQEMER != 1) { DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "1"); prev_VHFFM_FREQEMER = VHFFM_FREQEMER; } } if (mcp.digitalRead(2) == 0) { VHFFM_FREQEMER = 2; if (prev_VHFFM_FREQEMER != 2) { DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "2"); prev_VHFFM_FREQEMER = VHFFM_FREQEMER; } } if (mcp.digitalRead(3) == 0) { VHFFM_FREQEMER = 3; if (prev_VHFFM_FREQEMER != 3) { DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "3"); prev_VHFFM_FREQEMER = VHFFM_FREQEMER; } } // // Mode OFF/TR/DF if (mcp.digitalRead(4) == 0) { VHFFM_MODE = 0; if (prev_VHFFM_MODE != 0) { DcsBios::tryToSendDcsBiosMessage("VHFFM_MODE", "0"); prev_VHFFM_MODE = VHFFM_MODE; } } if (mcp.digitalRead(5) == 0) { VHFFM_MODE = 1; if (prev_VHFFM_MODE != 1) { DcsBios::tryToSendDcsBiosMessage("VHFFM_MODE", "1"); prev_VHFFM_MODE = VHFFM_MODE; } } if (mcp.digitalRead(6) == 0) { VHFFM_MODE = 2; if (prev_VHFFM_MODE != 2) { DcsBios::tryToSendDcsBiosMessage("VHFFM_MODE", "2"); prev_VHFFM_MODE = VHFFM_MODE; } } // // Preset Channel Selector if (mcp.digitalRead(7) == 0) { VHFFM_PRESET = 1; if (prev_VHFFM_PRESET != 1) { DcsBios::tryToSendDcsBiosMessage("VHFFM_PRESET", "DEC"); delay(debounce*10); prev_VHFFM_PRESET = 0; // reset to accept next push botton signal } } if (mcp.digitalRead(8) == 0) { VHFFM_PRESET = 2; if (prev_VHFFM_PRESET != 2) { DcsBios::tryToSendDcsBiosMessage("VHFFM_PRESET", "INC"); delay(debounce*10); prev_VHFFM_PRESET = 0; // reset to accept next push botton signal } } // // Squelch if ((mcp.digitalRead(9) == 1) && (mcp.digitalRead(10) == 1)) // 2 position switch workaround { VHFFM_SQUELCH = 1; if (prev_VHFFM_SQUELCH != 1) { DcsBios::tryToSendDcsBiosMessage("VHFFM_SQUELCH", "1"); prev_VHFFM_SQUELCH = VHFFM_SQUELCH; } } if (mcp.digitalRead(9) == 0) { VHFFM_SQUELCH = 0; if (prev_VHFFM_SQUELCH != 0) { DcsBios::tryToSendDcsBiosMessage("VHFFM_SQUELCH", "0"); prev_VHFFM_SQUELCH = VHFFM_SQUELCH; } } if (mcp.digitalRead(10) == 0) { VHFFM_SQUELCH = 2; if (prev_VHFFM_SQUELCH != 2) { DcsBios::tryToSendDcsBiosMessage("VHFFM_SQUELCH", "2"); prev_VHFFM_SQUELCH = VHFFM_SQUELCH; } } } // ---------- END of FUNCTIONS declaration ---------- Edited March 6, 2022 by Vinc_Vega Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
atkinson Posted February 18, 2022 Share Posted February 18, 2022 14.02.2022 в 23:25, No1sonuk сказал: The FlightPanels Fork control reference only shows these: Gear status 0-1 Weight ON Wheels Left Gear 0-1 Weight ON Wheels Nose Gear 0-1 Weight ON Wheels Right Gear 0-1 Left Speed Brake 0-65535 Right Speed Brake 0-65535 The numbers are the possible values. There's no flaps value I can see. And it is possible in more detail? I'm not that experienced! I did not understand how to apply this data to the sketch. Or at least a sample, would be grateful. Link to comment Share on other sites More sharing options...
byteman59 Posted February 18, 2022 Share Posted February 18, 2022 (edited) Thanks Vinc_Vega Thats what I thought. Thanks for posting the code. I'm not much of a programmer, and new to arduino. Edited February 18, 2022 by byteman59 Link to comment Share on other sites More sharing options...
No1sonuk Posted February 18, 2022 Share Posted February 18, 2022 47 minutes ago, atkinson said: And it is possible in more detail? I'm not that experienced! I did not understand how to apply this data to the sketch. Or at least a sample, would be grateful. This sketch will turn on the built-in LED (on pin 13) when an FC3 aircraft gear is down and locked: /* 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::LED fc3Gear(0x601a, 0x0400, 13); void setup() { DcsBios::setup(); } void loop() { DcsBios::loop(); } Link to comment Share on other sites More sharing options...
byteman59 Posted February 18, 2022 Share Posted February 18, 2022 6 hours ago, Vinc_Vega said: DCS BIOS itself does not support port expanders. You have to create your own instances for checking the input states from an expander and than send the command to DCS. That`s how I plan to do the port extension on the VHF Radio Panel switches. I would apply the same logic to the PCF chips as I did for the MCP23017 expander. Reveal hidden contents // ---------- VHF FM radio panel ---------- #define DCSBIOS_IRQ_SERIAL #include "DcsBios.h" #include <Wire.h> // ----- 16 bit port expander connected @ IC2 address 0x27 #include "MCP23017.h" MCP23017 mcp; // Connect pin SCL of the expander to NANO/UNO pin A5 // Connect pin SDA of the expander to NANO/UNO pin A4 // MCP23017 connections // Physial Pin# PinName PinID // 21 GPA0 0 // 22 GPA1 1 // 23 GPA2 2 // 24 GPA3 3 // 25 GPA4 4 // 26 GPA5 5 // 27 GPA6 6 // 28 GPA7 7 // 1 GPB0 8 // 2 GPB1 9 // 3 GPB2 10 // 4 GPB3 11 // 5 GPB4 12 // 6 GPB5 13 // 7 GPB6 14 // 8 GPB7 15 // ----- declaration of variables long lastChangeTime = 0; const byte period = 10; // refresh and send switch positions regularily seconds (value to be multiplied by 1000 to make an integer) const byte debounce = 35; // debounce time, currently used for the preset selector (value to be multiplied by 10 to make an integer) byte VHFFM_FREQEMER = 0; byte prev_VHFFM_FREQEMER = 0; byte VHFFM_MODE = 0; byte prev_VHFFM_MODE = 0; byte VHFFM_PRESET = 0; byte prev_VHFFM_PRESET = 0; byte VHFFM_SQUELCH = 1; byte prev_VHFFM_SQUELCH = 1; // ---------- DCS content here below ---------- // ---------- SETUP Loop ---------- void setup() { DcsBios::setup(); // ----- initialize the 16 bit port expander mcp.begin(0x27); mcp.pinMode(0, INPUT); mcp.pullUp(0, HIGH); mcp.pinMode(1, INPUT); mcp.pullUp(1, HIGH); mcp.pinMode(2, INPUT); mcp.pullUp(2, HIGH); mcp.pinMode(3, INPUT); mcp.pullUp(3, HIGH); mcp.pinMode(4, INPUT); mcp.pullUp(4, HIGH); mcp.pinMode(5, INPUT); mcp.pullUp(5, HIGH); mcp.pinMode(6, INPUT); mcp.pullUp(6, HIGH); mcp.pinMode(7, INPUT); mcp.pullUp(7, HIGH); mcp.pinMode(8, INPUT); mcp.pullUp(8, HIGH); mcp.pinMode(9, INPUT); mcp.pullUp(9, HIGH); mcp.pinMode(10, INPUT); mcp.pullUp(10, HIGH); // ... continue to pin 15 if necessary // ----- first read the VHF FM radio switch positions and save to variables // Frequency Selection Dial FM/AM/MAN/PRE if (mcp.digitalRead(0) == 0) {VHFFM_FREQEMER = 0;} // Emergency FM if (mcp.digitalRead(1) == 0) {VHFFM_FREQEMER = 1;} // Emergency AM if (mcp.digitalRead(2) == 0) {VHFFM_FREQEMER = 2;} // Manual mode if (mcp.digitalRead(3) == 0) {VHFFM_FREQEMER = 3;} // preselected channel mode // Mode OFF/TR/DF if (mcp.digitalRead(4) == 0) {VHFFM_MODE = 0;} // OFF - disables the radio if (mcp.digitalRead(5) == 0) {VHFFM_MODE = 1;} // TR - Transmit and Recieve mode if (mcp.digitalRead(6) == 0) {VHFFM_MODE = 2;} // DF - Direction finding mode for the ADI and HSI // Preset Channel Selector if (mcp.digitalRead(7) == 0) {VHFFM_PRESET = 0;} // decrease channel selection if (mcp.digitalRead(8) == 0) {VHFFM_PRESET = 1;} // increase channel selection // Squelch if ((mcp.digitalRead(9) == 1) && (mcp.digitalRead(10) == 1)) {VHFFM_SQUELCH = 0;} // if no push botton is pressed if (mcp.digitalRead(9) == 0) {VHFFM_SQUELCH = 1;} // Squelch disabled if (mcp.digitalRead(10) == 0) {VHFFM_SQUELCH = 2;} // Squelch tone mode } // ---------- End of SETUP Loop ---------- // ---------- EXECUTION loop ---------- void loop() { readMCP(); // send switch positions on change // send switch positions regularily long now = millis(); if (now > lastChangeTime + (period*1000)) { readMCP(); lastChangeTime = now; } } // ---------- End of EXECUTION loop ---------- // ---------- FUNCTIONS declaration ---------- // read Inputs from MCP23017 and send switch positions only on change void readMCP() { // // Frequency Selection Dial FM/AM/MAN/PRE if (mcp.digitalRead(0) == 0) { VHFFM_FREQEMER = 0; if (prev_VHFFM_FREQEMER != 0) { DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "0"); // "tryToSendDcsBiosMessage" or "sendDcsBiosMessage" prev_VHFFM_FREQEMER = VHFFM_FREQEMER; } } if (mcp.digitalRead(1) == 0) { VHFFM_FREQEMER = 1; if (prev_VHFFM_FREQEMER != 1) { DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "1"); prev_VHFFM_FREQEMER = VHFFM_FREQEMER; } } if (mcp.digitalRead(2) == 0) { VHFFM_FREQEMER = 2; if (prev_VHFFM_FREQEMER != 2) { DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "2"); prev_VHFFM_FREQEMER = VHFFM_FREQEMER; } } if (mcp.digitalRead(3) == 0) { VHFFM_FREQEMER = 3; if (prev_VHFFM_FREQEMER != 3) { DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "3"); prev_VHFFM_FREQEMER = VHFFM_FREQEMER; } } // // Mode OFF/TR/DF if (mcp.digitalRead(4) == 0) { VHFFM_MODE = 0; if (prev_VHFFM_MODE != 0) { DcsBios::tryToSendDcsBiosMessage("VHFFM_MODE", "0"); prev_VHFFM_MODE = VHFFM_MODE; } } if (mcp.digitalRead(5) == 0) { VHFFM_MODE = 1; if (prev_VHFFM_MODE != 1) { DcsBios::tryToSendDcsBiosMessage("VHFFM_MODE", "1"); prev_VHFFM_MODE = VHFFM_MODE; } } if (mcp.digitalRead(6) == 0) { VHFFM_MODE = 2; if (prev_VHFFM_MODE != 2) { DcsBios::tryToSendDcsBiosMessage("VHFFM_MODE", "2"); prev_VHFFM_MODE = VHFFM_MODE; } } // // Preset Channel Selector if (mcp.digitalRead(7) == 0) { VHFFM_PRESET = 1; if (prev_VHFFM_PRESET != 1) { DcsBios::tryToSendDcsBiosMessage("VHFFM_PRESET", "DEC"); delay(debounce*10); prev_VHFFM_PRESET = 0; // reset to accept next push botton signal } } if (mcp.digitalRead(8) == 0) { VHFFM_PRESET = 2; if (prev_VHFFM_PRESET != 2) { DcsBios::tryToSendDcsBiosMessage("VHFFM_PRESET", "INC"); delay(debounce*10); prev_VHFFM_PRESET = 0; // reset to accept next push botton signal } } // // Squelch if ((mcp.digitalRead(9) == 1) && (mcp.digitalRead(10) == 1)) // 2 position switch workaround { VHFFM_SQUELCH = 1; if (prev_VHFFM_SQUELCH != 1) { DcsBios::tryToSendDcsBiosMessage("VHFFM_SQUELCH", "1"); prev_VHFFM_SQUELCH = VHFFM_SQUELCH; } } if (mcp.digitalRead(9) == 0) { VHFFM_SQUELCH = 0; if (prev_VHFFM_SQUELCH != 0) { DcsBios::tryToSendDcsBiosMessage("VHFFM_SQUELCH", "0"); prev_VHFFM_SQUELCH = VHFFM_SQUELCH; } } if (mcp.digitalRead(10) == 0) { VHFFM_SQUELCH = 2; if (prev_VHFFM_SQUELCH != 2) { DcsBios::tryToSendDcsBiosMessage("VHFFM_SQUELCH", "2"); prev_VHFFM_SQUELCH = VHFFM_SQUELCH; } } } // ---------- END of FUNCTIONS declaration ---------- I'm using a PCF8575 Module which uses P0,P1, etc as the names of the pins. Does this look right? Also, 8575 did not recognize the pullUp command, so i removed it. // ---------- VHF FM radio panel ---------- #define DCSBIOS_IRQ_SERIAL #include "DcsBios.h" #include "Arduino.h" #include "PCF8575.h" // ----- 16 bit port expander connected @ IC2 address 0x27 PCF8575 pcf8575(0x20); // Connect pin SCL of the expander to NANO/UNO pin A5 // Connect pin SDA of the expander to NANO/UNO pin A4 // pcf8575 connections // Pin# PinName // P0 0 // P1 1 // P2 2 // P3 3 // P4 4 // P5 5 // P6 6 // P7 7 // P8 8 // P9 9 // P10 10 // P11 11 // P12 12 // P13 13 // P14 14 // P15 15 // ----- declaration of variables long lastChangeTime = 0; const byte period = 10; // refresh and send switch positions regularily seconds (value to be multiplied by 1000 to make an integer) const byte debounce = 35; // debounce time, currently used for the preset selector (value to be multiplied by 10 to make an integer) byte VHFFM_FREQEMER = 0; byte prev_VHFFM_FREQEMER = 0; byte VHFFM_MODE = 0; byte prev_VHFFM_MODE = 0; byte VHFFM_PRESET = 0; byte prev_VHFFM_PRESET = 0; byte VHFFM_SQUELCH = 1; byte prev_VHFFM_SQUELCH = 1; // ---------- DCS content here below ---------- // ---------- SETUP Loop ---------- void setup() { DcsBios::setup(); // ----- initialize the 16 bit port expander pcf8575.begin(); pcf8575.pinMode(P0, INPUT); pcf8575.pinMode(P1, INPUT); pcf8575.pinMode(P2, INPUT); pcf8575.pinMode(P3, INPUT); pcf8575.pinMode(P4, INPUT); pcf8575.pinMode(P5, INPUT); pcf8575.pinMode(P6, INPUT); pcf8575.pinMode(P7, INPUT); pcf8575.pinMode(P8, INPUT); pcf8575.pinMode(P9, INPUT); pcf8575.pinMode(P10, INPUT); // ... continue to pin 15 if necessary // ----- first read the VHF FM radio switch positions and save to variables // Frequency Selection Dial FM/AM/MAN/PRE if (pcf8575.digitalRead(P0) == 0) {VHFFM_FREQEMER = 0;} // Emergency FM if (pcf8575.digitalRead(P1) == 0) {VHFFM_FREQEMER = 1;} // Emergency AM if (pcf8575.digitalRead(P2) == 0) {VHFFM_FREQEMER = 2;} // Manual mode if (pcf8575.digitalRead(P3) == 0) {VHFFM_FREQEMER = 3;} // preselected channel mode // Mode OFF/TR/DF if (pcf8575.digitalRead(P4) == 0) {VHFFM_MODE = 0;} // OFF - disables the radio if (pcf8575.digitalRead(P5) == 0) {VHFFM_MODE = 1;} // TR - Transmit and Recieve mode if (pcf8575.digitalRead(P6) == 0) {VHFFM_MODE = 2;} // DF - Direction finding mode for the ADI and HSI // Preset Channel Selector if (pcf8575.digitalRead(P7) == 0) {VHFFM_PRESET = 0;} // decrease channel selection if (pcf8575.digitalRead(P8) == 0) {VHFFM_PRESET = 1;} // increase channel selection // Squelch if ((pcf8575.digitalRead(P9) == 1) && (pcf8575.digitalRead(P10) == 1)) {VHFFM_SQUELCH = 0;} // if no push botton is pressed if (pcf8575.digitalRead(P9) == 0) {VHFFM_SQUELCH = 1;} // Squelch disabled if (pcf8575.digitalRead(P10) == 0) {VHFFM_SQUELCH = 2;} // Squelch tone mode } // ---------- End of SETUP Loop ---------- // ---------- EXECUTION loop ---------- void loop() { readpcf8575(); // send switch positions on change // send switch positions regularily long now = millis(); if (now > lastChangeTime + (period*1000)) { readpcf8575(); lastChangeTime = now; } } // ---------- End of EXECUTION loop ---------- // ---------- FUNCTIONS declaration ---------- // read Inputs from pcf857523017 and send switch positions only on change void readpcf8575() { // // Frequency Selection Dial FM/AM/MAN/PRE if (pcf8575.digitalRead(P0) == 0) { VHFFM_FREQEMER = 0; if (prev_VHFFM_FREQEMER != 0) { DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "0"); // "tryToSendDcsBiosMessage" or "sendDcsBiosMessage" prev_VHFFM_FREQEMER = VHFFM_FREQEMER; } } if (pcf8575.digitalRead(P1) == 0) { VHFFM_FREQEMER = 1; if (prev_VHFFM_FREQEMER != 1) { DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "1"); prev_VHFFM_FREQEMER = VHFFM_FREQEMER; } } if (pcf8575.digitalRead(P2) == 0) { VHFFM_FREQEMER = 2; if (prev_VHFFM_FREQEMER != 2) { DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "2"); prev_VHFFM_FREQEMER = VHFFM_FREQEMER; } } if (pcf8575.digitalRead(P3) == 0) { VHFFM_FREQEMER = 3; if (prev_VHFFM_FREQEMER != 3) { DcsBios::tryToSendDcsBiosMessage("VHFFM_FREQEMER", "3"); prev_VHFFM_FREQEMER = VHFFM_FREQEMER; } } // // Mode OFF/TR/DF if (pcf8575.digitalRead(P4) == 0) { VHFFM_MODE = 0; if (prev_VHFFM_MODE != 0) { DcsBios::tryToSendDcsBiosMessage("VHFFM_MODE", "0"); prev_VHFFM_MODE = VHFFM_MODE; } } if (pcf8575.digitalRead(P5) == 0) { VHFFM_MODE = 1; if (prev_VHFFM_MODE != 1) { DcsBios::tryToSendDcsBiosMessage("VHFFM_MODE", "1"); prev_VHFFM_MODE = VHFFM_MODE; } } if (pcf8575.digitalRead(P6) == 0) { VHFFM_MODE = 2; if (prev_VHFFM_MODE != 2) { DcsBios::tryToSendDcsBiosMessage("VHFFM_MODE", "2"); prev_VHFFM_MODE = VHFFM_MODE; } } // // Preset Channel Selector if (pcf8575.digitalRead(P7) == 0) { VHFFM_PRESET = 1; if (prev_VHFFM_PRESET != 1) { DcsBios::tryToSendDcsBiosMessage("VHFFM_PRESET", "DEC"); delay(debounce*10); prev_VHFFM_PRESET = 0; // reset to accept next push botton signal } } if (pcf8575.digitalRead(P8) == 0) { VHFFM_PRESET = 2; if (prev_VHFFM_PRESET != 2) { DcsBios::tryToSendDcsBiosMessage("VHFFM_PRESET", "INC"); delay(debounce*10); prev_VHFFM_PRESET = 0; // reset to accept next push botton signal } } // // Squelch if ((pcf8575.digitalRead(P9) == 1) && (pcf8575.digitalRead(P10) == 1)) // 2 position switch workaround { VHFFM_SQUELCH = 1; if (prev_VHFFM_SQUELCH != 1) { DcsBios::tryToSendDcsBiosMessage("VHFFM_SQUELCH", "1"); prev_VHFFM_SQUELCH = VHFFM_SQUELCH; } } if (pcf8575.digitalRead(P9) == 0) { VHFFM_SQUELCH = 0; if (prev_VHFFM_SQUELCH != 0) { DcsBios::tryToSendDcsBiosMessage("VHFFM_SQUELCH", "0"); prev_VHFFM_SQUELCH = VHFFM_SQUELCH; } } if (pcf8575.digitalRead(P10) == 0) { VHFFM_SQUELCH = 2; if (prev_VHFFM_SQUELCH != 2) { DcsBios::tryToSendDcsBiosMessage("VHFFM_SQUELCH", "2"); prev_VHFFM_SQUELCH = VHFFM_SQUELCH; } } } // ---------- END of FUNCTIONS declaration ---------- Link to comment Share on other sites More sharing options...
Recommended Posts