TRC Library for FTC (2011) 2011
TRC Library Code Project

C:/Users/Michael/Ftc/2011/code/trclib/trcdefs.h File Reference

Go to the source code of this file.


#define _TRCDEFS_H
#define __in
#define __out
#define __inout
#define ARRAYSIZE(a)   (sizeof(a)/sizeof(a[0]))
#define BOUND(n, l, h)   (((n) < (l))? (l): ((n) > (h))? (h): (n))
#define NORMALIZE(n, sl, sh, tl, th)   (int)(((long)(n) - (sl))*((th) - (tl))/((sh) - (sl)) + (tl))
#define DEADBAND(n, t)   ((abs(n) > (t))? (n): 0)
#define BOUND_INPUT(n)   BOUND(n, -128, 127)
#define LOOP_TIME   10

Define Documentation

#define __in

Definition at line 21 of file trcdefs.h.

#define __inout

Definition at line 23 of file trcdefs.h.

#define __out

Definition at line 22 of file trcdefs.h.

#define _TRCDEFS_H

Definition at line 16 of file trcdefs.h.

#define ARRAYSIZE (   a)    (sizeof(a)/sizeof(a[0]))

Definition at line 25 of file trcdefs.h.

#define BOUND (   n,
)    (((n) < (l))? (l): ((n) > (h))? (h): (n))

The BOUND macro limits the value (n) within the bounds between the given low (l) and high (h).

Definition at line 31 of file trcdefs.h.

#define BOUND_INPUT (   n)    BOUND(n, -128, 127)

This macro limits the input value (n) to the range between -128 and 127. This is useful when calculations on the input value may bring the result outside of the valid range. This macro will make sure the result is within bounds.

Definition at line 61 of file trcdefs.h.

#define DEADBAND (   n,
)    ((abs(n) > (t))? (n): 0)

These macros ignore input value (n) that is within the DEADBAND_THRESHOLD. This is necessary because analog joysticks do not always centered at zero. So if the joystick is at the rest position, we will consider it zero even though the value is non-zero but within DEADBAND_THRESHOLD.

Definition at line 52 of file trcdefs.h.


Definition at line 53 of file trcdefs.h.


Definition at line 43 of file trcdefs.h.

#define LOOP_TIME   10

Definition at line 64 of file trcdefs.h.

#define NORMALIZE (   n,
)    (int)(((long)(n) - (sl))*((th) - (tl))/((sh) - (sl)) + (tl))

The NORMALIZE macro transforms a value (n) in the range between (sl) and (sh) to the range between (tl) and (th).

Definition at line 37 of file trcdefs.h.

 All Data Structures Files Functions Variables Defines