Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polling Issue when using latest version of DCS-BIOS v0.3.8 #42

Open
byteman59 opened this issue Feb 16, 2023 · 6 comments
Open

Polling Issue when using latest version of DCS-BIOS v0.3.8 #42

byteman59 opened this issue Feb 16, 2023 · 6 comments

Comments

@byteman59
Copy link

I recently upgraded to DCS-Bios v0.3.8 from 0.2.11. Now i am receiving a polling error when compliling. Sketch works fine with v2.11

Below is the sketch I'm trying to use. I have attached error message as well

Thanks!

#define DCSBIOS_IRQ_SERIAL
#include <DcsBios.h>
#include <timer.h>
Timer tm;

namespace DcsBios {
class SwitchMultiPosBCD : PollingInput {
private:
const char* msg_;
const byte* pins_;
char numberOfPins_;
char lastState_;

 char readState() {
   unsigned char i;
   unsigned char state = 0;
   for (i=0; i<numberOfPins_; i++) {
     unsigned char j = numberOfPins_ - i - 1;

// state |= (digitalRead(pins_[i]) << j);
state |= ((digitalRead(pins_[i]) ^ 1) << j); // to invert logic

   }
   return state;
 }

 void pollInput() {
   char state = readState();
   if (state != lastState_) {
     char buf[7];
     utoa(state, buf, 10);
     if (tryToSendDcsBiosMessage(msg_, buf))
       lastState_ = state;
   }
 }

public:
SwitchMultiPosBCD(const char* msg, const byte* pins, char numberOfPins) : lastState_(0) {
msg_ = msg;
pins_ = pins;
numberOfPins_ = numberOfPins;
unsigned char i;
for (i=0; i<numberOfPins; i++) {
pinMode(pins[i], INPUT_PULLUP);
}
lastState_ = readState();
}
};
}

//Mode-1 Wheel 1 ROTARY ENCODER
const byte iffMode1Wheel1Pins[3] = {27, 26, 25};
DcsBios::SwitchMultiPosBCD iffMode1Wheel1("IFF_MODE1_WHEEL1", iffMode1Wheel1Pins, 3);

//Mode-1 Wheel 2 ROTARY ENCODER
const byte iffMode1Wheel2Pins[2] = {23, 24};
DcsBios::SwitchMultiPosBCD iffMode1Wheel2("IFF_MODE1_WHEEL2", iffMode1Wheel2Pins, 2);

//Mode-3A Wheel 1 ROTARY ENCODER
const byte iffMode3aWheel1Pins[3] = {56, 55, 54};
DcsBios::SwitchMultiPosBCD iffMode3aWheel1("IFF_MODE3A_WHEEL1", iffMode3aWheel1Pins, 3);

//Mode-3A Wheel 2 ROTARY ENCODER
const byte iffMode3aWheel2Pins[3] = {58, 59, 60};
DcsBios::SwitchMultiPosBCD iffMode3aWheel2("IFF_MODE3A_WHEEL2", iffMode3aWheel2Pins, 3);

//Mode-3A Wheel 3 ROTARY ENCODER
const byte iffMode3aWheel3Pins[3] = {62, 63, 64};
DcsBios::SwitchMultiPosBCD iffMode3aWheel3("IFF_MODE3A_WHEEL3", iffMode3aWheel3Pins, 3);

//Mode-3A Wheel 4 ROTARY ENCODER
const byte iffMode3aWheel4Pins[3] = {66, 67, 68};
DcsBios::SwitchMultiPosBCD iffMode3aWheel4("IFF_MODE3A_WHEEL4", iffMode3aWheel4Pins, 3);

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

}

void loop() {
DcsBios::loop();
polling error.txt
}

@byteman59 byteman59 changed the title Polling Issue when using latest version Polling Issue when using latest version of DCS-BIOS v0.3.8 Feb 17, 2023
@WarLord211 WarLord211 transferred this issue from DCS-Skunkworks/dcs-bios Mar 1, 2023
@talbotmcinnis
Copy link
Collaborator

