blob: a8084a85cd5e90b0a70542aa8e4ef9c06c3c49db [file] [log] [blame]
// Copyright 2024 The Pigweed Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
#include "modules/air_sensor/air_sensor.h"
#include <mutex>
namespace sense {
float AirSensor::temperature() const {
std::lock_guard lock(lock_);
return temperature_;
}
float AirSensor::pressure() const {
std::lock_guard lock(lock_);
return pressure_;
}
float AirSensor::humidity() const {
std::lock_guard lock(lock_);
return humidity_;
}
float AirSensor::gas_resistance() const {
std::lock_guard lock(lock_);
return gas_resistance_;
}
void AirSensor::Update(float temperature, float pressure, float humidity, float gas_resistance) {
std::lock_guard lock(lock_);
temperature_ = temperature;
pressure_ = pressure;
humidity_ = humidity;
gas_resistance_ = gas_resistance;
}
} // namespace sense