setProfileDuration method
Sets the profile duration
of the sensor.
Implementation
void setProfileDuration(int duration) {
var cycles = oversampMulti2int(_sensorSettings.oversamplingTemperature);
cycles += oversampMulti2int(_sensorSettings.oversamplingPressure);
cycles += oversampMulti2int(_sensorSettings.oversamplingHumidity);
/// TPH measurement duration calculated in microseconds [us]
var tphDuration = cycles * 1963;
tphDuration += (477 * 4); // TPH switching duration
tphDuration += (477 * 5); // Gas measurement duration
tphDuration += 500; // Get it to the closest whole number
tphDuration ~/= 1000; // Convert to millisecond [ms]
tphDuration += 1; // Wake up duration of 1ms
// The remaining time should be used for heating
_gasSettings.heaterDuration = duration - tphDuration;
}