|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ch.aplu.ftcontroller.Motor
public class Motor
Class to handle the 4 motors at motor ports M1..M4.
For all methods with a step parameter, the motor is put in the so-called
"RobMode". Two switches/counters are used: The "step switch" is preset to
the number of steps and counts left each time the switch
is pressed/released. When the count reaches 0, the motor stops. When the
"end switch" is pressed the step switch is set to 0 and the motor
stops immediately. The end switch is only active, if the motor turns left
(if motor.right(n) is called).
The following switch assignement is assumed:
motor nb 1: end switch I1, step switch I2
motor nb 2: end switch I3, step switch I4
motor nb 3: end switch I5, step switch I6
motor nb 4: end switch I7, step switch I8
In RobMode a registered counter listener at the step switch reports the
count changes, but the counter at the end switch is disabled and a
registered counter listener at the end switch will not report the press event.
It is recommended to register a MotorListener that reports each step change
and information whether the motor stopped because the step is reached or
the end switch is pressed.
Method Summary | |
---|---|
int |
getNumber()
Returns number of motor (1..4). |
boolean |
isRotating()
Returns state of motor. |
Motor |
left()
Starts turning the motor to the left (seen from front). |
Motor |
left(int steps)
Turns right given nb of steps to the left (seen from front). |
Motor |
left(int steps,
boolean blocking)
Same as left(steps) but if blocking = true, blocks until steps is reached or the end switch is pressed. |
Motor |
right()
Starts turning the motor to the right (seen from front). |
Motor |
right(int steps)
Turns right given nb of steps to the right (seen from front). |
Motor |
right(int steps,
boolean blocking)
Same as right(steps) but if blocking = true, blocks until steps is reached. |
Motor |
setSpeed(int speed)
Sets the rotation speed. |
Motor |
stop()
Stops the motor. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public int getNumber()
public Motor setSpeed(int speed)
speed
- the speed value 1..8 (1 is slowest)
public Motor stop()
public Motor left()
public Motor right()
public Motor left(int steps)
steps
- the number of switch actuations (press or release) of the
step switch
public Motor right(int steps)
steps
- the number of switch actuations (press or release) of the
step switch (see comment in the Motor class overview).
public Motor left(int steps, boolean blocking)
steps
- the number of switch actuations (press or release)blocking
- if true, the methods blocks until the step is reachedpublic Motor right(int steps, boolean blocking)
steps
- the number of switch actuations (press or release)blocking
- if true, the methods blocks until the step is reachedpublic boolean isRotating()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |