mirror of
https://github.com/esphome/esphome.git
synced 2025-04-09 12:20:30 +01:00
Merge branch 'dev' into separate-ota-backend
This commit is contained in:
commit
6dcb038294
@ -1 +1,108 @@
|
|||||||
|
import esphome.codegen as cg
|
||||||
|
import esphome.config_validation as cv
|
||||||
|
from esphome.components import sensor
|
||||||
|
from esphome.const import (
|
||||||
|
CONF_HUMIDITY,
|
||||||
|
CONF_ID,
|
||||||
|
CONF_IIR_FILTER,
|
||||||
|
CONF_OVERSAMPLING,
|
||||||
|
CONF_PRESSURE,
|
||||||
|
CONF_TEMPERATURE,
|
||||||
|
DEVICE_CLASS_HUMIDITY,
|
||||||
|
DEVICE_CLASS_PRESSURE,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
STATE_CLASS_MEASUREMENT,
|
||||||
|
UNIT_CELSIUS,
|
||||||
|
UNIT_HECTOPASCAL,
|
||||||
|
UNIT_PERCENT,
|
||||||
|
)
|
||||||
|
|
||||||
CODEOWNERS = ["@esphome/core"]
|
CODEOWNERS = ["@esphome/core"]
|
||||||
|
|
||||||
|
bme280_ns = cg.esphome_ns.namespace("bme280_base")
|
||||||
|
BME280Oversampling = bme280_ns.enum("BME280Oversampling")
|
||||||
|
OVERSAMPLING_OPTIONS = {
|
||||||
|
"NONE": BME280Oversampling.BME280_OVERSAMPLING_NONE,
|
||||||
|
"1X": BME280Oversampling.BME280_OVERSAMPLING_1X,
|
||||||
|
"2X": BME280Oversampling.BME280_OVERSAMPLING_2X,
|
||||||
|
"4X": BME280Oversampling.BME280_OVERSAMPLING_4X,
|
||||||
|
"8X": BME280Oversampling.BME280_OVERSAMPLING_8X,
|
||||||
|
"16X": BME280Oversampling.BME280_OVERSAMPLING_16X,
|
||||||
|
}
|
||||||
|
|
||||||
|
BME280IIRFilter = bme280_ns.enum("BME280IIRFilter")
|
||||||
|
IIR_FILTER_OPTIONS = {
|
||||||
|
"OFF": BME280IIRFilter.BME280_IIR_FILTER_OFF,
|
||||||
|
"2X": BME280IIRFilter.BME280_IIR_FILTER_2X,
|
||||||
|
"4X": BME280IIRFilter.BME280_IIR_FILTER_4X,
|
||||||
|
"8X": BME280IIRFilter.BME280_IIR_FILTER_8X,
|
||||||
|
"16X": BME280IIRFilter.BME280_IIR_FILTER_16X,
|
||||||
|
}
|
||||||
|
|
||||||
|
CONFIG_SCHEMA_BASE = cv.Schema(
|
||||||
|
{
|
||||||
|
cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(
|
||||||
|
unit_of_measurement=UNIT_CELSIUS,
|
||||||
|
accuracy_decimals=1,
|
||||||
|
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||||
|
state_class=STATE_CLASS_MEASUREMENT,
|
||||||
|
).extend(
|
||||||
|
{
|
||||||
|
cv.Optional(CONF_OVERSAMPLING, default="16X"): cv.enum(
|
||||||
|
OVERSAMPLING_OPTIONS, upper=True
|
||||||
|
),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
cv.Optional(CONF_PRESSURE): sensor.sensor_schema(
|
||||||
|
unit_of_measurement=UNIT_HECTOPASCAL,
|
||||||
|
accuracy_decimals=1,
|
||||||
|
device_class=DEVICE_CLASS_PRESSURE,
|
||||||
|
state_class=STATE_CLASS_MEASUREMENT,
|
||||||
|
).extend(
|
||||||
|
{
|
||||||
|
cv.Optional(CONF_OVERSAMPLING, default="16X"): cv.enum(
|
||||||
|
OVERSAMPLING_OPTIONS, upper=True
|
||||||
|
),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
cv.Optional(CONF_HUMIDITY): sensor.sensor_schema(
|
||||||
|
unit_of_measurement=UNIT_PERCENT,
|
||||||
|
accuracy_decimals=1,
|
||||||
|
device_class=DEVICE_CLASS_HUMIDITY,
|
||||||
|
state_class=STATE_CLASS_MEASUREMENT,
|
||||||
|
).extend(
|
||||||
|
{
|
||||||
|
cv.Optional(CONF_OVERSAMPLING, default="16X"): cv.enum(
|
||||||
|
OVERSAMPLING_OPTIONS, upper=True
|
||||||
|
),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
cv.Optional(CONF_IIR_FILTER, default="OFF"): cv.enum(
|
||||||
|
IIR_FILTER_OPTIONS, upper=True
|
||||||
|
),
|
||||||
|
}
|
||||||
|
).extend(cv.polling_component_schema("60s"))
|
||||||
|
|
||||||
|
|
||||||
|
async def to_code_base(config):
|
||||||
|
var = cg.new_Pvariable(config[CONF_ID])
|
||||||
|
await cg.register_component(var, config)
|
||||||
|
|
||||||
|
if temperature_config := config.get(CONF_TEMPERATURE):
|
||||||
|
sens = await sensor.new_sensor(temperature_config)
|
||||||
|
cg.add(var.set_temperature_sensor(sens))
|
||||||
|
cg.add(var.set_temperature_oversampling(temperature_config[CONF_OVERSAMPLING]))
|
||||||
|
|
||||||
|
if pressure_config := config.get(CONF_PRESSURE):
|
||||||
|
sens = await sensor.new_sensor(pressure_config)
|
||||||
|
cg.add(var.set_pressure_sensor(sens))
|
||||||
|
cg.add(var.set_pressure_oversampling(pressure_config[CONF_OVERSAMPLING]))
|
||||||
|
|
||||||
|
if humidity_config := config.get(CONF_HUMIDITY):
|
||||||
|
sens = await sensor.new_sensor(humidity_config)
|
||||||
|
cg.add(var.set_humidity_sensor(sens))
|
||||||
|
cg.add(var.set_humidity_oversampling(humidity_config[CONF_OVERSAMPLING]))
|
||||||
|
|
||||||
|
cg.add(var.set_iir_filter(config[CONF_IIR_FILTER]))
|
||||||
|
|
||||||
|
return var
|
||||||
|
@ -1,106 +0,0 @@
|
|||||||
import esphome.codegen as cg
|
|
||||||
import esphome.config_validation as cv
|
|
||||||
from esphome.components import sensor
|
|
||||||
from esphome.const import (
|
|
||||||
CONF_HUMIDITY,
|
|
||||||
CONF_ID,
|
|
||||||
CONF_IIR_FILTER,
|
|
||||||
CONF_OVERSAMPLING,
|
|
||||||
CONF_PRESSURE,
|
|
||||||
CONF_TEMPERATURE,
|
|
||||||
DEVICE_CLASS_HUMIDITY,
|
|
||||||
DEVICE_CLASS_PRESSURE,
|
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
|
||||||
STATE_CLASS_MEASUREMENT,
|
|
||||||
UNIT_CELSIUS,
|
|
||||||
UNIT_HECTOPASCAL,
|
|
||||||
UNIT_PERCENT,
|
|
||||||
)
|
|
||||||
|
|
||||||
bme280_ns = cg.esphome_ns.namespace("bme280_base")
|
|
||||||
BME280Oversampling = bme280_ns.enum("BME280Oversampling")
|
|
||||||
OVERSAMPLING_OPTIONS = {
|
|
||||||
"NONE": BME280Oversampling.BME280_OVERSAMPLING_NONE,
|
|
||||||
"1X": BME280Oversampling.BME280_OVERSAMPLING_1X,
|
|
||||||
"2X": BME280Oversampling.BME280_OVERSAMPLING_2X,
|
|
||||||
"4X": BME280Oversampling.BME280_OVERSAMPLING_4X,
|
|
||||||
"8X": BME280Oversampling.BME280_OVERSAMPLING_8X,
|
|
||||||
"16X": BME280Oversampling.BME280_OVERSAMPLING_16X,
|
|
||||||
}
|
|
||||||
|
|
||||||
BME280IIRFilter = bme280_ns.enum("BME280IIRFilter")
|
|
||||||
IIR_FILTER_OPTIONS = {
|
|
||||||
"OFF": BME280IIRFilter.BME280_IIR_FILTER_OFF,
|
|
||||||
"2X": BME280IIRFilter.BME280_IIR_FILTER_2X,
|
|
||||||
"4X": BME280IIRFilter.BME280_IIR_FILTER_4X,
|
|
||||||
"8X": BME280IIRFilter.BME280_IIR_FILTER_8X,
|
|
||||||
"16X": BME280IIRFilter.BME280_IIR_FILTER_16X,
|
|
||||||
}
|
|
||||||
|
|
||||||
CONFIG_SCHEMA_BASE = cv.Schema(
|
|
||||||
{
|
|
||||||
cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(
|
|
||||||
unit_of_measurement=UNIT_CELSIUS,
|
|
||||||
accuracy_decimals=1,
|
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
|
||||||
).extend(
|
|
||||||
{
|
|
||||||
cv.Optional(CONF_OVERSAMPLING, default="16X"): cv.enum(
|
|
||||||
OVERSAMPLING_OPTIONS, upper=True
|
|
||||||
),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
cv.Optional(CONF_PRESSURE): sensor.sensor_schema(
|
|
||||||
unit_of_measurement=UNIT_HECTOPASCAL,
|
|
||||||
accuracy_decimals=1,
|
|
||||||
device_class=DEVICE_CLASS_PRESSURE,
|
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
|
||||||
).extend(
|
|
||||||
{
|
|
||||||
cv.Optional(CONF_OVERSAMPLING, default="16X"): cv.enum(
|
|
||||||
OVERSAMPLING_OPTIONS, upper=True
|
|
||||||
),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
cv.Optional(CONF_HUMIDITY): sensor.sensor_schema(
|
|
||||||
unit_of_measurement=UNIT_PERCENT,
|
|
||||||
accuracy_decimals=1,
|
|
||||||
device_class=DEVICE_CLASS_HUMIDITY,
|
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
|
||||||
).extend(
|
|
||||||
{
|
|
||||||
cv.Optional(CONF_OVERSAMPLING, default="16X"): cv.enum(
|
|
||||||
OVERSAMPLING_OPTIONS, upper=True
|
|
||||||
),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
cv.Optional(CONF_IIR_FILTER, default="OFF"): cv.enum(
|
|
||||||
IIR_FILTER_OPTIONS, upper=True
|
|
||||||
),
|
|
||||||
}
|
|
||||||
).extend(cv.polling_component_schema("60s"))
|
|
||||||
|
|
||||||
|
|
||||||
async def to_code(config, func=None):
|
|
||||||
var = cg.new_Pvariable(config[CONF_ID])
|
|
||||||
await cg.register_component(var, config)
|
|
||||||
if func is not None:
|
|
||||||
await func(var, config)
|
|
||||||
|
|
||||||
if temperature_config := config.get(CONF_TEMPERATURE):
|
|
||||||
sens = await sensor.new_sensor(temperature_config)
|
|
||||||
cg.add(var.set_temperature_sensor(sens))
|
|
||||||
cg.add(var.set_temperature_oversampling(temperature_config[CONF_OVERSAMPLING]))
|
|
||||||
|
|
||||||
if pressure_config := config.get(CONF_PRESSURE):
|
|
||||||
sens = await sensor.new_sensor(pressure_config)
|
|
||||||
cg.add(var.set_pressure_sensor(sens))
|
|
||||||
cg.add(var.set_pressure_oversampling(pressure_config[CONF_OVERSAMPLING]))
|
|
||||||
|
|
||||||
if humidity_config := config.get(CONF_HUMIDITY):
|
|
||||||
sens = await sensor.new_sensor(humidity_config)
|
|
||||||
cg.add(var.set_humidity_sensor(sens))
|
|
||||||
cg.add(var.set_humidity_oversampling(humidity_config[CONF_OVERSAMPLING]))
|
|
||||||
|
|
||||||
cg.add(var.set_iir_filter(config[CONF_IIR_FILTER]))
|
|
@ -1,9 +1,10 @@
|
|||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
|
import esphome.config_validation as cv
|
||||||
from esphome.components import i2c
|
from esphome.components import i2c
|
||||||
from ..bme280_base.sensor import to_code as to_code_base, cv, CONFIG_SCHEMA_BASE
|
from ..bme280_base import to_code_base, CONFIG_SCHEMA_BASE
|
||||||
|
|
||||||
DEPENDENCIES = ["i2c"]
|
|
||||||
AUTO_LOAD = ["bme280_base"]
|
AUTO_LOAD = ["bme280_base"]
|
||||||
|
DEPENDENCIES = ["i2c"]
|
||||||
|
|
||||||
bme280_ns = cg.esphome_ns.namespace("bme280_i2c")
|
bme280_ns = cg.esphome_ns.namespace("bme280_i2c")
|
||||||
BME280I2CComponent = bme280_ns.class_(
|
BME280I2CComponent = bme280_ns.class_(
|
||||||
@ -16,4 +17,5 @@ CONFIG_SCHEMA = CONFIG_SCHEMA_BASE.extend(
|
|||||||
|
|
||||||
|
|
||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
await to_code_base(config, func=i2c.register_i2c_device)
|
var = await to_code_base(config)
|
||||||
|
await i2c.register_i2c_device(var, config)
|
||||||
|
@ -1 +0,0 @@
|
|||||||
CODEOWNERS = ["@apbodrov"]
|
|
@ -4,19 +4,19 @@
|
|||||||
#include "bme280_spi.h"
|
#include "bme280_spi.h"
|
||||||
#include <esphome/components/bme280_base/bme280_base.h>
|
#include <esphome/components/bme280_base/bme280_base.h>
|
||||||
|
|
||||||
int set_bit(uint8_t num, int position) {
|
namespace esphome {
|
||||||
|
namespace bme280_spi {
|
||||||
|
|
||||||
|
uint8_t set_bit(uint8_t num, int position) {
|
||||||
int mask = 1 << position;
|
int mask = 1 << position;
|
||||||
return num | mask;
|
return num | mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
int clear_bit(uint8_t num, int position) {
|
uint8_t clear_bit(uint8_t num, int position) {
|
||||||
int mask = 1 << position;
|
int mask = 1 << position;
|
||||||
return num & ~mask;
|
return num & ~mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace esphome {
|
|
||||||
namespace bme280_spi {
|
|
||||||
|
|
||||||
void BME280SPIComponent::setup() {
|
void BME280SPIComponent::setup() {
|
||||||
this->spi_setup();
|
this->spi_setup();
|
||||||
BME280Component::setup();
|
BME280Component::setup();
|
||||||
@ -30,34 +30,33 @@ void BME280SPIComponent::setup() {
|
|||||||
|
|
||||||
bool BME280SPIComponent::read_byte(uint8_t a_register, uint8_t *data) {
|
bool BME280SPIComponent::read_byte(uint8_t a_register, uint8_t *data) {
|
||||||
this->enable();
|
this->enable();
|
||||||
// cause: *data = this->delegate_->transfer(tmp) doesnt work
|
this->transfer_byte(set_bit(a_register, 7));
|
||||||
this->delegate_->transfer(set_bit(a_register, 7));
|
*data = this->transfer_byte(0);
|
||||||
*data = this->delegate_->transfer(0);
|
|
||||||
this->disable();
|
this->disable();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BME280SPIComponent::write_byte(uint8_t a_register, uint8_t data) {
|
bool BME280SPIComponent::write_byte(uint8_t a_register, uint8_t data) {
|
||||||
this->enable();
|
this->enable();
|
||||||
this->delegate_->transfer(clear_bit(a_register, 7));
|
this->transfer_byte(clear_bit(a_register, 7));
|
||||||
this->delegate_->transfer(data);
|
this->transfer_byte(data);
|
||||||
this->disable();
|
this->disable();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BME280SPIComponent::read_bytes(uint8_t a_register, uint8_t *data, size_t len) {
|
bool BME280SPIComponent::read_bytes(uint8_t a_register, uint8_t *data, size_t len) {
|
||||||
this->enable();
|
this->enable();
|
||||||
this->delegate_->transfer(set_bit(a_register, 7));
|
this->transfer_byte(set_bit(a_register, 7));
|
||||||
this->delegate_->read_array(data, len);
|
this->read_array(data, len);
|
||||||
this->disable();
|
this->disable();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BME280SPIComponent::read_byte_16(uint8_t a_register, uint16_t *data) {
|
bool BME280SPIComponent::read_byte_16(uint8_t a_register, uint16_t *data) {
|
||||||
this->enable();
|
this->enable();
|
||||||
this->delegate_->transfer(set_bit(a_register, 7));
|
this->transfer_byte(set_bit(a_register, 7));
|
||||||
((uint8_t *) data)[1] = this->delegate_->transfer(0);
|
((uint8_t *) data)[1] = this->transfer_byte(0);
|
||||||
((uint8_t *) data)[0] = this->delegate_->transfer(0);
|
((uint8_t *) data)[0] = this->transfer_byte(0);
|
||||||
this->disable();
|
this->disable();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
|
import esphome.config_validation as cv
|
||||||
from esphome.components import spi
|
from esphome.components import spi
|
||||||
from esphome.components.bme280_base.sensor import (
|
from ..bme280_base import to_code_base, CONFIG_SCHEMA_BASE
|
||||||
to_code as to_code_base,
|
|
||||||
cv,
|
|
||||||
CONFIG_SCHEMA_BASE,
|
|
||||||
)
|
|
||||||
|
|
||||||
DEPENDENCIES = ["spi"]
|
|
||||||
AUTO_LOAD = ["bme280_base"]
|
AUTO_LOAD = ["bme280_base"]
|
||||||
|
CODEOWNERS = ["@apbodrov"]
|
||||||
|
DEPENDENCIES = ["spi"]
|
||||||
|
|
||||||
|
|
||||||
bme280_spi_ns = cg.esphome_ns.namespace("bme280_spi")
|
bme280_spi_ns = cg.esphome_ns.namespace("bme280_spi")
|
||||||
@ -21,4 +19,5 @@ CONFIG_SCHEMA = CONFIG_SCHEMA_BASE.extend(spi.spi_device_schema()).extend(
|
|||||||
|
|
||||||
|
|
||||||
async def to_code(config):
|
async def to_code(config):
|
||||||
await to_code_base(config, func=spi.register_spi_device)
|
var = await to_code_base(config)
|
||||||
|
await spi.register_spi_device(var, config)
|
||||||
|
@ -15,11 +15,11 @@ class Rect {
|
|||||||
int16_t h; ///< Height of region
|
int16_t h; ///< Height of region
|
||||||
|
|
||||||
Rect() : x(VALUE_NO_SET), y(VALUE_NO_SET), w(VALUE_NO_SET), h(VALUE_NO_SET) {} // NOLINT
|
Rect() : x(VALUE_NO_SET), y(VALUE_NO_SET), w(VALUE_NO_SET), h(VALUE_NO_SET) {} // NOLINT
|
||||||
inline Rect(int16_t x, int16_t y, int16_t w, int16_t h) ALWAYS_INLINE : x(x), y(y), w(w), h(h) {}
|
inline Rect(int16_t x, int16_t y, int16_t w, int16_t h) ESPHOME_ALWAYS_INLINE : x(x), y(y), w(w), h(h) {}
|
||||||
inline int16_t x2() const { return this->x + this->w; }; ///< X coordinate of corner
|
inline int16_t x2() const { return this->x + this->w; }; ///< X coordinate of corner
|
||||||
inline int16_t y2() const { return this->y + this->h; }; ///< Y coordinate of corner
|
inline int16_t y2() const { return this->y + this->h; }; ///< Y coordinate of corner
|
||||||
|
|
||||||
inline bool is_set() const ALWAYS_INLINE { return (this->h != VALUE_NO_SET) && (this->w != VALUE_NO_SET); }
|
inline bool is_set() const ESPHOME_ALWAYS_INLINE { return (this->h != VALUE_NO_SET) && (this->w != VALUE_NO_SET); }
|
||||||
|
|
||||||
void expand(int16_t horizontal, int16_t vertical);
|
void expand(int16_t horizontal, int16_t vertical);
|
||||||
|
|
||||||
|
@ -49,7 +49,16 @@ def _process_git_config(config: dict, refresh) -> str:
|
|||||||
password=config.get(CONF_PASSWORD),
|
password=config.get(CONF_PASSWORD),
|
||||||
)
|
)
|
||||||
|
|
||||||
if (repo_dir / "esphome" / "components").is_dir():
|
if path := config.get(CONF_PATH):
|
||||||
|
if (repo_dir / path).is_dir():
|
||||||
|
components_dir = repo_dir / path
|
||||||
|
else:
|
||||||
|
raise cv.Invalid(
|
||||||
|
"Could not find components folder for source. Please check the source contains a '"
|
||||||
|
+ path
|
||||||
|
+ "' folder"
|
||||||
|
)
|
||||||
|
elif (repo_dir / "esphome" / "components").is_dir():
|
||||||
components_dir = repo_dir / "esphome" / "components"
|
components_dir = repo_dir / "esphome" / "components"
|
||||||
elif (repo_dir / "components").is_dir():
|
elif (repo_dir / "components").is_dir():
|
||||||
components_dir = repo_dir / "components"
|
components_dir = repo_dir / "components"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "hmc5883l.h"
|
#include "hmc5883l.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
#include "esphome/core/application.h"
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace hmc5883l {
|
namespace hmc5883l {
|
||||||
@ -31,6 +32,10 @@ void HMC5883LComponent::setup() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->get_update_interval() < App.get_loop_interval()) {
|
||||||
|
high_freq_.start();
|
||||||
|
}
|
||||||
|
|
||||||
if (id[0] != 0x48 || id[1] != 0x34 || id[2] != 0x33) {
|
if (id[0] != 0x48 || id[1] != 0x34 || id[2] != 0x33) {
|
||||||
this->error_code_ = ID_REGISTERS;
|
this->error_code_ = ID_REGISTERS;
|
||||||
this->mark_failed();
|
this->mark_failed();
|
||||||
|
@ -63,6 +63,7 @@ class HMC5883LComponent : public PollingComponent, public i2c::I2CDevice {
|
|||||||
COMMUNICATION_FAILED,
|
COMMUNICATION_FAILED,
|
||||||
ID_REGISTERS,
|
ID_REGISTERS,
|
||||||
} error_code_;
|
} error_code_;
|
||||||
|
HighFrequencyLoopRequester high_freq_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace hmc5883l
|
} // namespace hmc5883l
|
||||||
|
@ -11,54 +11,54 @@ class ESPColorCorrection {
|
|||||||
void set_max_brightness(const Color &max_brightness) { this->max_brightness_ = max_brightness; }
|
void set_max_brightness(const Color &max_brightness) { this->max_brightness_ = max_brightness; }
|
||||||
void set_local_brightness(uint8_t local_brightness) { this->local_brightness_ = local_brightness; }
|
void set_local_brightness(uint8_t local_brightness) { this->local_brightness_ = local_brightness; }
|
||||||
void calculate_gamma_table(float gamma);
|
void calculate_gamma_table(float gamma);
|
||||||
inline Color color_correct(Color color) const ALWAYS_INLINE {
|
inline Color color_correct(Color color) const ESPHOME_ALWAYS_INLINE {
|
||||||
// corrected = (uncorrected * max_brightness * local_brightness) ^ gamma
|
// corrected = (uncorrected * max_brightness * local_brightness) ^ gamma
|
||||||
return Color(this->color_correct_red(color.red), this->color_correct_green(color.green),
|
return Color(this->color_correct_red(color.red), this->color_correct_green(color.green),
|
||||||
this->color_correct_blue(color.blue), this->color_correct_white(color.white));
|
this->color_correct_blue(color.blue), this->color_correct_white(color.white));
|
||||||
}
|
}
|
||||||
inline uint8_t color_correct_red(uint8_t red) const ALWAYS_INLINE {
|
inline uint8_t color_correct_red(uint8_t red) const ESPHOME_ALWAYS_INLINE {
|
||||||
uint8_t res = esp_scale8(esp_scale8(red, this->max_brightness_.red), this->local_brightness_);
|
uint8_t res = esp_scale8(esp_scale8(red, this->max_brightness_.red), this->local_brightness_);
|
||||||
return this->gamma_table_[res];
|
return this->gamma_table_[res];
|
||||||
}
|
}
|
||||||
inline uint8_t color_correct_green(uint8_t green) const ALWAYS_INLINE {
|
inline uint8_t color_correct_green(uint8_t green) const ESPHOME_ALWAYS_INLINE {
|
||||||
uint8_t res = esp_scale8(esp_scale8(green, this->max_brightness_.green), this->local_brightness_);
|
uint8_t res = esp_scale8(esp_scale8(green, this->max_brightness_.green), this->local_brightness_);
|
||||||
return this->gamma_table_[res];
|
return this->gamma_table_[res];
|
||||||
}
|
}
|
||||||
inline uint8_t color_correct_blue(uint8_t blue) const ALWAYS_INLINE {
|
inline uint8_t color_correct_blue(uint8_t blue) const ESPHOME_ALWAYS_INLINE {
|
||||||
uint8_t res = esp_scale8(esp_scale8(blue, this->max_brightness_.blue), this->local_brightness_);
|
uint8_t res = esp_scale8(esp_scale8(blue, this->max_brightness_.blue), this->local_brightness_);
|
||||||
return this->gamma_table_[res];
|
return this->gamma_table_[res];
|
||||||
}
|
}
|
||||||
inline uint8_t color_correct_white(uint8_t white) const ALWAYS_INLINE {
|
inline uint8_t color_correct_white(uint8_t white) const ESPHOME_ALWAYS_INLINE {
|
||||||
uint8_t res = esp_scale8(esp_scale8(white, this->max_brightness_.white), this->local_brightness_);
|
uint8_t res = esp_scale8(esp_scale8(white, this->max_brightness_.white), this->local_brightness_);
|
||||||
return this->gamma_table_[res];
|
return this->gamma_table_[res];
|
||||||
}
|
}
|
||||||
inline Color color_uncorrect(Color color) const ALWAYS_INLINE {
|
inline Color color_uncorrect(Color color) const ESPHOME_ALWAYS_INLINE {
|
||||||
// uncorrected = corrected^(1/gamma) / (max_brightness * local_brightness)
|
// uncorrected = corrected^(1/gamma) / (max_brightness * local_brightness)
|
||||||
return Color(this->color_uncorrect_red(color.red), this->color_uncorrect_green(color.green),
|
return Color(this->color_uncorrect_red(color.red), this->color_uncorrect_green(color.green),
|
||||||
this->color_uncorrect_blue(color.blue), this->color_uncorrect_white(color.white));
|
this->color_uncorrect_blue(color.blue), this->color_uncorrect_white(color.white));
|
||||||
}
|
}
|
||||||
inline uint8_t color_uncorrect_red(uint8_t red) const ALWAYS_INLINE {
|
inline uint8_t color_uncorrect_red(uint8_t red) const ESPHOME_ALWAYS_INLINE {
|
||||||
if (this->max_brightness_.red == 0 || this->local_brightness_ == 0)
|
if (this->max_brightness_.red == 0 || this->local_brightness_ == 0)
|
||||||
return 0;
|
return 0;
|
||||||
uint16_t uncorrected = this->gamma_reverse_table_[red] * 255UL;
|
uint16_t uncorrected = this->gamma_reverse_table_[red] * 255UL;
|
||||||
uint8_t res = ((uncorrected / this->max_brightness_.red) * 255UL) / this->local_brightness_;
|
uint8_t res = ((uncorrected / this->max_brightness_.red) * 255UL) / this->local_brightness_;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
inline uint8_t color_uncorrect_green(uint8_t green) const ALWAYS_INLINE {
|
inline uint8_t color_uncorrect_green(uint8_t green) const ESPHOME_ALWAYS_INLINE {
|
||||||
if (this->max_brightness_.green == 0 || this->local_brightness_ == 0)
|
if (this->max_brightness_.green == 0 || this->local_brightness_ == 0)
|
||||||
return 0;
|
return 0;
|
||||||
uint16_t uncorrected = this->gamma_reverse_table_[green] * 255UL;
|
uint16_t uncorrected = this->gamma_reverse_table_[green] * 255UL;
|
||||||
uint8_t res = ((uncorrected / this->max_brightness_.green) * 255UL) / this->local_brightness_;
|
uint8_t res = ((uncorrected / this->max_brightness_.green) * 255UL) / this->local_brightness_;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
inline uint8_t color_uncorrect_blue(uint8_t blue) const ALWAYS_INLINE {
|
inline uint8_t color_uncorrect_blue(uint8_t blue) const ESPHOME_ALWAYS_INLINE {
|
||||||
if (this->max_brightness_.blue == 0 || this->local_brightness_ == 0)
|
if (this->max_brightness_.blue == 0 || this->local_brightness_ == 0)
|
||||||
return 0;
|
return 0;
|
||||||
uint16_t uncorrected = this->gamma_reverse_table_[blue] * 255UL;
|
uint16_t uncorrected = this->gamma_reverse_table_[blue] * 255UL;
|
||||||
uint8_t res = ((uncorrected / this->max_brightness_.blue) * 255UL) / this->local_brightness_;
|
uint8_t res = ((uncorrected / this->max_brightness_.blue) * 255UL) / this->local_brightness_;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
inline uint8_t color_uncorrect_white(uint8_t white) const ALWAYS_INLINE {
|
inline uint8_t color_uncorrect_white(uint8_t white) const ESPHOME_ALWAYS_INLINE {
|
||||||
if (this->max_brightness_.white == 0 || this->local_brightness_ == 0)
|
if (this->max_brightness_.white == 0 || this->local_brightness_ == 0)
|
||||||
return 0;
|
return 0;
|
||||||
uint16_t uncorrected = this->gamma_reverse_table_[white] * 255UL;
|
uint16_t uncorrected = this->gamma_reverse_table_[white] * 255UL;
|
||||||
|
@ -24,11 +24,11 @@ struct ESPHSVColor {
|
|||||||
};
|
};
|
||||||
uint8_t raw[3];
|
uint8_t raw[3];
|
||||||
};
|
};
|
||||||
inline ESPHSVColor() ALWAYS_INLINE : h(0), s(0), v(0) { // NOLINT
|
inline ESPHSVColor() ESPHOME_ALWAYS_INLINE : h(0), s(0), v(0) { // NOLINT
|
||||||
}
|
}
|
||||||
inline ESPHSVColor(uint8_t hue, uint8_t saturation, uint8_t value) ALWAYS_INLINE : hue(hue),
|
inline ESPHSVColor(uint8_t hue, uint8_t saturation, uint8_t value) ESPHOME_ALWAYS_INLINE : hue(hue),
|
||||||
saturation(saturation),
|
saturation(saturation),
|
||||||
value(value) {}
|
value(value) {}
|
||||||
Color to_rgb() const;
|
Color to_rgb() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -39,7 +39,23 @@ void Logger::write_header_(int level, const char *tag, int line) {
|
|||||||
|
|
||||||
const char *color = LOG_LEVEL_COLORS[level];
|
const char *color = LOG_LEVEL_COLORS[level];
|
||||||
const char *letter = LOG_LEVEL_LETTERS[level];
|
const char *letter = LOG_LEVEL_LETTERS[level];
|
||||||
this->printf_to_buffer_("%s[%s][%s:%03u]: ", color, letter, tag, line);
|
#if defined(USE_ESP32) || defined(USE_LIBRETINY)
|
||||||
|
TaskHandle_t current_task = xTaskGetCurrentTaskHandle();
|
||||||
|
#else
|
||||||
|
void *current_task = nullptr;
|
||||||
|
#endif
|
||||||
|
if (current_task == main_task_) {
|
||||||
|
this->printf_to_buffer_("%s[%s][%s:%03u]: ", color, letter, tag, line);
|
||||||
|
} else {
|
||||||
|
const char *thread_name = "";
|
||||||
|
#if defined(USE_ESP32)
|
||||||
|
thread_name = pcTaskGetName(current_task);
|
||||||
|
#elif defined(USE_LIBRETINY)
|
||||||
|
thread_name = pcTaskGetTaskName(current_task);
|
||||||
|
#endif
|
||||||
|
this->printf_to_buffer_("%s[%s][%s:%03u]%s[%s]%s: ", color, letter, tag, line,
|
||||||
|
ESPHOME_LOG_BOLD(ESPHOME_LOG_COLOR_RED), thread_name, color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HOT Logger::log_vprintf_(int level, const char *tag, int line, const char *format, va_list args) { // NOLINT
|
void HOT Logger::log_vprintf_(int level, const char *tag, int line, const char *format, va_list args) { // NOLINT
|
||||||
@ -127,6 +143,9 @@ void HOT Logger::log_message_(int level, const char *tag, int offset) {
|
|||||||
Logger::Logger(uint32_t baud_rate, size_t tx_buffer_size) : baud_rate_(baud_rate), tx_buffer_size_(tx_buffer_size) {
|
Logger::Logger(uint32_t baud_rate, size_t tx_buffer_size) : baud_rate_(baud_rate), tx_buffer_size_(tx_buffer_size) {
|
||||||
// add 1 to buffer size for null terminator
|
// add 1 to buffer size for null terminator
|
||||||
this->tx_buffer_ = new char[this->tx_buffer_size_ + 1]; // NOLINT
|
this->tx_buffer_ = new char[this->tx_buffer_size_ + 1]; // NOLINT
|
||||||
|
#if defined(USE_ESP32) || defined(USE_LIBRETINY)
|
||||||
|
this->main_task_ = xTaskGetCurrentTaskHandle();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_LOGGER_USB_CDC
|
#ifdef USE_LOGGER_USB_CDC
|
||||||
|
@ -167,6 +167,7 @@ class Logger : public Component {
|
|||||||
CallbackManager<void(int, const char *, const char *)> log_callback_{};
|
CallbackManager<void(int, const char *, const char *)> log_callback_{};
|
||||||
/// Prevents recursive log calls, if true a log message is already being processed.
|
/// Prevents recursive log calls, if true a log message is already being processed.
|
||||||
bool recursion_guard_ = false;
|
bool recursion_guard_ = false;
|
||||||
|
void *main_task_ = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Logger *global_logger; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
extern Logger *global_logger; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
||||||
|
@ -2124,6 +2124,7 @@ GIT_SCHEMA = Schema(
|
|||||||
Optional(CONF_REF): git_ref,
|
Optional(CONF_REF): git_ref,
|
||||||
Optional(CONF_USERNAME): string,
|
Optional(CONF_USERNAME): string,
|
||||||
Optional(CONF_PASSWORD): string,
|
Optional(CONF_PASSWORD): string,
|
||||||
|
Optional(CONF_PATH): string,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
LOCAL_SCHEMA = Schema(
|
LOCAL_SCHEMA = Schema(
|
||||||
|
@ -31,19 +31,19 @@ struct Color {
|
|||||||
uint32_t raw_32;
|
uint32_t raw_32;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline Color() ALWAYS_INLINE : r(0), g(0), b(0), w(0) {} // NOLINT
|
inline Color() ESPHOME_ALWAYS_INLINE : r(0), g(0), b(0), w(0) {} // NOLINT
|
||||||
inline Color(uint8_t red, uint8_t green, uint8_t blue) ALWAYS_INLINE : r(red), g(green), b(blue), w(0) {}
|
inline Color(uint8_t red, uint8_t green, uint8_t blue) ESPHOME_ALWAYS_INLINE : r(red), g(green), b(blue), w(0) {}
|
||||||
|
|
||||||
inline Color(uint8_t red, uint8_t green, uint8_t blue, uint8_t white) ALWAYS_INLINE : r(red),
|
inline Color(uint8_t red, uint8_t green, uint8_t blue, uint8_t white) ESPHOME_ALWAYS_INLINE : r(red),
|
||||||
g(green),
|
g(green),
|
||||||
b(blue),
|
b(blue),
|
||||||
w(white) {}
|
w(white) {}
|
||||||
inline explicit Color(uint32_t colorcode) ALWAYS_INLINE : r((colorcode >> 16) & 0xFF),
|
inline explicit Color(uint32_t colorcode) ESPHOME_ALWAYS_INLINE : r((colorcode >> 16) & 0xFF),
|
||||||
g((colorcode >> 8) & 0xFF),
|
g((colorcode >> 8) & 0xFF),
|
||||||
b((colorcode >> 0) & 0xFF),
|
b((colorcode >> 0) & 0xFF),
|
||||||
w((colorcode >> 24) & 0xFF) {}
|
w((colorcode >> 24) & 0xFF) {}
|
||||||
|
|
||||||
inline bool is_on() ALWAYS_INLINE { return this->raw_32 != 0; }
|
inline bool is_on() ESPHOME_ALWAYS_INLINE { return this->raw_32 != 0; }
|
||||||
|
|
||||||
inline bool operator==(const Color &rhs) { // NOLINT
|
inline bool operator==(const Color &rhs) { // NOLINT
|
||||||
return this->raw_32 == rhs.raw_32;
|
return this->raw_32 == rhs.raw_32;
|
||||||
@ -57,31 +57,33 @@ struct Color {
|
|||||||
inline bool operator!=(uint32_t colorcode) { // NOLINT
|
inline bool operator!=(uint32_t colorcode) { // NOLINT
|
||||||
return this->raw_32 != colorcode;
|
return this->raw_32 != colorcode;
|
||||||
}
|
}
|
||||||
inline uint8_t &operator[](uint8_t x) ALWAYS_INLINE { return this->raw[x]; }
|
inline uint8_t &operator[](uint8_t x) ESPHOME_ALWAYS_INLINE { return this->raw[x]; }
|
||||||
inline Color operator*(uint8_t scale) const ALWAYS_INLINE {
|
inline Color operator*(uint8_t scale) const ESPHOME_ALWAYS_INLINE {
|
||||||
return Color(esp_scale8(this->red, scale), esp_scale8(this->green, scale), esp_scale8(this->blue, scale),
|
return Color(esp_scale8(this->red, scale), esp_scale8(this->green, scale), esp_scale8(this->blue, scale),
|
||||||
esp_scale8(this->white, scale));
|
esp_scale8(this->white, scale));
|
||||||
}
|
}
|
||||||
inline Color operator~() const ALWAYS_INLINE { return Color(255 - this->red, 255 - this->green, 255 - this->blue); }
|
inline Color operator~() const ESPHOME_ALWAYS_INLINE {
|
||||||
inline Color &operator*=(uint8_t scale) ALWAYS_INLINE {
|
return Color(255 - this->red, 255 - this->green, 255 - this->blue);
|
||||||
|
}
|
||||||
|
inline Color &operator*=(uint8_t scale) ESPHOME_ALWAYS_INLINE {
|
||||||
this->red = esp_scale8(this->red, scale);
|
this->red = esp_scale8(this->red, scale);
|
||||||
this->green = esp_scale8(this->green, scale);
|
this->green = esp_scale8(this->green, scale);
|
||||||
this->blue = esp_scale8(this->blue, scale);
|
this->blue = esp_scale8(this->blue, scale);
|
||||||
this->white = esp_scale8(this->white, scale);
|
this->white = esp_scale8(this->white, scale);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
inline Color operator*(const Color &scale) const ALWAYS_INLINE {
|
inline Color operator*(const Color &scale) const ESPHOME_ALWAYS_INLINE {
|
||||||
return Color(esp_scale8(this->red, scale.red), esp_scale8(this->green, scale.green),
|
return Color(esp_scale8(this->red, scale.red), esp_scale8(this->green, scale.green),
|
||||||
esp_scale8(this->blue, scale.blue), esp_scale8(this->white, scale.white));
|
esp_scale8(this->blue, scale.blue), esp_scale8(this->white, scale.white));
|
||||||
}
|
}
|
||||||
inline Color &operator*=(const Color &scale) ALWAYS_INLINE {
|
inline Color &operator*=(const Color &scale) ESPHOME_ALWAYS_INLINE {
|
||||||
this->red = esp_scale8(this->red, scale.red);
|
this->red = esp_scale8(this->red, scale.red);
|
||||||
this->green = esp_scale8(this->green, scale.green);
|
this->green = esp_scale8(this->green, scale.green);
|
||||||
this->blue = esp_scale8(this->blue, scale.blue);
|
this->blue = esp_scale8(this->blue, scale.blue);
|
||||||
this->white = esp_scale8(this->white, scale.white);
|
this->white = esp_scale8(this->white, scale.white);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
inline Color operator+(const Color &add) const ALWAYS_INLINE {
|
inline Color operator+(const Color &add) const ESPHOME_ALWAYS_INLINE {
|
||||||
Color ret;
|
Color ret;
|
||||||
if (uint8_t(add.r + this->r) < this->r)
|
if (uint8_t(add.r + this->r) < this->r)
|
||||||
ret.r = 255;
|
ret.r = 255;
|
||||||
@ -101,10 +103,10 @@ struct Color {
|
|||||||
ret.w = this->w + add.w;
|
ret.w = this->w + add.w;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
inline Color &operator+=(const Color &add) ALWAYS_INLINE { return *this = (*this) + add; }
|
inline Color &operator+=(const Color &add) ESPHOME_ALWAYS_INLINE { return *this = (*this) + add; }
|
||||||
inline Color operator+(uint8_t add) const ALWAYS_INLINE { return (*this) + Color(add, add, add, add); }
|
inline Color operator+(uint8_t add) const ESPHOME_ALWAYS_INLINE { return (*this) + Color(add, add, add, add); }
|
||||||
inline Color &operator+=(uint8_t add) ALWAYS_INLINE { return *this = (*this) + add; }
|
inline Color &operator+=(uint8_t add) ESPHOME_ALWAYS_INLINE { return *this = (*this) + add; }
|
||||||
inline Color operator-(const Color &subtract) const ALWAYS_INLINE {
|
inline Color operator-(const Color &subtract) const ESPHOME_ALWAYS_INLINE {
|
||||||
Color ret;
|
Color ret;
|
||||||
if (subtract.r > this->r)
|
if (subtract.r > this->r)
|
||||||
ret.r = 0;
|
ret.r = 0;
|
||||||
@ -124,11 +126,11 @@ struct Color {
|
|||||||
ret.w = this->w - subtract.w;
|
ret.w = this->w - subtract.w;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
inline Color &operator-=(const Color &subtract) ALWAYS_INLINE { return *this = (*this) - subtract; }
|
inline Color &operator-=(const Color &subtract) ESPHOME_ALWAYS_INLINE { return *this = (*this) - subtract; }
|
||||||
inline Color operator-(uint8_t subtract) const ALWAYS_INLINE {
|
inline Color operator-(uint8_t subtract) const ESPHOME_ALWAYS_INLINE {
|
||||||
return (*this) - Color(subtract, subtract, subtract, subtract);
|
return (*this) - Color(subtract, subtract, subtract, subtract);
|
||||||
}
|
}
|
||||||
inline Color &operator-=(uint8_t subtract) ALWAYS_INLINE { return *this = (*this) - subtract; }
|
inline Color &operator-=(uint8_t subtract) ESPHOME_ALWAYS_INLINE { return *this = (*this) - subtract; }
|
||||||
static Color random_color() {
|
static Color random_color() {
|
||||||
uint32_t rand = random_uint32();
|
uint32_t rand = random_uint32();
|
||||||
uint8_t w = rand >> 24;
|
uint8_t w = rand >> 24;
|
||||||
|
@ -15,18 +15,23 @@
|
|||||||
#define ESPHOME_VARIANT "ESP32"
|
#define ESPHOME_VARIANT "ESP32"
|
||||||
|
|
||||||
// Feature flags
|
// Feature flags
|
||||||
|
#define USE_ALARM_CONTROL_PANEL
|
||||||
#define USE_API
|
#define USE_API
|
||||||
#define USE_API_NOISE
|
#define USE_API_NOISE
|
||||||
#define USE_API_PLAINTEXT
|
#define USE_API_PLAINTEXT
|
||||||
#define USE_ALARM_CONTROL_PANEL
|
|
||||||
#define USE_BINARY_SENSOR
|
#define USE_BINARY_SENSOR
|
||||||
#define USE_BUTTON
|
#define USE_BUTTON
|
||||||
#define USE_CLIMATE
|
#define USE_CLIMATE
|
||||||
#define USE_COVER
|
#define USE_COVER
|
||||||
|
#define USE_DATETIME
|
||||||
|
#define USE_DATETIME_DATE
|
||||||
|
#define USE_DATETIME_DATETIME
|
||||||
|
#define USE_DATETIME_TIME
|
||||||
#define USE_DEEP_SLEEP
|
#define USE_DEEP_SLEEP
|
||||||
#define USE_EVENT
|
#define USE_EVENT
|
||||||
#define USE_FAN
|
#define USE_FAN
|
||||||
#define USE_GRAPH
|
#define USE_GRAPH
|
||||||
|
#define USE_GRAPHICAL_DISPLAY_MENU
|
||||||
#define USE_HOMEASSISTANT_TIME
|
#define USE_HOMEASSISTANT_TIME
|
||||||
#define USE_JSON
|
#define USE_JSON
|
||||||
#define USE_LIGHT
|
#define USE_LIGHT
|
||||||
@ -37,10 +42,6 @@
|
|||||||
#define USE_MQTT
|
#define USE_MQTT
|
||||||
#define USE_NEXTION_TFT_UPLOAD
|
#define USE_NEXTION_TFT_UPLOAD
|
||||||
#define USE_NUMBER
|
#define USE_NUMBER
|
||||||
#define USE_DATETIME
|
|
||||||
#define USE_DATETIME_DATE
|
|
||||||
#define USE_DATETIME_TIME
|
|
||||||
#define USE_DATETIME_DATETIME
|
|
||||||
#define USE_OTA
|
#define USE_OTA
|
||||||
#define USE_OTA_PASSWORD
|
#define USE_OTA_PASSWORD
|
||||||
#define USE_OTA_STATE_CALLBACK
|
#define USE_OTA_STATE_CALLBACK
|
||||||
@ -60,7 +61,6 @@
|
|||||||
#define USE_VALVE
|
#define USE_VALVE
|
||||||
#define USE_WIFI
|
#define USE_WIFI
|
||||||
#define USE_WIFI_AP
|
#define USE_WIFI_AP
|
||||||
#define USE_GRAPHICAL_DISPLAY_MENU
|
|
||||||
|
|
||||||
// Arduino-specific feature flags
|
// Arduino-specific feature flags
|
||||||
#ifdef USE_ARDUINO
|
#ifdef USE_ARDUINO
|
||||||
@ -78,17 +78,19 @@
|
|||||||
|
|
||||||
// ESP32-specific feature flags
|
// ESP32-specific feature flags
|
||||||
#ifdef USE_ESP32
|
#ifdef USE_ESP32
|
||||||
|
#define USE_BLUETOOTH_PROXY
|
||||||
|
#define USE_ESP32_BLE
|
||||||
#define USE_ESP32_BLE_CLIENT
|
#define USE_ESP32_BLE_CLIENT
|
||||||
#define USE_ESP32_BLE_SERVER
|
#define USE_ESP32_BLE_SERVER
|
||||||
#define USE_ESP32_CAMERA
|
#define USE_ESP32_CAMERA
|
||||||
#define USE_IMPROV
|
#define USE_IMPROV
|
||||||
#define USE_SOCKET_IMPL_BSD_SOCKETS
|
|
||||||
#define USE_WIFI_11KV_SUPPORT
|
|
||||||
#define USE_BLUETOOTH_PROXY
|
|
||||||
#define USE_VOICE_ASSISTANT
|
|
||||||
#define USE_MICROPHONE
|
#define USE_MICROPHONE
|
||||||
|
#define USE_PSRAM
|
||||||
|
#define USE_SOCKET_IMPL_BSD_SOCKETS
|
||||||
#define USE_SPEAKER
|
#define USE_SPEAKER
|
||||||
#define USE_SPI
|
#define USE_SPI
|
||||||
|
#define USE_VOICE_ASSISTANT
|
||||||
|
#define USE_WIFI_11KV_SUPPORT
|
||||||
|
|
||||||
#ifdef USE_ARDUINO
|
#ifdef USE_ARDUINO
|
||||||
#define USE_ARDUINO_VERSION_CODE VERSION_CODE(2, 0, 5)
|
#define USE_ARDUINO_VERSION_CODE VERSION_CODE(2, 0, 5)
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#define HOT __attribute__((hot))
|
#define HOT __attribute__((hot))
|
||||||
#define ESPDEPRECATED(msg, when) __attribute__((deprecated(msg)))
|
#define ESPDEPRECATED(msg, when) __attribute__((deprecated(msg)))
|
||||||
#define ALWAYS_INLINE __attribute__((always_inline))
|
#define ESPHOME_ALWAYS_INLINE __attribute__((always_inline))
|
||||||
#define PACKED __attribute__((packed))
|
#define PACKED __attribute__((packed))
|
||||||
|
|
||||||
// Various functions can be constexpr in C++14, but not in C++11 (because their body isn't just a return statement).
|
// Various functions can be constexpr in C++14, but not in C++11 (because their body isn't just a return statement).
|
||||||
|
19
tests/components/bme280_i2c/common.yaml
Normal file
19
tests/components/bme280_i2c/common.yaml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
i2c:
|
||||||
|
- id: i2c_bme280
|
||||||
|
scl: ${scl_pin}
|
||||||
|
sda: ${sda_pin}
|
||||||
|
|
||||||
|
sensor:
|
||||||
|
- platform: bme280_i2c
|
||||||
|
i2c_id: i2c_bme280
|
||||||
|
address: 0x76
|
||||||
|
temperature:
|
||||||
|
id: bme280_temperature
|
||||||
|
name: BME280 Temperature
|
||||||
|
humidity:
|
||||||
|
id: bme280_humidity
|
||||||
|
name: BME280 Humidity
|
||||||
|
pressure:
|
||||||
|
id: bme280_pressure
|
||||||
|
name: BME280 Pressure
|
||||||
|
update_interval: 15s
|
@ -1,18 +1,5 @@
|
|||||||
i2c:
|
substitutions:
|
||||||
- id: i2c_bme280
|
scl_pin: GPIO5
|
||||||
scl: 5
|
sda_pin: GPIO4
|
||||||
sda: 4
|
|
||||||
|
|
||||||
sensor:
|
<<: !include common.yaml
|
||||||
- platform: bme280_i2c
|
|
||||||
address: 0x76
|
|
||||||
temperature:
|
|
||||||
id: bme280_temperature
|
|
||||||
name: BME280 Temperature
|
|
||||||
humidity:
|
|
||||||
id: bme280_humidity
|
|
||||||
name: BME280 Humidity
|
|
||||||
pressure:
|
|
||||||
id: bme280_pressure
|
|
||||||
name: BME280 Pressure
|
|
||||||
update_interval: 15s
|
|
||||||
|
@ -1,18 +1,5 @@
|
|||||||
i2c:
|
substitutions:
|
||||||
- id: i2c_bme280
|
scl_pin: GPIO5
|
||||||
scl: 5
|
sda_pin: GPIO4
|
||||||
sda: 4
|
|
||||||
|
|
||||||
sensor:
|
<<: !include common.yaml
|
||||||
- platform: bme280_i2c
|
|
||||||
address: 0x76
|
|
||||||
temperature:
|
|
||||||
id: bme280_temperature
|
|
||||||
name: BME280 Temperature
|
|
||||||
humidity:
|
|
||||||
id: bme280_humidity
|
|
||||||
name: BME280 Humidity
|
|
||||||
pressure:
|
|
||||||
id: bme280_pressure
|
|
||||||
name: BME280 Pressure
|
|
||||||
update_interval: 15s
|
|
||||||
|
@ -1,18 +1,5 @@
|
|||||||
i2c:
|
substitutions:
|
||||||
- id: i2c_bme280
|
scl_pin: GPIO16
|
||||||
scl: 16
|
sda_pin: GPIO17
|
||||||
sda: 17
|
|
||||||
|
|
||||||
sensor:
|
<<: !include common.yaml
|
||||||
- platform: bme280_i2c
|
|
||||||
address: 0x76
|
|
||||||
temperature:
|
|
||||||
id: bme280_temperature
|
|
||||||
name: BME280 Temperature
|
|
||||||
humidity:
|
|
||||||
id: bme280_humidity
|
|
||||||
name: BME280 Humidity
|
|
||||||
pressure:
|
|
||||||
id: bme280_pressure
|
|
||||||
name: BME280 Pressure
|
|
||||||
update_interval: 15s
|
|
||||||
|
@ -1,18 +1,5 @@
|
|||||||
i2c:
|
substitutions:
|
||||||
- id: i2c_bme280
|
scl_pin: GPIO16
|
||||||
scl: 16
|
sda_pin: GPIO17
|
||||||
sda: 17
|
|
||||||
|
|
||||||
sensor:
|
<<: !include common.yaml
|
||||||
- platform: bme280_i2c
|
|
||||||
address: 0x76
|
|
||||||
temperature:
|
|
||||||
id: bme280_temperature
|
|
||||||
name: BME280 Temperature
|
|
||||||
humidity:
|
|
||||||
id: bme280_humidity
|
|
||||||
name: BME280 Humidity
|
|
||||||
pressure:
|
|
||||||
id: bme280_pressure
|
|
||||||
name: BME280 Pressure
|
|
||||||
update_interval: 15s
|
|
||||||
|
@ -1,18 +1,5 @@
|
|||||||
i2c:
|
substitutions:
|
||||||
- id: i2c_bme280
|
scl_pin: GPIO5
|
||||||
scl: 5
|
sda_pin: GPIO4
|
||||||
sda: 4
|
|
||||||
|
|
||||||
sensor:
|
<<: !include common.yaml
|
||||||
- platform: bme280_i2c
|
|
||||||
address: 0x76
|
|
||||||
temperature:
|
|
||||||
id: bme280_temperature
|
|
||||||
name: BME280 Temperature
|
|
||||||
humidity:
|
|
||||||
id: bme280_humidity
|
|
||||||
name: BME280 Humidity
|
|
||||||
pressure:
|
|
||||||
id: bme280_pressure
|
|
||||||
name: BME280 Pressure
|
|
||||||
update_interval: 15s
|
|
||||||
|
@ -1,18 +1,5 @@
|
|||||||
i2c:
|
substitutions:
|
||||||
- id: i2c_bme280
|
scl_pin: GPIO5
|
||||||
scl: 5
|
sda_pin: GPIO4
|
||||||
sda: 4
|
|
||||||
|
|
||||||
sensor:
|
<<: !include common.yaml
|
||||||
- platform: bme280_i2c
|
|
||||||
address: 0x76
|
|
||||||
temperature:
|
|
||||||
id: bme280_temperature
|
|
||||||
name: BME280 Temperature
|
|
||||||
humidity:
|
|
||||||
id: bme280_humidity
|
|
||||||
name: BME280 Humidity
|
|
||||||
pressure:
|
|
||||||
id: bme280_pressure
|
|
||||||
name: BME280 Pressure
|
|
||||||
update_interval: 15s
|
|
||||||
|
20
tests/components/bme280_spi/common.yaml
Normal file
20
tests/components/bme280_spi/common.yaml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
spi:
|
||||||
|
- id: spi_bme280
|
||||||
|
clk_pin: ${clk_pin}
|
||||||
|
mosi_pin: ${mosi_pin}
|
||||||
|
miso_pin: ${miso_pin}
|
||||||
|
|
||||||
|
sensor:
|
||||||
|
- platform: bme280_spi
|
||||||
|
spi_id: spi_bme280
|
||||||
|
cs_pin: ${cs_pin}
|
||||||
|
temperature:
|
||||||
|
id: bme280_temperature
|
||||||
|
name: BME280 Temperature
|
||||||
|
humidity:
|
||||||
|
id: bme280_humidity
|
||||||
|
name: BME280 Humidity
|
||||||
|
pressure:
|
||||||
|
id: bme280_pressure
|
||||||
|
name: BME280 Pressure
|
||||||
|
update_interval: 15s
|
@ -1,19 +1,7 @@
|
|||||||
spi:
|
substitutions:
|
||||||
- id: spi_bme280
|
clk_pin: GPIO6
|
||||||
clk_pin: 6
|
mosi_pin: GPIO7
|
||||||
mosi_pin: 7
|
miso_pin: GPIO5
|
||||||
miso_pin: 5
|
cs_pin: GPIO8
|
||||||
|
|
||||||
sensor:
|
<<: !include common.yaml
|
||||||
- platform: bme280_spi
|
|
||||||
cs_pin: 8
|
|
||||||
temperature:
|
|
||||||
id: bme280_temperature
|
|
||||||
name: BME280 Temperature
|
|
||||||
humidity:
|
|
||||||
id: bme280_humidity
|
|
||||||
name: BME280 Humidity
|
|
||||||
pressure:
|
|
||||||
id: bme280_pressure
|
|
||||||
name: BME280 Pressure
|
|
||||||
update_interval: 15s
|
|
||||||
|
@ -1,19 +1,7 @@
|
|||||||
spi:
|
substitutions:
|
||||||
- id: spi_bme280
|
clk_pin: GPIO6
|
||||||
clk_pin: 6
|
mosi_pin: GPIO7
|
||||||
mosi_pin: 7
|
miso_pin: GPIO5
|
||||||
miso_pin: 5
|
cs_pin: GPIO8
|
||||||
|
|
||||||
sensor:
|
<<: !include common.yaml
|
||||||
- platform: bme280_spi
|
|
||||||
cs_pin: 8
|
|
||||||
temperature:
|
|
||||||
id: bme280_temperature
|
|
||||||
name: BME280 Temperature
|
|
||||||
humidity:
|
|
||||||
id: bme280_humidity
|
|
||||||
name: BME280 Humidity
|
|
||||||
pressure:
|
|
||||||
id: bme280_pressure
|
|
||||||
name: BME280 Pressure
|
|
||||||
update_interval: 15s
|
|
||||||
|
@ -1,19 +1,7 @@
|
|||||||
spi:
|
substitutions:
|
||||||
- id: spi_bme280
|
clk_pin: GPIO16
|
||||||
clk_pin: 16
|
mosi_pin: GPIO17
|
||||||
mosi_pin: 17
|
miso_pin: GPIO15
|
||||||
miso_pin: 15
|
cs_pin: GPIO5
|
||||||
|
|
||||||
sensor:
|
<<: !include common.yaml
|
||||||
- platform: bme280_spi
|
|
||||||
cs_pin: 12
|
|
||||||
temperature:
|
|
||||||
id: bme280_temperature
|
|
||||||
name: BME280 Temperature
|
|
||||||
humidity:
|
|
||||||
id: bme280_humidity
|
|
||||||
name: BME280 Humidity
|
|
||||||
pressure:
|
|
||||||
id: bme280_pressure
|
|
||||||
name: BME280 Pressure
|
|
||||||
update_interval: 15s
|
|
||||||
|
@ -1,19 +1,7 @@
|
|||||||
spi:
|
substitutions:
|
||||||
- id: spi_bme280
|
clk_pin: GPIO16
|
||||||
clk_pin: 16
|
mosi_pin: GPIO17
|
||||||
mosi_pin: 17
|
miso_pin: GPIO15
|
||||||
miso_pin: 15
|
cs_pin: GPIO5
|
||||||
|
|
||||||
sensor:
|
<<: !include common.yaml
|
||||||
- platform: bme280_spi
|
|
||||||
cs_pin: 12
|
|
||||||
temperature:
|
|
||||||
id: bme280_temperature
|
|
||||||
name: BME280 Temperature
|
|
||||||
humidity:
|
|
||||||
id: bme280_humidity
|
|
||||||
name: BME280 Humidity
|
|
||||||
pressure:
|
|
||||||
id: bme280_pressure
|
|
||||||
name: BME280 Pressure
|
|
||||||
update_interval: 15s
|
|
||||||
|
@ -1,19 +1,7 @@
|
|||||||
spi:
|
substitutions:
|
||||||
- id: spi_bme280
|
clk_pin: GPIO14
|
||||||
clk_pin: 14
|
mosi_pin: GPIO13
|
||||||
mosi_pin: 13
|
miso_pin: GPIO12
|
||||||
miso_pin: 12
|
cs_pin: GPIO15
|
||||||
|
|
||||||
sensor:
|
<<: !include common.yaml
|
||||||
- platform: bme280_spi
|
|
||||||
cs_pin: 15
|
|
||||||
temperature:
|
|
||||||
id: bme280_temperature
|
|
||||||
name: BME280 Temperature
|
|
||||||
humidity:
|
|
||||||
id: bme280_humidity
|
|
||||||
name: BME280 Humidity
|
|
||||||
pressure:
|
|
||||||
id: bme280_pressure
|
|
||||||
name: BME280 Pressure
|
|
||||||
update_interval: 15s
|
|
||||||
|
@ -1,19 +1,7 @@
|
|||||||
spi:
|
substitutions:
|
||||||
- id: spi_bme280
|
clk_pin: GPIO2
|
||||||
clk_pin: 2
|
mosi_pin: GPIO3
|
||||||
mosi_pin: 3
|
miso_pin: GPIO4
|
||||||
miso_pin: 4
|
cs_pin: GPIO5
|
||||||
|
|
||||||
sensor:
|
<<: !include common.yaml
|
||||||
- platform: bme280_spi
|
|
||||||
cs_pin: 6
|
|
||||||
temperature:
|
|
||||||
id: bme280_temperature
|
|
||||||
name: BME280 Temperature
|
|
||||||
humidity:
|
|
||||||
id: bme280_humidity
|
|
||||||
name: BME280 Humidity
|
|
||||||
pressure:
|
|
||||||
id: bme280_pressure
|
|
||||||
name: BME280 Pressure
|
|
||||||
update_interval: 15s
|
|
||||||
|
@ -706,35 +706,6 @@ sensor:
|
|||||||
update_interval: 30s
|
update_interval: 30s
|
||||||
mode: low_power
|
mode: low_power
|
||||||
i2c_id: i2c_bus
|
i2c_id: i2c_bus
|
||||||
- platform: bme280_i2c
|
|
||||||
temperature:
|
|
||||||
name: Outside Temperature
|
|
||||||
oversampling: 16x
|
|
||||||
pressure:
|
|
||||||
name: Outside Pressure
|
|
||||||
oversampling: none
|
|
||||||
humidity:
|
|
||||||
name: Outside Humidity
|
|
||||||
oversampling: 8x
|
|
||||||
address: 0x77
|
|
||||||
iir_filter: 16x
|
|
||||||
update_interval: 15s
|
|
||||||
i2c_id: i2c_bus
|
|
||||||
- platform: bme280_spi
|
|
||||||
temperature:
|
|
||||||
name: Outside Temperature
|
|
||||||
oversampling: 16x
|
|
||||||
pressure:
|
|
||||||
name: Outside Pressure
|
|
||||||
oversampling: none
|
|
||||||
humidity:
|
|
||||||
name: Outside Humidity
|
|
||||||
oversampling: 8x
|
|
||||||
cs_pin:
|
|
||||||
allow_other_uses: true
|
|
||||||
number: GPIO23
|
|
||||||
iir_filter: 16x
|
|
||||||
update_interval: 15s
|
|
||||||
- platform: bme680
|
- platform: bme680
|
||||||
temperature:
|
temperature:
|
||||||
name: Outside Temperature
|
name: Outside Temperature
|
||||||
|
Loading…
x
Reference in New Issue
Block a user