Sign in to follow this  
Guest Patrick_Waugh

Making a needle go round and round =)

Recommended Posts

Hey, I'm trying to get a needle to go from 0 and around to zero again for units in a value like this:NONLINEARITY ng2_nonLinearity[] ={ { {175, 199}, 0, 0}, { {164, 196}, 1, 0}, { {156, 186}, 2, 0}, { {156, 174}, 3, 0}, { {164, 164}, 4, 0}, { {175, 199}, 5, 0}, { {187, 164}, 6, 0}, { {193, 174}, 7, 0}, { {193, 186}, 8, 0}, { {187, 196}, 9, 0},};FLOAT64 FSAPI NgNeedle2_cb(PELEMENT_NEEDLE pelement){ double temp = pelement->source_var.var_value.n / 1638.4; return (temp - (int)temp ) * 10;}and, of course, the needle gets to .9 correctly, but then as it goes to zero, it moves CCW back to zero to begin again, while I want it to simply keeping moving forward.I'm guessing one way to solve this is just to leave the integer part so it gets larger and larger.Other ideas?

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

I tried this:NONLINEARITY ng2_nonLinearity[] ={ { {175, 199}, 0, 0}, { {164, 196}, 1, 0}, { {156, 186}, 2, 0}, { {156, 174}, 3, 0}, { {164, 164}, 4, 0}, { {175, 199}, 5, 0}, { {187, 164}, 6, 0}, { {193, 174}, 7, 0}, { {193, 186}, 8, 0}, { {187, 196}, 9, 0}};FLOAT64 FSAPI NgNeedle2_cb(PELEMENT_NEEDLE pelement){ return pelement->source_var.var_value.n / 163.84;}which basically just lets the units needle continue around, but now it does not line up on the correct unit number.For example, the value might be "79.9" and the main needle pointing correctly, and this needle pointing to the '7'. The non-linearity is correct, and the gauge did correctly point earlier when it would return to zero to begin again.So, not sure what others do to solve this.

Share this post


Link to post
Share on other sites

You might try this:NONLINEARITY ng2_nonLinearity[] ={{ {175, 199}, 0, 0},{ {164, 196}, 1, 0},{ {156, 186}, 2, 0},{ {156, 174}, 3, 0},{ {164, 164}, 4, 0},{ {175, 199}, 5, 0},{ {187, 164}, 6, 0},{ {193, 174}, 7, 0},{ {193, 186}, 8, 0},{ {187, 196}, 9, 0},{ {175, 199}, 10, 0}, //Bring non-linearity back round to 0};FLOAT64 FSAPI NgNeedle2_cb(PELEMENT_NEEDLE pelement){double previous_return;double temp = pelement->source_var.var_value.n / 1638.4;temp = (temp - (int)temp ) * 10;if ( previous_return > 9.5 && temp < 0.5 ) { previous_return = temp; return temp + 10; //Special case - we've crossed the line }else { previous_return = temp; return temp; //Normal case }}Doug

Share this post


Link to post
Share on other sites

Doug,Thanks for the suggestion. Just before reading this, I tried adding the 10 line to the non-linearity, and then I also lowered the so-called "degs-per-sec" variable that controls the number of tics required between draws to zero. That did the trick for the most part, and it now spins continuously.I forgot to change the main needle to '0' too, and think that was causing it to lag, so I'm about to test it.If that doesn't work, then I'll insert your suggested code, which is a great idea too.Patrick

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this