DCS-BIOS Discussion Thread - Page 83 - ED Forums
 


Notices

Reply
 
Thread Tools Display Modes
Old 02-04-2018, 04:03 PM   #821
Patriot
Member
 
Patriot's Avatar
 
Join Date: Mar 2014
Location: Russia / Samara
Posts: 139
Default

This code is work:

Code:
#define DCSBIOS_IRQ_SERIAL

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "DcsBios.h"

#define digits_00_32x64_width 32
#define digits_00_32x64_height 64
const PROGMEM unsigned char digits_00_32x64_bits[] = {
// cut
};

#define digits_1to9_32x64_width 32
#define digits_1to9_32x64_height 704
const PROGMEM unsigned char digits_1to9_32x64_bits[] = {
//cut
};
#define digits_32x64_width 32
#define digits_32x64_height 704
const PROGMEM unsigned char digits_32x64_bits[] = {
// cut
};

DcsBios::ProtocolParser parser;
Adafruit_SSD1306 display(4);

void onAlt10000ftCntChange(unsigned int newValue) {
    drawDigit(0, newValue, digits_1to9_32x64_bits);
}
void onAlt1000ftCntChange(unsigned int newValue) {
    drawDigit(1, newValue, digits_32x64_bits);
}
void onAlt100ftCntChange(unsigned int newValue) {
    drawDigit(2, newValue, digits_32x64_bits);
}

DcsBios::IntegerBuffer alt10000ftCntBuffer(0x1080, 0xffff, 0, onAlt10000ftCntChange);
DcsBios::IntegerBuffer alt1000ftCntBuffer(0x1082, 0xffff, 0, onAlt1000ftCntChange);
DcsBios::IntegerBuffer alt100ftCntBuffer(0x1084, 0xffff, 0, onAlt100ftCntChange);



void drawDigit(unsigned int index, unsigned int offset, unsigned char* bits) {
  unsigned int y_offset_lines = offset / 103;
   display.fillRect(32*index, 0, 32, 64, BLACK);
   display.drawXBitmap(32*index, 0, &bits[4*y_offset_lines], 32, 64, WHITE);
   display.display();   
}

void setup() {
  DcsBios::setup();
  display.begin(SSD1306_SWITCHCAPVCC);
  display.clearDisplay();
  drawDigit(0, 0, digits_1to9_32x64_bits);
  drawDigit(1, 0, digits_32x64_bits);
  drawDigit(2, 0, digits_32x64_bits);
  drawDigit(3, 0, digits_00_32x64_bits);
}

void loop() {
  DcsBios::loop();
}
But why not work this code? Not run method onDcsBiosWrite. I use last version of DCS-BIOS

Code:
#define DCSBIOS_IRQ_SERIAL

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "DcsBios.h"

#define digits_00_32x64_width 32
#define digits_00_32x64_height 64
const PROGMEM unsigned char digits_00_32x64_bits[] = {
// cut
};

#define digits_1to9_32x64_width 32
#define digits_1to9_32x64_height 704
const PROGMEM unsigned char digits_1to9_32x64_bits[] = {
//cut
};
#define digits_32x64_width 32
#define digits_32x64_height 704
const PROGMEM unsigned char digits_32x64_bits[] = {
// cut
};

DcsBios::ProtocolParser parser;
Adafruit_SSD1306 display(4);

void drawDigit(unsigned int index, unsigned int offset, unsigned char* bits) {
  //double y_offset = (double)offset / 65535.0d;
  //unsigned int y_offset_lines = y_offset * 640;
  unsigned int y_offset_lines = offset / 103;
   display.fillRect(32*index, 0, 32, 64, BLACK);
   display.drawXBitmap(32*index, 0, &bits[4*y_offset_lines], 32, 64, WHITE);
   display.display();   
}

