Voffcon Esp32 device server
|
Class for handling GPIO pins Use it to read from or write to a pin More...
Public Member Functions | |
GPin (const char *strPinName, PINTYPE pinType, int pinNumber, int pinValue) | |
Constructor for the GPin object You will need to porovide name, type, number and a starting value of the pin More... | |
~GPin () | |
Deconstructor for the pin More... | |
void | setName (const char *strPinName) |
Assigns a name to a specific pin More... | |
String | getName () |
Gets a pin name More... | |
void | setValue (int value) |
Sets a new value to a pin If the pin is of the type PINTYPE_OUTPUT_ANALOG or PINTYPE_OUTPUT_DIGITAL Then the GPIO pin of the device will be changed to this value. More... | |
int | getValue (bool readValueFromHardware=true) |
Read a pin value. If input type is PINTYPE_INPUT_DIGITAL or PINTYPE_INPUT_ANALOG and readValueFromHardware is true then a read will be maid directly to the hardwarepin. otherwise the old member value will be returned. More... | |
int | getNumber () |
Get the number of a pin. More... | |
int | getType () |
Gets the type of the pin More... | |
String | toJson () |
Converts the pin -name, -number, -type and -value to a valid json object string More... | |
String | toJsonKeyValue () |
Returns pin number and value as a Key value pair with no surrounding curly brackets More... | |
Class for handling GPIO pins Use it to read from or write to a pin
GPin::GPin | ( | const char * | strPinName, |
PINTYPE | pinType, | ||
int | pinNumber, | ||
int | pinValue | ||
) |
Constructor for the GPin object You will need to porovide name, type, number and a starting value of the pin
strPinName | Name of the pin |
pinType | Type of the pin |
Possible pin types 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"
pinNumber | Number of the pin. That is the GPIO number |
pinValue | The value to set the pin to |
GPin::~GPin | ( | ) |
Deconstructor for the pin
String GPin::getName | ( | ) |
Gets a pin name
int GPin::getNumber | ( | ) |
Get the number of a pin.
You can then use this number to search for the index of the pin in the GPins object
int GPin::getType | ( | ) |
Gets the type of the pin
Possible pin types 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"
int GPin::getValue | ( | bool | readValueFromHardware = true | ) |
Read a pin value. If input type is PINTYPE_INPUT_DIGITAL or PINTYPE_INPUT_ANALOG and readValueFromHardware is true then a read will be maid directly to the hardwarepin. otherwise the old member value will be returned.
readValueFromHardware |
void GPin::setName | ( | const char * | strPinName | ) |
Assigns a name to a specific pin
strPinName | Name of the pin |
void GPin::setValue | ( | int | value | ) |
Sets a new value to a pin If the pin is of the type PINTYPE_OUTPUT_ANALOG or PINTYPE_OUTPUT_DIGITAL Then the GPIO pin of the device will be changed to this value.
value | The new value to set |
String GPin::toJson | ( | ) |
Converts the pin -name, -number, -type and -value to a valid json object string
String GPin::toJsonKeyValue | ( | ) |
Returns pin number and value as a Key value pair with no surrounding curly brackets