mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 16:38:16 +01:00
Format
This commit is contained in:
parent
95428b4cfe
commit
3fe9c20188
8 changed files with 11 additions and 31 deletions
|
@ -12,8 +12,7 @@ namespace adc {
|
||||||
ADC_MODE(ADC_VCC)
|
ADC_MODE(ADC_VCC)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class ADCSensor : public sensor::Sensor, public PollingComponent,
|
class ADCSensor : public sensor::Sensor, public PollingComponent, public voltage_sampler::VoltageSampler {
|
||||||
public voltage_sampler::VoltageSampler {
|
|
||||||
public:
|
public:
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
/// Set the attenuation for this pin. Only available on the ESP32.
|
/// Set the attenuation for this pin. Only available on the ESP32.
|
||||||
|
|
|
@ -59,9 +59,7 @@ void ADS1115Component::setup() {
|
||||||
}
|
}
|
||||||
for (auto *sensor : this->sensors_) {
|
for (auto *sensor : this->sensors_) {
|
||||||
this->set_interval(sensor->get_name(), sensor->update_interval(),
|
this->set_interval(sensor->get_name(), sensor->update_interval(),
|
||||||
[this, sensor] {
|
[this, sensor] { this->request_measurement(sensor); });
|
||||||
this->request_measurement(sensor);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ADS1115Component::dump_config() {
|
void ADS1115Component::dump_config() {
|
||||||
|
@ -153,9 +151,7 @@ uint8_t ADS1115Sensor::get_multiplexer() const { return this->multiplexer_; }
|
||||||
void ADS1115Sensor::set_multiplexer(ADS1115Multiplexer multiplexer) { this->multiplexer_ = multiplexer; }
|
void ADS1115Sensor::set_multiplexer(ADS1115Multiplexer multiplexer) { this->multiplexer_ = multiplexer; }
|
||||||
uint8_t ADS1115Sensor::get_gain() const { return this->gain_; }
|
uint8_t ADS1115Sensor::get_gain() const { return this->gain_; }
|
||||||
void ADS1115Sensor::set_gain(ADS1115Gain gain) { this->gain_ = gain; }
|
void ADS1115Sensor::set_gain(ADS1115Gain gain) { this->gain_ = gain; }
|
||||||
float ADS1115Sensor::sample() {
|
float ADS1115Sensor::sample() { return this->parent_->request_measurement(this); }
|
||||||
return this->parent_->request_measurement(this);
|
|
||||||
}
|
|
||||||
void ADS1115Sensor::update() {
|
void ADS1115Sensor::update() {
|
||||||
float v = this->parent_->request_measurement(this);
|
float v = this->parent_->request_measurement(this);
|
||||||
if (!isnan(v)) {
|
if (!isnan(v)) {
|
||||||
|
|
|
@ -47,8 +47,7 @@ class ADS1115Component : public Component, public i2c::I2CDevice {
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Internal holder class that is in instance of Sensor so that the hub can create individual sensors.
|
/// Internal holder class that is in instance of Sensor so that the hub can create individual sensors.
|
||||||
class ADS1115Sensor : public sensor::Sensor, public PollingComponent,
|
class ADS1115Sensor : public sensor::Sensor, public PollingComponent, public voltage_sampler::VoltageSampler {
|
||||||
public voltage_sampler::VoltageSampler {
|
|
||||||
public:
|
public:
|
||||||
ADS1115Sensor(ADS1115Component *parent) : parent_(parent) {}
|
ADS1115Sensor(ADS1115Component *parent) : parent_(parent) {}
|
||||||
void update() override;
|
void update() override;
|
||||||
|
|
|
@ -13,9 +13,7 @@ class BLEPresenceDevice : public binary_sensor::BinarySensor,
|
||||||
public esp32_ble_tracker::ESPBTDeviceListener,
|
public esp32_ble_tracker::ESPBTDeviceListener,
|
||||||
public Component {
|
public Component {
|
||||||
public:
|
public:
|
||||||
void set_address(uint64_t address) {
|
void set_address(uint64_t address) { address_ = address; }
|
||||||
address_ = address;
|
|
||||||
}
|
|
||||||
void on_scan_end() override {
|
void on_scan_end() override {
|
||||||
if (!this->found_)
|
if (!this->found_)
|
||||||
this->publish_state(false);
|
this->publish_state(false);
|
||||||
|
|
|
@ -11,9 +11,7 @@ namespace ble_rssi {
|
||||||
|
|
||||||
class BLERSSISensor : public sensor::Sensor, public esp32_ble_tracker::ESPBTDeviceListener, public Component {
|
class BLERSSISensor : public sensor::Sensor, public esp32_ble_tracker::ESPBTDeviceListener, public Component {
|
||||||
public:
|
public:
|
||||||
void set_address(uint64_t address) {
|
void set_address(uint64_t address) { address_ = address; }
|
||||||
address_ = address;
|
|
||||||
}
|
|
||||||
void on_scan_end() override {
|
void on_scan_end() override {
|
||||||
if (!this->found_)
|
if (!this->found_)
|
||||||
this->publish_state(NAN);
|
this->publish_state(NAN);
|
||||||
|
|
|
@ -100,19 +100,13 @@ class RealTimeClock : public Component {
|
||||||
std::string get_timezone() { return this->timezone_; }
|
std::string get_timezone() { return this->timezone_; }
|
||||||
|
|
||||||
/// Get the time in the currently defined timezone.
|
/// Get the time in the currently defined timezone.
|
||||||
ESPTime now() {
|
ESPTime now() { return ESPTime::from_epoch_utc(this->timestamp_now()); }
|
||||||
return ESPTime::from_epoch_utc(this->timestamp_now());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the time without any time zone or DST corrections.
|
/// Get the time without any time zone or DST corrections.
|
||||||
ESPTime utcnow() {
|
ESPTime utcnow() { return ESPTime::from_epoch_local(this->timestamp_now()); }
|
||||||
return ESPTime::from_epoch_local(this->timestamp_now());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the current time as the UTC epoch since January 1st 1970.
|
/// Get the current time as the UTC epoch since January 1st 1970.
|
||||||
time_t timestamp_now() {
|
time_t timestamp_now() { return ::time(nullptr); }
|
||||||
return ::time(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void call_setup() override;
|
void call_setup() override;
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,7 @@ namespace xiaomi_miflora {
|
||||||
|
|
||||||
class XiaomiMiflora : public Component, public esp32_ble_tracker::ESPBTDeviceListener {
|
class XiaomiMiflora : public Component, public esp32_ble_tracker::ESPBTDeviceListener {
|
||||||
public:
|
public:
|
||||||
void set_address(uint64_t address) {
|
void set_address(uint64_t address) { address_ = address; }
|
||||||
address_ = address;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override {
|
bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override {
|
||||||
if (device.address_uint64() != this->address_)
|
if (device.address_uint64() != this->address_)
|
||||||
|
|
|
@ -12,9 +12,7 @@ namespace xiaomi_mijia {
|
||||||
|
|
||||||
class XiaomiMijia : public Component, public esp32_ble_tracker::ESPBTDeviceListener {
|
class XiaomiMijia : public Component, public esp32_ble_tracker::ESPBTDeviceListener {
|
||||||
public:
|
public:
|
||||||
void set_address(uint64_t address) {
|
void set_address(uint64_t address) { address_ = address; }
|
||||||
address_ = address;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override {
|
bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override {
|
||||||
if (device.address_uint64() != this->address_)
|
if (device.address_uint64() != this->address_)
|
||||||
|
|
Loading…
Reference in a new issue