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: 582
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: 21
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: 129
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: 129
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: 3
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
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 06:09 AM. vBulletin Skin by ForumMonkeys. Powered by vBulletin®.
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.