<commit_before>
//------------------------------------------------------------------------------------------------
// * moveToTarget
// This function is responsible for moving the stage to an absolute location. It takes two 
// inputs: an array of floats defining how much to move the stage in each axis and the step size. 
// The length of the array should be equal to the number of axes. The step size indicates the 
// fraction of a full step being taken and is a float. 
//
// **  You will need to change the speed and step sizes in this file for your motors **
void moveToTarget(float target[]){
  
 byte verbose=0;
 int ii; //for loop counter
 float intendedMove[numAxes]; //How far to move on each axis. 
 setStep(moveToStepSize);
 
 
  
  if (doGamePad){     
    PS3.setAllOff(); //Switch off the LEDs to indicate that we're making a non-manual motion
  }

  float oneStep[numAxes]; //how far one step takes us
  long stepsToTake[numAxes]; //how many steps to take on each axis


  for (ii=0; ii<numAxes; ii++){
    if (!axisPresent[ii])
      continue;
  
 
    intendedMove[ii]=target[ii]-stagePosition[ii]; //How far we need to move
/*
    //compensate for backlash
    if (intendedMove[ii]<0 && digitalRead(stepDir[ii])==1)
       intendedMove[ii]=intendedMove[ii]-0.32; //the measured backlash in z
    if (intendedMove[ii]>0 && digitalRead(stepDir[ii])==0)
       intendedMove[ii]=intendedMove[ii]+0.32; //the measured backlash in z
  */  
  
    oneStep[ii] = (fullStep[ii]/360.0) * moveToStepSize * gearRatio[ii];
  
    stepsToTake[ii]=round(intendedMove[ii]/oneStep[ii]); //total number of steps we have to take

    if (verbose){
      Serial.print(ii+1);
      Serial.print(". Targ: ");
      Serial.print(target[ii]);
      Serial.print("; Pos: ");
      Serial.print(stagePosition[ii]);
      Serial.print("; Spd: ");
      Serial.print(moveToSpeed[ii]);
      Serial.print("; oneStp: ");
      Serial.print(oneStep[ii]);
      Serial.print("; steps2take: ");
      Serial.print(stepsToTake[ii]);
      Serial.print("; CurPos B4: ");
      Serial.println((*mySteppers[ii]).currentPosition() );
    }
    
    //Now set the maximum pulse speed on this stepper axis
    (*mySteppers[ii]).setSpeed(moveToSpeed[ii]/oneStep[ii]); //seems to be necessary that this is set to a reasonable value
    (*mySteppers[ii]).setMaxSpeed(moveToSpeed[ii]/oneStep[ii]);
    (*mySteppers[ii]).setAcceleration(moveToAccel[ii]);       

      if (disableWhenStationary[ii] && abs(intendedMove[ii])>0)
         digitalWrite(enable[ii],LOW);
  
      //Update the stage position to what it will be once the move is complete
      //No point waiting to do this, since there is no feedback from the stepper
      //anyway.
      updateStagePos(ii,stepsToTake[ii],moveToStepSize); 
      
    
      //Set up axes for motions
      (*mySteppers[ii]).moveTo( (*mySteppers[ii]).currentPosition()+stepsToTake[ii] );
          
  }


  //Now run the steppers until they get there
  if (verbose){
    Serial.println("Moving");
  }

  runSteppersToPos();  


  //Return LEDs and Big Easy Drivers to previously selected step size<commit_msg>Don't print verbose information to USB if USB is being used to control stage.<commit_after>
//------------------------------------------------------------------------------------------------
// * moveToTarget
// This function is responsible for moving the stage to an absolute location. It takes two 
// inputs: an array of floats defining how much to move the stage in each axis and the step size. 
// The length of the array should be equal to the number of axes. The step size indicates the 
// fraction of a full step being taken and is a float. 
//
// **  You will need to change the speed and step sizes in this file for your motors **
void moveToTarget(float target[]){
  
 byte verbose=0;
 int ii; //for loop counter
 float intendedMove[numAxes]; //How far to move on each axis. 
 setStep(moveToStepSize);
 
 
  
  if (doGamePad){     
    PS3.setAllOff(); //Switch off the LEDs to indicate that we're making a non-manual motion
  }

  float oneStep[numAxes]; //how far one step takes us
  long stepsToTake[numAxes]; //how many steps to take on each axis


  for (ii=0; ii<numAxes; ii++){
    if (!axisPresent[ii])
      continue;
  
 
    intendedMove[ii]=target[ii]-stagePosition[ii]; //How far we need to move
/*
    //compensate for backlash
    if (intendedMove[ii]<0 && digitalRead(stepDir[ii])==1)
       intendedMove[ii]=intendedMove[ii]-0.32; //the measured backlash in z
    if (intendedMove[ii]>0 && digitalRead(stepDir[ii])==0)
       intendedMove[ii]=intendedMove[ii]+0.32; //the measured backlash in z
  */  
  
    oneStep[ii] = (fullStep[ii]/360.0) * moveToStepSize * gearRatio[ii];
  
    stepsToTake[ii]=round(intendedMove[ii]/oneStep[ii]); //total number of steps we have to take

    if (verbose && !controlViaUSB){
      Serial.print(ii+1);
      Serial.print(". Targ: ");
      Serial.print(target[ii]);
      Serial.print("; Pos: ");
      Serial.print(stagePosition[ii]);
      Serial.print("; Spd: ");
      Serial.print(moveToSpeed[ii]);
      Serial.print("; oneStp: ");
      Serial.print(oneStep[ii]);
      Serial.print("; steps2take: ");
      Serial.print(stepsToTake[ii]);
      Serial.print("; CurPos B4: ");
      Serial.println((*mySteppers[ii]).currentPosition() );
    }
    
    //Now set the maximum pulse speed on this stepper axis
    (*mySteppers[ii]).setSpeed(moveToSpeed[ii]/oneStep[ii]); //seems to be necessary that this is set to a reasonable value
    (*mySteppers[ii]).setMaxSpeed(moveToSpeed[ii]/oneStep[ii]);
    (*mySteppers[ii]).setAcceleration(moveToAccel[ii]);       

      if (disableWhenStationary[ii] && abs(intendedMove[ii])>0)
         digitalWrite(enable[ii],LOW);
  
      //Update the stage position to what it will be once the move is complete
      //No point waiting to do this, since there is no feedback from the stepper
      //anyway.
      updateStagePos(ii,stepsToTake[ii],moveToStepSize); 
      
    
      //Set up axes for motions
      (*mySteppers[ii]).moveTo( (*mySteppers[ii]).currentPosition()+stepsToTake[ii] );
          
  }


  //Now run the steppers until they get there
  if (verbose && !controlViaUSB){
    Serial.println("Moving");
  }

  runSteppersToPos();  


  //Return LEDs and Big Easy Drivers to previously selected step size
{'fraction_non_alphanumeric': 0.15372524363407733, 'fraction_numerical': 0.006601697579377554, 'mean_word_length': 2.776261127596439, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6485029', 'n_tokens_mistral': 1995, 'n_tokens_neox': 1888, 'n_words': 600}