/ src / hal / components / deadzone.comp
deadzone.comp
 1  component deadzone "Return the center if within the threshold";
 2  param rw float center = 0.0 "The center of the dead zone";
 3  param rw float threshhold = 1.0 "The dead zone is \\fBcenter\\fR \\(+- (\\fBthreshhold\\fR/2)";
 4  pin in float in;
 5  pin out float out;
 6  
 7  function _ "Update \\fBout\\fR based on \\fBin\\fR and the parameters.";
 8  
 9  license "GPL";
10  ;;
11  FUNCTION(_) {
12      double th2 = threshhold / 2;
13      double lo = center - th2;
14      double hi = center + th2;
15      double in_ = in;
16      
17      if(in_ < lo) out = in_ + th2;
18      else if(in_ > hi) out = in_ - th2;
19      else out = center;
20  }