Jump to content

DCS-BIOS Discussion Thread


FSFIan

Recommended Posts

hello every body :)

 

i d like to ask if there is a tutorial about how to connect arduino s with the configuration one mega with many others?

 

have a nice day very one :)

 

Yes - its very important . Now I try to connect 2 arduino via rs-485. use 2 Max 485 for it.

video about rs-485

But how it working with dcs - bios. Wich pins i must use for DCS-BIOS working. Where i must write sendmessage. So - it s many questons...

Now my system consist from 2 Mega and 3 nano. 5 USB wire connected with usb hub with exrternal 5V 3A.


Edited by jazzymanserg
Link to comment
Share on other sites

Yes - its very important . Now I try to connect 2 arduino via rs-485. use 2 Max 485 for it.

video about rs-485

But how it working with dcs - bios. Wich pins i must use for DCS-BIOS working. Where i must write sendmessage. So - it s many questons...

 

 

yep, i m using a DIY solution (that i know not very brilliant ) to make two megas work with two instances of DCS-bios with differant com ports ... but i want to pass to the "PRO LEAGUE" ... :smartass:

With respect

_________________

Kadda

_________________

My works

TL-39 (NewGen) project (Ру)/(EN)

Link to comment
Share on other sites

Some have been asking for the code for Fuel Quantity Gauge for the A-10C. This one drives the 7 segment display using the MAX7219 chip. Also a few other items are driven with the same arduino other than the fuel gauge.

 

/*

Fuel Panel and Front Dash

*/

 

#define DCSBIOS_DEFAULT_SERIAL

#include "DcsBios.h"

#include <LedControl.h>

#include <Servo.h>

#include <Wire.h>

 

Servo FuelQtyLeft_gauge; // create servo object to control a servo motor

Servo FuelQtyRight_gauge; // create servo object to control a servo motor

Servo L_HYD_Press_gauge; // create servo object to control a servo motor

Servo R_HYD_Press_gauge; // create servo object to control a servo motor

 

// MAX 7219 only works with Common Cathode Displays

// inputs: DIN pin, CLK pin, LOAD (/CS) pin. number of MAX7219chips

LedControl FuelDisplay = LedControl(12, 11, 10, 1);

 

int val_1 = 0;

int val_2 = 0;

int val_3 = 0;

 

void setup() {

DcsBios::setup();

FuelDisplay.shutdown(0, false); // turns on display

FuelDisplay.setIntensity(0, 10); // 15 = brightest

FuelQtyLeft_gauge.attach(3); // attaches the servo on pin 3 to the servo object

FuelQtyRight_gauge.attach(5); // attaches the servo on pin 5 to the servo object

L_HYD_Press_gauge.attach(6); // attaches the servo on pin 6 to the servo object

R_HYD_Press_gauge.attach(9); // attaches the servo on pin 9 to the servo object

}

 

void loop() {

DcsBios::loop();

}

 

// GUN READY Indicator

DcsBios::LED gunReady(0x1026, 0x8000, 13);

 

// Nosewheel Steering Indicator

DcsBios::LED nosewheelSteering(0x10da, 0x0001, 2);

 

// MARKER BEACON Indicator

DcsBios::LED markerBeacon(0x10da, 0x0002, 4);

 

// CANOPY UNLOCKED Indicator

DcsBios::LED canopyUnlocked(0x10da, 0x0004, 7);

 

// Fuel Display Selector

const byte fqisSelectPins[5] = {A0, A1, A2, A3, A4};

DcsBios::SwitchMultiPos fqisSelect("FQIS_SELECT", fqisSelectPins, 5);

 

// Fuel Gauge Test

DcsBios::Switch2Pos fqisTest("FQIS_TEST", A5);

 

// Fuel Quantity Counter 10000

void onFuelQty10000Change(unsigned int newValue1) {

unsigned int value1 = (newValue1 & 0xffff) >> 0;

unsigned int Disp_Digit_1 = map(value1, 0, 65535, 0, 10000);

val_1 = Disp_Digit_1;

if (Disp_Digit_1 > 501)

{val_1 = 1;}

else

{val_1 = 0;}

FuelDisplay.setDigit(0, 0, val_1, false); // Print "10,000"'s slot

FuelDisplay.setDigit(0, 3, 0, false); // Blank out "10"s slot

FuelDisplay.setDigit(0, 4, 0, false); // Blank out "1"s slot

}

DcsBios::IntegerBuffer fuelQty10000Buffer(0x10ce, 0xffff, 0, onFuelQty10000Change);

 

// Fuel Quantity Counter 1000

void onFuelQty1000Change(unsigned int newValue2) {

unsigned int value2 = (newValue2 & 0xffff) >> 0;

unsigned int Disp_Digit_2 = map(value2, 0, 65535, 0, 1000);

val_2 = Disp_Digit_2;

if (val_2 > 900)

{val_2 = 0;}

else if (val_2 > 800)

{val_2 = 9;}

else if (val_2 > 700)

{val_2 = 8;}

else if (val_2 > 600)

{val_2 = 7;}

else if (val_2 > 500)

{val_2 = 6;}

else if (val_2 > 400)

{val_2 = 5;}

else if (val_2 > 300)

{val_2 = 4;}

else if (val_2 > 200)

{val_2 = 3;}

else if (val_2 > 100)

{val_2 = 2;}

else

{val_2 = 1;}

FuelDisplay.setDigit(0, 1, val_2, false); // Print "1,000"'s slot

FuelDisplay.setDigit(0, 3, 0, false); // Blank out "10"s slot

FuelDisplay.setDigit(0, 4, 0, false); // Blank out "1"s slot

}

