Serial Wombat Arduino Library
Public Member Functions | List of all members
SerialWombatPulseOnChange Class Reference

Monitors other pin(s) or public data in the Serial Wombat chip and generates a pin pulse on change. More...

#include <SerialWombatPulseOnChange.h>

Inheritance diagram for SerialWombatPulseOnChange:
SerialWombatPin

Public Member Functions

 SerialWombatPulseOnChange (SerialWombatChip &serialWombat)
 Class constructor for SerialWombatPulseOnChange. More...
 
int16_t begin (uint8_t pin, SerialWombatPinState_t activeMode=SW_HIGH, SerialWombatPinState_t inactiveMode=SW_LOW, uint16_t pulseOnTime=50, uint16_t pulseOffTime=50, uint8_t orNotAnd=1, uint16_t PWMperiod=0, uint16_t PWMdutyCycle=0x8000)
 Initialization routine for SerialWombatPulseOnChange. More...
 
int16_t setEntryOnChange (uint8_t entryID, uint8_t sourcePin)
 Configure a change entry to pulse when a pin or public data changes. More...
 
int16_t setEntryOnIncrease (uint8_t entryID, uint8_t sourcePin)
 Configure a change entry to pulse when a pin or public data increases. More...
 
int16_t setEntryOnDecrease (uint8_t entryID, uint8_t sourcePin)
 Configure a change entry to pulse when a pin or public data Decreases. More...
 
int16_t setEntryOnEqualValue (uint8_t entryID, uint8_t sourcePin, uint16_t value)
 Configure a change entry to pulse when a pin or public data equals a specified value. More...
 
int16_t setEntryOnLessThanValue (uint8_t entryID, uint8_t sourcePin, uint16_t value)
 Configure a change entry to pulse when a pin or public data is below a specified value. More...
 
int16_t setEntryOnGreaterThanValue (uint8_t entryID, uint8_t sourcePin, uint16_t value)
 Configure a change entry to pulse when a pin or public data is above a specified value. More...
 
int16_t setEntryOnNotEqualValue (uint8_t entryID, uint8_t sourcePin, uint16_t value)
 Configure a change entry to pulse when a pin or public data is not equal to a specified value. More...
 
int16_t setEntryOnPinsEqual (uint8_t entryID, uint8_t sourcePin, uint8_t secondPin)
 Configure a change entry to pulse when a pin or public data equals a second pin or public data's value. More...
 
int16_t setEntryOnPinsNotEqual (uint8_t entryID, uint8_t sourcePin, uint8_t secondPin)
 Configure a change entry to pulse when a pin or public data is not equal to a second pin or public data's value. More...
 
int16_t setEntryOnPinGTPin (uint8_t entryID, uint8_t sourcePin, uint8_t secondPin)
 Configure a change entry to pulse when a pin or public data is greater than a second pin or public data's value. More...
 
int16_t setEntryOnPinLTPin (uint8_t entryID, uint8_t sourcePin, uint8_t secondPin)
 Configure a change entry to pulse when a pin or public data is less than a second pin or public data's value. More...
 
int16_t setEntryOnPinCrossValue (uint8_t entryID, uint8_t sourcePin, uint16_t value)
 Configure a change entry to pulse when a pin or public data crosses a specified value. More...
 
int16_t setEntryOnPinCrossAscending (uint8_t entryID, uint8_t sourcePin, uint16_t value)
 Configure a change entry to pulse when a pin or public data rises above a specified value. More...
 
int16_t setEntryOnPinCrossDescending (uint8_t entryID, uint8_t sourcePin, uint16_t value)
 Configure a change entry to pulse when a pin or public data falls below a specified value. More...
 
int16_t setEntryOnPinWithinRange (uint8_t entryID, uint8_t sourcePin, uint16_t lowValue, uint16_t highValue)
 Configure a change entry to pulse when a pin or public data is within a specified range. More...
 
int16_t setEntryOnPinOutsideRange (uint8_t entryID, uint8_t sourcePin, uint16_t lowValue, uint16_t highValue)
 Configure a change entry to pulse when a pin or public data is within a specified range. More...
 
- Public Member Functions inherited from SerialWombatPin
 SerialWombatPin (SerialWombatChip &serialWombatChip)
 Instantiates a Serial Wombat Pin. More...
 
 SerialWombatPin (SerialWombatChip &serialWombatChip, uint8_t pin)
 Instantiates a Serial Wombat Pin. More...
 
