Treehopper Java API
io.treehopper.SoftPwm Class Reference

This class provides software-based pulse-width modulation (PWM) on any pin. More...

Inheritance diagram for io.treehopper.SoftPwm:

Public Member Functions

 SoftPwm (TreehopperUsb board, Pin pin)
double getDutyCycle ()
void setDutyCycle (double dutyCycle)
double getPulseWidth ()
void setPulseWidth (double pulseWidth)
boolean isEnabled ()
void setEnabled (boolean enabled)
String toString ()

Detailed Description

This class provides software-based pulse-width modulation (PWM) on any pin.

The period of the SoftPwm module defaults to approximately 60 Hz. Changing this period will affect all active SoftPwm pins.

Compared to HardwarePwm (which is implemented in hardware), SoftPwm has some jitter. However, it has good precision, fine-tuned period control, and works well even when many (or all!) Treehopper pins are used for SoftPwm.

Constructor & Destructor Documentation

◆ SoftPwm()

io.treehopper.SoftPwm.SoftPwm ( TreehopperUsb  board,
Pin  pin 

Member Function Documentation

◆ getDutyCycle()

double io.treehopper.SoftPwm.getDutyCycle ( )

◆ getPulseWidth()

double io.treehopper.SoftPwm.getPulseWidth ( )

◆ isEnabled()

boolean io.treehopper.SoftPwm.isEnabled ( )

◆ setDutyCycle()

void io.treehopper.SoftPwm.setDutyCycle ( double  dutyCycle)

◆ setEnabled()

void io.treehopper.SoftPwm.setEnabled ( boolean  enabled)

◆ setPulseWidth()

void io.treehopper.SoftPwm.setPulseWidth ( double  pulseWidth)

◆ toString()

String io.treehopper.SoftPwm.toString ( )

The documentation for this class was generated from the following file: