<commit_before>package org.frc4931.zach.drive;

import edu.wpi.first.wpilibj.DigitalInput;

public class SingleLimitMotor extends Motor{
	public final DigitalInput limit;
	public int currentPosition = -1;
	public int moveDirection = 0;
	public boolean waitingForSwitch=false;
	
	public SingleLimitMotor(int channel, int type, int limit){
		super(channel, type);
		this.limit = new DigitalInput(limit);
	}
	
	public void toggle(){
		if(!limit.get()){
			System.out.println("Motor is lost, assuming motor is at "+currentPosition);
		}
		System.out.println("Motor is at "+currentPosition);
		moveDirection = currentPosition*-1;
	}
	
	public boolean update(double speed){
		if(moveDirection!=0){
			if(limit.get()){
				waitingForSwitch = true;
			}
			if(waitingForSwitch&&limit.get()){
				currentPosition = moveDirection;
				moveDirection = 0;
				waitingForSwitch = false;
				return true;
			}else{
				controller.set(speed*moveDirection);
				return false;
			}
		}
		return false;
	}
	
	
}<commit_msg>Revert "Modified SingleLimitMotor to use a normally open switch."<commit_after>package org.frc4931.zach.drive;

import edu.wpi.first.wpilibj.DigitalInput;

public class SingleLimitMotor extends Motor{
	public final DigitalInput limit;
	public int currentPosition = -1;
	public int moveDirection = 0;
	public boolean waitingForSwitch=false;
	
	public SingleLimitMotor(int channel, int type, int limit){
		super(channel, type);
		this.limit = new DigitalInput(limit);
	}
	
	public void toggle(){
		if(!limit.get()){
			System.out.println("Motor is lost, assuming motor is at "+currentPosition);
		}
		System.out.println("Motor is at "+currentPosition);
		moveDirection = currentPosition*-1;
	}
	
	public boolean update(double speed){
		if(moveDirection!=0){
			if(!limit.get()){
				waitingForSwitch = true;
			}
			if(waitingForSwitch&&limit.get()){
				currentPosition = moveDirection;
				moveDirection = 0;
				waitingForSwitch = false;
				return true;
			}else{
				controller.set(speed*moveDirection);
				return false;
			}
		}
		return false;
	}
	
	
}
{'fraction_non_alphanumeric': 0.11245758603974794, 'fraction_numerical': 0.00872515753756665, 'mean_word_length': 4.134328358208955, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6647143', 'n_tokens_mistral': 767, 'n_tokens_neox': 646, 'n_words': 162}