DcsBios::IntegerBuffer fuelQty1000Buffer(0x10d0, 0xffff, 0, onFuelQty1000Change);

 

// Fuel Quantity Counter 100

void onFuelQty100Change(unsigned int newValue3) {

unsigned int value3 = (newValue3 & 0xffff) >> 0;

unsigned int Disp_Digit_3 = map(value3, 0, 65535, 0, 100);

val_3 = Disp_Digit_3;

if (val_3 > 90)

{val_3 = 0;}

else if (val_3 > 80)

{val_3 = 9;}

else if (val_3 > 70)

{val_3 = 8;}

else if (val_3 > 60)

{val_3 = 7;}

else if (val_3 > 50)

{val_3 = 6;}

else if (val_3 > 40)

{val_3 = 5;}

else if (val_3 > 30)

{val_3 = 4;}

else if (val_3 > 20)

{val_3 = 3;}

else if (val_3 > 10)

{val_3 = 2;}

else

{val_3 = 1;}

FuelDisplay.setDigit(0, 2, val_3, false); // Print "100"'s slot

FuelDisplay.setDigit(0, 3, 0, false); // Blank out "10"s slot

FuelDisplay.setDigit(0, 4, 0, false); // Blank out "1"s slot

}

DcsBios::IntegerBuffer fuelQty100Buffer(0x10d2, 0xffff, 0, onFuelQty100Change);

 

// Fuel Qty Left

void onFuelQtyLChange(unsigned int newFuel_L_Value) {

unsigned int FuelQtyLeft_Value = (newFuel_L_Value & 0xffff) >> 0;

unsigned int FuelQtyLeft = map(FuelQtyLeft_Value, 0, 65535, 0, 110);

FuelQtyLeft_gauge.write(FuelQtyLeft);

}

DcsBios::IntegerBuffer fuelQtyLBuffer(0x10ca, 0xffff, 0, onFuelQtyLChange);

 

// Fuel Qty Right

void onFuelQtyRChange(unsigned int newFuel_R_Value) {

unsigned int FuelQtyRight_Value = (newFuel_R_Value & 0xffff) >> 0;

unsigned int FuelQtyRight = map(FuelQtyRight_Value, 0, 65535, 110, 0);

FuelQtyRight_gauge.write(FuelQtyRight);

}

DcsBios::IntegerBuffer fuelQtyRBuffer(0x10cc, 0xffff, 0, onFuelQtyRChange);

 

// Left Hydraulic Pressure

void onLHydPressChange(unsigned int newL_HYD_Press_Value) {

unsigned int L_HYD_Press_Value = (newL_HYD_Press_Value & 0xffff) >> 0;

unsigned int L_HYD_Press = map(L_HYD_Press_Value, 0, 65535, 0, 180);

L_HYD_Press_gauge.write(L_HYD_Press);

}

DcsBios::IntegerBuffer lHydPressBuffer(0x10c2, 0xffff, 0, onLHydPressChange);

 

// Right Hydraulic Pressure

void onRHydPressChange(unsigned int newR_HYD_Press_Value) {

unsigned int R_HYD_Press_Value = (newR_HYD_Press_Value & 0xffff) >> 0;

unsigned int R_HYD_Press = map(R_HYD_Press_Value, 0, 65535, 0, 180);

R_HYD_Press_gauge.write(R_HYD_Press);

}

DcsBios::IntegerBuffer rHydPressBuffer(0x10c4, 0xffff, 0, onRHydPressChange);

Link to comment
Share on other sites

Some have been asking for the code for Fuel Quantity Gauge for the A-10C. This one drives the 7 segment display using the MAX7219 chip. Also a few other items are driven with the same arduino other than the fuel gauge.

 

/*

Fuel Panel and Front Dash

*/

 

#define DCSBIOS_DEFAULT_SERIAL

#include "DcsBios.h"

#include <LedControl.h>

#include <Servo.h>

#include <Wire.h>

 

Servo FuelQtyLeft_gauge; // create servo object to control a servo motor

Servo FuelQtyRight_gauge; // create servo object to control a servo motor

Servo L_HYD_Press_gauge; // create servo object to control a servo motor

Servo R_HYD_Press_gauge; // create servo object to control a servo motor

 

// MAX 7219 only works with Common Cathode Displays

// inputs: DIN pin, CLK pin, LOAD (/CS) pin. number of MAX7219chips

LedControl FuelDisplay = LedControl(12, 11, 10, 1);

 

int val_1 = 0;

int val_2 = 0;

int val_3 = 0;

 

void setup() {

DcsBios::setup();

FuelDisplay.shutdown(0, false); // turns on display

FuelDisplay.setIntensity(0, 10); // 15 = brightest

FuelQtyLeft_gauge.attach(3); // attaches the servo on pin 3 to the servo object

FuelQtyRight_gauge.attach(5); // attaches the servo on pin 5 to the servo object

L_HYD_Press_gauge.attach(6); // attaches the servo on pin 6 to the servo object

R_HYD_Press_gauge.attach(9); // attaches the servo on pin 9 to the servo object

}

 

