Replaced two methods with a new one ie temperatureAndATMPressureFromBMP280 and added a missing delay to let the 3V3 rail stabilize
This commit is contained in:
parent
d958d5f8c2
commit
a86ed2d318
@ -10,7 +10,7 @@ uint8_t WSPeripherals::init()
|
||||
pinMode(_boardConfig.LDOEnable, OUTPUT);
|
||||
_3V3PowerRail(OFF);
|
||||
pinMode(_boardConfig.LDRVSensEnable, OUTPUT);
|
||||
digitalWrite(_boardConfig.LDRVSensEnable, HIGH); //High means that it is disabled and low is active /!\
|
||||
digitalWrite(_boardConfig.LDRVSensEnable, HIGH); //High means that it is disabled and low is active /!\/
|
||||
pinMode(_boardConfig.BATVSensEnable, OUTPUT);
|
||||
digitalWrite(_boardConfig.BATVSensEnable, LOW);
|
||||
|
||||
@ -41,15 +41,15 @@ uint8_t WSPeripherals::init()
|
||||
uint8_t WSPeripherals::initExternalPeripherals()
|
||||
{
|
||||
uint8_t toReturn(0);
|
||||
_BMP280.setSampling( Adafruit_BMP280::MODE_FORCED,
|
||||
Adafruit_BMP280::SAMPLING_X16,
|
||||
Adafruit_BMP280::SAMPLING_X16,
|
||||
Adafruit_BMP280::FILTER_X16,
|
||||
Adafruit_BMP280::STANDBY_MS_4000);
|
||||
|
||||
|
||||
toReturn |= _BMP280.begin(0x76);
|
||||
toReturn |= _HTU21.begin() << 1;
|
||||
toReturn |= _NRF.begin() << 2;
|
||||
|
||||
//We disable the I2C internal pullups :
|
||||
digitalWrite(SDA, LOW);
|
||||
digitalWrite(SCL, LOW);
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
@ -73,14 +73,20 @@ int WSPeripherals::sunlightMeasurement()
|
||||
return rawSunlightMeasurement;
|
||||
}
|
||||
|
||||
float WSPeripherals::temperatureFromBMP280()
|
||||
void WSPeripherals::temperatureAndATMPressureFromBMP280(float *temperature, float *ATMPressure)
|
||||
{
|
||||
return _BMP280.readTemperature();
|
||||
}
|
||||
|
||||
float WSPeripherals::ATMPressure()
|
||||
{
|
||||
return _BMP280.readPressure();
|
||||
if(!temperature && !ATMPressure)return;
|
||||
|
||||
_BMP280.setSampling( Adafruit_BMP280::MODE_FORCED,
|
||||
Adafruit_BMP280::SAMPLING_X16,
|
||||
Adafruit_BMP280::SAMPLING_X16,
|
||||
Adafruit_BMP280::FILTER_X16,
|
||||
Adafruit_BMP280::STANDBY_MS_4000);
|
||||
if(temperature)
|
||||
*temperature = _BMP280.readTemperature();
|
||||
|
||||
if(ATMPressure)
|
||||
*ATMPressure = _BMP280.readPressure();
|
||||
}
|
||||
|
||||
float WSPeripherals::temperatureFromHTU21()
|
||||
@ -101,7 +107,15 @@ float WSPeripherals::compensatedHumidity()
|
||||
void WSPeripherals::_3V3PowerRail(State state)
|
||||
{
|
||||
digitalWrite(_boardConfig.LDOEnable, state);
|
||||
if(state) //We let some time for the voltage to stabilize on the rail.
|
||||
delay(2);
|
||||
}
|
||||
|
||||
const RF24 &WSPeripherals::getRadio(){return _NRF;}
|
||||
void WSPeripherals::applyRadioConfig(uint8_t channel = RADIO_CHANNEL, uint8_t paLevel = RADIO_PA_LEVEL, rf24_datarate_e datarate = RADIO_DATARATE);
|
||||
|
||||
void WSPeripherals::applyRadioConfig(uint8_t channel, uint8_t paLevel, rf24_datarate_e datarate)
|
||||
{
|
||||
_NRF.setChannel(channel);
|
||||
_NRF.setPALevel(paLevel);
|
||||
_NRF.setDataRate(datarate);
|
||||
}
|
||||
|
@ -36,8 +36,7 @@ class WSPeripherals
|
||||
|
||||
float batteryVoltage();
|
||||
int sunlightMeasurement();
|
||||
float temperatureFromBMP280();
|
||||
float ATMPressure();
|
||||
void temperatureAndATMPressureFromBMP280(float *temperature = NULL, float *ATMPressure = NULL);
|
||||
float temperatureFromHTU21();
|
||||
float humidity();
|
||||
float compensatedHumidity();
|
||||
@ -45,12 +44,7 @@ class WSPeripherals
|
||||
/*
|
||||
* Before calling this method, externalPeripherals(ON) and initExternalPeripherals() must be called respectively
|
||||
*/
|
||||
void applyRadioConfig(uint8_t channel, uint8_t paLevel, rf24_datarate_e datarate)
|
||||
{
|
||||
_NRF.setChannel(channel);
|
||||
_NRF.setPALevel(paLevel);
|
||||
_NRF.setDataRate(rf24_datarate_e);
|
||||
}
|
||||
void applyRadioConfig(uint8_t channel = RADIO_CHANNEL, uint8_t paLevel = RADIO_PA_LEVEL, rf24_datarate_e datarate = RADIO_DATARATE);
|
||||
const RF24 &getRadio();
|
||||
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user