mirror of
https://github.com/esphome/esphome.git
synced 2026-09-04 03:56:04 +00:00
Merge remote-tracking branch 'upstream/dev' into integration
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
a172e2f65981e98354cc6b5ecf69bdb055dd13602226042ab2c7acd037a2bf41
|
||||
=======
|
||||
d565b0589e35e692b5f2fc0c14723a99595b4828a3a3ef96c442e86a23176c00
|
||||
@@ -11,3 +12,6 @@ a172e2f65981e98354cc6b5ecf69bdb055dd13602226042ab2c7acd037a2bf41
|
||||
=======
|
||||
08c21fa4c044fd80c8f3296371f30c4f5ff3418f1bc1efe63c5bad938301f122
|
||||
>>>>>>> rp2040_web_server_only_no_cap
|
||||
=======
|
||||
cf3d341206b4184ec8b7fe85141aef4fe4696aa720c3f8a06d4e57930574bdab
|
||||
>>>>>>> upstream/dev
|
||||
|
||||
@@ -1124,7 +1124,7 @@ async def to_code(config):
|
||||
|
||||
cg.add_build_flag("-Wno-nonnull-compare")
|
||||
|
||||
# Use CMN (common CAs) bundle by default to save ~35KB flash
|
||||
# Use CMN (common CAs) bundle by default to save ~51KB flash
|
||||
# CMN covers CAs with >1% market share (~99% of websites)
|
||||
# Components needing uncommon CAs can call require_full_certificate_bundle()
|
||||
use_full_bundle = conf[CONF_ADVANCED].get(
|
||||
|
||||
@@ -2,6 +2,25 @@
|
||||
|
||||
from . import BoardConfig
|
||||
|
||||
# Huidu HD-WF1
|
||||
BoardConfig(
|
||||
"huidu-hd-wf1",
|
||||
r1_pin=2,
|
||||
g1_pin=6,
|
||||
b1_pin=3,
|
||||
r2_pin=4,
|
||||
g2_pin=8,
|
||||
b2_pin=5,
|
||||
a_pin=39,
|
||||
b_pin=38,
|
||||
c_pin=37,
|
||||
d_pin=36,
|
||||
e_pin=12,
|
||||
lat_pin=33,
|
||||
oe_pin=35,
|
||||
clk_pin=34,
|
||||
)
|
||||
|
||||
# Huidu HD-WF2
|
||||
BoardConfig(
|
||||
"huidu-hd-wf2",
|
||||
|
||||
@@ -69,9 +69,21 @@ def set_core_data(config: ConfigType) -> ConfigType:
|
||||
|
||||
|
||||
def set_framework(config: ConfigType) -> ConfigType:
|
||||
version = cv.Version.parse(cv.version_number(config[CONF_FRAMEWORK][CONF_VERSION]))
|
||||
CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] = version
|
||||
return config
|
||||
framework_ver = cv.Version.parse(
|
||||
cv.version_number(config[CONF_FRAMEWORK][CONF_VERSION])
|
||||
)
|
||||
CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] = framework_ver
|
||||
if framework_ver < cv.Version(2, 9, 2):
|
||||
return cv.require_framework_version(
|
||||
nrf52_zephyr=cv.Version(2, 6, 1, "a"),
|
||||
)(config)
|
||||
if framework_ver < cv.Version(3, 2, 0):
|
||||
return cv.require_framework_version(
|
||||
nrf52_zephyr=cv.Version(2, 9, 2, "2"),
|
||||
)(config)
|
||||
return cv.require_framework_version(
|
||||
nrf52_zephyr=cv.Version(3, 2, 0, "1"),
|
||||
)(config)
|
||||
|
||||
|
||||
BOOTLOADERS = [
|
||||
@@ -140,7 +152,7 @@ CONFIG_SCHEMA = cv.All(
|
||||
cv.Optional(CONF_UICR_ERASE, default=False): cv.boolean,
|
||||
}
|
||||
),
|
||||
cv.Optional(CONF_FRAMEWORK, default={CONF_VERSION: "2.6.1-7"}): cv.Schema(
|
||||
cv.Optional(CONF_FRAMEWORK, default={CONF_VERSION: "2.6.1-a"}): cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_VERSION): cv.string_strict,
|
||||
}
|
||||
@@ -181,13 +193,12 @@ async def to_code(config: ConfigType) -> None:
|
||||
cg.add_platformio_option(CONF_FRAMEWORK, CORE.data[KEY_CORE][KEY_TARGET_FRAMEWORK])
|
||||
cg.add_platformio_option(
|
||||
"platform",
|
||||
"https://github.com/tomaszduda23/platform-nordicnrf52/archive/refs/tags/v10.3.0-1.zip",
|
||||
"https://github.com/tomaszduda23/platform-nordicnrf52/archive/refs/tags/v10.3.0-5.zip",
|
||||
)
|
||||
cg.add_platformio_option(
|
||||
"platform_packages",
|
||||
[
|
||||
f"platformio/framework-zephyr@https://github.com/tomaszduda23/framework-sdk-nrf/archive/refs/tags/v{CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]}.zip",
|
||||
"platformio/toolchain-gccarmnoneeabi@https://github.com/tomaszduda23/toolchain-sdk-ng/archive/refs/tags/v0.17.4-0.zip",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -9,19 +9,18 @@ namespace text_sensor {
|
||||
static const char *const TAG = "text_sensor.filter";
|
||||
|
||||
// Filter
|
||||
void Filter::input(const std::string &value) {
|
||||
void Filter::input(std::string value) {
|
||||
ESP_LOGVV(TAG, "Filter(%p)::input(%s)", this, value.c_str());
|
||||
optional<std::string> out = this->new_value(value);
|
||||
if (out.has_value())
|
||||
this->output(*out);
|
||||
if (this->new_value(value))
|
||||
this->output(value);
|
||||
}
|
||||
void Filter::output(const std::string &value) {
|
||||
void Filter::output(std::string &value) {
|
||||
if (this->next_ == nullptr) {
|
||||
ESP_LOGVV(TAG, "Filter(%p)::output(%s) -> SENSOR", this, value.c_str());
|
||||
this->parent_->internal_send_state_to_frontend(value);
|
||||
} else {
|
||||
ESP_LOGVV(TAG, "Filter(%p)::output(%s) -> %p", this, value.c_str(), this->next_);
|
||||
this->next_->input(value);
|
||||
this->next_->input(std::move(value));
|
||||
}
|
||||
}
|
||||
void Filter::initialize(TextSensor *parent, Filter *next) {
|
||||
@@ -35,43 +34,48 @@ LambdaFilter::LambdaFilter(lambda_filter_t lambda_filter) : lambda_filter_(std::
|
||||
const lambda_filter_t &LambdaFilter::get_lambda_filter() const { return this->lambda_filter_; }
|
||||
void LambdaFilter::set_lambda_filter(const lambda_filter_t &lambda_filter) { this->lambda_filter_ = lambda_filter; }
|
||||
|
||||
optional<std::string> LambdaFilter::new_value(std::string value) {
|
||||
auto it = this->lambda_filter_(value);
|
||||
ESP_LOGVV(TAG, "LambdaFilter(%p)::new_value(%s) -> %s", this, value.c_str(), it.value_or("").c_str());
|
||||
return it;
|
||||
bool LambdaFilter::new_value(std::string &value) {
|
||||
auto result = this->lambda_filter_(value);
|
||||
if (result.has_value()) {
|
||||
ESP_LOGVV(TAG, "LambdaFilter(%p)::new_value(%s) -> %s (continue)", this, value.c_str(), result->c_str());
|
||||
value = std::move(*result);
|
||||
return true;
|
||||
}
|
||||
ESP_LOGVV(TAG, "LambdaFilter(%p)::new_value(%s) -> (stop)", this, value.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// ToUpperFilter
|
||||
optional<std::string> ToUpperFilter::new_value(std::string value) {
|
||||
bool ToUpperFilter::new_value(std::string &value) {
|
||||
for (char &c : value)
|
||||
c = ::toupper(c);
|
||||
return value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ToLowerFilter
|
||||
optional<std::string> ToLowerFilter::new_value(std::string value) {
|
||||
bool ToLowerFilter::new_value(std::string &value) {
|
||||
for (char &c : value)
|
||||
c = ::tolower(c);
|
||||
return value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Append
|
||||
optional<std::string> AppendFilter::new_value(std::string value) {
|
||||
bool AppendFilter::new_value(std::string &value) {
|
||||
value.append(this->suffix_);
|
||||
return value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Prepend
|
||||
optional<std::string> PrependFilter::new_value(std::string value) {
|
||||
bool PrependFilter::new_value(std::string &value) {
|
||||
value.insert(0, this->prefix_);
|
||||
return value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Substitute
|
||||
SubstituteFilter::SubstituteFilter(const std::initializer_list<Substitution> &substitutions)
|
||||
: substitutions_(substitutions) {}
|
||||
|
||||
optional<std::string> SubstituteFilter::new_value(std::string value) {
|
||||
bool SubstituteFilter::new_value(std::string &value) {
|
||||
for (const auto &sub : this->substitutions_) {
|
||||
// Compute lengths once per substitution (strlen is fast, called infrequently)
|
||||
const size_t from_len = strlen(sub.from);
|
||||
@@ -84,20 +88,20 @@ optional<std::string> SubstituteFilter::new_value(std::string value) {
|
||||
pos += to_len;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Map
|
||||
MapFilter::MapFilter(const std::initializer_list<Substitution> &mappings) : mappings_(mappings) {}
|
||||
|
||||
optional<std::string> MapFilter::new_value(std::string value) {
|
||||
bool MapFilter::new_value(std::string &value) {
|
||||
for (const auto &mapping : this->mappings_) {
|
||||
if (value == mapping.from) {
|
||||
value.assign(mapping.to);
|
||||
return value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return value; // Pass through if no match
|
||||
return true; // Pass through if no match
|
||||
}
|
||||
|
||||
} // namespace text_sensor
|
||||
|
||||
@@ -17,21 +17,20 @@ class Filter {
|
||||
public:
|
||||
/** This will be called every time the filter receives a new value.
|
||||
*
|
||||
* It can return an empty optional to indicate that the filter chain
|
||||
* should stop, otherwise the value in the filter will be passed down
|
||||
* the chain.
|
||||
* Modify the value in place. Return false to stop the filter chain
|
||||
* (value will not be published), or true to continue.
|
||||
*
|
||||
* @param value The new value.
|
||||
* @return An optional string, the new value that should be pushed out.
|
||||
* @param value The value to filter (modified in place).
|
||||
* @return True to continue the filter chain, false to stop.
|
||||
*/
|
||||
virtual optional<std::string> new_value(std::string value) = 0;
|
||||
virtual bool new_value(std::string &value) = 0;
|
||||
|
||||
/// Initialize this filter, please note this can be called more than once.
|
||||
virtual void initialize(TextSensor *parent, Filter *next);
|
||||
|
||||
void input(const std::string &value);
|
||||
void input(std::string value);
|
||||
|
||||
void output(const std::string &value);
|
||||
void output(std::string &value);
|
||||
|
||||
protected:
|
||||
friend TextSensor;
|
||||
@@ -45,15 +44,14 @@ using lambda_filter_t = std::function<optional<std::string>(std::string)>;
|
||||
/** This class allows for creation of simple template filters.
|
||||
*
|
||||
* The constructor accepts a lambda of the form std::string -> optional<std::string>.
|
||||
* It will be called with each new value in the filter chain and returns the modified
|
||||
* value that shall be passed down the filter chain. Returning an empty Optional
|
||||
* means that the value shall be discarded.
|
||||
* Return a modified string to continue the chain, or return {} to stop
|
||||
* (value will not be published).
|
||||
*/
|
||||
class LambdaFilter : public Filter {
|
||||
public:
|
||||
explicit LambdaFilter(lambda_filter_t lambda_filter);
|
||||
|
||||
optional<std::string> new_value(std::string value) override;
|
||||
bool new_value(std::string &value) override;
|
||||
|
||||
const lambda_filter_t &get_lambda_filter() const;
|
||||
void set_lambda_filter(const lambda_filter_t &lambda_filter);
|
||||
@@ -71,7 +69,14 @@ class StatelessLambdaFilter : public Filter {
|
||||
public:
|
||||
explicit StatelessLambdaFilter(optional<std::string> (*lambda_filter)(std::string)) : lambda_filter_(lambda_filter) {}
|
||||
|
||||
optional<std::string> new_value(std::string value) override { return this->lambda_filter_(value); }
|
||||
bool new_value(std::string &value) override {
|
||||
auto result = this->lambda_filter_(value);
|
||||
if (result.has_value()) {
|
||||
value = std::move(*result);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
optional<std::string> (*lambda_filter_)(std::string);
|
||||
@@ -80,20 +85,20 @@ class StatelessLambdaFilter : public Filter {
|
||||
/// A simple filter that converts all text to uppercase
|
||||
class ToUpperFilter : public Filter {
|
||||
public:
|
||||
optional<std::string> new_value(std::string value) override;
|
||||
bool new_value(std::string &value) override;
|
||||
};
|
||||
|
||||
/// A simple filter that converts all text to lowercase
|
||||
class ToLowerFilter : public Filter {
|
||||
public:
|
||||
optional<std::string> new_value(std::string value) override;
|
||||
bool new_value(std::string &value) override;
|
||||
};
|
||||
|
||||
/// A simple filter that adds a string to the end of another string
|
||||
class AppendFilter : public Filter {
|
||||
public:
|
||||
explicit AppendFilter(const char *suffix) : suffix_(suffix) {}
|
||||
optional<std::string> new_value(std::string value) override;
|
||||
bool new_value(std::string &value) override;
|
||||
|
||||
protected:
|
||||
const char *suffix_;
|
||||
@@ -103,7 +108,7 @@ class AppendFilter : public Filter {
|
||||
class PrependFilter : public Filter {
|
||||
public:
|
||||
explicit PrependFilter(const char *prefix) : prefix_(prefix) {}
|
||||
optional<std::string> new_value(std::string value) override;
|
||||
bool new_value(std::string &value) override;
|
||||
|
||||
protected:
|
||||
const char *prefix_;
|
||||
@@ -118,7 +123,7 @@ struct Substitution {
|
||||
class SubstituteFilter : public Filter {
|
||||
public:
|
||||
explicit SubstituteFilter(const std::initializer_list<Substitution> &substitutions);
|
||||
optional<std::string> new_value(std::string value) override;
|
||||
bool new_value(std::string &value) override;
|
||||
|
||||
protected:
|
||||
FixedVector<Substitution> substitutions_;
|
||||
@@ -151,7 +156,7 @@ class SubstituteFilter : public Filter {
|
||||
class MapFilter : public Filter {
|
||||
public:
|
||||
explicit MapFilter(const std::initializer_list<Substitution> &mappings);
|
||||
optional<std::string> new_value(std::string value) override;
|
||||
bool new_value(std::string &value) override;
|
||||
|
||||
protected:
|
||||
FixedVector<Substitution> mappings_;
|
||||
|
||||
+2
-3
@@ -230,11 +230,10 @@ build_src_flags = -include Arduino.h
|
||||
; This is the common settings for the nRF52 using Zephyr.
|
||||
[common:nrf52-zephyr]
|
||||
extends = common
|
||||
platform = https://github.com/tomaszduda23/platform-nordicnrf52/archive/refs/tags/v10.3.0-1.zip
|
||||
platform = https://github.com/tomaszduda23/platform-nordicnrf52/archive/refs/tags/v10.3.0-5.zip
|
||||
framework = zephyr
|
||||
platform_packages =
|
||||
platformio/framework-zephyr @ https://github.com/tomaszduda23/framework-sdk-nrf/archive/refs/tags/v2.6.1-7.zip
|
||||
platformio/toolchain-gccarmnoneeabi@https://github.com/tomaszduda23/toolchain-sdk-ng/archive/refs/tags/v0.17.4-0.zip
|
||||
platformio/framework-zephyr @ https://github.com/tomaszduda23/framework-sdk-nrf/archive/refs/tags/v2.6.1-a.zip
|
||||
build_flags =
|
||||
${common.build_flags}
|
||||
-DUSE_ZEPHYR
|
||||
|
||||
@@ -20,4 +20,4 @@ nrf52:
|
||||
voltage: 2.1V
|
||||
uicr_erase: true
|
||||
framework:
|
||||
version: "2.6.1-7"
|
||||
version: "2.6.1-a"
|
||||
|
||||
Reference in New Issue
Block a user