 #define MAX_RUDDER 10.0
 
 unsigned long lastDataPacketSent;
+unsigned long timeOnCurrentTack;
 
 char state;
 char remoteState;

  Wire.begin();
  remoteState = SBTSailbotModelStateManualControl;
  windDirection = -1.0;
  compassOffset = M_PI;
  calibratedWind = false;
  imu = RTIMU::createIMU(&settings);                        // create the imu object



    // Update rudder and sheet
    if (state == SBTSailbotModelStateAutomaticControl) {
      float rudderAngle;
      float angleToWind = angleSubtractf(windDirection, automaticHeading);
      if (abs(angleToWind) < tackAngle / 2.0) {
        float tack = angleToWind > 0 ? tackAngle / 2.0 : -tackAngle / 2.0;
        rudderAngle = angleSubtractf(angleSubtractf(windDirection, tack), heading);
        Serial.print("Angle towards wind: "); Serial.println(angleToWind * 180.0 / M_PI);
      } else {
        rudderAngle = angleSubtractf(automaticHeading, heading);
      }
      setRudder(40.0 * rudderAngle / M_PI);

    } else if (state == SBTSailbotModelStateRecoveryMode) {

    }
