mirror of
https://github.com/esphome/esphome.git
synced 2024-11-28 12:46:22 +01:00
Prefix member variables and function calls with 'this->'
This commit is contained in:
parent
44ba88506e
commit
b7043f3fcd
@ -99,7 +99,7 @@ void Sen0501Component::read_temperature_() {
|
|||||||
uint8_t buffer[2];
|
uint8_t buffer[2];
|
||||||
uint16_t data;
|
uint16_t data;
|
||||||
float temp;
|
float temp;
|
||||||
read_bytes(REG_TEMP, buffer, 2);
|
this->read_bytes(REG_TEMP, buffer, 2);
|
||||||
data = buffer[0] << 8 | buffer[1];
|
data = buffer[0] << 8 | buffer[1];
|
||||||
temp = 175.0f * float(data) / 65536.0f - 45.0f;
|
temp = 175.0f * float(data) / 65536.0f - 45.0f;
|
||||||
this->temperature_->publish_state(temp);
|
this->temperature_->publish_state(temp);
|
||||||
@ -111,7 +111,7 @@ void Sen0501Component::read_humidity_() {
|
|||||||
uint8_t buffer[2];
|
uint8_t buffer[2];
|
||||||
uint16_t data;
|
uint16_t data;
|
||||||
float humidity;
|
float humidity;
|
||||||
read_bytes(REG_HUMIDITY, buffer, 2);
|
this->read_bytes(REG_HUMIDITY, buffer, 2);
|
||||||
data = buffer[0] << 8 | buffer[1];
|
data = buffer[0] << 8 | buffer[1];
|
||||||
humidity = (float) data * 100 / 65536;
|
humidity = (float) data * 100 / 65536;
|
||||||
this->humidity_->publish_state(humidity);
|
this->humidity_->publish_state(humidity);
|
||||||
@ -124,14 +124,14 @@ void Sen0501Component::read_uv_intensity_() {
|
|||||||
uint16_t uv_level;
|
uint16_t uv_level;
|
||||||
uint16_t version = 0;
|
uint16_t version = 0;
|
||||||
float ultra_violet;
|
float ultra_violet;
|
||||||
read_bytes(REG_VERSION, buffer, 2);
|
this->read_bytes(REG_VERSION, buffer, 2);
|
||||||
version = buffer[0] << 8 | buffer[1];
|
version = buffer[0] << 8 | buffer[1];
|
||||||
if (version == 0x1001) {
|
if (version == 0x1001) {
|
||||||
read_bytes(REG_ULTRAVIOLET_INTENSITY, buffer, 2);
|
this->read_bytes(REG_ULTRAVIOLET_INTENSITY, buffer, 2);
|
||||||
uv_level = buffer[0] << 8 | buffer[1];
|
uv_level = buffer[0] << 8 | buffer[1];
|
||||||
ultra_violet = (float) uv_level / 1800.0;
|
ultra_violet = (float) uv_level / 1800.0;
|
||||||
} else {
|
} else {
|
||||||
read_bytes(REG_ULTRAVIOLET_INTENSITY, buffer, 2);
|
this->read_bytes(REG_ULTRAVIOLET_INTENSITY, buffer, 2);
|
||||||
uv_level = buffer[0] << 8 | buffer[1];
|
uv_level = buffer[0] << 8 | buffer[1];
|
||||||
float output_voltage = 3.0 * uv_level / 1024;
|
float output_voltage = 3.0 * uv_level / 1024;
|
||||||
if (output_voltage <= 0.99) {
|
if (output_voltage <= 0.99) {
|
||||||
@ -139,7 +139,7 @@ void Sen0501Component::read_uv_intensity_() {
|
|||||||
} else if (output_voltage >= 2.99) {
|
} else if (output_voltage >= 2.99) {
|
||||||
output_voltage = 2.99;
|
output_voltage = 2.99;
|
||||||
}
|
}
|
||||||
ultra_violet = remap(output_voltage, 0.99f, 2.9f, 0.0f, 15.0f);
|
ultra_violet = this->remap(output_voltage, 0.99f, 2.9f, 0.0f, 15.0f);
|
||||||
}
|
}
|
||||||
this->uv_intensity_->publish_state(ultra_violet);
|
this->uv_intensity_->publish_state(ultra_violet);
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ void Sen0501Component::read_luminous_intensity_() {
|
|||||||
return;
|
return;
|
||||||
uint8_t buffer[2];
|
uint8_t buffer[2];
|
||||||
uint16_t data;
|
uint16_t data;
|
||||||
read_bytes(REG_LUMINOUS_INTENSITY, buffer, 2);
|
this->read_bytes(REG_LUMINOUS_INTENSITY, buffer, 2);
|
||||||
data = buffer[0] << 8 | buffer[1];
|
data = buffer[0] << 8 | buffer[1];
|
||||||
float luminous = data;
|
float luminous = data;
|
||||||
luminous = luminous * (1.0023f + luminous * (8.1488e-5f + luminous * (-9.3924e-9f + luminous * 6.0135e-13f)));
|
luminous = luminous * (1.0023f + luminous * (8.1488e-5f + luminous * (-9.3924e-9f + luminous * 6.0135e-13f)));
|
||||||
@ -161,12 +161,12 @@ void Sen0501Component::read_atmospheric_pressure_() {
|
|||||||
return;
|
return;
|
||||||
uint8_t buffer[2];
|
uint8_t buffer[2];
|
||||||
uint16_t atmosphere;
|
uint16_t atmosphere;
|
||||||
read_bytes(REG_ATMOSPHERIC_PRESSURE, buffer, 2);
|
this->read_bytes(REG_ATMOSPHERIC_PRESSURE, buffer, 2);
|
||||||
atmosphere = buffer[0] << 8 | buffer[1];
|
atmosphere = buffer[0] << 8 | buffer[1];
|
||||||
this->atmospheric_pressure_->publish_state(atmosphere);
|
this->atmospheric_pressure_->publish_state(atmosphere);
|
||||||
if (this->elevation_ == nullptr)
|
if (this->elevation_ == nullptr)
|
||||||
return;
|
return;
|
||||||
float elevation = 44330 * (1.0 - pow(atmosphere / 1015.0f, 0.1903));
|
float elevation = 44330 * (1.0 - this->pow(atmosphere / 1015.0f, 0.1903));
|
||||||
this->elevation_->publish_state(elevation);
|
this->elevation_->publish_state(elevation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,12 +12,12 @@ namespace sen0501 {
|
|||||||
|
|
||||||
class Sen0501Component : public PollingComponent, public i2c::I2CDevice {
|
class Sen0501Component : public PollingComponent, public i2c::I2CDevice {
|
||||||
public:
|
public:
|
||||||
void set_temperature(sensor::Sensor *temperature) { temperature_ = temperature; }
|
void set_temperature(sensor::Sensor *temperature) { this->temperature_ = temperature; }
|
||||||
void set_humidity(sensor::Sensor *humidity) { humidity_ = humidity; }
|
void set_humidity(sensor::Sensor *humidity) { this->humidity_ = humidity; }
|
||||||
void set_uv_intensity(sensor::Sensor *uv_intensity) { uv_intensity_ = uv_intensity; }
|
void set_uv_intensity(sensor::Sensor *uv_intensity) { this->uv_intensity_ = uv_intensity; }
|
||||||
void set_luminous_intensity(sensor::Sensor *luminous_intensity) { luminous_intensity_ = luminous_intensity; }
|
void set_luminous_intensity(sensor::Sensor *luminous_intensity) { this->luminous_intensity_ = luminous_intensity; }
|
||||||
void set_atmospheric_pressure(sensor::Sensor *atmospheric_pressure) { atmospheric_pressure_ = atmospheric_pressure; }
|
void set_atmospheric_pressure(sensor::Sensor *atmospheric_pressure) { this->atmospheric_pressure_ = atmospheric_pressure; }
|
||||||
void set_elevation(sensor::Sensor *elevation) { elevation_ = elevation; }
|
void set_elevation(sensor::Sensor *elevation) { this->elevation_ = elevation; }
|
||||||
|
|
||||||
void setup() override;
|
void setup() override;
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
@ -44,7 +44,7 @@ class Sen0501Component : public PollingComponent, public i2c::I2CDevice {
|
|||||||
COMMUNICATION_FAILED,
|
COMMUNICATION_FAILED,
|
||||||
WRONG_DEVICE_ID,
|
WRONG_DEVICE_ID,
|
||||||
WRONG_VENDOR_ID,
|
WRONG_VENDOR_ID,
|
||||||
} error_code_{NONE};
|
} this->error_code_{NONE};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sen0501
|
} // namespace sen0501
|
||||||
|
Loading…
Reference in New Issue
Block a user