uint16_t readPublicData ()
 Read the 16 Bit public data associated with this pin. More...
 
void pinMode (uint8_t mode, bool pullDown=false, bool openDrain=false)
 Set pin to INPUT or OUTPUT, with options for pull Ups and open Drain settings. More...
 
void digitalWrite (uint8_t val)
 Set output pin High or Low. More...
 
int digitalRead ()
 Reads the state of the Pin. More...
 
uint16_t writePublicData (uint16_t value)
 Write a 16 bit value to this pin. More...
 
uint8_t pin ()
 Returns the current SW pin number. Used primarily for virtual calls by derived classes. More...
 
uint8_t swPinModeNumber ()
 Returns the Mode number. Used primarily by derived classes to populate packet data. More...
 

Additional Inherited Members

- Protected Attributes inherited from SerialWombatPin
uint8_t _pin = 255
 
SerialWombatChip_sw
 
uint8_t _pinMode = 0
 

Detailed Description

Monitors other pin(s) or public data in the Serial Wombat chip and generates a pin pulse on change.

This class controls the Pulse on Change pin mode of the Serial Wombat Chip. Pulse on Change is useful to generate a pulse that can drive an interrupt on the host Arduino, or for creating user alerts such as LED pulses or buzzer tones that acknowledge data reception or human input.

For instance, a pulse could be generated when the output value of a rotary encoder state machine on other pins changes value. Or an LED could be pulsed to command traffic on the Serial Wombat chip by making it pulse when SW_DATA_SOURCE_PACKETS_RECEIVED changes.

Reference the Public Data and Pin Modes section on the main page to learn more about public data and how public data on the Serial Wombat chip works.

The each pin can monitor up to 8 other pins or data sources for changes. A pulse will be generated when any of the criteria (orNotAnd == 1) or all (simultaneously) of the criteria (orNotAnd == 0) are met. Criteria can be any of the following:

A video Tutorial on this pin mode is available:

TODO

TODO https://youtu.be/

Constructor & Destructor Documentation

◆ SerialWombatPulseOnChange()

SerialWombatPulseOnChange::SerialWombatPulseOnChange ( SerialWombatChip serialWombat)
inline

Class constructor for SerialWombatPulseOnChange.

Parameters
serialWombatThe Serial Wombat chip on which the SerialWombatPulseTimer pinmode will be run

Member Function Documentation

◆ begin()

int16_t SerialWombatPulseOnChange::begin ( uint8_t  pin,
SerialWombatPinState_t  activeMode = SW_HIGH,
SerialWombatPinState_t  inactiveMode = SW_LOW,
uint16_t  pulseOnTime = 50,
uint16_t  pulseOffTime = 50,
uint8_t  orNotAnd = 1,
uint16_t  PWMperiod = 0,
uint16_t  PWMdutyCycle = 0x8000 
)
inline

Initialization routine for SerialWombatPulseOnChange.

Parameters
pinThe Serial Wombat pin that will pulse on change
pulseOnTimeThe Number of mS that the pulse will last when the true condition occurs. Set to 65535 to stay on constantly until condition is false
pulseOffTimethe number of mS that the pulse will stay off until another pulse can be triggered.
orNotAnd0 = all initialized entries must be true to generate pulse. 1 = Any intitialized entry will generate a pulse if true
PWMperiodthe period in uS of ouput pulse. Set to 0 for constant Active.
PWMdutyCyclefor output pulse. Only valid if PWM Period is not 0.

◆ setEntryOnChange()

int16_t SerialWombatPulseOnChange::setEntryOnChange ( uint8_t  entryID,
uint8_t  sourcePin 
)
inline

Configure a change entry to pulse when a pin or public data changes.

Parameters
entryIDto set one entry in this pin's change entry table to OnChange. Valid values are 0-7
sourcePinPin or data source to monitor for change. Enumerated types should be casted to uint8_t
Returns
returns a number 0 or greater for success, negative numbers indicate an error occured.

◆ setEntryOnDecrease()

int16_t SerialWombatPulseOnChange::setEntryOnDecrease ( uint8_t  entryID,
uint8_t  sourcePin 
)
inline

Configure a change entry to pulse when a pin or public data Decreases.

Parameters
entryIDto set one entry in this pin's change entry table to OnChange. Valid values are 0-7
sourcePinPin or data source to monitor for change. Enumerated types should be casted to uint8_t
Returns
returns a number 0 or greater for success, negative numbers indicate an error occured.

