Re: DCS-BIOS: pas d'INPUT vers cockpit DCS [RESOLU]
Publié : dim. févr. 09, 2020 10:00 am
par Carleo
Bonjour,
Après maints essais a tatonner, j'ai finis par trouver la solution a mon problème d'affichage
Désormais, j'arrive a afficher les valeurs Altitudes compas vitesse sur 2 afficheurs Segment7 Max7219
Me reste a faire fonctionner un nouvelle série d'afficheur pour les températures moteur le vario. Mais j'ai l'impression qu'il faut des Pin spécifique sur mon arduino mega 2560 pour le faire marcher
Sinon voici le code arduino que j'utilise. Attention toutes fois pour l'altitude et la vitesse il y a un decallage avec le cadrant Ingame, je pense qu'il y a un multiplicateur a joindre a la valeur
newValuealt et newValuevit pour correspondre exactement (du genre *1.015). je vais me pencher dessus
#define DCSBIOS_IRQ_SERIAL
#include <DcsBios.h>
#include <LedControl.h>
unsigned long delaytime=250;
//pin 51 is connected to the DataIn
//pin 52 is connected to the CLK
//pin 53 is connected to LOAD / CS
//pin 44 is connected to the DataIn
//pin 42 is connected to the CLK
//pin 43 is connected to LOAD / CS
LedControl lc1=LedControl(51,52,53,4); //This creates an instance of a single controller named "lc1" for the first 4 Segment7 display
LedControl lc2=LedControl(44,42,43,4); //This creates an instance of a single controller named "lc2" for the last 4 Segment7 display
// GENERAL REF NOTE BELOW
/*
The sequence of pins used above are in the following order... LedControl(DIN,CLK,LOAD,# OF IC's)
pin X is connected to the DataIn
pin X is connected to the CLK
pin X is connected to LOAD
the last number...(1) is for how many MAX7219 we have daisy chained. (8 STATED, HOWEVER 4 ACTUALLY PRESENT)
*/
/*
void onUhfFrequencyChange(char* newValue) {
lc1.setChar(0,7,newValue[0],false);
lc1.setChar(0,6,newValue[1],false);
lc1.setChar(0,5,newValue[2],true);
lc1.setChar(0,4,newValue[3],false);
lc1.setChar(0,3,newValue[4],false);
lc1.setChar(0,2,newValue[5],false);
lc1.setChar(0,1,newValue[6],false);
}
DcsBios::StringBuffer<7> uhfFrequencyBuffer(0x1180, onUhfFrequencyChange);
*/
void onAltitudeValueChange(unsigned int newValuealt) {
/*unsigned int newValuealt;*/
/*newValuealt = ( newValuealt, DEC);*/
/*
if (newValuealt=0) { lc1.setChar(0,0,0,false);}
if (newValuealt < 0 || newValuealt > 20000) {
*/
int altunit;
int altdeci;
int altcenti;
int altmilli;
int altdecmilli;
altunit=newValuealt%10;
newValuealt=newValuealt/10;
altdeci=newValuealt%10;
newValuealt=newValuealt/10;
altcenti=newValuealt%10;
newValuealt=newValuealt/10;
altmilli=newValuealt%10;
newValuealt=newValuealt/10;
altdecmilli=newValuealt;
lc1.setDigit(0,4,altdecmilli,false);
lc1.setDigit(0,3,altmilli,false);
lc1.setDigit(0,2,altcenti,false);
lc1.setDigit(0,1,altdeci,false);
lc1.setDigit(0,0,altunit,false);
/*
lc1.setDigit(0,7,newValuealt[0],false);
lc1.setDigit(0,6,newValuealt[1],false);
lc1.setDigit(0,5,newValuealt[2],false);
lc1.setDigit(0,4,newValuealt[3],false);
lc1.setDigit(0,3,newValuealt[4],false);
lc1.setDigit(0,2,newValuealt[5],false);
lc1.setDigit(0,4,newValuealt[6],false);*/
}
DcsBios::IntegerBuffer altitudeValueBuffer(0x42a0, 0xffff, 0, onAltitudeValueChange);
/////////////////////////////////////////////////////////////////////////////////
void onCompassHeadingValueChange(unsigned int newValuehdg) {
int hdgunit;
int hdgdeci;
int hdgcenti;
hdgunit=newValuehdg%10;
newValuehdg=newValuehdg/10;
hdgdeci=newValuehdg%10;
newValuehdg=newValuehdg/10;
hdgcenti=newValuehdg;
lc1.setDigit(1,7,hdgcenti,false);
lc1.setDigit(1,6,hdgdeci,false);
lc1.setDigit(1,5,hdgunit,true);
}
DcsBios::IntegerBuffer compassHeadingValueBuffer(0x42a6, 0xffff, 0, onCompassHeadingValueChange);
/////////////////////////////////////////////////////////////////////////////////
void onAirspeedValueChange(unsigned int newValuevit) {
int vitunit;
int vitdeci;
int vitcenti;
int vitmilli;
vitunit=newValuevit%10;
newValuevit=newValuevit/10;
vitdeci=newValuevit%10;
newValuevit=newValuevit/10;
vitcenti=newValuevit%10;
newValuevit=newValuevit/10;
vitmilli=newValuevit;
lc1.setDigit(1,3,vitmilli,false);
lc1.setDigit(1,2,vitcenti,false);
lc1.setDigit(1,1,vitdeci,false);
lc1.setDigit(1,0,vitunit,false);
}
DcsBios::IntegerBuffer airspeedValueBuffer(0x429e, 0xffff, 0, onAirspeedValueChange);
/////////////////////////////////////////////////////////////////////////////////
void onCoolantTemperatureValueChange(unsigned int newValuetemp1) {
int temp1unit;
int temp1deci;
int temp1centi;
boolean negative;
if(newValuetemp1<0) { negative=true; newValuetemp1=newValuetemp1*-1; }
temp1unit=newValuetemp1%10;
newValuetemp=newValuetemp/10;
temp1deci=newValuetemp1%10;
newValuetemp=newValuetemp/10;
temp1centi=newValuetemp1;
if(negative) {lc1.setChar(2,7,'-',false);}else{lc1.setChar(2,7,' ',false); }
lc1.setDigit(2,4,temp1unit,false);
lc1.setDigit(2,5,temp1deci,false);
lc1.setDigit(2,6,temp1centi,false);
}
DcsBios::IntegerBuffer coolantTemperatureValueBuffer(0x429a, 0xffff, 0, onCoolantTemperatureValueChange);
/////////////////////////////////////////////////////////////////////////////////
void onOilTemperatureValueChange(unsigned int newValuetemp2) {
int temp2unit;
int temp2deci;
int temp2centi;
boolean negative;
if(newValuetemp2<0) { negative=true; newValuetemp2=newValuetemp2*-1; }
temp2unit=newValuetemp2%10;
newValuetemp2=newValuetemp2/10;
temp2deci=newValuetemp2%10;
newValuetemp2=newValuetemp2/10;
temp2centi=newValuetemp2;
if(negative) {lc1.setChar(2,3,'-',false);}else{lc1.setChar(2,3,' ',false); }
lc1.setDigit(2,0,temp2unit,false);
lc1.setDigit(2,1,temp2deci,false);
lc1.setDigit(2,2,temp2centi,false);
}
DcsBios::IntegerBuffer oilTemperatureValueBuffer(0x4298, 0xffff, 0, onOilTemperatureValueChange);
/////////////////////////////////////////////////////////////////////////////////
void onFuelLevelValueChange(unsigned int newValueFuel) {
int fuelunit;
int fueldeci;
int fuelcenti;
int fuelmilli;
fuelunit=newValueFuel%1000;
newValueFuel=newValueFuel/10;
fueldeci=newValueFuel%100;
newValueFuel=newValueFuel/10;
fuelcenti=newValueFuel%10;
newValueFuel=newValueFuel/10;
fuelmilli=newValueFuel;
lc1.setDigit(3,4,fuelunit,false);
lc1.setDigit(3,5,fueldeci,false);
lc1.setDigit(3,6,fuelcenti,false);
lc1.setDigit(3,7,fuelmilli,false);
}
DcsBios::IntegerBuffer fuelLevelValueBuffer(0x4292, 0xffff, 0, onFuelLevelValueChange);
/////////////////////////////////////////////////////////////////////////////////
void onTachometerValueChange(unsigned int newValueTach) {
int tachunit;
int tachdeci;
boolean negative;
if(newValueTach < -100 || newValueTach > 100)return;
if(newValueTach<0) {negative=true; newValueTach=newValueTach*-1; }
tachunit=newValueTach%10;
newValueTach=newValueTach/10;
tachdeci=newValueTach;
if(negative) {lc1.setChar(3,3,'-',false);}else{lc1.setChar(3,3,' ',false);}
lc1.setDigit(3,0,(byte)tachunit,false);
lc1.setDigit(3,1,(byte)tachdeci,false);
}
DcsBios::IntegerBuffer tachometerValueBuffer(0x42a2, 0xffff, 0, onTachometerValueChange);
/////////////////////////////////////////////////////////////////////////////////
//Loading LED on event
DcsBios::LED lgDown(0x4204, 0x0800, 2);//Green Led for landing gear down
DcsBios::LED lgUp(0x4204, 0x0400, 4);//Red Led for landing gear up
/////////////////////////////////////////////////////////////////////////////////
void setup() {
DcsBios::setup();
// MAX7219 INITIALISATION
//This initializes the MAX7219 and gets it ready for use:
//FIRST - 8 DIGIT 7 SEGMENT DISPLAY - MAX7219 INITIALISATION
lc1.shutdown(0,false); //turn on the display
lc1.setIntensity(0,8);//set the brightness
lc1.clearDisplay(0); //clear the display
lc1.setChar(0,7,'H',false);
lc1.setChar(0,6,'e',false);
lc1.setChar(0,5,'l',false);
lc1.setChar(0,4,'l',false);
lc1.setChar(0,3,'o',false);
lc1.setChar(0,2,'1',true);
delay(2000);
lc1.clearDisplay(0); //clear the display
//SECOND - 8 DIGIT 7 SEGMENT DISPLAY - MAX7219 INITIALISATION
lc1.shutdown(1,false); //turn on the display
lc1.setIntensity(1,8);//set the brightness
lc1.clearDisplay(1); //clear the display
lc1.setChar(1,7,'H',false);
lc1.setChar(1,6,'e',false);
lc1.setChar(1,5,'l',false);
lc1.setChar(1,4,'l',false);
lc1.setChar(1,3,'o',false);
lc1.setChar(1,2,'2',true);
delay(2000);
lc1.clearDisplay(1); //clear the display
//THIRD - 8 DIGIT 7 SEGMENT DISPLAY - MAX7219 INITIALISATION
lc2.shutdown(2,false); //turn on the display
lc2.setIntensity(2,8);//set the brightness
lc2.clearDisplay(2); //clear the display
lc2.setChar(2,7,'H',false);
lc2.setChar(2,6,'e',false);
lc2.setChar(2,5,'l',false);
lc2.setChar(2,4,'l',false);
lc2.setChar(2,3,'o',false);
lc2.setChar(2,2,'3',true);
delay(2000);
lc2.clearDisplay(2); //clear the display
//FOURTH - 8 DIGIT 7 SEGMENT DISPLAY - MAX7219 INITIALISATION
lc1.shutdown(3,false); //turn on the display
lc1.setIntensity(3,8);//set the brightness
lc1.clearDisplay(3); //clear the display
lc1.setChar(3,7,'H',false);
lc1.setChar(3,6,'e',false);
lc1.setChar(3,5,'l',false);
lc1.setChar(3,4,'l',false);
lc1.setChar(3,3,'o',false);
lc1.setChar(3,2,'4',true);
delay(2000);
lc1.clearDisplay(3); //clear the display
}
void loop() {
DcsBios::loop();
}