TDuino
Convenient functionality for Arduino
Public Member Functions
TPinOutput Class Reference

Output functionality for a pin. More...

#include <TPinOutput.h>

Public Member Functions

 TPinOutput ()
 Default constructor for TPinOutput. More...
 
virtual void attach (byte pin, byte mode=OUTPUT)
 Attach the instance of TPinOutput to a pin. More...
 
void oscillate (unsigned int intervalRising, unsigned int intervalFalling, unsigned int repetitions, int initialState, int stateLowest, int stateHighest)
 Oscillates a pin using PWM. More...
 
void oscillate (unsigned int intervalRising, unsigned int intervalFalling, unsigned int repetitions, int initialState)
 
void oscillate (unsigned int interval, unsigned int repetitions, int initialState)
 
void oscillate (unsigned int interval, unsigned int repetitions)
 
void oscillate (unsigned int interval)
 
void pulse (unsigned int intervalLow, unsigned int intervalHigh, unsigned int repetitions, int initialState)
 Pulses a pin between by switching it between LOW and HIGH. More...
 
void pulse (unsigned int interval, unsigned int repetitions, int initialState)
 
void pulse (unsigned int interval, unsigned int repetitions)
 
void pulse (unsigned int interval)
 
virtual void loop ()
 The extended pins loop phase. More...
 
void stop ()
 Stop the current pin task. More...
 
- Public Member Functions inherited from TPin
 TPin ()
 Default constructor for the TPin class. More...
 
void enable (byte on)
 Enable / disable a digital pin. More...
 
void flip ()
 Flip pin state. More...
 
void off ()
 Turn off the pin. More...
 
void on ()
 Turn on the pin. More...
 
void pwm (int value)
 Set the pin to a PWM value. More...
 
int read ()
 Read the value from the pin. More...
 
byte state ()
 Get the digital state of the pin. More...
 
bool isAnalog ()
 Checks if the pin is analog. More...
 
bool hasPwm ()
 Checkt if the pin has PWM capabilities. More...
 
byte getMode ()
 Get the pin's mode. More...
 
byte getPin ()
 Get the pin's number. More...
 
- Public Member Functions inherited from TBase
 TBase ()
 Constructor for class TBase. More...
 
virtual ~TBase ()
 Destructor for class TBase. More...
 

Additional Inherited Members

- Protected Member Functions inherited from TPin
bool isPinValid (const char *token=NULL)
 
bool isPwmValid (int &value, const char *token=NULL)
 
- Protected Member Functions inherited from TBase
virtual void defaults ()
 Method used to reset all class internal variables. More...
 
- Protected Attributes inherited from TPin
byte pin
 The pin assigned to this instance.
 
byte mode
 The mode used for the pin (INPUT / INPUT_PULLUP / OUTPUT). The two high order bits are used to store additional info about the pin.
 
- Protected Attributes inherited from TBase
unsigned long loopMillis
 The value of millis() to be used within loop()
 

Detailed Description

Output functionality for a pin.

Extends the basic pin features with additional functionality like pulsing and oscillating.

Constructor & Destructor Documentation

◆ TPinOutput()

TPinOutput::TPinOutput ( )

Default constructor for TPinOutput.

Please see docs for the default constructor of TPin.

See also
TPin::TPin() attach()

Member Function Documentation

◆ attach()

void TPinOutput::attach ( byte  pin,
byte mode  UNUSED_ATTR = OUTPUT 
)
virtual

Attach the instance of TPinOutput to a pin.

Parameters
pinSee TPin::attach()
modeSee TPin::attach()

The value of mode is ignored, always set to OUTPUT.

See also
TPin()::attach()

Reimplemented from TPin.

◆ loop()

void TPinOutput::loop ( )
virtual

The extended pins loop phase.

You must ensure that this method is called regularly or else any active task will not be performed.

Reimplemented from TBase.

◆ oscillate() [1/5]

TPinOutput::oscillate ( unsigned int  intervalRising,
unsigned int  intervalFalling,
unsigned int  repetitions,
int  initialState,
int  stateLowest,
int  stateHighest 
)

Oscillates a pin using PWM.

Parameters
intervalRisingMilliseconds from low to high.
intervalFallingMilliseconds from high to low.
repetitionsNumber of repetitions to perform (default = 0).
initialStateThe initial PWM value to start from (default = 0).
stateLowestThe lowest PWM value to use (default = 0).
stateHighestThe highest PWM value to use (default = 255).

This method will oscillate a PWM signal between the lowest value defined by stateLowest and the highest value defined by stateHighest. The amount of milliseconds it takes from lowest to highest is defined with intervalRising and intervalFalling defines the equivalent for high to low. The oscillation will start at initialState and it will keep oscillating until repetitions oscillations has been performed. If repetitions is zero it will oscillate forever.

The overloaded versions of this method will use the default values described above to define the omitted parameters.

NOTE: If initialState is not equal to stateLowest or stateHighest, it will be mapped to whichever of the two values is the nearest.

◆ oscillate() [2/5]

TPinOutput::oscillate ( unsigned int  intervalRising,
unsigned int  intervalFalling,
unsigned int  repetitions,
int  initialState 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

See also
oscillate()

◆ oscillate() [3/5]

TPinOutput::oscillate ( unsigned int  interval,
unsigned int  repetitions,
int  initialState 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

interval will be used for both intervalRising and intervalFalling.

See also
oscillate()

◆ oscillate() [4/5]

TPinOutput::oscillate ( unsigned int  interval,
unsigned int  repetitions 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

interval will be used for both intervalRising and intervalFalling.

See also
oscillate()

◆ oscillate() [5/5]

TPinOutput::oscillate ( unsigned int  interval)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

interval will be used for both intervalRising and intervalFalling.

See also
oscillate()

◆ pulse() [1/4]

TPinOutput::pulse ( unsigned int  intervalLow,
unsigned int  intervalHigh,
unsigned int  repetitions,
int  initialState 
)

Pulses a pin between by switching it between LOW and HIGH.

Parameters
intervalLowMilliseconds for the pin to be LOW.
intervalHighMilliseconds for the pin to be HIGH.
repetitionsNumber of pulses to perform (default = 0).
initialStateThe initial state of the pulse (default = LOW).

This will start a pulse on the pin which will be LOW for intervalLow milliseconds and then HIGH for intervalHigh milliseconds and so on. the pulse will start as initialState and it will continue until repetition pulses have been performed. If repetitions is zero the pulse will go on forever. initialState will be clamped to a modulus by 2 of the specified value.

The overloaded versions of this method will use the default values described above to define the omitted parameters.

◆ pulse() [2/4]

TPinOutput::pulse ( unsigned int  interval,
unsigned int  repetitions,
int  initialState 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

interval will be used as both intervalLow and intervalHigh

See also
pulse()

◆ pulse() [3/4]

TPinOutput::pulse ( unsigned int  interval,
unsigned int  repetitions 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

interval will be used as both intervalLow and intervalHigh

See also
pulse()

◆ pulse() [4/4]

TPinOutput::pulse ( unsigned int  interval)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

interval will be used as both intervalLow and intervalHigh

See also
pulse()

◆ stop()

void TPinOutput::stop ( )

Stop the current pin task.

If you want to abort / stop an active oscillate or pulse you must call this method.