void onDcsBiosWrite(unsigned int address, unsigned int value) {
  address = address & 0xffff;
  value = value & 0xffff;
  if (address == 0x1080) {
    unsigned int alt10000ftCntValue = (value & 0xffff) >> 0;
    drawDigit(0, alt10000ftCntValue, digits_1to9_32x64_bits);
  }
  
  if (address == 0x1082) {
    unsigned int alt1000ftCntValue = (value & 0xffff) >> 0;
    drawDigit(1, alt1000ftCntValue, digits_32x64_bits);
  }
  
  if (address == 0x1084) {
    unsigned int alt100ftCntValue = (value & 0xffff) >> 0;
    drawDigit(2, alt100ftCntValue, digits_32x64_bits);
  }
}

void setup() {
  DcsBios::setup();
  display.begin(SSD1306_SWITCHCAPVCC);
  display.clearDisplay();
  drawDigit(0, 0, digits_1to9_32x64_bits);
  drawDigit(1, 0, digits_32x64_bits);
  drawDigit(2, 0, digits_32x64_bits);
  drawDigit(3, 0, digits_00_32x64_bits);
}

void loop() {
  DcsBios::loop();
}
__________________
My cockpit A-10C
Строю кокпит A-10C
i7 7700k, 32Gb RAM, SSD NVMe, GTX 1080, Hotas Warthog, HTC Vive.
-----------------
With love from Russia
Patriot is offline   Reply With Quote
Old 02-06-2018, 04:44 AM   #822
rocketeer
Member
 
rocketeer's Avatar
 
Join Date: Apr 2005
Location: California
Posts: 604
Default

Alburg, maybe mega to mega is impossible or at least difficult. why don't you try mega to nano first? hansolo has many panels set up that way. if you can at least make it work for mega to nano, that can be your backup set up.

i know some panels need many input or output. my plan is to use 2 nanos when needed instead of a mega slave. nanos are much cheaper anyway.
__________________
My A10C cockpit thread
rocketeer is offline   Reply With Quote
Old 02-06-2018, 06:19 AM   #823
Patriot
Member
 
Patriot's Avatar
 
Join Date: Mar 2014
Location: Russia / Samara
Posts: 139
Default

Ian, do you plan to add support for STM32 boards in the future? These boards have the same price as arduino nano, but are several times more powerful.
__________________
My cockpit A-10C
Строю кокпит A-10C
i7 7700k, 32Gb RAM, SSD NVMe, GTX 1080, Hotas Warthog, HTC Vive.
-----------------
With love from Russia
Patriot is offline   Reply With Quote
Old 02-10-2018, 02:51 PM   #824
cBass
Junior Member
 
cBass's Avatar
 
Join Date: Sep 2010
Posts: 22
Default TCP commands

Using zerobrane to open tcp connection to send commands to pull t handles. I can see a tcp socket open through netstat but no joy on dcs getting the commands any hints?

Code:
while true do
        local server = assert(s.bind("127.0.0.1",7778))  
        print("waiting for connection on port 7778  ")
        local client = server:accept()
        print("connected")
        client:send("FIRE_EXT_DISCH INC \n")
        client:send("FIRE_EXT_DISCH DEC \n")
       -- sleep(10)
        client:send("FIRE_LENG_PULL INC\n")
        client:send("FIRE_LENG_PULL DEC\n")
        client:settimeout(10)
        
      end
cBass is offline   Reply With Quote
Old 03-09-2018, 02:22 PM   #825
frogger
Member
 
frogger's Avatar
 
Join Date: Oct 2010
Posts: 141
Default

just a quick question from a newbie. i have the m2000c library and im working with the rpm gauge needle

DcsBios::ServoOutput nRpm(0x6058, 9, 544, 2400);

i can control a servo just fine but id like to control a small dc motor from a playstation controller in my joystick to add slight vibration. when i connect the motor to gnd and pin 9 it whines as its not being supplied enough voltage? i have some L298N h bridges and if i understand correctly i should be able to use them to control the motors speed with pulse width modulation. this is where im lost. ive been watching tutorials on how to do it standalone but linking it to dcs bios has got me stuck. could anyone point me in the right direction. again im very new to this and basicly just winging it
frogger is offline   Reply With Quote
Old 03-11-2018, 10:08 AM   #826
frogger
Member
 
frogger's Avatar
 
Join Date: Oct 2010
Posts: 141
Default

