PaulStoffregen / X-Plane_Plugin

TeensyControls Plugin for X-Plane Flight Simulator
31 stars 15 forks source link

dataref seems to not be read #1

Closed orthopteroid closed 10 years ago

orthopteroid commented 10 years ago

Hi. I'm using the plugin from https://www.pjrc.com/teensy/td_flightsim.html with teensy 3.1 (code below) and I only see 0.0 for the time ( the dataref browser shows network_time_sec increasing ). Is this a common problem with a well known ( except to me ) solution? Is this a possible bug and should I fork repo, instrument and try to fix?

cheers

-------8<---------8<-------

FlightSimFloat time_ref;

void setup() { time_ref = XPlaneRef("sim/network/misc/network_time_sec"); time_ref.onChange(time_change); pinMode(13, OUTPUT); Serial.begin(9600); Serial.println("TimeRef Demo"); }

float time_value = 0.; void time_change(float val) { time_value = val; }

static float tickstep = .1; boolean tick() { static float tickval = 0; tickval += tickstep; if( tickval < 0. || tickval > 10000. ) { tickstep *= -1.; return true; } return false; }

void loop() { FlightSim.update();

if( tickstep > 0 ) digitalWrite(13, HIGH); else digitalWrite(13, LOW); if( tick() ) { Serial.print("network time = "); Serial.println( time_value ); } }

orthopteroid commented 10 years ago

My bad... had some build issues but I figured it out.