void loop() {

DcsBios::loop();

}

 

// GUN READY Indicator

DcsBios::LED gunReady(0x1026, 0x8000, 13);

 

// Nosewheel Steering Indicator

DcsBios::LED nosewheelSteering(0x10da, 0x0001, 2);

 

// MARKER BEACON Indicator

DcsBios::LED markerBeacon(0x10da, 0x0002, 4);

 

// CANOPY UNLOCKED Indicator

DcsBios::LED canopyUnlocked(0x10da, 0x0004, 7);

 

// Fuel Display Selector

const byte fqisSelectPins[5] = {A0, A1, A2, A3, A4};

DcsBios::SwitchMultiPos fqisSelect("FQIS_SELECT", fqisSelectPins, 5);

 

// Fuel Gauge Test

DcsBios::Switch2Pos fqisTest("FQIS_TEST", A5);

 

// Fuel Quantity Counter 10000

void onFuelQty10000Change(unsigned int newValue1) {

unsigned int value1 = (newValue1 & 0xffff) >> 0;

unsigned int Disp_Digit_1 = map(value1, 0, 65535, 0, 10000);

val_1 = Disp_Digit_1;

if (Disp_Digit_1 > 501)

{val_1 = 1;}

else

{val_1 = 0;}

FuelDisplay.setDigit(0, 0, val_1, false); // Print "10,000"'s slot

FuelDisplay.setDigit(0, 3, 0, false); // Blank out "10"s slot

FuelDisplay.setDigit(0, 4, 0, false); // Blank out "1"s slot

}

DcsBios::IntegerBuffer fuelQty10000Buffer(0x10ce, 0xffff, 0, onFuelQty10000Change);

 

// Fuel Quantity Counter 1000

void onFuelQty1000Change(unsigned int newValue2) {

unsigned int value2 = (newValue2 & 0xffff) >> 0;

unsigned int Disp_Digit_2 = map(value2, 0, 65535, 0, 1000);

val_2 = Disp_Digit_2;

if (val_2 > 900)

{val_2 = 0;}

else if (val_2 > 800)

{val_2 = 9;}

else if (val_2 > 700)

{val_2 = 8;}

else if (val_2 > 600)

{val_2 = 7;}

else if (val_2 > 500)

{val_2 = 6;}

else if (val_2 > 400)

{val_2 = 5;}

else if (val_2 > 300)

{val_2 = 4;}

else if (val_2 > 200)

{val_2 = 3;}

else if (val_2 > 100)

{val_2 = 2;}

else

{val_2 = 1;}

FuelDisplay.setDigit(0, 1, val_2, false); // Print "1,000"'s slot

FuelDisplay.setDigit(0, 3, 0, false); // Blank out "10"s slot

FuelDisplay.setDigit(0, 4, 0, false); // Blank out "1"s slot

}

DcsBios::IntegerBuffer fuelQty1000Buffer(0x10d0, 0xffff, 0, onFuelQty1000Change);

 

// Fuel Quantity Counter 100

void onFuelQty100Change(unsigned int newValue3) {

unsigned int value3 = (newValue3 & 0xffff) >> 0;

unsigned int Disp_Digit_3 = map(value3, 0, 65535, 0, 100);

val_3 = Disp_Digit_3;

if (val_3 > 90)

{val_3 = 0;}

else if (val_3 > 80)

{val_3 = 9;}

else if (val_3 > 70)

{val_3 = 8;}

else if (val_3 > 60)

{val_3 = 7;}

else if (val_3 > 50)

{val_3 = 6;}

else if (val_3 > 40)

{val_3 = 5;}

else if (val_3 > 30)

{val_3 = 4;}

else if (val_3 > 20)

{val_3 = 3;}

else if (val_3 > 10)

{val_3 = 2;}

else

{val_3 = 1;}

FuelDisplay.setDigit(0, 2, val_3, false); // Print "100"'s slot

FuelDisplay.setDigit(0, 3, 0, false); // Blank out "10"s slot

FuelDisplay.setDigit(0, 4, 0, false); // Blank out "1"s slot

}

DcsBios::IntegerBuffer fuelQty100Buffer(0x10d2, 0xffff, 0, onFuelQty100Change);

 

// Fuel Qty Left

void onFuelQtyLChange(unsigned int newFuel_L_Value) {

unsigned int FuelQtyLeft_Value = (newFuel_L_Value & 0xffff) >> 0;

unsigned int FuelQtyLeft = map(FuelQtyLeft_Value, 0, 65535, 0, 110);

FuelQtyLeft_gauge.write(FuelQtyLeft);

}

DcsBios::IntegerBuffer fuelQtyLBuffer(0x10ca, 0xffff, 0, onFuelQtyLChange);

 

// Fuel Qty Right

void onFuelQtyRChange(unsigned int newFuel_R_Value) {

unsigned int FuelQtyRight_Value = (newFuel_R_Value & 0xffff) >> 0;

unsigned int FuelQtyRight = map(FuelQtyRight_Value, 0, 65535, 110, 0);

FuelQtyRight_gauge.write(FuelQtyRight);

}

DcsBios::IntegerBuffer fuelQtyRBuffer(0x10cc, 0xffff, 0, onFuelQtyRChange);

 

// Left Hydraulic Pressure

void onLHydPressChange(unsigned int newL_HYD_Press_Value) {

unsigned int L_HYD_Press_Value = (newL_HYD_Press_Value & 0xffff) >> 0;

unsigned int L_HYD_Press = map(L_HYD_Press_Value, 0, 65535, 0, 180);

L_HYD_Press_gauge.write(L_HYD_Press);

}

DcsBios::IntegerBuffer lHydPressBuffer(0x10c2, 0xffff, 0, onLHydPressChange);

 

// Right Hydraulic Pressure

void onRHydPressChange(unsigned int newR_HYD_Press_Value) {

unsigned int R_HYD_Press_Value = (newR_HYD_Press_Value & 0xffff) >> 0;

unsigned int R_HYD_Press = map(R_HYD_Press_Value, 0, 65535, 0, 180);

R_HYD_Press_gauge.write(R_HYD_Press);

}

DcsBios::IntegerBuffer rHydPressBuffer(0x10c4, 0xffff, 0, onRHydPressChange);

Awesome...tx for sharing GSS Rain.

 

 

Sent from my SM-N910G using Tapatalk

Link to comment
Share on other sites

Hi

I have problem with compile sketch with RS 485 communication.

 

In sketch i have function:

void Switch2Pos(char* msg, double arg, int chip, int pin) {
 char state = NumToChip(chip).digitalRead(pin); // reads the Pin of the MCP
 if (state != lastState[chip][pin]) {
   sendDcsBiosMessage(msg, state == 0 ? "1" : "0");
 }
 lastState[chip][pin] = state;
}

 

During compile get error:

dcs_bios_LeftPanel_OK.cpp.o: In function `Switch2Pos(char*, double, int, int)':

undefined reference to `sendDcsBiosMessage(char const*, char const*)'

 

If I change #define DCSBIOS_RS485_SLAVE 1 to #define DCSBIOS_IRQ_SERIAL then compiling with no problem. How to fix this?


Edited by lancer2000
Link to comment
Share on other sites

llancer2000: Declare the parameters of your Switch2Pos function as "const char*" instead of "char*".

 

The "const" modifier is a promise to the compiler that you won't modify the parameter value. Newer versions of DCS-BIOS use "const char*" for all the message parameters to fix compiler warnings.

 

 

 

Anyone: In case you have posted in the past two weeks and have not received an answer, please post again in a new thread. I have not kept up with this thread as frequently as usual and now there are several intertwined conversations going on and I have lost track.

 

I have tried to encourage people to open new threads for anything that might require troubleshooting (and that other people might want to find in the future with the search function), but the vast majority of people still post here for everything. I have had cases where I knew I had answered a question before, but spent twenty minutes writing out another answer because that was faster than trying to find the old answer that was buried deep within a thread that's 70+ pages long.

 

So here's a question for all of you: what motivates people to post here instead of opening a new thread? Is it the impression that I won't notice a new thread? (Don't worry about that, I am subscribed to the Home Cockpits forum.) Is it just the convenience of not having to think of a thread title?

How can I get people to start opening new threads for each issue without flat out refusing to do any support in this thread?

Link to comment
Share on other sites

Thanks for quick reply.

I change "char*" to "const char*" in Switch2Pos function but still is same error

 

void Switch2Pos(const char* msg, double arg, int chip, int pin) {
 char state = NumToChip(chip).digitalRead(pin); // reads the Pin of the MCP
 if (state != lastState[chip][pin]) {
   sendDcsBiosMessage(msg, state == 0 ? "1" : "0");
 }
 lastState[chip][pin] = state;
}

Link to comment
Share on other sites

Hi Ian...maybe if you can close this threat with a message to the people about how to get help regarding DCS Bios..that might force people to open new threats. Any case, your work...response and know how is just amazing. Realy awsome support that you are giving to this comunity. Cheers for that.

 

Sent from my SM-N910G using Tapatalk

Link to comment
Share on other sites

Dcs bios library 0.2.9

Arduino 1.6.5.

 

Complete sketch:

//#define SERIAL_TX_BUFFER_SIZE 256
//#define SERIAL_RX_BUFFER_SIZE 256
//#define SERIALSPEED 500000
#define DCSBIOS_RS485_SLAVE 1
#define TXENABLE_PIN 2
//#define DCSBIOS_IRQ_SERIAL
//#define DCSBIOS_DEFAULT_SERIAL

#include <DcsBios.h>
#include "LedControl.h"
#include "Adafruit_MCP23017.h"
#include <Wire.h>

const byte WeaponsModePins[5] = {0, 1, 2, 3, 4};
const byte EngSelectorPins[4] = {8, 9, 10, 11};
const byte RadioSelectorPins[4] = {0,1,2,3};

int lastState[3][16];

Adafruit_MCP23017 mcp1;
Adafruit_MCP23017 mcp2;
Adafruit_MCP23017 mcp3;

LedControl lc=LedControl(12,11,10,1);
int nums[11] = {
 B11110110,
 B00100010,//B01000100,
 B11110001,
 B10110011,
 B00100111,
 B10010111,
 B11010111,
 B00110010,
 B11110111,
 B10110111,
 B00000000};

 void Led_digit(int addr, int digit, int number) {

   switch(number) {
     case 0:
       lc.setLed(addr, 0,digit,true);
       lc.setLed(addr, 1,digit,true);
       lc.setLed(addr, 2,digit,true);
       lc.setLed(addr, 3,digit,true);
       lc.setLed(addr, 5,digit,true);
       lc.setLed(addr, 6,digit,true);
       lc.setLed(addr, 7,digit,false);
     break;

    case 1:
       lc.setLed(addr, 0,digit,false);
       lc.setLed(addr, 1,digit,false);
       lc.setLed(addr, 2,digit,true);
       lc.setLed(addr, 3,digit,false);
       lc.setLed(addr, 5,digit,false);
       lc.setLed(addr, 6,digit,true);
       lc.setLed(addr, 7,digit,false);
     break;
   
    case 2:
       lc.setLed(addr, 0,digit,true);
       lc.setLed(addr, 1,digit,true);
       lc.setLed(addr, 2,digit,true);
       lc.setLed(addr, 3,digit,true);
       lc.setLed(addr, 5,digit,false); 
       lc.setLed(addr, 6,digit,false);
       lc.setLed(addr, 7,digit,true);
     break;

    case 3:
       lc.setLed(addr, 0,digit,true);
       lc.setLed(addr, 1,digit,false);
       lc.setLed(addr, 2,digit,true);
       lc.setLed(addr, 3,digit,true);
       lc.setLed(addr, 5,digit,false);
       lc.setLed(addr, 6,digit,true);
       lc.setLed(addr, 7,digit,true);
     break;

    case 4:
       lc.setLed(addr, 0,digit,false);
       lc.setLed(addr, 1,digit,false);
       lc.setLed(addr, 2,digit,true);
       lc.setLed(addr, 3,digit,false);
       lc.setLed(addr, 5,digit,true);
       lc.setLed(addr, 6,digit,true);
       lc.setLed(addr, 7,digit,true);
     break;

    case 5:
       lc.setLed(addr, 0,digit,true);
       lc.setLed(addr, 1,digit,false);
       lc.setLed(addr, 2,digit,false);
       lc.setLed(addr, 3,digit,true);
       lc.setLed(addr, 5,digit,true);
       lc.setLed(addr, 6,digit,true);
       lc.setLed(addr, 7,digit,true);
     break;

    case 6:
       lc.setLed(addr, 0,digit,true);
       lc.setLed(addr, 1,digit,true);
       lc.setLed(addr, 2,digit,false);
       lc.setLed(addr, 3,digit,true);
       lc.setLed(addr, 5,digit,true);
       lc.setLed(addr, 6,digit,true);
       lc.setLed(addr, 7,digit,true);
     break;

     case 7:
       lc.setLed(addr, 0,digit,false);
       lc.setLed(addr, 1,digit,false);
       lc.setLed(addr, 2,digit,true);
       lc.setLed(addr, 3,digit,true);
       lc.setLed(addr, 5,digit,false);
       lc.setLed(addr, 6,digit,true);
       lc.setLed(addr, 7,digit,false);
     break;

     case 8:
       lc.setLed(addr, 0,digit,true);
       lc.setLed(addr, 1,digit,true);
       lc.setLed(addr, 2,digit,true);
       lc.setLed(addr, 3,digit,true);
       lc.setLed(addr, 5,digit,true);
       lc.setLed(addr, 6,digit,true);
       lc.setLed(addr, 7,digit,true);
     break;

     case 9:
       lc.setLed(addr, 0,digit,true);
       lc.setLed(addr, 1,digit,false);
       lc.setLed(addr, 2,digit,true);
       lc.setLed(addr, 3,digit,true);
       lc.setLed(addr, 5,digit,true);
       lc.setLed(addr, 6,digit,true);
       lc.setLed(addr, 7,digit,true);
     break;
 }
}

//***********R800 Frequency podwójne liczby*********************
DcsBios::StringBuffer<2> r800Freq1StrBuffer(0x190e, onR800Freq1Change);
void onR800Freq1Change(char* newValue) {
   int one, two;
    one = newValue[0]-'0';
    Led_digit(0,0,one);
    two = newValue[1]-'0';
    Led_digit(0,1,two);  
}

DcsBios::StringBuffer<2> r800Freq4StrBuffer(0x1912, onR800Freq4Change);
void onR800Freq4Change(char* newValue) {
    int one, two;
    one = newValue[0]-'0';
    Led_digit(0,4,one);
    two = newValue[1]-'0';
    Led_digit(0,5,two); 
}

//****************R800 Frequency pojedyńcze cyfry***************************
DcsBios::IntegerBuffer r800Freq2(0x190c, 0x3c00, 10, onR800Freq2Change);
void onR800Freq2Change(unsigned int value) {
   Led_digit(0,2,value);
}

DcsBios::IntegerBuffer r800Freq3(0x1910, 0x000f, 0, onR800Freq3Change);
void onR800Freq3Change(unsigned int value) {
   Led_digit(0,3,value);
}
//****************KONIEC R800 Frequency **************************


DcsBios::IntegerBuffer weaponsAirborneTargetLedBuffer(0x1910, 0x8000, 15, onWeaponsAirborneTargetLedChange);
void onWeaponsAirborneTargetLedChange(unsigned int newValue) {
   lc.setLed(0,7,7,newValue);
}
DcsBios::IntegerBuffer weaponsGroundTargetLedBuffer(0x1916, 0x0800, 11, onWeaponsGroundTargetLedChange);
void onWeaponsGroundTargetLedChange(unsigned int newValue) {
   lc.setLed(0,6,7,newValue);
}
DcsBios::IntegerBuffer weaponsForwardHemiTargetLedBuffer(0x1916, 0x0200, 9, onWeaponsForwardHemiTargetLedChange);
void onWeaponsForwardHemiTargetLedChange(unsigned int newValue) {
  lc.setLed(0,5,7,newValue);
}
DcsBios::IntegerBuffer weaponsAutoTurnLedBuffer(0x1910, 0x2000, 13, onWeaponsAutoTurnLedChange);
void onWeaponsAutoTurnLedChange(unsigned int newValue) {
   lc.setLed(0,4,7,newValue);
}

DcsBios::IntegerBuffer weaponsTargetResetLedBuffer(0x1916, 0x2000, 13, onWeaponsTargetResetLedChange);
void onWeaponsTargetResetLedChange(unsigned int newValue) {
  lc.setLed(0,2,7,newValue);
}

void setup() {
 //********* LED CONTROL********************
 lc.shutdown(0,false);
 lc.setIntensity(0,15);
 lc.clearDisplay(0);
//**** END LED CONTROL*********************

 mcp1.begin(0);    
  for (int thisPin1 = 0; thisPin1 < 16; thisPin1++)  {    
 mcp1.pinMode(thisPin1, INPUT);
 mcp1.pullUp(thisPin1, HIGH); 
   }
 
  mcp2.begin(2);    
 for (int thisPin2 = 0; thisPin2 < 16; thisPin2++)  {    
 mcp2.pinMode(thisPin2, INPUT);
 mcp2.pullUp(thisPin2, HIGH);
 }

  mcp3.begin(4);    
for (int thisPin3 = 0; thisPin3 < 16; thisPin3++)  {    
 mcp3.pinMode(thisPin3, INPUT);
 mcp3.pullUp(thisPin3, HIGH); 
   }

DcsBios::setup();
}

void loop() {
DcsBios::loop();

 // WEAPON PANEL + R800 zużył wszystkie piny MCP1
 Switch2Pos ("WEAPONS_AUTO_TURN_BTN", 0, 1, 0);
 Switch2Pos ("WEAPONS_FORWARD_HEMI_TARGET_BTN", 0, 1, 1);
 Switch2Pos ("WEAPONS_GROUND_TARGET_BTN", 0, 1, 2);
 Switch2Pos ("WEAPONS_AIRBORNE_TARGET_BTN", 0, 1, 3);
 Switch2Pos ("WEAPONS_TARGET_RESET_BTN", 0, 1, 4);
 Switch2Pos ("WEAPONS_TRAINING_MODE", 0, 1, 5);
 Switch2Pos ("K041_POWER", 0, 1, 6);
 Switch2Pos ("HMS_POWER", 0, 1, 7);
 Switch2Pos ("WEAPONS_AUTOTRACK_GUNSIGHT", 0, 1, 8);
 Switch2Pos ("LASER_STANDBY", 0, 1, 9);
 Switch2Pos ("R800_AM_FM", 0, 1, 10);
 Switch2Pos ("R800_DATA_TRANSFER_RATE", 0, 1, 11);
 Switch2Pos ("R800_EMER_RCVR", 0, 1, 12);
 Switch2Pos ("R800_ADF", 0, 1, 13);
 Switch2Pos ("R800_SQUELCH", 0, 1, 14);
 Switch2Pos ("R800_TEST_BTN", 0, 1, 15);
 // KONIEC MCP1

 // START MCP2 
 SwitchMultiPos("WEAPONS_MODE",WeaponsModePins,2, 5);
 Switch2Pos ("ENG_START", 0, 2, 5);
 Switch2Pos ("ENG_STOP", 0, 2, 6);
 Switch2Pos ("ENG_APU_STOP", 0, 2, 7);
 SwitchMultiPos("ENG_SELECTOR",EngSelectorPins,2, 4);
 Switch3Pos ("ENG_STARTUP_MODE", 0,2, 12, 13);
 // pin14.......
 // pin15......
 // KONIEC MCP2

 //START MCP3
 SwitchMultiPos("RADIO_SELECTOR",RadioSelectorPins,3, 4);
 
//6 pin4...pin11 - enkodery
//KONIEC MCP3

}

Adafruit_MCP23017 NumToChip(byte num) {
switch (num) {     
   case 1:
     return mcp1;
   case 2:
     return mcp2;
   case 3:
     return mcp3;
}
}

void Led(unsigned int address, unsigned int addressLed, unsigned int value, unsigned int mask, int chip, int pin) {
 bool is_on;

 if (address == addressLed) {
   is_on = (value & mask);
   if (is_on == 1) {
     NumToChip(chip).digitalWrite(pin, HIGH);
   }
   else {
     NumToChip(chip).digitalWrite(pin, LOW);
   }
 } 
}

void Switch2Pos(char* msg, double arg, int chip, int pin) {
 char state = NumToChip(chip).digitalRead(pin); // reads the Pin of the MCP
 if (state != lastState[chip][pin]) {
  sendDcsBiosMessage(msg, state == 0 ? "1" : "0");	 
 }
 lastState[chip][pin] = state;
}

char Switch3Pos_readState(int chip, int pinA, int pinB) {
 if (NumToChip(chip).digitalRead(pinA) == LOW) return 0;
 if (NumToChip(chip).digitalRead(pinB) == LOW) return 2;
 return 1;
}

void Switch3Pos(char* msg, double arg, int chip, int pinA, int pinB) {
 char state = Switch3Pos_readState(chip, pinA, pinB);
 if (state != lastState[chip][pinA]) {
   if (state == 0)
     sendDcsBiosMessage(msg, "0");
   if (state == 1)
     sendDcsBiosMessage(msg, "1");
if (state == 2)
	 sendDcsBiosMessage(msg, "2");	
 }
 lastState[chip][pinA] = state;
}

char SwitchMultiPosRead(const byte* pinsArray, byte chip, char numberOfPins)
{
 char i;
 for (i = 0; i < numberOfPins; i++) {
   if (NumToChip(chip).digitalRead(pinsArray[i]) == LOW) return i;
 }
 return 0;
}

void SwitchMultiPos(const char* msg, const byte* pinsArray, byte chip, char numberOfPins) {
 char i;
 char state = SwitchMultiPosRead(pinsArray, chip, numberOfPins);
 if (state != lastState[chip][pinsArray[0]]) {
   char buf[7];
   utoa(state, buf, 10);
   sendDcsBiosMessage(msg, buf);    
 }
lastState[chip][pinsArray[0]] = state;
}

Link to comment
Share on other sites

Sprigload

 

-I repost my early message-

 

Somebody knows how to do this realize

springloaded_3_pos_tumb on encoder ?

 

for example trimmer

springloaded_3_pos_tumb(_("Aileron Trimmer Switch, LEFT/OFF/RIGHT"),         devices.CONTROL_INTERFACE,     control_commands.Mig15_Command_TrimAileron,     control_commands.Mig15_Command_TrimAileron,    142)

code from clickabledata.lua

function springloaded_3_pos_tumb(hint_, device_, command1_, command2_, arg_, val1_, val2_, val3_)
   local val1 = val1_ or -1.0
   local val2 = val2_ or 0.0
   local val3 = val3_ or 1.0
   return  {    
               class         = {class_type.BTN,class_type.BTN},
               hint          = hint_,
               device         = device_,
               action         = {command1_,command2_},
               stop_action = {command1_,command2_},
               arg           = {arg_,arg_},
               arg_value     = {val1,val3}, 
               arg_lim       = {{val1,val2},{val2,val3}},
               updatable     = true, 
               use_OBB     = true,
               use_release_message = {true,true},
               sound        = {{SOUND_SW1}, {SOUND_SW1}}
           }
end

The only func I found is defineRockerSwitch

 

then i wrote in wrote in lu defineRockerSwitch("TrimAilerons",3,3002,3002,3002,3002,142,"Heading Knob","Aileron Trimmer Switch, LEFT/OFF/RIGHT")

in Arduino

DcsBios::Switch3Pos TrimAilerons("TrimAilerons",2,3);

2,3 its encoder pins

 

Its woking, BUT no correct.

Sometimes not return to the center position, and sometime moving between left and central or right and centrall

 

Socat protecol :

Rotate left :

TrimAilerons 0

TrimAilerons 2

TrimAilerons 1

Rotate right :

TrimAilerons 2

TrimAilerons 0

TrimAilerons 1


Edited by jazzymanserg
Link to comment
Share on other sites

Mig-15bis.Lua

 

Maybe somebody need Mig-15 Addon for DCS

So, i wrote 85 %. It has no Axis and some buttons. I need not them. Now i make L-39 Addon, and i have no time for finish Mig.

So take it.

Put AircraftList.lua , MiG-15bis.lua, L-39C.lua in ..dcs-bios\lib\

Put bios.lua in ..dcs-bios\

unzip control-reference.zip in ..dcs-bios\doc\

unzip and install in arduino sketch from dcs.zip

Good luck !

MiG-15bis.lua

AircraftList.lua

BIOS.lua

L-39C.lua

control-reference.zip

dcs.zip


Edited by jazzymanserg
Link to comment
Share on other sites

Maybe somebody need Mig-15 Addon for DCS

So, i wrote 85 %. It has no Axis and some buttons. I need not them. Now i make L-39 Addon, and i have no time for finish Mig.

So take it.

Put AircraftList.lua , MiG-15bis.lua, L-39C.lua in ..dcs\lib\

Put bios.lua in ..dcs\

unzip control-reference.zip in ..dcs\doc\

 

Good luck !

 

 

good work :)

With respect

_________________

Kadda

_________________

My works

TL-39 (NewGen) project (Ру)/(EN)

Link to comment
Share on other sites

lancer2000: I have released a new version of the Arduino library (v0.2.10) that should fix your problem.

 

jazzymanserg: You'd have to play around with that switch in the Lua Console and understand which commands you have to send in which state. Maybe your problem is similar to the CMSP switches in the A-10C, which require different command sequences to go to a certain state depending on which state they are currently in.

 

@Everyone: ...and we had two simultaneous topics in here again. In the future, please do not use this thread to request help with bugs or compile errors. This was meant for general feedback ("I just started with DCS-BIOS, here's what worked, here's where I was confused"), feature requests, etc. The answer to any question answered in here is likely to be buried within a multi-dozen page thread, and will be very difficult to dig up again with the search function.

Link to comment
Share on other sites

the most difficult instrument the i ve remade, working without azimuts indication for the moment but the sketch is ready , just waiting for a new power source

 

thank you another time IAN, for the BIOS, and thank to all the poeple here in the tread ...

 

only two instrument to make and i ll finnish :)

 

 

With respect

_________________

Kadda

_________________

My works

TL-39 (NewGen) project (Ру)/(EN)

Link to comment
Share on other sites

Hi Ian. Thanks for fix my problem. But in new arduino library is another issue.

Master sketch have compile error:

:\Moje Dokumenty\Arduino\libraries\dcs-bios-arduino-library-0.2.10\src/DcsBios.h: In function 'bool sendDcsBiosMessage(const char*, const char*)':

D:\Moje Dokumenty\Arduino\libraries\dcs-bios-arduino-library-0.2.10\src/DcsBios.h:133:9: error: 'tryToSendDcsBiosMessage' is not a member of 'DcsBios'

 while(!DcsBios::tryToSendDcsBiosMessage(msg, arg));

 

After modify DcsBios.h and comment this at line 132:

inline bool sendDcsBiosMessage(const char* msg, const char* arg) {
while(!DcsBios::tryToSendDcsBiosMessage(msg, arg));
return true;
}

 

compile is succesful

 

Another problem is in command:

DcsBios::Switch2Pos weaponsForwardHemiTargetBtn("WEAPONS_FORWARD_HEMI_TARGET_BTN", PIN);

Its doesnt work. I think problem is in to small buffer for long command

Link to comment
Share on other sites

I released v0.2.11 which fixes the compile error.

 

You are right, your command is too long. Command names have to be short enough that the complete message (such as "WEAPONS_FORWARD_HEMI_TARGET_BTN 0\n") fits in 31 characters. I suggest to keep them below 20 characters.

 

