
// ----------------------------------------------------------------------
void calcLidAng(long zVal) {
  // calculate the Lid angle value from the calibration limits  
  LidVal = zVal;
  LidAng = ((servoLidMax - LidVal)* 71)/(servoLidMax - servoLidTap);
}

// ----------------------------------------------------------------------

void calcLidVal(long zAng) {
  // calculate the Lid microsecond value from the calibration limits  
  LidAng = zAng;
  LidVal = servoLidMax - (((servoLidMax - servoLidTap) * zAng)/71);
}

// ----------------------------------------------------------------------

void delayLidAng(long zAng) {
  // delay for a period approximately proportional to angle
  // minimum delay accounts for inertia
  delay(100 + (zAng * 4));
}

// ----------------------------------------------------------------------

void MoveLidAngle(long zLidAng,long zDel) {
  // move the lid from the current angle to a new angle progressively
  long zAng;
  for (long zP = 1 + abs(LidAng - zLidAng); zP > 0; zP--) {
      zAng = LidAng + ((zLidAng - LidAng)/zP);
      calcLidVal(zAng); servoLid.writeMicroseconds(LidVal);
      delay(zDel);
//      Serial.println(zAng);
  }
}

// ----------------------------------------------------------------------

void SetLidAngle(long zAng) {
  // move the Lid to the angle position immediately
  calcLidVal(zAng); servoLid.writeMicroseconds(LidVal);
}

// ----------------------------------------------------------------------

void SetLidVal(long zVal) {
  // move the Lid to the Microsecond position immediately
  calcLidAng(zVal); servoLid.writeMicroseconds(LidVal);
}

// ----------------------------------------------------------------------

void SetLidToRest() {
  // move the Lid to the Rest position immediately
  SetLidAngle(82);
}

// ----------------------------------------------------------------------

void SetLidToTap() {
  // move the Lid to the Tap position immediately
  SetLidVal(servoLidTap);
}

// ----------------------------------------------------------------------


