Hello guys hoping someone can get me on the right track here. I'm running Teensy 2.0++ with X Plane 11. Trying to get an encoder to activate a certain dataref. here is the program:
#include <Encoder.h>
#define TempSel_Left 25
#define TempSel_Right 26
Encoder TempSel = Encoder(25,26);
FlightSimInteger TempSelRotary;
long encoder_prev=0; // detects rotary position change
void setup() {
pinMode(25, INPUT_PULLUP);
pinMode(26, INPUT_PULLUP);
TempSelRotary = XPlaneRef("1-sim/gauge/Tempsel");
}
void loop() {
FlightSim.update();
long enc = TempSel.read();
if (enc != encoder_prev){
TempSelRotary = TempSelRotary + (enc - encoder_prev);
encoder_prev = enc;}
This is for a third party aircraft. I have the correct dataref that's not an issue.
Basically
what the knob in the 3rd party aircraft is its a D rate knob that changes the engine temp from
-30 to +70. and the dataref for those are 0.0 to 1.00. So there is only 21 detents changing
5 degrees each detent.
The code I wrote changes the knob in x plane but, it only changes +70 and -30 only those 2
detents nothing in between. I can't figure out what exactly I am missing to turn the rest. I am using a cts288 encoder.
Any help would be awesome.
#include <Encoder.h>
#define TempSel_Left 25
#define TempSel_Right 26
Encoder TempSel = Encoder(25,26);
FlightSimInteger TempSelRotary;
long encoder_prev=0; // detects rotary position change
void setup() {
pinMode(25, INPUT_PULLUP);
pinMode(26, INPUT_PULLUP);
TempSelRotary = XPlaneRef("1-sim/gauge/Tempsel");
}
void loop() {
FlightSim.update();
long enc = TempSel.read();
if (enc != encoder_prev){
TempSelRotary = TempSelRotary + (enc - encoder_prev);
encoder_prev = enc;}
This is for a third party aircraft. I have the correct dataref that's not an issue.
Basically
what the knob in the 3rd party aircraft is its a D rate knob that changes the engine temp from
-30 to +70. and the dataref for those are 0.0 to 1.00. So there is only 21 detents changing
5 degrees each detent.
The code I wrote changes the knob in x plane but, it only changes +70 and -30 only those 2
detents nothing in between. I can't figure out what exactly I am missing to turn the rest. I am using a cts288 encoder.
Any help would be awesome.