◆ setEntryOnEqualValue()

int16_t SerialWombatPulseOnChange::setEntryOnEqualValue ( uint8_t  entryID,
uint8_t  sourcePin,
uint16_t  value 
)
inline

Configure a change entry to pulse when a pin or public data equals a specified value.

Parameters
entryIDto set one entry in this pin's change entry table to OnChange. Valid values are 0-7
sourcePinPin or data source to monitor for change. Enumerated types should be casted to uint8_t
valueA constant value to be compared against the public data specified by sourcePin
Returns
returns a number 0 or greater for success, negative numbers indicate an error occured.

◆ setEntryOnGreaterThanValue()

int16_t SerialWombatPulseOnChange::setEntryOnGreaterThanValue ( uint8_t  entryID,
uint8_t  sourcePin,
uint16_t  value 
)
inline

Configure a change entry to pulse when a pin or public data is above a specified value.

Parameters
entryIDto set one entry in this pin's change entry table to OnChange. Valid values are 0-7
sourcePinPin or data source to monitor for change. Enumerated types should be casted to uint8_t
valueA constant value to be compared against the public data specified by sourcePin
Returns
returns a number 0 or greater for success, negative numbers indicate an error occured.

◆ setEntryOnIncrease()

int16_t SerialWombatPulseOnChange::setEntryOnIncrease ( uint8_t  entryID,
uint8_t  sourcePin 
)
inline

Configure a change entry to pulse when a pin or public data increases.

Parameters
entryIDto set one entry in this pin's change entry table to OnChange. Valid values are 0-7
sourcePinPin or data source to monitor for change. Enumerated types should be casted to uint8_t
Returns
returns a number 0 or greater for success, negative numbers indicate an error occured.

◆ setEntryOnLessThanValue()

int16_t SerialWombatPulseOnChange::setEntryOnLessThanValue ( uint8_t  entryID,
uint8_t  sourcePin,
uint16_t  value 
)
inline

Configure a change entry to pulse when a pin or public data is below a specified value.

Parameters
entryIDto set one entry in this pin's change entry table to OnChange. Valid values are 0-7
sourcePinPin or data source to monitor for change. Enumerated types should be casted to uint8_t
valueA constant value to be compared against the public data specified by sourcePin
Returns
returns a number 0 or greater for success, negative numbers indicate an error occured.

◆ setEntryOnNotEqualValue()

int16_t SerialWombatPulseOnChange::setEntryOnNotEqualValue ( uint8_t  entryID,
uint8_t  sourcePin,
uint16_t  value 
)
inline

Configure a change entry to pulse when a pin or public data is not equal to a specified value.

Parameters
entryIDto set one entry in this pin's change entry table to OnChange. Valid values are 0-7
sourcePinPin or data source to monitor for change. Enumerated types should be casted to uint8_t
valueA constant value to be compared against the public data specified by sourcePin
Returns
returns a number 0 or greater for success, negative numbers indicate an error occured.

◆ setEntryOnPinCrossAscending()

int16_t SerialWombatPulseOnChange::setEntryOnPinCrossAscending ( uint8_t  entryID,
uint8_t  sourcePin,
uint16_t  value 
)

Configure a change entry to pulse when a pin or public data rises above a specified value.

Parameters
entryIDto set one entry in this pin's change entry table to OnChange. Valid values are 0-7
sourcePinPin or data source to monitor for change. Enumerated types should be casted to uint8_t
valueA constant value to be compared against the public data specified by sourcePin
Returns
returns a number 0 or greater for success, negative numbers indicate an error occured.

◆ setEntryOnPinCrossDescending()

int16_t SerialWombatPulseOnChange::setEntryOnPinCrossDescending ( uint8_t  entryID,
uint8_t  sourcePin,
uint16_t  value 
)

Configure a change entry to pulse when a pin or public data falls below a specified value.

Parameters
entryIDto set one entry in this pin's change entry table to OnChange. Valid values are 0-7
sourcePinPin or data source to monitor for change. Enumerated types should be casted to uint8_t
valueA constant value to be compared against the public data specified by sourcePin
Returns
returns a number 0 or greater for success, negative numbers indicate an error occured.

◆ setEntryOnPinCrossValue()

int16_t SerialWombatPulseOnChange::setEntryOnPinCrossValue ( uint8_t  entryID,
uint8_t  sourcePin,
uint16_t  value 
)

Configure a change entry to pulse when a pin or public data crosses a specified value.

Parameters
entryIDto set one entry in this pin's change entry table to OnChange. Valid values are 0-7
sourcePinPin or data source to monitor for change. Enumerated types should be casted to uint8_t
valueA constant value to be compared against the public data specified by sourcePin
Returns
returns a number 0 or greater for success, negative numbers indicate an error occured.

◆ setEntryOnPinGTPin()

int16_t SerialWombatPulseOnChange::setEntryOnPinGTPin ( uint8_t  entryID,
uint8_t  sourcePin,
uint8_t  secondPin 
)

Configure a change entry to pulse when a pin or public data is greater than a second pin or public data's value.

Parameters
entryIDto set one entry in this pin's change entry table to OnChange. Valid values are 0-7
sourcePinPin or data source to monitor for change. Enumerated types should be casted to uint8_t
secondPinPin or public data whose data will be compared to the public data from sourcePin
Returns
returns a number 0 or greater for success, negative numbers indicate an error occured.

◆ setEntryOnPinLTPin()

int16_t SerialWombatPulseOnChange::setEntryOnPinLTPin ( uint8_t  entryID,
uint8_t  sourcePin,
uint8_t  secondPin 
)

Configure a change entry to pulse when a pin or public data is less than a second pin or public data's value.

Parameters
entryIDto set one entry in this pin's change entry table to OnChange. Valid values are 0-7
sourcePinPin or data source to monitor for change. Enumerated types should be casted to uint8_t
secondPinPin or public data whose data will be compared to the public data from sourcePin
Returns
returns a number 0 or greater for success, negative numbers indicate an error occured.

◆ setEntryOnPinOutsideRange()

int16_t SerialWombatPulseOnChange::setEntryOnPinOutsideRange ( uint8_t  entryID,
uint8_t  sourcePin,
uint16_t  lowValue,
uint16_t  highValue 
)

Configure a change entry to pulse when a pin or public data is within a specified range.

Parameters
entryIDto set one entry in this pin's change entry table to OnChange. Valid values are 0-7
sourcePinPin or data source to monitor for change. Enumerated types should be casted to uint8_t
lowValueA constant value to be compared against the public data specified by sourcePin
highValueA constant value to be compared against the public data specified by sourcePin
Returns
returns a number 0 or greater for success, negative numbers indicate an error occured.

◆ setEntryOnPinsEqual()

int16_t SerialWombatPulseOnChange::setEntryOnPinsEqual ( uint8_t  entryID,
uint8_t  sourcePin,
uint8_t  secondPin 
)
inline

Configure a change entry to pulse when a pin or public data equals a second pin or public data's value.

Parameters
entryIDto set one entry in this pin's change entry table to OnChange. Valid values are 0-7
sourcePinPin or data source to monitor for change. Enumerated types should be casted to uint8_t
secondPinPin or public data whose data will be compared to the public data from sourcePin
Returns
returns a number 0 or greater for success, negative numbers indicate an error occured.

◆ setEntryOnPinsNotEqual()

int16_t SerialWombatPulseOnChange::setEntryOnPinsNotEqual ( uint8_t  entryID,
uint8_t  sourcePin,
uint8_t  secondPin 
)
inline

Configure a change entry to pulse when a pin or public data is not equal to a second pin or public data's value.

Parameters
entryIDto set one entry in this pin's change entry table to OnChange. Valid values are 0-7
sourcePinPin or data source to monitor for change. Enumerated types should be casted to uint8_t
secondPinPin or public data whose data will be compared to the public data from sourcePin
Returns
returns a number 0 or greater for success, negative numbers indicate an error occured.

◆ setEntryOnPinWithinRange()

int16_t SerialWombatPulseOnChange::setEntryOnPinWithinRange ( uint8_t  entryID,
uint8_t  sourcePin,
uint16_t  lowValue,
uint16_t  highValue 
)

Configure a change entry to pulse when a pin or public data is within a specified range.

Parameters
entryIDto set one entry in this pin's change entry table to OnChange. Valid values are 0-7
sourcePinPin or data source to monitor for change. Enumerated types should be casted to uint8_t
lowValueA constant value to be compared against the public data specified by sourcePin
highValueA constant value to be compared against the public data specified by sourcePin
Returns
returns a number 0 or greater for success, negative numbers indicate an error occured.