All pastes #1246959 Raw Edit

SensorActuatorConnection.java

public java v1 · immutable
#1246959 ·published 2008-11-06 15:53 UTC
rendered paste body
import lejos.nxt.*;import lejos.util.*;public class SensorActuatorConnection// extends Thread{	private RCXLightSensor m_sensorInterface = null;	private MotorPort[] m_motorAbstraction = null;	private final int m_low = 68;	private final int m_lowMotor = 50;	private final int m_high = 80;	private final int m_highMotor = 100;	private int m_sensorResult = 0;	private int m_motorPower = 0;        	public SensorActuatorConnection(RCXLightSensor sensorInterface, MotorPort[] actuatorAbstraction)	{		m_sensorInterface = sensorInterface;		m_motorAbstraction = actuatorAbstraction;	}        	public void run()	{		m_sensorInterface.activate();				//while(!Thread.currentThread().isInterrupted())		//{                        			//LCD.clear();			m_sensorResult = m_sensorInterface.readValue();			//LCD.drawString("Sensorinput: ", 0,0);			//LCD.drawInt(m_sensorResult,0,1);						m_motorPower = ( ( ( (100 - m_sensorResult) - m_low ) * (m_highMotor - m_lowMotor) )/(m_high - m_low)) + m_lowMotor;						//LCD.drawString("Motoroutput: ", 0,2);			//LCD.drawInt(m_motorPower,0,3);			//LCD.refresh();			for(int i = 0; i < m_motorAbstraction.length; i++)				m_motorAbstraction[i].controlMotor(m_motorPower,1 /* = forward */);                                                                                                //try {			//Thread.sleep(10);			//}			//catch(InterruptedException ex){}		//}			}}