Voffcon Esp32 device server
 All Classes Functions
PinWatch Class Reference

Used to monitor a pin. Can monitor if a pin value changes more or less than something and can monitor if a certain amount of time has passed. More...

Public Member Functions

 PinWatch (GPin *gPin, unsigned int pinValueMargin, int sampleTotalCount, unsigned long sampleInterval, unsigned long minLogInterval)
 PinWatch. More...
 
 PinWatch (const PinWatch &pinWatch)
 Copy constructor, not used by default More...
 
void serialPrintValues ()
 
void serialPrintLnValues ()
 
bool check (unsigned long currentTimeInMillis)
 Checks if enough time has passed sinse the last check More...
 
void reset (unsigned long currentTimeInMillis, bool updateLastPinValue=true, bool updateMinLogInterval=true)
 Resets the timer sampleInterva and if update parameters are both true, update the last pin value and the minLogInterval timer as well. More...
 
int getPinNumber ()
 Get a number of the pin (not the index of a pin) More...
 
int getPinValue ()
 Get a value of a pin More...
 
int getPinType ()
 Get a pin type (PINTYPE) as a integer More...
 
bool isValidPin ()
 Checks if a pin is valid More...
 
String toJson ()
 Exports the object to a Json string More...
 

Detailed Description

Used to monitor a pin. Can monitor if a pin value changes more or less than something and can monitor if a certain amount of time has passed.

Constructor & Destructor Documentation

PinWatch::PinWatch ( GPin gPin,
unsigned int  pinValueMargin,
int  sampleTotalCount,
unsigned long  sampleInterval,
unsigned long  minLogInterval 
)

PinWatch.

Constructor for a PinWatch

Parameters
gPinValid GPin to watch
pinValueMarginHow much must a value of a pin change to recive a positive check
sampleTotalCountHow many samples of a pin value should be averaged
sampleIntervalHow many milliseconds must pass between a sample is taken from a pin value
minLogIntervalHow many milliseconds between forsed positive checks (f.example how many milliseconds between logs) Pin values are not taken into account here
Returns
True if a PinWatch is added to the list, otherwise false
PinWatch::PinWatch ( const PinWatch pinWatch)

Copy constructor, not used by default

Parameters
pinWatchThe other object to copy values from

Member Function Documentation

bool PinWatch::check ( unsigned long  currentTimeInMillis)

Checks if enough time has passed sinse the last check

Parameters
currentTimeInMillisThe time that must pass before a check returns true
Returns
true if enough time has passed. false if not.
int PinWatch::getPinNumber ( )

Get a number of the pin (not the index of a pin)

Returns
Success: Returns the number of the pin. Fail: Returns -1
int PinWatch::getPinType ( )

Get a pin type (PINTYPE) as a integer

Returns
Success: Returns a positive integer value. Fail: Returns -1
int PinWatch::getPinValue ( )

Get a value of a pin

Returns
Success: Returns the value of the pin. Fail: Returns -1
bool PinWatch::isValidPin ( )

Checks if a pin is valid

void PinWatch::reset ( unsigned long  currentTimeInMillis,
bool  updateLastPinValue = true,
bool  updateMinLogInterval = true 
)

Resets the timer sampleInterva and if update parameters are both true, update the last pin value and the minLogInterval timer as well.

Parameters
currentTimeInMillisCurrent time usually gotten with the millis() function
updateLastPinValueIf true, the last pin value is updated with the current one and reset the minLogInterval as well
updateMinLogIntervalIf True, reset the minLogInterval as well
Returns
Success:The index of the pinWatch in the list. fail : -1 if the pin number was not found.
String PinWatch::toJson ( )

Exports the object to a Json string

Returns
A json object String

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