Go Down

Topic: SOLVED:LMS303 sample reading (Read 1 time) previous topic - next topic

btsp

Rob,

thanks for simplifying the code i am yet to test it out but just a question,

what does:

hstate = (max - min > FUDGE_FACTOR) ? SPECIAL : NORMAL; 

that do?

Graynomad

#6
Jul 28, 2011, 04:56 pm Last Edit: Jul 28, 2011, 05:05 pm by Graynomad Reason: 1
It's a shorthand version of

Code: [Select]
if (max - min > FUDGE_FACTOR)
  hstate = SPECIAL;
else
  hstate = NORMAL; 


It's called a ternary operator

x = test ? true_result : false_result;

http://cprogramminglanguage.net/c-ternary-operator.aspx

much like IIF in many other languages.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

btsp

ah thanks.

well ran the code, everything is good except around the 350 mark.

I am going to look into it more and get back to you


btsp

#8
Jul 28, 2011, 05:46 pm Last Edit: Jul 28, 2011, 05:59 pm by btsp Reason: 1
found the error,
was the max/min reset values.

had min and max both at 0

min should be at 359 and max at 0.

she works great now,

thanks again

Graynomad

No problems, I might file that away for future use myself :)

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

Go Up