Compare commits
7 Commits
2023.3.0b4
...
2023.3.0b6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c298c1166f | ||
|
|
c3d9eef01f | ||
|
|
5ffdc66864 | ||
|
|
9922c1503a | ||
|
|
fce99d4b17 | ||
|
|
11567085d8 | ||
|
|
83f8e84247 |
@@ -32,9 +32,11 @@ void Rect::extend(Rect rect) {
|
||||
this->h = rect.h;
|
||||
} else {
|
||||
if (this->x > rect.x) {
|
||||
this->w = this->w + (this->x - rect.x);
|
||||
this->x = rect.x;
|
||||
}
|
||||
if (this->y > rect.y) {
|
||||
this->h = this->h + (this->y - rect.y);
|
||||
this->y = rect.y;
|
||||
}
|
||||
if (this->x2() < rect.x2()) {
|
||||
@@ -49,29 +51,35 @@ void Rect::shrink(Rect rect) {
|
||||
if (!this->inside(rect)) {
|
||||
(*this) = Rect();
|
||||
} else {
|
||||
if (this->x < rect.x) {
|
||||
this->x = rect.x;
|
||||
}
|
||||
if (this->y < rect.y) {
|
||||
this->y = rect.y;
|
||||
}
|
||||
if (this->x2() > rect.x2()) {
|
||||
this->w = rect.x2() - this->x;
|
||||
}
|
||||
if (this->x < rect.x) {
|
||||
this->w = this->w + (this->x - rect.x);
|
||||
this->x = rect.x;
|
||||
}
|
||||
if (this->y2() > rect.y2()) {
|
||||
this->h = rect.y2() - this->y;
|
||||
}
|
||||
if (this->y < rect.y) {
|
||||
this->h = this->h + (this->y - rect.y);
|
||||
this->y = rect.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Rect::inside(int16_t x, int16_t y, bool absolute) { // NOLINT
|
||||
bool Rect::equal(Rect rect) {
|
||||
return (rect.x == this->x) && (rect.w == this->w) && (rect.y == this->y) && (rect.h == this->h);
|
||||
}
|
||||
|
||||
bool Rect::inside(int16_t test_x, int16_t test_y, bool absolute) { // NOLINT
|
||||
if (!this->is_set()) {
|
||||
return true;
|
||||
}
|
||||
if (absolute) {
|
||||
return ((x >= 0) && (x <= this->w) && (y >= 0) && (y <= this->h));
|
||||
return ((test_x >= this->x) && (test_x <= this->x2()) && (test_y >= this->y) && (test_y <= this->y2()));
|
||||
} else {
|
||||
return ((x >= this->x) && (x <= this->x2()) && (y >= this->y) && (y <= this->y2()));
|
||||
return ((test_x >= 0) && (test_x <= this->w) && (test_y >= 0) && (test_y <= this->h));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,15 +88,16 @@ bool Rect::inside(Rect rect, bool absolute) {
|
||||
return true;
|
||||
}
|
||||
if (absolute) {
|
||||
return ((rect.x <= this->w) && (rect.w >= 0) && (rect.y <= this->h) && (rect.h >= 0));
|
||||
} else {
|
||||
return ((rect.x <= this->x2()) && (rect.x2() >= this->x) && (rect.y <= this->y2()) && (rect.y2() >= this->y));
|
||||
} else {
|
||||
return ((rect.x <= this->w) && (rect.w >= 0) && (rect.y <= this->h) && (rect.h >= 0));
|
||||
}
|
||||
}
|
||||
|
||||
void Rect::info(const std::string &prefix) {
|
||||
if (this->is_set()) {
|
||||
ESP_LOGI(TAG, "%s [%3d,%3d,%3d,%3d]", prefix.c_str(), this->x, this->y, this->w, this->h);
|
||||
ESP_LOGI(TAG, "%s [%3d,%3d,%3d,%3d] (%3d,%3d)", prefix.c_str(), this->x, this->y, this->w, this->h, this->x2(),
|
||||
this->y2());
|
||||
} else
|
||||
ESP_LOGI(TAG, "%s ** IS NOT SET **", prefix.c_str());
|
||||
}
|
||||
|
||||
@@ -120,8 +120,9 @@ class Rect {
|
||||
void extend(Rect rect);
|
||||
void shrink(Rect rect);
|
||||
|
||||
bool inside(Rect rect, bool absolute = false);
|
||||
bool inside(int16_t x, int16_t y, bool absolute = false);
|
||||
bool inside(Rect rect, bool absolute = true);
|
||||
bool inside(int16_t test_x, int16_t test_y, bool absolute = true);
|
||||
bool equal(Rect rect);
|
||||
void info(const std::string &prefix = "rect info:");
|
||||
};
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ from esphome.const import (
|
||||
CONF_VOLTAGE_ATTENUATION,
|
||||
)
|
||||
from esphome.core import TimePeriod
|
||||
from esphome.components import esp32
|
||||
|
||||
AUTO_LOAD = ["binary_sensor"]
|
||||
DEPENDENCIES = ["esp32"]
|
||||
@@ -50,30 +51,37 @@ VOLTAGE_ATTENUATION = {
|
||||
"0V": cg.global_ns.TOUCH_HVOLT_ATTEN_0V,
|
||||
}
|
||||
|
||||
CONFIG_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(ESP32TouchComponent),
|
||||
cv.Optional(CONF_SETUP_MODE, default=False): cv.boolean,
|
||||
cv.Optional(
|
||||
CONF_IIR_FILTER, default="0ms"
|
||||
): cv.positive_time_period_milliseconds,
|
||||
cv.Optional(CONF_SLEEP_DURATION, default="27306us"): cv.All(
|
||||
cv.positive_time_period, cv.Range(max=TimePeriod(microseconds=436906))
|
||||
),
|
||||
cv.Optional(CONF_MEASUREMENT_DURATION, default="8192us"): cv.All(
|
||||
cv.positive_time_period, cv.Range(max=TimePeriod(microseconds=8192))
|
||||
),
|
||||
cv.Optional(CONF_LOW_VOLTAGE_REFERENCE, default="0.5V"): validate_voltage(
|
||||
LOW_VOLTAGE_REFERENCE
|
||||
),
|
||||
cv.Optional(CONF_HIGH_VOLTAGE_REFERENCE, default="2.7V"): validate_voltage(
|
||||
HIGH_VOLTAGE_REFERENCE
|
||||
),
|
||||
cv.Optional(CONF_VOLTAGE_ATTENUATION, default="0V"): validate_voltage(
|
||||
VOLTAGE_ATTENUATION
|
||||
),
|
||||
}
|
||||
).extend(cv.COMPONENT_SCHEMA)
|
||||
CONFIG_SCHEMA = cv.All(
|
||||
cv.Schema(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(ESP32TouchComponent),
|
||||
cv.Optional(CONF_SETUP_MODE, default=False): cv.boolean,
|
||||
cv.Optional(
|
||||
CONF_IIR_FILTER, default="0ms"
|
||||
): cv.positive_time_period_milliseconds,
|
||||
cv.Optional(CONF_SLEEP_DURATION, default="27306us"): cv.All(
|
||||
cv.positive_time_period, cv.Range(max=TimePeriod(microseconds=436906))
|
||||
),
|
||||
cv.Optional(CONF_MEASUREMENT_DURATION, default="8192us"): cv.All(
|
||||
cv.positive_time_period, cv.Range(max=TimePeriod(microseconds=8192))
|
||||
),
|
||||
cv.Optional(CONF_LOW_VOLTAGE_REFERENCE, default="0.5V"): validate_voltage(
|
||||
LOW_VOLTAGE_REFERENCE
|
||||
),
|
||||
cv.Optional(CONF_HIGH_VOLTAGE_REFERENCE, default="2.7V"): validate_voltage(
|
||||
HIGH_VOLTAGE_REFERENCE
|
||||
),
|
||||
cv.Optional(CONF_VOLTAGE_ATTENUATION, default="0V"): validate_voltage(
|
||||
VOLTAGE_ATTENUATION
|
||||
),
|
||||
}
|
||||
).extend(cv.COMPONENT_SCHEMA),
|
||||
esp32.only_on_variant(
|
||||
supported=[
|
||||
esp32.const.VARIANT_ESP32,
|
||||
]
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
|
||||
@@ -477,7 +477,6 @@ void Sprinkler::configure_valve_switch(size_t valve_number, switch_::Switch *val
|
||||
if (this->is_a_valid_valve(valve_number)) {
|
||||
this->valve_[valve_number].valve_switch.set_on_switch(valve_switch);
|
||||
this->valve_[valve_number].run_duration = run_duration;
|
||||
valve_switch->turn_off();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -489,8 +488,6 @@ void Sprinkler::configure_valve_switch_pulsed(size_t valve_number, switch_::Swit
|
||||
this->valve_[valve_number].valve_switch.set_on_switch(valve_switch_on);
|
||||
this->valve_[valve_number].valve_switch.set_pulse_duration(pulse_duration);
|
||||
this->valve_[valve_number].run_duration = run_duration;
|
||||
valve_switch_off->turn_off();
|
||||
valve_switch_on->turn_off();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -505,7 +502,6 @@ void Sprinkler::configure_valve_pump_switch(size_t valve_number, switch_::Switch
|
||||
this->pump_.resize(this->pump_.size() + 1);
|
||||
this->pump_.back().set_on_switch(pump_switch);
|
||||
this->valve_[valve_number].pump_switch_index = this->pump_.size() - 1; // save the index to the new pump
|
||||
pump_switch->turn_off();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -524,8 +520,6 @@ void Sprinkler::configure_valve_pump_switch_pulsed(size_t valve_number, switch_:
|
||||
this->pump_.back().set_on_switch(pump_switch_on);
|
||||
this->pump_.back().set_pulse_duration(pulse_duration);
|
||||
this->valve_[valve_number].pump_switch_index = this->pump_.size() - 1; // save the index to the new pump
|
||||
pump_switch_off->turn_off();
|
||||
pump_switch_on->turn_off();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ class SprinklerControllerNumber : public number::Number, public Component {
|
||||
public:
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
float get_setup_priority() const override { return setup_priority::HARDWARE; }
|
||||
float get_setup_priority() const override { return setup_priority::PROCESSOR; }
|
||||
|
||||
Trigger<float> *get_set_trigger() const { return set_trigger_; }
|
||||
void set_initial_value(float initial_value) { initial_value_ = initial_value; }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Constants used by esphome."""
|
||||
|
||||
__version__ = "2023.3.0b4"
|
||||
__version__ = "2023.3.0b6"
|
||||
|
||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user