|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectjcontrol.io.PWM
public class PWM
Controls the Pulse Width Modulation of JControl. This is used to control analog devices, e.g., lights, motors, buzzers.
The number of available PWM-channels is hardware dependent, you can
Management.getProperty("io.pwmchannels"),GPIO
class.
| all |
| Constructor Summary | |
|---|---|
protected |
PWM()
Disables instantiation. |
| Method Summary | |
|---|---|
static int |
getDuty(int channel)
Gets the duty cycle of the given channel. |
static int |
getFrequency(int channel)
Returns the current PWM signal frequency resulting of current scale and load. |
static void |
setActive(int channel,
boolean active)
Turns the specified channel on or off. |
protected static void |
setCycles(int scale,
int load)
Sets both the prescale and the preload value of the PWM unit. |
static void |
setDuty(int channel,
int duty)
Sets the duty cycle of the given channel. |
static void |
setFrequency(int freq)
Sets the frequency of the PWM signal (in Hz), uses setCycles(). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, notifyAll, wait |
| Constructor Detail |
|---|
protected PWM()
| Method Detail |
|---|
public static int getDuty(int channel)
channel - to use (valid range: 0...3, hardware dependent)
public static int getFrequency(int channel)
scale and load.
channel - to use (valid range: 0...3, hardware dependent)
setCycles(int scale, int load),
setFrequency(int freq)
public static void setActive(int channel,
boolean active)
channel - to turn on of offactive - true activates the channel
protected static void setCycles(int scale,
int load)
scale - the prescaler value (valid range: 0...7).load - the preload value of the counter (valid range: 0...255).scaleload)load in the following way:
resolution=1/(256-load)#setFrequency(short freq)
public static void setDuty(int channel,
int duty)
channel - to use (valid range: 0...3, hardware dependent)duty - cycle (positive values -256..0..256 are scaled to hardware and frequency dependent parameters)public static void setFrequency(int freq)
setCycles().
This method affects the frequency of all channels. Setting frequency also affect current
duty cycle of all channels so this must be set or refreshed afterwards.
freq - the frequency to use (range 244 ... 32767 - hardware dependent)setCycles(int scale, int load),
#setDuty(byte, int)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||