Treehopper Java API
io.treehopper.Pin Class Reference

A GPIO/Analog pin on the board. More...

Inheritance diagram for io.treehopper.Pin:
io.treehopper.interfaces.DigitalIO io.treehopper.interfaces.SpiChipSelectPin io.treehopper.interfaces.DigitalIn io.treehopper.interfaces.DigitalOut io.treehopper.interfaces.DigitalBase io.treehopper.interfaces.DigitalBase

Public Member Functions

int getPinNumber ()
 Gets the pin number of this pin. More...
 
Spi getSpiModule ()
 Gets the SPI module that can use this pin as an SpiChipSelectPin. More...
 
TreehopperUsb getBoard ()
 Get the board this pin belongs to. More...
 
PinMode getMode ()
 Get the current PinMode of the pin. More...
 
void setMode (PinMode value)
 Set this pin's mode. More...
 
void addDigitalInValueChangedEventHandler (DigitalInValueChangedEventHandler handler)
 Add a DigitalInValueCHangedEventHandler. More...
 
void removeDigitalInValueChangedEventHandler (DigitalInValueChangedEventHandler handler)
 Remove a DigitalInValueCHangedEventHandler. More...
 
boolean getDigitalValue ()
 Gets the current digital value of the pin. More...
 
void setDigitalValue (boolean value)
 Sets the digital value of this pin. More...
 
void toggleOutput ()
 Toggles the output of the pin. More...
 
void makeDigitalPushPullOutput ()
 Make this pin a digital push-pull output. More...
 
void makeDigitalIn ()
 Make this pin a digital input. More...
 
void addAdcValueChangedEventHandler (AdcValueChangedEventHandler handler)
 Add an AdcValueChangedEventHandler. More...
 
void removeAdcValueChangedEventHandler (AdcValueChangedEventHandler handler)
 Remove an AdcValueChangedEventHandler. More...
 
void addAnalogValueChangedEventHandler (AnalogValueChangedEventHandler handler)
 Add an AnalogValueChangedEventHandler. More...
 
void removeAnalogValueChangedEventHandler (AnalogValueChangedEventHandler handler)
 Remove an AnalogValueChangedEventHandler. More...
 
void addAnalogVoltageChangedEventHandler (AnalogVoltageChangedEventHandler handler)
 Add an AnalogVoltageChangedEventHandler. More...
 
void removeAnalogVoltageChangedEventHandler (AnalogVoltageChangedEventHandler handler)
 Remove an AnalogVoltageChangedEventHandler. More...
 
int getAdcValueChangedThreshold ()
 Gets the threshold the ADC value must change by for the event to fire. More...
 
void setAdcValueChangedThreshold (int adcValueChangedThreshold)
 Sets the threshold the ADC value must change by for the event to fire. More...
 
double getAnalogValueChangedThreshold ()
 Gets the threshold the analog value must change by for the event to fire. More...
 
void setAnalogValueChangedThreshold (double analogValueChangedThreshold)
 Sets the threshold the ADC value must change by for the event to fire. More...
 
double getAnalogVoltageChangedThreshold ()
 Gets the threshold the analog voltage must change by for the event to fire. More...
 
void setAnalogVoltageChangedThreshold (double analogVoltageChangedThreshold)
 Sets the threshold the analog voltage must change by for the event to fire. More...
 
int getAdcValue ()
 Get the ADC value, 0-4091, of the pin. More...
 
double getAnalogVoltage ()
 Gets the analog voltage (0-3.3) of this pin. More...
 
double getAnalogValue ()
 Gets the analog value (from 0-1) of this pin. More...
 
AdcReferenceLevel getReferenceLevel ()
 Gets the AdcReferenceLevel of this pin. More...
 
void setReferenceLevel (AdcReferenceLevel referenceLevel)
 Set the AdcReferenceLevel of this pin. More...
 

Public Attributes

final SoftPwm softPwm
 

Detailed Description

A GPIO/Analog pin on the board.

Member Function Documentation

◆ addAdcValueChangedEventHandler()

void io.treehopper.Pin.addAdcValueChangedEventHandler ( AdcValueChangedEventHandler  handler)

Add an AdcValueChangedEventHandler.

Parameters
handlerthe AdcValueChangedEventHandler to add

◆ addAnalogValueChangedEventHandler()

void io.treehopper.Pin.addAnalogValueChangedEventHandler ( AnalogValueChangedEventHandler  handler)

Add an AnalogValueChangedEventHandler.

Parameters
handlerthe AnalogValueChangedEventHandler to add

◆ addAnalogVoltageChangedEventHandler()

void io.treehopper.Pin.addAnalogVoltageChangedEventHandler ( AnalogVoltageChangedEventHandler  handler)

Add an AnalogVoltageChangedEventHandler.

Parameters
handlerthe AnalogVoltageChangedEventHandler to add

◆ addDigitalInValueChangedEventHandler()

void io.treehopper.Pin.addDigitalInValueChangedEventHandler ( DigitalInValueChangedEventHandler  handler)

Add a DigitalInValueCHangedEventHandler.

Parameters
handlerthe handler to add

Implements io.treehopper.interfaces.DigitalIn.

◆ getAdcValue()

int io.treehopper.Pin.getAdcValue ( )

Get the ADC value, 0-4091, of the pin.

Returns
the ADC value of the pin

◆ getAdcValueChangedThreshold()

int io.treehopper.Pin.getAdcValueChangedThreshold ( )

Gets the threshold the ADC value must change by for the event to fire.

Returns
the ADC threshold value

◆ getAnalogValue()