In the future, please open a separate new thread for each issue.

Link to comment
Share on other sites

Control Reference

 

Hi, I'm Dan from Italy, I'm a newby in dcs Bios and Arduino, last week I Starded with a MASTER CAUTION EXAMPLE everythink works fine. I tried to export reference for implement F-5E But I do not understand how reference work.

I had follow the step in developer documents, Add aircraft in AricraftList, script in CONTROL REFERENCE .HTML, ecc. ecc, it's also created a json jsonp file, control reference live trought chrome set and working. My question is:

when I launch dcs world and the serial connection, The field of the Control reference, like master caution, for example with the correct address, pop up automaticly or I Need to compile the Json Jsonp file, in this case I'm not able to compile because I'm not a programmer.

thanks in advance and sorry for my bad English.

Dan

Link to comment
Share on other sites

I launch dcs world and the serial connection, The field of the Control reference, like master caution, for example with the correct address, pop up automaticly

 

The JSON files are generated when DCS-BIOS is loaded. After you have written your Lua file, you have to make DCS-BIOS reload your aircraft module. To do that, you can either jump into a new misson, or use the Lua Console from my Witchcraft project to execute a dofile(...) statement that loads your Lua file.

 

After that, your newly defined controls should be visible in the control reference.

 

If you have more questions, please create a new thread and post your Lua file. This thread is meant for general feedback, not help requests.

Link to comment
Share on other sites

Hi!

 

I have any problem with NMSP in A-10C module. The LED's work the opposite way than in the module: in module is ON, in panel is OFF. Where is problem?

 

My scatch:

#define DCSBIOS_IRQ_SERIAL
#include <DcsBios.h>

DcsBios::LED nmspHarsLed(0x1110, 0x0200, 3);
DcsBios::LED nmspEgiLed(0x1110, 0x0800, 4);
DcsBios::LED nmspTislLed(0x1110, 0x2000, 5);
DcsBios::LED nmspSteerptLed(0x1110, 0x8000, 6);
DcsBios::LED nmspAnchrLed(0x1112, 0x0002, 7);
DcsBios::LED nmspTcnLed(0x1112, 0x0008, 8);
DcsBios::LED nmspIlsLed(0x1112, 0x0020, 9);

void onDcsBiosFrameSync() {
}

void setup() {
 DcsBios::setup();
}

void loop() {
 DcsBios::loop();
}

 

I use DCS BIOS v 0.5.2 and library 0.2.11

Arduino Uno.


Edited by Marcin_B
Link to comment
Share on other sites

control-reference.html

 

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<link rel="stylesheet" href="css/doc.css">

<title>DCS-BIOS Documentation</title>

<script src="js/jquery-2.1.1.min.js"></script>

<script src="js/underscore-min.js"></script>

<script src="js/q.js"></script>

<script src="js/tcp-promise-wrapper.js"></script>

<script src="js/globals.js"></script>

<script src="json/MetadataEnd.jsonp"></script>

<script src="json/MetadataStart.jsonp"></script>

<script src="json/CommonData.jsonp"></script>

<script src="json/A-10C.jsonp"></script>

<script src="json/UH-1H.jsonp"></script>

<script src="json/MiG-21Bis.jsonp"></script>

<script src="json/Ka-50.jsonp"></script>

<script src="json/L-39C.jsonp"></script>

<script src="js/control-reference.js"></script>

<script src="js/dcs-bios-connection.js"></script>

</head>

<body ng-controller="DocController">

<noscript>

<h2 style="color: red;">This page requires JavaScript to be enabled.</h2>

</noscript>

 

<div id="app">

 

</div>

 

</body>

</html>

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...