Allow setting the ADC pin of a MQUnifiedsensor object.

The ADC pin can only be set when using the full/long constructor, causing the short constructor (name/type only) useless because the pin is unset.

Also default the ADC pin to 1 for consistency sake.
This commit is contained in:
Adriano Cunha 2023-04-11 14:30:49 -07:00
parent b6bff185f3
commit f7f2c1f3f4
2 changed files with 5 additions and 1 deletions

View File

@ -41,6 +41,9 @@ void MQUnifiedsensor::setVoltResolution(float voltage_resolution)
{
_VOLT_RESOLUTION = voltage_resolution;
}
void MQUnifiedsensor::setPin(int pin) {
this->_pin = pin;
}
void MQUnifiedsensor::setRegressionMethod(int regressionMethod)
{
//this->_regressionMethod = regressionMethod;

View File

@ -22,6 +22,7 @@ class MQUnifiedsensor
void setB(float b);
void setRegressionMethod(int regressionMethod);
void setVoltResolution(float voltage_resolution = 5);
void setPin(int pin = 1);
void serialDebug(bool onSetup = false); //Show on serial port information about sensor
void setADC(int value); //For external ADC Usage
@ -47,7 +48,7 @@ class MQUnifiedsensor
private:
/************************Private vars************************************/
byte _pin;
byte _pin = 1;
byte _firstFlag = false;
float _VOLT_RESOLUTION = 5.0; // if 3.3v use 3.3
float _RL = 10; //Value in KiloOhms