Jump to content

lancer2000

Members
  • Posts

    13
  • Joined

  • Last visited

Personal Information

  • Flight Simulators
    DCS Ka-50
  • Location
    Poland
  • Interests
    CNC, Laser co2, Flight simulators
  1. I make videos - difference between IRQ_Serial and RS485 IRQ_Serial very fast working: RS485 Lags:
  2. I make test with IRQ_SERIAL mode and work great. I thought if RS485 works then wiring is ok. I have connection like this ( only enable pins i have pin2 instead pin8 )
  3. Hi I have Arduino Mega and one Arduino Nano connected via RS485. Arduino library 0.2.11 DCS-BIOS 0.5.2 Arduine IDE 1.8.2 Everything is working but problem is in very slow working with 7-segment displays. I have two MAX7219 with 14 displays. If in-game change value then in the cockpit will change after even a few seconds My sketch: #define DCSBIOS_RS485_SLAVE 1 #define TXENABLE_PIN 2 #include <DcsBios.h> #include <LiquidCrystal.h> #include "LedControl.h" #include <Wire.h> LiquidCrystal lcd(4, 5, 6, 7, 8, 9); LedControl lc = LedControl(12, 11, 10, 2); int nums[11] = { B11110110, B00100010,//B01000100, B11110001, B10110011, B00100111, B10010111, B11010111, B00110010, B11110111, B10110111, B00000000 }; byte pvi_one, pvi_two, pvi_three, pvi_four, pvi_five, pvi_six, pvi_seven; byte oldpvi_one, oldpvi_two, oldpvi_three, oldpvi_four, oldpvi_five, oldpvi_six, oldpvi_seven; byte pvi2_one, pvi2_two, pvi2_three, pvi2_four, pvi2_five, pvi2_six, pvi2_seven; byte oldpvi2_one, oldpvi2_two, oldpvi2_three, oldpvi2_four, oldpvi2_five, oldpvi2_six, oldpvi2_seven; 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; } } //******************** PVI 800 Display ***************************** DcsBios::StringBuffer<1> pviLine1Apostrophe1Buffer(0x1934, onPviLine1Apostrophe1Change); void onPviLine1Apostrophe1Change(char* newValue) { if (newValue[0] == ' ') { lc.setLed(0, 4, 2, false); } else { lc.setLed(0, 4, 2, true); } } DcsBios::StringBuffer<1> pviLine1Apostrophe2Buffer(0x1936, onPviLine1Apostrophe2Change); void onPviLine1Apostrophe2Change(char* newValue) { if (newValue[0] == ' ') { lc.setLed(0, 4, 4, false); } else { lc.setLed(0, 4, 4, true); } } DcsBios::StringBuffer<6> pviLine1TextBuffer(0x1924, onPviLine1TextChange); void onPviLine1TextChange(char* newValue) { int one, two, three, four, five, six; if ((newValue[0] != ' ') && (newValue[0] != oldpvi_one)) { pvi_one = newValue[0] - '0'; // lc.setColumn(0,0,nums[one]); } Led_digit(0, 0, pvi_one); oldpvi_one = pvi_one; } else { lc.setColumn(0, 0, nums[10]); } if ((newValue[1] != ' ') && (newValue[1] != oldpvi_two)) { pvi_two = newValue[1] - '0'; Led_digit(0, 1, pvi_two); oldpvi_two = pvi_two; } else { lc.setColumn(0, 1, nums[10]); } if ((newValue[2] != ' ') && (newValue[2] != oldpvi_three)) { pvi_three = newValue[2] - '0'; Led_digit(0, 2, pvi_three); oldpvi_three = pvi_three; } else { lc.setColumn(0, 2, nums[10]); } if ((newValue[3] != ' ') && (newValue[3] != oldpvi_four)) { pvi_four = newValue[3] - '0'; Led_digit(0, 3, pvi_four); oldpvi_four = pvi_four; } else { lc.setColumn(0, 3, nums[10]); } if ((newValue[4] != ' ') && (newValue[4] != oldpvi_five)) { pvi_five = newValue[4] - '0'; Led_digit(0, 4, pvi_five); oldpvi_five = pvi_five; } else { lc.setColumn(0, 4, nums[10]); } if ((newValue[5] != ' ') && (newValue[5] != oldpvi_six)) { pvi_six = newValue[5] - '0'; Led_digit(0, 5, pvi_six); oldpvi_six = pvi_six; } else { lc.setColumn(0, 5, nums[10]); } } DcsBios::StringBuffer<1> pviLine1PointBuffer(0x1930, onPviLine1PointChange); void onPviLine1PointChange(char* newValue) { int digit; if ((newValue[0] != ' ') && (newValue[0] != oldpvi_seven)) { pvi_seven = newValue[0] - '0'; Led_digit(0, 6, pvi_seven); oldpvi_seven = pvi_seven; } else { lc.setColumn(0, 6, nums[10]); } } DcsBios::StringBuffer<1> pviLine2Apostrophe1Buffer(0x1938, onPviLine2Apostrophe1Change); void onPviLine2Apostrophe1Change(char* newValue) { if (newValue[0] == ' ') { lc.setLed(1, 4, 2, false); } else { lc.setLed(1, 4, 2, true); } } DcsBios::StringBuffer<1> pviLine2Apostrophe2Buffer(0x193a, onPviLine2Apostrophe2Change); void onPviLine2Apostrophe2Change(char* newValue) { if (newValue[0] == ' ') { lc.setLed(1, 4, 4, false); } else { lc.setLed(1, 4, 4, true); } } DcsBios::StringBuffer<6> pviLine2TextBuffer(0x192a, onPviLine2TextChange); void onPviLine2TextChange(char* newValue) { int one, two, three, four, five, six; if ((newValue[0] != ' ') && (newValue[0] != oldpvi2_one)) { pvi2_one = newValue[0] - '0'; // lc.setColumn(0,0,nums[one]); } Led_digit(1, 0, pvi2_one); oldpvi2_one = pvi2_one; } else { lc.setColumn(1, 0, nums[10]); } if ((newValue[1] != ' ') && (newValue[1] != oldpvi2_two)) { pvi2_two = newValue[1] - '0'; Led_digit(1, 1, pvi2_two); oldpvi2_two = pvi2_two; } else { lc.setColumn(1, 1, nums[10]); } if ((newValue[2] != ' ') && (newValue[2] != oldpvi2_three)) { pvi2_three = newValue[2] - '0'; Led_digit(1, 2, pvi2_three); oldpvi2_three = pvi2_three; } else { lc.setColumn(1, 2, nums[10]); } if ((newValue[3] != ' ') && (newValue[3] != oldpvi2_four)) { pvi2_four = newValue[3] - '0'; Led_digit(1, 3, pvi2_four); oldpvi2_four = pvi2_four; } else { lc.setColumn(1, 3, nums[10]); } if ((newValue[4] != ' ') && (newValue[4] != oldpvi2_five)) { pvi2_five = newValue[4] - '0'; Led_digit(1, 4, pvi2_five); oldpvi2_five = pvi2_five; } else { lc.setColumn(1, 4, nums[10]); } if ((newValue[5] != ' ') && (newValue[5] != oldpvi2_six)) { pvi2_six = newValue[5] - '0'; Led_digit(1, 5, pvi2_six); oldpvi2_six = pvi2_six; } else { lc.setColumn(1, 5, nums[10]); } } DcsBios::StringBuffer<1> pviLine2PointBuffer(0x1932, onPviLine2PointChange); void onPviLine2PointChange(char* newValue) { int digit; if ((newValue[0] != ' ') && (newValue[0] != oldpvi2_seven)) { pvi2_seven = newValue[0] - '0'; Led_digit(1, 6, pvi2_seven); oldpvi2_seven = pvi2_seven; } else { lc.setColumn(1, 6, nums[10]); } } //*********** PVI-800 Display END ********************* DcsBios::StringBuffer<10> ekranTxt1Line1Buffer(0x189c, onEkranTxt1Line1Change); void onEkranTxt1Line1Change(char* newValue) { lcd.setCursor(0, 0); lcd.write(newValue[0]); lcd.write(newValue[1]); lcd.write(newValue[2]); lcd.write(newValue[3]); lcd.write(newValue[4]); lcd.write(newValue[5]); lcd.write(newValue[6]); lcd.write(newValue[7]); } DcsBios::StringBuffer<10> ekranTxt1Line2Buffer(0x18a6, onEkranTxt1Line2Change); void onEkranTxt1Line2Change(char* newValue) { lcd.setCursor(0, 1); lcd.write(newValue[0]); lcd.write(newValue[1]); lcd.write(newValue[2]); lcd.write(newValue[3]); lcd.write(newValue[4]); lcd.write(newValue[5]); lcd.write(newValue[6]); lcd.write(newValue[7]); } DcsBios::StringBuffer<10> ekranTxt1Line3Buffer(0x18b0, onEkranTxt1Line3Change); void onEkranTxt1Line3Change(char* newValue) { lcd.setCursor(0, 2); lcd.write(newValue[0]); lcd.write(newValue[1]); lcd.write(newValue[2]); lcd.write(newValue[3]); lcd.write(newValue[4]); lcd.write(newValue[5]); lcd.write(newValue[6]); lcd.write(newValue[7]); } DcsBios::StringBuffer<10> ekranTxt1Line4Buffer(0x18ba, onEkranTxt1Line4Change); void onEkranTxt1Line4Change(char* newValue) { lcd.setCursor(0, 3); lcd.write(newValue[0]); lcd.write(newValue[1]); lcd.write(newValue[2]); lcd.write(newValue[3]); lcd.write(newValue[4]); lcd.write(newValue[5]); lcd.write(newValue[6]); lcd.write(newValue[7]); } DcsBios::StringBuffer<10> ekranTxt2Line1Buffer(0x18c4, onEkranTxt2Line1Change); void onEkranTxt2Line1Change(char* newValue) { lcd.setCursor(0, 0); lcd.write(newValue[0]); lcd.write(newValue[1]); lcd.write(newValue[2]); lcd.write(newValue[3]); lcd.write(newValue[4]); lcd.write(newValue[5]); lcd.write(newValue[6]); lcd.write(newValue[7]); } DcsBios::StringBuffer<10> ekranTxt2Line2Buffer(0x18ce, onEkranTxt2Line2Change); void onEkranTxt2Line2Change(char* newValue) { lcd.setCursor(0, 1); lcd.write(newValue[0]); lcd.write(newValue[1]); lcd.write(newValue[2]); lcd.write(newValue[3]); lcd.write(newValue[4]); lcd.write(newValue[5]); lcd.write(newValue[6]); lcd.write(newValue[7]); } DcsBios::StringBuffer<10> ekranTxt2Line3Buffer(0x18d8, onEkranTxt2Line3Change); void onEkranTxt2Line3Change(char* newValue) { lcd.setCursor(0, 2); lcd.write(newValue[0]); lcd.write(newValue[1]); lcd.write(newValue[2]); lcd.write(newValue[3]); lcd.write(newValue[4]); lcd.write(newValue[5]); lcd.write(newValue[6]); lcd.write(newValue[7]); } DcsBios::StringBuffer<10> ekranTxt2Line4Buffer(0x18e2, onEkranTxt2Line4Change); void onEkranTxt2Line4Change(char* newValue) { lcd.setCursor(0, 3); lcd.write(newValue[0]); lcd.write(newValue[1]); lcd.write(newValue[2]); lcd.write(newValue[3]); lcd.write(newValue[4]); lcd.write(newValue[5]); lcd.write(newValue[6]); lcd.write(newValue[7]); } void setup() { lc.shutdown(0, false); lc.setIntensity(0, 8); lc.clearDisplay(0); lc.shutdown(1, false); lc.setIntensity(1, 8); lc.clearDisplay(1); DcsBios::setup(); } void loop() { DcsBios::loop(); } In Dcsbios.log i have lots of this: (maybe 10 or more lines per second) value -65535.000000 is too small for address 6212 mask 65535 And screen of socat: I use this MAX485: https://www.aliexpress.com/item/FREE-SHIPPING-5PCS-LOT-MAX485-module-RS485-module-TTL-turn-RS-485-module-MCU-development-accessories/32255771572.html?spm=2114.01010208.3.81.AAubEO&ws_ab_test=searchweb0_0,searchweb201602_3_10152_10065_10151_10068_10136_10137_10157_10060_10138_10155_10062_10156_10154_10056_10055_10054_10059_10099_10103_10102_10096_10148_10147_10052_10053_10142_10107_10050_10051_10171_10084_10083_10080_10082_10081_10110_10111_10112_10113_10114_10181_10182_10078_10079_10073_10070_10123_10124-10051,searchweb201603_2,ppcSwitch_5&btsid=8bc712f9-3267-4c68-a8b4-6cf08615893b&algo_expid=58944ec8-62ad-4314-8db9-45586fead0e8-10&algo_pvid=58944ec8-62ad-4314-8db9-45586fead0e8
  4. 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
  5. 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; }
  6. 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; }
  7. 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?
  8. Hi I have problem to write MultiPosSwitch for I2C. My code: void SwitchMultiPos(char* msg, const byte* pinsArray, byte chip, char numberOfPins) { char i; for (i=0; i<numberOfPins; i++) { char state = MCP[chip].digitalRead(0, pinsArray[i]); if (state != lastState[chip][0][pinsArray[i]]) { char buf[7]; utoa(state, buf,10); sendDcsBiosMessage(msg, buf); } lastState[chip][0][pinsArray[i]] = state; } } With this code multiPosSwitch is set always to second position. What is wrong in this code?
  9. I have similar problem. When I start the game (Cold or Hot start) virtual switches not match with my cockpit. Sometimes is all OK, most often after second run the mission. I think have solution, I use one input to resync switches This is sample code: Link IOCARD_SW, Input 43 // Synchronise button { IF &WP_GUNSIGHT = 1 { &WP_GUNSIGHT = 1 } ELSE { &WP_GUNSIGHT = 0 } } Var 0109, name WP_GUNSIGHT, Link IOCARD_SW, Input 12, Type I // Weapon Panel Gun Sight
  10. Thanks for you reply Duckling I try with VAR 0 but doesn't work. I think have solution. I use one input to synchronise switches. This is part of my code: Var 9000, Link IOCARD_SW, Input 43 // Synchronise button { IF &WP_GUNSIGHT = 1 { &WP_GUNSIGHT = 1 } ELSE { &WP_GUNSIGHT = 0 } } Var 0109, name WP_GUNSIGHT, Link IOCARD_SW, Input 12, Type I // Weapon Panel Gun SightThis is now working but need futher tests
  11. Hello! Do you have solve problem with synchronisation?
  12. Hello Oakes! I have problem with synchronise virtual cockpit with real cockpit You say: After I start the game i must manipulate physical switches, then virtual cockpit match with physical. Other day switches are sets correctly after at second launch game (not working with first run). I don't know what happened, now it's not working at all. Sorry for my english
  13. Please add your scripts (dsi file and siocconfig.lua etc.). I have problem with configure encoders for radio channel
×
×
  • Create New...