I want to setup a dead-band or filter for a variable in my program. I wrote code that works, but I was wondering if there is a simpler, cleaner or faster way than what I've come up with.
Here's my code:
temp = p_gx - p_gxOff;
if((temp < 10) && (temp > -10)) p_gx = 0;
else p_gx = temp;
Edit: If my variable is less than 10 and greater than -10, I want to set my variable to 0. Otherwise I will keep the value of the variable.