FSFIan Posted April 1, 2016 Author Share Posted April 1, 2016 For some reason (i.e. "what was I thinking when I wrote that?") the SwitchMultiPos class defaults to position 0 when it should default to the last position that was seen: https://github.com/dcs-bios/dcs-bios-arduino-library/blob/v0.2.1/Switches.h#L87 Changing that line to "return lastState_" will fix that. I'll add that fix to the Arduino library soon. Implementing debounce timers is a trade-off between features, performance and memory usage. Method 1: make sure there is a certain minimum delay between separate reads of the switch status. Implementation 1a: call the delay() function in your loop() function. This has the disadvantage that you waste the time you spend waiting when you could have spent it on other computations, but it's a viable option when all we are talking about is a couple of switches. Implementation 1b: Store the last poll time for each control and return early from its pollInput() method if millis()-lastPollTime<threshold. This will allow other things to be processed while waiting, but requires additional memory per control. Method 2: implement a small state machine for each control that ensures a new switch state is only recognized if it has been unchanged for a certain amount of time. Similar advantages and disadvantages as 1b, but requires another byte of memory per control to store the current state (or stealing some of the high bits from an existing instance variable). I will have to think about what the default solution should be here. DCS-BIOS | How to export CMSP, RWR, etc. through MonitorSetup.lua Link to comment Share on other sites More sharing options...
Exo7 Posted April 3, 2016 Share Posted April 3, 2016 (edited) MAX7219 Display Problem Hi Ian, I have a litlle problem with display on max7219 using LedControl library. i'm using the latest DCS-BIOS Arduino Library (v0.2.1) 1- what i try to do : displaying M2000C UVHF Report Frequency + Selected Preset. 2 - What is the problem : Selected preset is displayed, frequency report is blank (only the DP) this is my function to keep the frequency report string, in my M2000C library: local function getUHFFrequency() local ret = {} local li = list_indication(9) if li == "" then return nil end local m = li:gmatch("-----------------------------------------\n([^\n]+)\n([^\n]*)\n") while true do local name, value = m() if not name then break end ret[name] = value end local freqStatus = ret["text_COM_UHF2"] return freqStatus:sub(0,3) .. freqStatus:sub(5,6) end local function getVHFFrequency() local ret = {} local li = list_indication(9) if li == "" then return nil end local m = li:gmatch("-----------------------------------------\n([^\n]+)\n([^\n]*)\n") while true do local name, value = m() if not name then break end ret[name] = value end local freqStatus = ret["text_COM_UHF1"] return freqStatus:sub(0,3) .. freqStatus:sub(5,6) end this is my calls to function, in M2000C library to : defineString("UHF_FREQUENCY", getUHFFrequency, 5, "UHF Radio", "UHF Frequency Report Display") defineString("VHF_FREQUENCY", getVHFFrequency, 5, "U/VHF Radio", "U/VHF Frequency Report Display") this is my use of defineFloat function to get the Selected preset value : defineFloat("UVHF_PRESET", 445, {0,1}, "U/VHF Radio", "U/VHF PRESET Display") defineFloat("UHF_PRESET", 435, {0,1}, "UHF Radio", "UHF PRESET Display") and this is my sketch : #define DCSBIOS_DEFAULT_SERIAL #include "DcsBios.h" #include <LedControl.h> //on inclus la librairie pour commander le MAX7219 LedControl lc=LedControl(10,11,12,1); void onVhfFrequencyChange(char* newValue) { char hundredths = newValue[0]; char tenths = newValue[1]; char ones = newValue[2]; char tens = newValue[3]; char hundreds = newValue[4]; lc.setChar(0,0,hundredths,false); lc.setChar(0,1,tenths,false); lc.setChar(0,2,ones,true); lc.setChar(0,3,tens,false); lc.setChar(0,4,hundreds,false); } DcsBios::StringBuffer<6> vhfFrequencyBuffer(0x30a0, onVhfFrequencyChange); void onUvhfPresetChange(unsigned int uvhfPresetValue) { unsigned int firstDigit; unsigned int secondDigit; if (uvhfPresetValue>2000 && uvhfPresetValue<5000){firstDigit=0;secondDigit=1;} else if (uvhfPresetValue>5000 && uvhfPresetValue<7000){firstDigit=0;secondDigit=2;} else if (uvhfPresetValue>7000 && uvhfPresetValue<11000){firstDigit=0;secondDigit=3;} else if (uvhfPresetValue>11000 && uvhfPresetValue<14500){firstDigit=0;secondDigit=4;} else if (uvhfPresetValue>14500 && uvhfPresetValue<17500){firstDigit=0;secondDigit=5;} else if (uvhfPresetValue>17500 && uvhfPresetValue<21500){firstDigit=0;secondDigit=6;} else if (uvhfPresetValue>21500 && uvhfPresetValue<24000){firstDigit=0;secondDigit=7;} else if (uvhfPresetValue>24000 && uvhfPresetValue<27500){firstDigit=0;secondDigit=8;} else if (uvhfPresetValue>27500 && uvhfPresetValue<30500){firstDigit=0;secondDigit=9;} else if (uvhfPresetValue>30500 && uvhfPresetValue<34000){firstDigit=1;secondDigit=0;} else if (uvhfPresetValue>34000 && uvhfPresetValue<37500){firstDigit=1;secondDigit=1;} else if (uvhfPresetValue>37500 && uvhfPresetValue<41000){firstDigit=1;secondDigit=2;} else if (uvhfPresetValue>41000 && uvhfPresetValue<44000){firstDigit=1;secondDigit=3;} else if (uvhfPresetValue>44000 && uvhfPresetValue<47000){firstDigit=1;secondDigit=4;} else if (uvhfPresetValue>47000 && uvhfPresetValue<51000){firstDigit=1;secondDigit=5;} else if (uvhfPresetValue>51000 && uvhfPresetValue<54000){firstDigit=1;secondDigit=6;} else if (uvhfPresetValue>54000 && uvhfPresetValue<56500){firstDigit=1;secondDigit=7;} else if (uvhfPresetValue>56500 && uvhfPresetValue<60000){firstDigit=1;secondDigit=8;} else if (uvhfPresetValue>60000 && uvhfPresetValue<63000){firstDigit=1;secondDigit=9;} else if (uvhfPresetValue>63000 && uvhfPresetValue<=65535){firstDigit=2;secondDigit=0;} lc.setDigit(0,5,firstDigit,false); lc.setDigit(0,6,secondDigit,false); } DcsBios::IntegerBuffer uvhfPresetBuffer(0x30a6, 0xffff, 0, onUvhfPresetChange); DcsBios::RotaryEncoder uvhfPresetRot("UVHF_PRESET_ROT", "DEC", "INC", 6, 7); void setup() { DcsBios::setup(); lc.shutdown(0, false); lc.setIntensity(0,9); } void loop() { DcsBios::loop(); } if i look in the liveData ControlReference, the values are good. Separatly, the functions are working well, but when them are both in my sketch only the Selected Preset works. The same functions works well with UHF Radio.. i don't understand where is the problem... i'm working on it since many days... Thanks for your help and for my burning head..:thumbup: Edited April 3, 2016 by Exo7 [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
FSFIan Posted April 4, 2016 Author Share Posted April 4, 2016 @Exo7: I have read through your code and can't see anything wrong with it. The only theory I have right now is that your receive buffer is getting filled up under some specific circumstances. Using #define DCSBIOS_IRQ_SERIAL would fix that. I have pushed a commit to the master branch on GitHub now that should make IRQ_SERIAL work on the Arduino Mega, although I haven't had the time yet to test it on actual hardware or make sure it doesn't break anything on the Uno, so it's not in a release yet. DCS-BIOS | How to export CMSP, RWR, etc. through MonitorSetup.lua Link to comment Share on other sites More sharing options...
Exo7 Posted April 5, 2016 Share Posted April 5, 2016 thanks Ian, i will try on another card that MEGA (UNO or NANO) and with / without IRQ_SERIAL [sIGPIC][/sIGPIC] Link to comment Share on other sites More sharing options...
Marcin_B Posted May 2, 2016 Share Posted May 2, 2016 A-10C CMSP - Arduino via USB Hi! A try connection Arduino Uno with LCD 16x2 via USB. I have a problem with my code #include <DcsBios.h> #include <Servo.h> #include <LiquidCrystal.h> LiquidCrystal lcd(2, 3, 4, 5, 6, 7); /**** Make your changes after this line ****/ void onCmsp1Change(char* newValue) { lcd.setCursor(0, 0); lcd.print(newValue); } DcsBios::StringBuffer<16> cmsp1Buffer(0x1000, onCmsp1Change); void onCmsp2Change(char* newValue) { lcd.setCursor(0, 1); lcd.print(newValue); } DcsBios::StringBuffer<16> cmsp2Buffer(0x1014, onCmsp2Change); DcsBios::ProtocolParser parser; void setup() { Serial.begin(500000); lcd.begin(16, 2); lcd.clear(); } void loop() { while (Serial.available()) { parser.processChar(Serial.read()); } DcsBios::PollingInput::pollInputs(); } void sendDcsBiosMessage(const char* msg, const char* arg) { Serial.write(msg); Serial.write(' '); Serial.write(arg); Serial.write('\n'); } void onDcsBiosWrite(unsigned int address, unsigned int value) { } These lines Arduino are not accepted: void sendDcsBiosMessage(const char* msg, const char* arg) { Serial.write(msg); Serial.write(' '); Serial.write(arg); Serial.write('\n'); } and write: new declaration 'void sendDcsBiosMessage(const char*, const char*)' Does anyone know why? Link to comment Share on other sites More sharing options...
Warhog Posted May 2, 2016 Share Posted May 2, 2016 You need to download the new release of DCS-BIOS Arduino Library. It no longer uses those lines as its been streamlined a lot. See the example sketches in the IDE for DCS-BIOS and that will provide you with a new template to rewrite your sketch. Regards John W aka WarHog. My Cockpit Build Pictures... My Arduino Sketches ... https://drive.google.com/drive/folders/1-Dc0Wd9C5l3uY-cPj1iQD3iAEHY6EuHg?usp=sharing WIN 10 Pro, i8-8700k @ 5.0ghz, ASUS Maximus x Code, 16GB Corsair Dominator Platinum Ram, AIO Water Cooler, M.2 512GB NVMe, 500gb SSD, EVGA GTX 1080 ti (11gb), Sony 65” 4K Display VPC MongoosT-50, TM Warthog Throttle, TRK IR 5.0, Slaw Viper Pedals Link to comment Share on other sites More sharing options...
Marcin_B Posted May 3, 2016 Share Posted May 3, 2016 I installed the latest version DCS-BIOS Arduino library (v 0.2.3) but I do not know what to change in scetch. I can't find any fint of template :( Link to comment Share on other sites More sharing options...
FSFIan Posted May 3, 2016 Author Share Posted May 3, 2016 (edited) Your sketch was written for an older version (before v0.2.0) of the Arduino library. You'll have to remove any code belonging to the old template, then copy what's left into the new one (Examples -> DcsBios -> IRQSerial). You should arrive at something like this (untested): #define DCSBIOS_IRQ_SERIAL #include <DcsBios.h> #include <LiquidCrystal.h> LiquidCrystal lcd(2, 3, 4, 5, 6, 7); void onCmsp1Change(char* newValue) { lcd.setCursor(0, 0); lcd.print(newValue); } DcsBios::StringBuffer<16> cmsp1Buffer(0x1000, onCmsp1Change); void onCmsp2Change(char* newValue) { lcd.setCursor(0, 1); lcd.print(newValue); } DcsBios::StringBuffer<16> cmsp2Buffer(0x1014, onCmsp2Change); void setup() { DcsBios::setup(); lcd.begin(16, 2); lcd.clear(); } void loop() { DcsBios::loop(); } PS: Please make a new thread for things like this in the future. Troubleshooting often requires several back-and-forth posts and it becomes confusing when two of those conversations are going on in the same thread at the same time. It also makes it easier to find the answer again in the future. Edited May 3, 2016 by [FSF]Ian DCS-BIOS | How to export CMSP, RWR, etc. through MonitorSetup.lua Link to comment Share on other sites More sharing options...
Marcin_B Posted May 3, 2016 Share Posted May 3, 2016 Thanks Ian - this code works fine! Link to comment Share on other sites More sharing options...
What Goes Up Posted May 4, 2016 Share Posted May 4, 2016 Bios Setup Help Appriacted G'day Im new to this forum, and should really be introducing myself rather than begging for help, but I have not been able to get DCS BIOS to work and I would really appropriate some help. (I hope this is the right place to ask) The story so far... I have downloaded the DCS BIOS and installed/ set it up as per the instructions. The Arduino side of things appears to be working fine in that I can upload a sketch to the board, but it is not communicating with the sim. The problem I think is that I am not getting any Bios output from A10C. I have used both the connect to serial program and the direct Control Reference. From the comments I have found on this forum I have even checked that no antivirus software is stopping it from working. I have even tried previous versions of DCS BIOS, but still nothing works. What am I doing wrong? Can anyone help me? Link to comment Share on other sites More sharing options...
BravoYankee4 Posted May 4, 2016 Share Posted May 4, 2016 G'day Im new to this forum, and should really be introducing myself rather than begging for help, but I have not been able to get DCS BIOS to work and I would really appropriate some help. (I hope this is the right place to ask) The story so far... I have downloaded the DCS BIOS and installed/ set it up as per the instructions. The Arduino side of things appears to be working fine in that I can upload a sketch to the board, but it is not communicating with the sim. The problem I think is that I am not getting any Bios output from A10C. I have used both the connect to serial program and the direct Control Reference. From the comments I have found on this forum I have even checked that no antivirus software is stopping it from working. I have even tried previous versions of DCS BIOS, but still nothing works. What am I doing wrong? Can anyone help me? My prime suspect would be the export.lua file. Link to comment Share on other sites More sharing options...
What Goes Up Posted May 4, 2016 Share Posted May 4, 2016 G'day Bravo Yankee4. Thats the conclusion i have come to. Yet i have followed the instructions to the letter. Would it make any difference that the sim is on a different harddrive to that of where the export lua file is? Link to comment Share on other sites More sharing options...
FSFIan Posted May 4, 2016 Author Share Posted May 4, 2016 Any errors in dcs.log? Anything else that is using Export.lua? (Helios and TacView are known to behave, but there are several Export.lua scripts written by beginners that don't play nice with other scripts) Are you using the correct Saved Games\DCS folder? (DCS 1.5 uses "Saved Games/DCS", DCS 2.0 uses "Saved Games\DCS.openalpha")? DCS-BIOS | How to export CMSP, RWR, etc. through MonitorSetup.lua Link to comment Share on other sites More sharing options...
What Goes Up Posted May 5, 2016 Share Posted May 5, 2016 G'day Ian A real pleasure to talk with you. I have un-installed A10 DCS and DCS Bios folders and started with a brand new install of DCS A10 and then DCS Bios. Still nothing. I follow the process as set out in instructions, I download DCS BIOS V0.50 zip and extracted it. The first stumbling block is when I copy %userprofile%\saved games\DCS, windows cannot find that. On my PC it ends "DCS Warthog", but it has the same data such as mission and logs folders. I then make a script folder and copy the extracted Script contents along with the Export lua. I have skipped the Arduino part ( think thats all ok) and installed Control Reference Live as per the Youtube video. But alas nothing updates, even after an F5 refresh with DCS running un-paused. In answer to you question: nothing else is using Export lua. I assume I have version 1.5 as I dont have openalpha. Errors in log file.... just a few, see below: 00012.592 ERROR WRADIO: "NDB" beacon is on the water! 00012.908 WARNING LOG: 1 duplicate message(s) skipped. 00012.947 ERROR WRADIO: "NDB" beacon is on the water! 00014.417 ERROR GRAPHICSXP: ModelManager: can't find LAP-CABLES 00016.963 ERROR COCKPITBASE: Cockpit::avDevice::link_all: unable to find link variable 'TGPinterface' for device 'MAIN_PANEL' 00016.963 ERROR COCKPITBASE: Cockpit::avDevice::link_all: unable to find link variable 'padlock' for device 'MAIN_PANEL' 00016.963 ERROR COCKPITBASE: Cockpit::avDevice::link_all: unable to find link variable 'betty' for device 'AAR47' 00019.369 ERROR COCKPITBASE: Cockpit: Clickable - Wrong connector name EW-LGT-R1 00023.412 ERROR DXRENDERER: DXDefTexture: failed to load white.png. Reason: D3DXERR_INVALIDDATA. 00024.410 ERROR DXRENDERER: DXDefTexture: failed to load gausse.bmp. Reason: D3DXERR_INVALIDDATA. 00024.418 ERROR DXRENDERER: DXDefTexture: failed to load rl_target_sprite.bmp. Reason: D3DXERR_INVALIDDATA. 00024.426 ERROR DXRENDERER: DXDefTexture: failed to load noise_beam_0_256x1.bmp. Reason: D3DXERR_INVALIDDATA. 00024.949 INFO DXRENDERER: Creating Resource "Unicode" of type 5 00089.143 ERROR EFFECTS: parameter not registered reloadShader 00089.143 ERROR EFFECTS: parameter not registered Sort 00089.143 ERROR EFFECTS: parameter not registered sortFrontToBack 00089.143 ERROR EFFECTS: parameter not registered maxAlfa 00089.143 INFO EFFECTS: smoke 0 created at 61.050000 scale 1.000000, pos = {-281649.437500, 680.089661, 792172.562500} 00097.075 ERROR DCS: Error while launching weapon: Ammunition not found: 4, 5, 36, 86 00106.676 ERROR VFS: Can't unmount ''. Any ideas? Link to comment Share on other sites More sharing options...
FSFIan Posted May 5, 2016 Author Share Posted May 5, 2016 (edited) Those errors all look normal. Specifically, there is nothing related to loading Export.lua or DCS-BIOS in there. Make sure to run DCS at least once before trying to install DCS-BIOS. To verify that you have found the correct "Saved Games\DCS" folder, do the following: delete Saved Games\DCS\Logs\dcs.log run DCS verify that dcs.log has been recreated If you have a "Saved Games\DCS Warthog" folder, that may be a relic from the time when DCS: A-10C and DCS: Black Shark 2 were still separate programs (you are running DCS: World 1.5 with the A-10C module, right?). EDIT: Just re-read your post. I assume I have version 1.5 as I dont have openalpha. Wait a minute... you only assume you have 1.5... there is a "DCS Warthog" folder... that's not a relic, holy shit when you said you installed DCS: A10 you actually meant installing DCS: A10, probably from the DVD it came on! ED replaced that with the "DCS: World" platform years ago. You download and install DCS: World, which is free and comes with the Su-25T. Then you can install the A-10C through the module manager (the icon with the square blocks on top of the main menu) and activate it with your existing A-10C key. Waiting for that multi-gigabyte download will take a while, but I promise you when you start a mission after going from DCS: A-10C to DCS: World 1.5 you'll agree it was worth it. Much better visuals and higher framerates. Also, you should try playing multiplayer some time! Edited May 5, 2016 by [FSF]Ian DCS-BIOS | How to export CMSP, RWR, etc. through MonitorSetup.lua Link to comment Share on other sites More sharing options...
What Goes Up Posted May 5, 2016 Share Posted May 5, 2016 G'day Ian Right I understand now. I will download DCS world, thanks for the link, im really behind the times arnt I ! Haha talking about relics, I still have A10 Cuba somewhere at home. It was thinking about this great old game that got me into looking for better A10 sims and hence finding DCS all those years ago. I carnt wait to have a go at multilayer, I have never had a good enough Internet connection until now. Thanks for your help. Link to comment Share on other sites More sharing options...
BravoYankee4 Posted May 6, 2016 Share Posted May 6, 2016 That's no relic, my A-10 Tank killer Amiga game is :) Link to comment Share on other sites More sharing options...
What Goes Up Posted May 6, 2016 Share Posted May 6, 2016 Just Googled A10 Tank Killer, you maybe right with the description relic Bravo Yankee4. Ive just got to Google what an Amiga is now :smilewink: Link to comment Share on other sites More sharing options...
FSFIan Posted May 7, 2016 Author Share Posted May 7, 2016 Guys, a recent DCS update might have broken most of the controls in the Huey and the A-10C, and possibly in the Ka-50 as well due to changing device IDs. I cannot verify this right now, as I don't have access to my DCS computer, but I know it happened with the Huey, and Warhog just told me that most of the A-10C stuff doesn't work for him anymore. I'll look into this when I get back to my apartment. If it is what I think it is, fixing it will be relatively easy, if somewhat tedious. DCS-BIOS | How to export CMSP, RWR, etc. through MonitorSetup.lua Link to comment Share on other sites More sharing options...
Deadman Posted May 7, 2016 Share Posted May 7, 2016 Thanks:thumbup: https://www.shapeways.com/shops/a-10c-warthog-supplies https://forum.dcs.world/topic/133818-deadmans-cockpit-base-plans/#comment-133824 CNCs and Laser engravers are great but they can't do squat with out a precise set of plans. Link to comment Share on other sites More sharing options...
BravoYankee4 Posted May 7, 2016 Share Posted May 7, 2016 Ian;2770775']Guys, a recent DCS update might have broken most of the controls in the Huey and the A-10C, and possibly in the Ka-50 as well due to changing device IDs. I cannot verify this right now, as I don't have access to my DCS computer, but I know it happened with the Huey, and Warhog just told me that most of the A-10C stuff doesn't work for him anymore. I'll look into this when I get back to my apartment. If it is what I think it is, fixing it will be relatively easy, if somewhat tedious. Why did they do that?:chair: Anyway, thanks for trying to fix it. I'll see if I can get my MIG panels connected again and see if they messed that up as well. Link to comment Share on other sites More sharing options...
FSFIan Posted May 8, 2016 Author Share Posted May 8, 2016 I am back at my DCS rig now. Nothing has changed for the A-10C and it still works on my machine. So I assume the only aircraft I'll have to fix is the Huey. DCS-BIOS | How to export CMSP, RWR, etc. through MonitorSetup.lua Link to comment Share on other sites More sharing options...
Ghost46 Posted May 16, 2016 Share Posted May 16, 2016 Hey Guys - this might be the right spot :) Im new to this forum but diving all the way into the DCS, and DCS-BIOS world with cockpit building. I wanted to say thank Ian for all the hard work he put into DCS BIOS, this is a crazy amount of information and will be so much help for my project. I have some issues getting simple things to work tho. I think i was able to manage to install DCS Bios library and all. moved scripts and lua file. Worked out fine. I hooked up an LCD, working with hello world and tried to run the code for UHF/Clock display. i adapted the COM-port in the BAT file, however all i get is this: Couldnt compute FAST_CWD pointer. Please report this problem to the public mailing list cygwin@cygwin.com does anyone have an idea of what im doing wrong?. thanks so much guys cheers Link to comment Share on other sites More sharing options...
FSFIan Posted May 16, 2016 Author Share Posted May 16, 2016 That error message shows up on Windows 10, but it does not indicate anything going wrong; the script works anyway. I am on Windows 10 myself. If you are in an aircraft cockpit in DCS, the mission is unpaused, and the script is running, you should see a bunch of data showing up in the console window just like you see in the intro video. If that does not happen, you either did not set up DCS-BIOS correctly or some third-party software (firewall, antivirus) is interfering with the connection. If you are using anything else that makes use of Export.lua, that could also be an issue. The common ones such as Helios, TacView or Aries Radio are known to work, but I have seen some Export.lua scripts that did not play well with others because they don't make sure to call pre-existing callback functions. If you are in doubt, try with only DCS-BIOS enabled. Check your dcs.log for errors. If you have multiple DCS installations (1.5 and 2.0) on your computer, make sure DCS-BIOS is installed in the correct one (or just install it for all of them) -- 1.5 uses "Saved Games\DCS", 2.0 uses "Saved Games\DCS.openbeta". DCS-BIOS | How to export CMSP, RWR, etc. through MonitorSetup.lua Link to comment Share on other sites More sharing options...
Ghost46 Posted May 17, 2016 Share Posted May 17, 2016 Hey Ian Thanks a lot! You are good at identifying the problems :) It was a combination of two of the things you wrote. I actually only tried it with 2.0 Alpha and hat the stuff in the wrong folder - shame at me. And i also deactivated the Avira (Firewall/Antivirus) - however it seems to be now running with those aswell - as i reactivated them it asked me if I wanna add DCS to the firewall rules. Should be good now! Seeing that code running down for the first time was a great feeling :-) Unfortunately i dont see anything on my LCD so far - i followed your instructions on youtube. Only difference i use the IRQ_Serial cause there is no Template one - should it work aswell? Anyway i will stay at it until i find it out :D thx again Link to comment Share on other sites More sharing options...
Recommended Posts