

#include "sensor.h"
#include "environment.h"


Sensor::Sensor(TwoWire* i2c) {
    bme = new BME280(i2c);
    ltr = new LTR390(i2c);
    tsl = new TSL25911(i2c);
    sgp = new SGP40(i2c);
    pms = new PMSA003(i2c);
}

void Sensor::TSL_init(void) {
    tsl->begin();
}
void Sensor::BME_init(void) {
    bme->begin();
}
void Sensor::ICM_init(void) {} //Nothing to do afaik
void Sensor::LTR_init(void) {
    ltr->begin();
}
void Sensor::SGP_init(void) {
    sgp->begin();
}
void Sensor::PMS_init(void) {
    pms->begin();
}


void Sensor::BME_measure() {
    float t_temp = 0;
    float t_pres = 0;
    bme->read(t_pres, t_temp, hum);

    temp = t_temp - 5.0; // Correct heating offset
    heatidx = EnvironmentCalculations::HeatIndex(temp,hum);
    pres = EnvironmentCalculations::EquivalentSeaLevelPressure(100,temp, t_pres);
}
void Sensor::LTR_measure() {
    ltr->read(uv, uvi);
}
void Sensor::TSL_measure(void) {
    tsl->read(light_vis, light_ir, light_full, light_lux);
}
void Sensor::ICM_measure(void) {
    //Do realy care about this ????
}
void Sensor::SGP_measure(void) {
    sgp->read(voci, temp, hum);
}
void Sensor::PMS_measure(void) {
    pms->read(pmd);
}