 //********************************************************************************
 //********************************************************************************
 
-/*
 float mapFloat(float x, float in_min, float in_max, float out_min, float out_max)
 {
   return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
 }
-*/
 
 void setPinsMode() {
     pinMode(I2CEN, OUTPUT);

// These values are mapped and updated in the postSensingVariableMap() function
char Sound[63] = "0";
char Power[63] = "0.00 0.00 0.00";
char SoilTnH[63] = "0 0";
char PreTAlt[63] = "0.00 0.00 0.00";
char AmbiTnH[63] = "0.00 0.00";
char UVVisIR[63] = "0.00 0.00 0.00";

}

int readSoilTemperature() {
    //Formula basd on THERM200 documentation (Voltage Output Equation)
    //http://www.vegetronix.com/Products/THERM200/

    SOILTV = (mapFloat(analogRead(SOILT), 0, 4095, 0, 3.3) * 41.67) - 40;

    return 1;
}

int readSoilHumidity() {
    // Formula based on VH400 documentation (Voltage Output Curves)
    // http://vegetronix.com/Products/VH400/VH400-Piecewise-Curve.phtml

    float voltage = mapFloat(analogRead(SOILH), 0, 4095, 0, 3.3);

    if (0 < voltage && voltage <= 1.1)
    {
        SOILHV = (10 * voltage) - 1;
    }
    else if (1.1 < voltage && voltage <= 1.3)
    {
        SOILHV = (25 * voltage) - 17.5;
    }
    else if (1.3 < voltage && voltage <= 1.82)
    {
        SOILHV = (48.08 * voltage) - 47.5;
    }
    else if (1.82 < voltage && voltage <= 2.2)
    {
        SOILHV = (26.32 * voltage) - 7.89;
    }
    else
    {
        // All undocumented and out of range values get a value of -1
        SOILHV = -1;
    }

    return 2;
}
