|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--stamp.core.VirtualPeripheral | +--stamp.core.PWM
Perform Pulse Width Modulation (PWM) on an I/O pin. PWM is a virtual peripheral so it will continue to run in the background.
The timebase for PWM (and all other virtual peripherals) is 8.68 microseconds.
Field Summary | |
boolean |
stoppedState
The state that the pin should be set to whenever the PWM is stopped. |
Constructor Summary | |
PWM(int pin)
Creates a PWM object, assigns it to a pin but does not start it running. |
|
PWM(int pin,
int highTime,
int lowTime)
Creates a PWM object, assigns it to a pin and starts it running. |
|
PWM(int pin,
int highTime,
int lowTime,
boolean stoppedState)
Creates a PWM object, assigns it to a pin and starts it running. |
Method Summary | |
void |
start()
Start the PWM running. |
void |
stop()
Stop a running PWM. |
void |
update(int highTime,
int lowTime)
Update the PWM duty cycle. |
Methods inherited from class java.lang.Object |
equals |
Field Detail |
public boolean stoppedState
Constructor Detail |
public PWM(int pin)
pin
- the pin to generate the PWM signal on.public PWM(int pin, int highTime, int lowTime, boolean stoppedState)
pin
- the pin to generate the PWM signal on.highTime
- the number of 8.68us the waveform should be high.lowTime
- the number of 8.68us the waveform should be low.stoppedState
- the state that the pin should be set to whenever the
PWM is stopped.public PWM(int pin, int highTime, int lowTime)
pin
- the pin to generate the PWM signal on.highTime
- the number of 8.68us the waveform should be high.lowTime
- the number of 8.68us the waveform should be low.Method Detail |
public void update(int highTime, int lowTime)
highTime
- the number of 8.68us the waveform should be high.lowTime
- the number of 8.68us the waveform should be low.public void start()
stop()
then
start()
will start it again with the same set of parameters.
It is an error to call start if the PWM is already running.
public void stop()
The PWM will stop immediately and may leave the output pin in either a high or low state.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |