Voffcon Esp32 device server
 All Classes Functions
GPins Class Reference

This class stores GPin objects which connect the server to device hardware pins para/> More...

Public Member Functions

int addPin (const char *strPinName, PINTYPE pinType, int pinNumber, int pinValue)
 Adds a pin More...
 
boolean setValue (int pinNumber, int newValue)
 Sets the value of a pin with the given number. More...
 
boolean exists (int pinNumber)
 Checks if a pin with a given number exits. More...
 
GPinget (int pinNumber)
 Gets a pointer to a GPin More...
 
int getValue (int pinNumber)
 Gets a value of a pin More...
 
int count ()
 Gets the number of pins. More...
 
String toJson ()
 Returns all pin values in a json array a key-value Json object with the '{' and '}' around it. where first key is the first in the index with the key as the GPO key and the value is the last value set to that key. More...
 
String JsonPinout ()
 Creates a JSON object containg all pins name and their number. More...
 
 GPins ()
 Constructor for the GPins Object More...
 

Detailed Description

This class stores GPin objects which connect the server to device hardware pins para/>

Constructor & Destructor Documentation

GPins::GPins ( )

Constructor for the GPins Object

Member Function Documentation

int GPins::addPin ( const char *  strPinName,
PINTYPE  pinType,
int  pinNumber,
int  pinValue 
)

Adds a pin

Parameters
strPinNameThe name of the pin
pinTypeType of the pin

Possible types of a pin are:

PINTYPE_INPUT_ANALOG : "Read method analogRead shall be used"

PINTYPE_INPUT_DIGITAL : "Read method digitalRead shall be used"

PINTYPE_OUTPUT_ANALOG : "Write method analogWrite shall be used"

PINTYPE_OUTPUT_DIGITAL : "Write method digitalWrite shall be used"

PINTYPE_OUTPUT_VIRTUAL : "A pin not connected to hardware, but can store values"

Parameters
pinNumberNumber of the pin (GPIO number)
pinValueStarting value of the pin. If the pin type is an input pin then the value will be read from the hardware and this value ignored.
Returns
The number of pins after the pin was added.
int GPins::count ( )

Gets the number of pins.

Returns
Number of GPin objects in the GPins object
boolean GPins::exists ( int  pinNumber)

Checks if a pin with a given number exits.

Parameters
pinNumber
Returns
true if a pin was found otherwise false
GPin * GPins::get ( int  pinNumber)

Gets a pointer to a GPin

Parameters
pinNumberThe pin number to search for
Returns
A pointer to the GPin ojbect. Returns NULL if pin is not found
int GPins::getValue ( int  pinNumber)

Gets a value of a pin

Parameters
pinNumberThe pin to get the value from
Returns

The value of the given pin.

Returns -1 if pinNumber was not found

String GPins::JsonPinout ( )

Creates a JSON object containg all pins name and their number.

Returns
A string formatted as a JSON object which contains all pin names and number.
boolean GPins::setValue ( int  pinNumber,
int  newValue 
)

Sets the value of a pin with the given number.

Parameters
pinNumberThe number of the pin to search for
newValueThe new value to be set
Returns
True if value was set. False if value was not set because no pin with given pin number was not found.
String GPins::toJson ( )

Returns all pin values in a json array a key-value Json object with the '{' and '}' around it. where first key is the first in the index with the key as the GPO key and the value is the last value set to that key.

Returns
A Json object string containing status of all pins in the GPins object

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