This error is actually in your sketch as you are extending dcsbios and creating a new control SwitchMultiPosBCD. As such, we were unable to update your sketch when the PollingInput interface changed. I'm thrown by the name "Switch" but also "BCD". DCS-BIOS has supported BcdWheel which I suspect you want to use instead of a hand-spun class. But if you want to fix it in place, I suspect all you need is to change class SwitchMultiPosBCD : PollingInput { to class SwitchMultiPosBCD : PollingInput(POLL_EVERY_TIME) {

@byteman59
Copy link
Author

I did try to use the following without the addtional code, but it did not seem to update correctly. Am i doing something wrong?
const byte iffMode1Wheel1Pins[3] = {27, 26, 25};
DcsBios::BCDWheel iffMode1Wheel1("IFF_MODE1_WHEEL1", iffMode1Wheel1Pins, 3);

@talbotmcinnis
Copy link
Collaborator

This builds, give it a try and let me know if it works.:

`#define DCSBIOS_IRQ_SERIAL
#include <DcsBios.h>

//Mode-1 Wheel 1 ROTARY ENCODER
DcsBios::BcdWheel iffMode1Wheel1("IFF_MODE1_WHEEL1", 27, 26, 25);

//Mode-1 Wheel 2 ROTARY ENCODER
DcsBios::BcdWheel iffMode1Wheel2("IFF_MODE1_WHEEL2", 23, 24);

//Mode-3A Wheel 1 ROTARY ENCODER
DcsBios::BcdWheel iffMode3aWheel1("IFF_MODE3A_WHEEL1", 56, 55, 54);

//Mode-3A Wheel 2 ROTARY ENCODER
DcsBios::BcdWheel iffMode3aWheel2("IFF_MODE3A_WHEEL2", 58, 59, 60);

//Mode-3A Wheel 3 ROTARY ENCODER
DcsBios::BcdWheel iffMode3aWheel3("IFF_MODE3A_WHEEL3", 62, 63, 64);

//Mode-3A Wheel 4 ROTARY ENCODER
DcsBios::BcdWheel iffMode3aWheel4("IFF_MODE3A_WHEEL4", 66, 67, 68);

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

}

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

@byteman59
Copy link
Author

byteman59 commented Mar 10, 2023 via email

@byteman59
Copy link
Author

How should it be wired? I have 0,1,2 assigned to Arduino ports, along with Ground. Only whee4 seems to be working BUT, it's being reported as Wheel3 that is moving. None of the other wheels seem to be working.

@byteman59
Copy link
Author

This builds, give it a try and let me know if it works.:

`#define DCSBIOS_IRQ_SERIAL #include <DcsBios.h>

//Mode-1 Wheel 1 ROTARY ENCODER DcsBios::BcdWheel iffMode1Wheel1("IFF_MODE1_WHEEL1", 27, 26, 25);

//Mode-1 Wheel 2 ROTARY ENCODER DcsBios::BcdWheel iffMode1Wheel2("IFF_MODE1_WHEEL2", 23, 24);

//Mode-3A Wheel 1 ROTARY ENCODER DcsBios::BcdWheel iffMode3aWheel1("IFF_MODE3A_WHEEL1", 56, 55, 54);

//Mode-3A Wheel 2 ROTARY ENCODER DcsBios::BcdWheel iffMode3aWheel2("IFF_MODE3A_WHEEL2", 58, 59, 60);

//Mode-3A Wheel 3 ROTARY ENCODER DcsBios::BcdWheel iffMode3aWheel3("IFF_MODE3A_WHEEL3", 62, 63, 64);

//Mode-3A Wheel 4 ROTARY ENCODER DcsBios::BcdWheel iffMode3aWheel4("IFF_MODE3A_WHEEL4", 66, 67, 68);

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

}

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

Works with Input pullups.
but only in DSCBIOS port. Does not work within game.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants