lejos.hardware.device.RCXPlexedMotorPort Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lejos-ev3-api Show documentation
Show all versions of lejos-ev3-api Show documentation
leJOS (pronounced like the Spanish word "lejos" for "far") is a tiny Java Virtual Machine. In 2013 it was ported to the LEGO EV3 brick.
The newest version!
package lejos.hardware.device;
import lejos.hardware.port.BasicMotorPort;
/**
* Supports a motor connected to the Mindsensors RCX Motor Multiplexer
*
* @author Lawrie Griffiths
*
*/
public class RCXPlexedMotorPort implements BasicMotorPort {
private RCXMotorMultiplexer plex;
private int id;
public RCXPlexedMotorPort(RCXMotorMultiplexer plex, int id) {
this.plex = plex;
this.id = id;
}
public void controlMotor(int power, int mode) {
int mmMode = mode;
if (mmMode == BasicMotorPort.FLOAT) mmMode = 0; // float
int mmPower = (int) (power * 2.55f);
if (mmMode == BasicMotorPort.STOP) {
mmPower = 255; // Maximum breaking
}
plex.sendCommand(id, mmMode, mmPower);
}
public void setPWMMode(int mode) {
// Not implemented
}
@Override
public void close()
{
// not implemented
}
@Override
public String getName()
{
return null;
}
@Override
public boolean setPinMode(int mode)
{
return false;
}
}