formatting

This commit is contained in:
unsplorer 2024-09-29 12:10:59 -05:00
parent 4320e6ea14
commit a15c67a521
2 changed files with 8 additions and 8 deletions

View file

@ -21,7 +21,7 @@ bool Ams5915::read_raw_data_(uint16_t *pressure_counts, uint16_t *temperature_co
void Ams5915::setup() {
bool read_success = false;
// check to see if we can talk with the sensor
for (size_t i = 0; i < this->max_attempts_; i++) {
for (size_t i = 0; i < Ams5915::MAX_ATTEMPTS; i++) {
read_success = read_raw_data_(&raw_pressure_data_, &raw_temperature_data_);
if (read_success) {
return;
@ -41,10 +41,10 @@ void Ams5915::update() {
// convert raw_pressure_data_ to pressure, PA as noted in datasheet
// TODO: there maybe a helper function in helpers.h that can remap the value
float pressure =
(((float) (this->raw_pressure_data_ - this->dig_out_p_min_)) /
(((float) (this->dig_out_p_max_ - this->dig_out_p_min_)) / ((float) (this->p_max_ - this->p_min_))) +
(((float) (this->raw_pressure_data_ - Ams5915::DIG_OUT_P_MIN)) /
(((float) (Ams5915::DIG_PUT_P_MAX - Ams5915::DIG_OUT_P_MIN)) / ((float) (this->p_max_ - this->p_min_))) +
(float) this->p_min_);
this->pressure_sensor_->publish_state(pressure * this->mbar_to_pa_);
this->pressure_sensor_->publish_state(pressure * Ams5915::MBAR_TO_PA);
}
if (this->temperature_sensor_ != nullptr) {

View file

@ -26,7 +26,7 @@ class Ams5915 : public PollingComponent, public sensor::Sensor, public i2c::I2CD
uint8_t buffer_[4];
// maximum number of attempts to talk to sensor
static const size_t max_attempts_ = 10;
static const size_t MAX_ATTEMPTS = 10;
// pressure digital output, counts
uint16_t raw_pressure_data_;
// temperature digital output, counts
@ -35,11 +35,11 @@ class Ams5915 : public PollingComponent, public sensor::Sensor, public i2c::I2CD
int p_min_;
int p_max_;
// conversion millibar to PA
static constexpr float mbar_to_pa_ = 100.0f;
static constexpr float MBAR_TO_PA = 100.0f;
// digital output at minimum pressure
static const int dig_out_p_min_ = 1638;
static const int DIG_OUT_P_MIN = 1638;
// digital output at maximum pressure
static const int dig_out_p_max_ = 14745;
static const int DIG_PUT_P_MAX = 14745;
bool read_raw_data_(uint16_t *pressure_counts, uint16_t *temperature_counts);
sensor::Sensor *temperature_sensor_{nullptr};