double io.treehopper.Pin.getAnalogValue ( )

Gets the analog value (from 0-1) of this pin.

Returns
the last-read analog value of the pin

◆ getAnalogValueChangedThreshold()

double io.treehopper.Pin.getAnalogValueChangedThreshold ( )

Gets the threshold the analog value must change by for the event to fire.

Returns
the analog threshold value

◆ getAnalogVoltage()

double io.treehopper.Pin.getAnalogVoltage ( )

Gets the analog voltage (0-3.3) of this pin.

Returns
the analog voltage of the pin

◆ getAnalogVoltageChangedThreshold()

double io.treehopper.Pin.getAnalogVoltageChangedThreshold ( )

Gets the threshold the analog voltage must change by for the event to fire.

Returns
the analog voltage threshold value

◆ getBoard()

TreehopperUsb io.treehopper.Pin.getBoard ( )

Get the board this pin belongs to.

Returns
the board this pin belongs to

◆ getDigitalValue()

boolean io.treehopper.Pin.getDigitalValue ( )

Gets the current digital value of the pin.

Returns
the digital value of the pin

If the pin is an input, this function returns the last-read value of the pin. If the pin is an output, this function returns the value this pin is currently outputting.

Implements io.treehopper.interfaces.DigitalBase.

◆ getMode()

PinMode io.treehopper.Pin.getMode ( )

Get the current PinMode of the pin.

Returns
the PinMode of the pin

◆ getPinNumber()

int io.treehopper.Pin.getPinNumber ( )

Gets the pin number of this pin.

Returns
the pin number (starting at 0)

Implements io.treehopper.interfaces.SpiChipSelectPin.

◆ getReferenceLevel()

AdcReferenceLevel io.treehopper.Pin.getReferenceLevel ( )

Gets the AdcReferenceLevel of this pin.

Returns
the ADC reference level of the pin

◆ getSpiModule()

Spi io.treehopper.Pin.getSpiModule ( )

Gets the SPI module that can use this pin as an SpiChipSelectPin.

Returns
The supported SPI module

Implements io.treehopper.interfaces.SpiChipSelectPin.

◆ makeDigitalIn()

void io.treehopper.Pin.makeDigitalIn ( )

Make this pin a digital input.

Implements io.treehopper.interfaces.DigitalIn.

◆ makeDigitalPushPullOutput()

void io.treehopper.Pin.makeDigitalPushPullOutput ( )

Make this pin a digital push-pull output.

Implements io.treehopper.interfaces.DigitalOut.

◆ removeAdcValueChangedEventHandler()

void io.treehopper.Pin.removeAdcValueChangedEventHandler ( AdcValueChangedEventHandler  handler)

Remove an AdcValueChangedEventHandler.

Parameters
handlerthe AdcValueChangedEventHandler to remove

◆ removeAnalogValueChangedEventHandler()

void io.treehopper.Pin.removeAnalogValueChangedEventHandler ( AnalogValueChangedEventHandler  handler)

Remove an AnalogValueChangedEventHandler.

Parameters
handlerthe AnalogValueChangedEventHandler to remove

◆ removeAnalogVoltageChangedEventHandler()

void io.treehopper.Pin.removeAnalogVoltageChangedEventHandler ( AnalogVoltageChangedEventHandler  handler)

Remove an AnalogVoltageChangedEventHandler.

Parameters
handlerthe AnalogVoltageChangedEventHandler to remove

◆ removeDigitalInValueChangedEventHandler()

void io.treehopper.Pin.removeDigitalInValueChangedEventHandler ( DigitalInValueChangedEventHandler  handler)

Remove a DigitalInValueCHangedEventHandler.

Parameters
handlerthe handler to remove

Implements io.treehopper.interfaces.DigitalIn.

◆ setAdcValueChangedThreshold()

void io.treehopper.Pin.setAdcValueChangedThreshold ( int  adcValueChangedThreshold)

Sets the threshold the ADC value must change by for the event to fire.

Parameters
adcValueChangedThresholdthe ADC threshold value

◆ setAnalogValueChangedThreshold()

void io.treehopper.Pin.setAnalogValueChangedThreshold ( double  analogValueChangedThreshold)

Sets the threshold the ADC value must change by for the event to fire.

Parameters
analogValueChangedThresholdthe ADC threshold value

◆ setAnalogVoltageChangedThreshold()

void io.treehopper.Pin.setAnalogVoltageChangedThreshold ( double  analogVoltageChangedThreshold)

Sets the threshold the analog voltage must change by for the event to fire.

Parameters
analogVoltageChangedThresholdthe analog voltage threshold value

◆ setDigitalValue()

void io.treehopper.Pin.setDigitalValue ( boolean  value)

Sets the digital value of this pin.

Parameters
valuethe digital value

Implements io.treehopper.interfaces.DigitalOut.

◆ setMode()

void io.treehopper.Pin.setMode ( PinMode  value)

Set this pin's mode.

Parameters
valuethe mode of the pin

◆ setReferenceLevel()

void io.treehopper.Pin.setReferenceLevel ( AdcReferenceLevel  referenceLevel)

Set the AdcReferenceLevel of this pin.

Parameters
referenceLevelthe ADC reference level to use

◆ toggleOutput()

void io.treehopper.Pin.toggleOutput ( )

Toggles the output of the pin.

Just like setDigitalValue(), this function will turn the pin into a push-pull output if it is not already a push-pull or open-drain output.

Implements io.treehopper.interfaces.DigitalOut.

Member Data Documentation

◆ softPwm

final SoftPwm io.treehopper.Pin.softPwm

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