Purzel Posted October 11, 2023 Posted October 11, 2023 Hi folks, that's the situation: I've build a deskpit and now I want to get the panels backlit by an LED-strip I've bought. I'm using an arduino micro-pro board and the hook-/gear-down-LEDs are working. I'm working with the DCSbios original branch. But I can't find the DCSbios-code for the instrument-panels LEDs, this is the only thing I can find regarding on the instrumentpanels: So would someone be so nice to tell me the correct DCSbios-code? (I've set the code below already to PIN5 of the arduino-board.) And what ist the code to insert at the "your code here"-part? THX Purzel INST PNL Dimmer FA-18C_hornet/INST_PNL_DIMMER Input: set the position of the dial DcsBios::PotentiometerEWMA<5, 128, 5> instPnlDimmer("INST_PNL_DIMMER", PIN5); void onInstPnlDimmerChange(unsigned int newValue) { /* your code here */ } DcsBios::IntegerBuffer instPnlDimmerBuffer(0x7536, 0xffff, 5, onInstPnlDimmerChange); Integer Output: position of the potentiometer DcsBios::ServoOutput instPnlDimmer(0x7536,PIN5, 544, 2400); 1
Vinc_Vega Posted October 11, 2023 Posted October 11, 2023 Hi Purzel, I have to look into the control reference later when I'm back home, but at the first glance your output seems to be the position of the Potentiometer. I mean the rotating animation of the knob itself in the cockpit. That may be a workaround if really no output of the backlighting is available. Regards, Vinc Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
Vinc_Vega Posted October 11, 2023 Posted October 11, 2023 (edited) Hi Purzel, according to the control reference in your case I would suggest to use the code from the "Internal Lights" section -> Instrument Lightning (light green) of the F-18. That represents the gauge position and not the position of the potentiometer. void onInstrIntLtChange(unsigned int newValue) { /* your code here */ } DcsBios::IntegerBuffer instrIntLtBuffer(0x7560, 0xffff, 0, onInstrIntLtChange); Within the "your code here" section you have to define the output signal. See below code snippet from the A-10C console light script for example, that is included in almost all my panels. The pot is connected to A2 (analogue input pin, only applicable to the lighting control panel), digital pin 3 is used as signal output for backlit panels. You therefore, first have to declare the output pin (must be a pin with PWM functionality). As an Arduino Nano is only capable to PWM signals from 0 to 255 (0 to 5Volt), in my case the mapping function is simply a division of the returned "new Value" by 256. The calculated value finally is written as an analogue value to the output pin (PWM signal). I then use the 0 to 5Volt steering signal to control the brightness of a 12Volt backlighting LED-Strip via MOSFET. Spoiler // Code Snippets for the Console Lighting of the most panels /* 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" // For Console Lights: definition of the Output Pin (PWM) const int ConsoleLightsPin = 3; // use PWM PIN for Console Lights (via MOSFET) /* paste code snippets from the reference documentation here */ /* Begin: only for the Light System Control Panel Potentiometer at Pin A2 as Input for Console Lights */ DcsBios::Potentiometer lcpConsole("LCP_CONSOLE", A2); // taken from lighting control panel /* End Poti for Console Lights */ // For Console Lights: definition of the Output as PWM signal void onLcpConsoleChange(unsigned int newValue) { // Min. Value 0 - Max. Value: 65535 analogWrite(ConsoleLightsPin, (newValue/256)); // writes as PWM (0 - 255) } DcsBios::IntegerBuffer lcpConsoleBuffer(0x1150, 0xffff, 0, onLcpConsoleChange); void setup() { DcsBios::setup(); // For Console Lights: Output as PWM signal in setup loop pinMode(ConsoleLightsPin, OUTPUT) ; //define PWM PIN for Console Lights as output } void loop() { DcsBios::loop(); } Best regards, Vinc Edited October 11, 2023 by Vinc_Vega Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
No1sonuk Posted October 11, 2023 Posted October 11, 2023 10 hours ago, Purzel said: I'm working with the DCSbios original branch. This is likely your problem. Hub is woefully out of date - especially for the F-18. You'll be better off removing it and switch to the "Flightpanels Fork", which is actively updated. https://github.com/DCS-Skunkworks
hrnet940 Posted October 15, 2023 Posted October 15, 2023 Nice desktop cockpit Purzel. Bravo Zulu!! Wayne Wilson AKA: hrnet940 Alienware Aurora R3, i7 3820 3.5GHz(4.2GHz setting) processor, EVGA Nvidia RTX 2070 8GB Graphics, 16GB Ram, 1TB SSD.
Recommended Posts