View Single Post
  #4   Spotlight this post!  
Unread 15-02-2006, 18:16
ida_noeman's Avatar
ida_noeman ida_noeman is offline
Registered User
AKA: phobbs
FRC #1719 (Umbrella Corp.)
Team Role: Mechanical
 
Join Date: Jan 2006
Rookie Year: 2006
Location: Baltimore, MD
Posts: 129
ida_noeman is on a distinguished road
Re: Dead zone for RC control

A very readable way to do it is to make an inline function like this:
Code:
#define STOP 127
#define DEAD_ZONE 15 // or any other number, fool around with this to make it work as you want it to
#define IN_DEAD_ZONE(x) (x <= DEAD_ZONE + STOP && x>= STOP - DEAD_ZONE)
This would work with something like this:
Code:
if (IN_DEAD_ZONE(p1_y))
p1_y = STOP;
__________________
--
"Weeks of coding can save you hours of planning"
"If the code was hard to write, I'm dam well going to make it hard to read!"

Last edited by ida_noeman : 15-02-2006 at 18:23.