ok i got the idea to work. i just need to figure out motor speed as atm its not spinning fast enough to transfer noticeable vibrations
frogger is offline   Reply With Quote
Old 04-06-2018, 08:55 AM   #827
aymen
Junior Member
 
Join Date: Apr 2018
Location: tunis
Posts: 18
Default

hi im trying to build my own F-5e cockpit i need the appropriete files to add it to dcs-bios
aymen is offline   Reply With Quote
Old 05-11-2018, 04:02 PM   #828
cBass
Junior Member
 
cBass's Avatar
 
Join Date: Sep 2010
Posts: 22
Default Same issue connect serial port not working

My issue is the same as this video except his solution doesn't work with my win10 laptop rebooting running as admin checking Arduino port numbers to match connect serial port file does nothing it just hangs like the video.

cBass is offline   Reply With Quote
Old 05-11-2018, 07:40 PM   #829
molevitch
Member
 
molevitch's Avatar
 
Join Date: Jul 2006
Location: London UK
Posts: 284
Default I need some help please!

Hello DCS_BIOS enthusiasts and gurus!

I wrote here some time ago about a project, but did not get much feedback. I think I asked the question the wrong way.

I did manage to get something going on the Arduino that time, but the particular project is currently shelved.

I am building a Mi-24 pit in anticipation of Belsimtek's future module. I have acquired a soviet era ARK-15 Radio compass from a Mi-24 cockpit. It has these great clunky dials with really solid detents. Very mechanical.

The dials have up to 20 settings. These results are achieved by 5 switches. So for example the 0-1 khz dial has increments of .5 khz, 0 to 0.95. Each increment is achieved by a combination of high and low switch states. eg 0.0 is 1,1,1,1,1....while 3.0 is 1,0,1,1,0.

I have established which wires to connect to. There are 3 concentric dials. 2 use 5 switches (20 states) and the middle one uses 4 switches (10 states). There are 2 dials, as well as some momentary switches, toggle switches a rheostat/potentiometer and a 3 way rotary switch.

The dials are what I would like some guidance with. I can visualise a "pseudo-code". A series of conditional statements, "else if" type.

eg if pin 1=high, and pin 2=high, and pin 3=high, and pin 4=high, and pin 5=high, then set int_dial =0.0,
else if pin 1=low, and pin 2=high, and pin 3=high, and pin 4=high, and pin 5=high, then set int_dial =0.05
else if pin 1=high, and pin 2.....
etc.until all 20 options are covered. But that code seems very inelegant.... Is this some kind of Matrix idea? Can a value for a device in DCS be set from the values of more than 1 pin on the Arduino?

DCS needs to get the current value from the mechanical switched dial on startup, based on the states of the respective pins on the Arduino I guess...

I am just startin in on this coding thing, and I can sort of visualise the methoid. I have been scouring through this thread with great enthusiasm, but have noit found what I thin=k is the right way.

Any guidance is gratefully received!

Molevich
__________________
Scan 3XS Performance 7 GTX PC, Overclocked Intel Core i7 6700K, 16GB Corsair DDR4, NVIDIA GTX 1070, 240GB SSD, 2TB HDD, Win 10.
Oculus Rift CV1, custom Mi-24 cyclic and collective.

Mi-24 Cyclic and Collective with Magnetic Brakes and Force Feedback
Mag Brake in operation
molevitch is offline   Reply With Quote
Old 05-11-2018, 10:05 PM   #830
Hansolo
Senior Member
 
Hansolo's Avatar
 
Join Date: Aug 2012
Location: Denmark
Posts: 1,523
Default

Hi Mole,

Check out this post of mine; https://forums.eagle.ru/showpost.php...&postcount=180

I think this may be what you looking for especially the port registers.

However this does require that the airframe works with DCS-BIOS, which means that the airframe has to be released and someone has to make the module for DCS-BIOS.

If you post a map of the switch may be able to assist a little further.

Cheers
Solo
__________________
Hansolo is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 02:54 PM. vBulletin Skin by ForumMonkeys. Powered by vBulletin®.
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.