Skip to content

Commit

Permalink
Clean warning compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
khalil Kababe committed Jul 2, 2018
1 parent cccff8d commit 4839282
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 31 deletions.
4 changes: 3 additions & 1 deletion src/core/CoolBoard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ void CoolBoard::updateFirmware(String firmwareVersion, String firmwareUrl,
delete this->coolWifi;
INFO_LOG("Starting firmware update...");
t_httpUpdate_return ret =
ESPhttpUpdate.update(firmwareUrl, "", firmwareUrlFingerprint, true);
ESPhttpUpdate.update(firmwareUrl, "", firmwareUrlFingerprint);
switch (ret) {
case HTTP_UPDATE_FAILED:
ERROR_VAR("HTTP Update failed, code:", ESPhttpUpdate.getLastError());
Expand All @@ -668,6 +668,8 @@ void CoolBoard::updateFirmware(String firmwareVersion, String firmwareUrl,
case HTTP_UPDATE_OK:
INFO_LOG("HTTP update succeeded!");
break;
case HTTP_UPDATE_NO_UPDATES:
break;
}
} else {
ERROR_LOG("Cannot connect to Wifi, cancelling firmware update...");
Expand Down
4 changes: 2 additions & 2 deletions src/core/CoolBoardSensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ void CoolBoardSensors::begin() {
}
this->setEnvSensorSettings();
delay(100);
uint8_t envSensorStatus = this->envSensor.begin();
this->envSensor.begin();
// Make sure sensors had enough time to turn on.
// BME280 requires 2ms to start up.
delay(1000);
DEBUG_VAR("BME280 status after begin is:", envSensorStatus);
DEBUG_VAR("BME280 status after begin is:", this->envSensor.begin());
DEBUG_LOG("Builtin sensors started");
}

Expand Down
31 changes: 15 additions & 16 deletions src/core/ExternalSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class BaseExternalSensor {
BaseExternalSensor() {}
virtual uint8_t begin() { return (-2); }
virtual float read() { return (-2); }
virtual float read(int16_t *a) { return (-42, 42); }
virtual float read(int16_t *a) { return (-42); }
virtual float read(int16_t *a, int16_t *b, float *c) { return (-42.42); }
virtual float read(uint32_t *a, uint32_t *b, uint32_t *c) { return (-42.42); }
virtual float read(int16_t *a, int16_t *b, int16_t *c, int16_t *d) {
Expand Down Expand Up @@ -74,7 +74,7 @@ template <class T> class ExternalSensor : public BaseExternalSensor {

template <> class ExternalSensor<NDIR_I2C> : public BaseExternalSensor {
public:
ExternalSensor(uint8_t i2c_addr) { sensor = NDIR_I2C(i2c_addr); }
ExternalSensor(uint8_t i2c_addr) : sensor(i2c_addr){}
virtual uint8_t begin() {
if (sensor.begin()) {
delay(10000);
Expand All @@ -93,7 +93,7 @@ template <> class ExternalSensor<NDIR_I2C> : public BaseExternalSensor {
}

private:
NDIR_I2C sensor = NULL;
NDIR_I2C sensor;
};

template <>
Expand Down Expand Up @@ -169,23 +169,17 @@ template <> class ExternalSensor<Adafruit_CCS811> : public BaseExternalSensor {
;
float T = sensor.calculateTemperature();
sensor.setTempOffset(T - 25.0);
return(0);
}

virtual float read(int16_t *a, int16_t *b, float *c) {
uint16_t internC, internV;
float internT;

if (sensor.available()) {
internT = sensor.calculateTemperature();
*c = sensor.calculateTemperature();
if (!sensor.readData()) {
internC = sensor.geteCO2();
internV = sensor.getTVOC();
*a = sensor.geteCO2();
*b = sensor.getTVOC();
}
}

*a = (int16_t)internC;
*b = (int16_t)internV;
*c = internT;
return (0.0);
}

Expand Down Expand Up @@ -271,7 +265,9 @@ template <> class ExternalSensor<Gauges> : public BaseExternalSensor {
public:
ExternalSensor() { sensor = Gauges(); }

virtual uint8_t begin() {}
virtual uint8_t begin(){
return(0);
}

virtual float read(uint32_t *a, uint32_t *b, uint32_t *c) {
uint32_t A, B, C;
Expand All @@ -293,9 +289,11 @@ template <> class ExternalSensor<Gauges> : public BaseExternalSensor {
template <> class ExternalSensor<SHT1x> : public BaseExternalSensor {
public:
ExternalSensor() : sensor(SHT1X_DATA_PIN, SHT1X_CLOCK_PIN) {}
virtual uint8_t begin() {}
virtual uint8_t begin() {
return(0);
}
virtual float read(float *a, float *b) {
float A, B, C;
float A, B;
A = sensor.readHumidity();
B = sensor.readTemperatureC();
*a = A;
Expand All @@ -312,6 +310,7 @@ template <> class ExternalSensor<SDS011> : public BaseExternalSensor {
ExternalSensor() : sensor() {}
virtual uint8_t begin() {
sensor.start();
return(0);
}

virtual float read(float *a, float *b) {
Expand Down
10 changes: 4 additions & 6 deletions src/core/ExternalSensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void ExternalSensors::begin() {
sensors[i].exSensor->begin();
sensors[i].exSensor->read(&C02, &VOT, &Temp);
} else if ((sensors[i].reference) == "Adafruit_ADS1015") {
int16_t channel0, channel1, channel2, channel3, diff01, diff23;
int16_t channel0, channel1, channel2, channel3;
int16_t gain0, gain1, gain2, gain3;
std::unique_ptr<ExternalSensor<Adafruit_ADS1015>> analogI2C(
new ExternalSensor<Adafruit_ADS1015>(sensors[i].address));
Expand All @@ -76,7 +76,7 @@ void ExternalSensors::begin() {
&gain2, &channel3, &gain3);

} else if ((sensors[i].reference) == "Adafruit_ADS1115") {
int16_t channel0, channel1, channel2, channel3, diff01, diff23;
int16_t channel0, channel1, channel2, channel3;
int16_t gain0, gain1, gain2, gain3;

std::unique_ptr<ExternalSensor<Adafruit_ADS1115>> analogI2C(
Expand All @@ -92,13 +92,11 @@ void ExternalSensors::begin() {
sensors[i].exSensor = gauge.release();
sensors[i].exSensor->read(&A, &B, &C);
} else if ((sensors[i].reference) == "SHT1x") {
float A, B, C;
std::unique_ptr<ExternalSensor<SHT1x>> CoolSHT1x(
new ExternalSensor<SHT1x>());
sensors[i].exSensor = CoolSHT1x.release();
sensors[i].exSensor->begin();
} else if ((sensors[i].reference) == "SDS011") {
float A, B;
std::unique_ptr<ExternalSensor<SDS011>> sds011(
new ExternalSensor<SDS011>());
sensors[i].exSensor = sds011.release();
Expand Down Expand Up @@ -130,7 +128,7 @@ void ExternalSensors::read(JsonObject &root) {
root[sensors[i].kind2] = T;
} else if ((sensors[i].reference == "Adafruit_ADS1015") ||
(sensors[i].reference == "Adafruit_ADS1115")) {
int16_t channel0, channel1, channel2, channel3, diff01, diff23;
int16_t channel0, channel1, channel2, channel3;
int16_t gain0, gain1, gain2, gain3;

sensors[i].exSensor->read(&channel0, &gain0, &channel1, &gain1,
Expand All @@ -154,7 +152,7 @@ void ExternalSensors::read(JsonObject &root) {
root[sensors[i].kind1] = B;
root[sensors[i].kind2] = C;
} else if (sensors[i].reference == "SHT1x") {
float A, B, C;
float A, B;
sensors[i].exSensor->read(&A, &B);
root[sensors[i].kind0] = A;
root[sensors[i].kind1] = B;
Expand Down
5 changes: 2 additions & 3 deletions src/extras/CoolAdafruit_CCS811.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ void Adafruit_CCS811::setEnvironmentalData(uint8_t humidity, double temperature)
humidity would be 0x61, 0x00.*/

/* Temperature is stored as an unsigned 16 bits integer in 1/512
degrees; there is an offset: 0 maps to -25°C. The default value is
25°C = 0x64, 0x00. As an example 23.5% temperature would be
degrees; there is an offset: 0 maps to -25C. The default value is
25C = 0x64, 0x00. As an example 23.5% temperature would be
0x61, 0x00.
The internal algorithm uses these values (or default values if
not set by the application) to compensate for changes in
Expand Down Expand Up @@ -171,7 +171,6 @@ void Adafruit_CCS811::_i2c_init()

void Adafruit_CCS811::read(uint8_t reg, uint8_t *buf, uint8_t num)
{
uint8_t value;
uint8_t pos = 0;

//on arduino we need to read in 32 byte chunks
Expand Down
2 changes: 0 additions & 2 deletions src/extras/CoolNDIR_I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ uint8_t NDIR_I2C::receive(uint8_t *pbuf, uint8_t n) {

uint8_t NDIR_I2C::read_register(uint8_t reg_addr, uint8_t *pval)
{
uint8_t result;

WIRE.beginTransmission(i2c_addr);
WIRE.write(reg_addr << 3);
Expand All @@ -227,7 +226,6 @@ uint8_t NDIR_I2C::read_register(uint8_t reg_addr, uint8_t *pval)

uint8_t NDIR_I2C::write_register(uint8_t reg_addr, uint8_t *pdata, uint8_t n)
{
uint8_t result;

WIRE.beginTransmission(i2c_addr);
WIRE.write(reg_addr << 3);
Expand Down
2 changes: 1 addition & 1 deletion src/extras/WiFiManagerReadFileButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ bool WiFiManager::handleFileRead(String path){
if(SPIFFS.exists(pathWithGz))
path += ".gz";
File file = SPIFFS.open(path, "r");
size_t sent = server->streamFile(file, contentType);
server->streamFile(file, contentType);
Serial.println(server->streamFile(file, contentType));
file.close();
return true;
Expand Down

0 comments on commit 4839282

Please sign in to comment.