Compare commits
28 Commits
2024.8.2
...
jesserockz
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab8ac8707b | ||
|
|
47c68c8aef | ||
|
|
3cbdf63f56 | ||
|
|
30414667d0 | ||
|
|
1ffee9c4d2 | ||
|
|
b425912a80 | ||
|
|
10147d8e0e | ||
|
|
baedd74c7a | ||
|
|
8b6d6fe661 | ||
|
|
ac9417d469 | ||
|
|
56aa58780d | ||
|
|
75899162b3 | ||
|
|
a7167ec3bf | ||
|
|
a0c54504cd | ||
|
|
c3668b9a4d | ||
|
|
9001d1c0d4 | ||
|
|
abb2669f0f | ||
|
|
9713458368 | ||
|
|
5c31ab4060 | ||
|
|
965141fad7 | ||
|
|
ecd3d838c9 | ||
|
|
ce7adbae99 | ||
|
|
1bc3ccd969 | ||
|
|
5646ec7f9c | ||
|
|
80a0f13722 | ||
|
|
fef592b6c6 | ||
|
|
7133e08755 | ||
|
|
350f17e48f |
@@ -139,6 +139,7 @@ esphome/components/ezo_pmp/* @carlos-sarmiento
|
||||
esphome/components/factory_reset/* @anatoly-savchenkov
|
||||
esphome/components/fastled_base/* @OttoWinter
|
||||
esphome/components/feedback/* @ianchi
|
||||
esphome/components/file/* @jesserockz
|
||||
esphome/components/fingerprint_grow/* @OnFreund @alexborro @loongyh
|
||||
esphome/components/font/* @clydebarrow @esphome/core
|
||||
esphome/components/fs3000/* @kahrendt
|
||||
@@ -169,6 +170,7 @@ esphome/components/he60r/* @clydebarrow
|
||||
esphome/components/heatpumpir/* @rob-deutsch
|
||||
esphome/components/hitachi_ac424/* @sourabhjaiswal
|
||||
esphome/components/hm3301/* @freekode
|
||||
esphome/components/hmac_md5/* @dwmw2
|
||||
esphome/components/homeassistant/* @OttoWinter @esphome/core
|
||||
esphome/components/homeassistant/number/* @landonr
|
||||
esphome/components/homeassistant/switch/* @Links2004
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "captive_portal.h"
|
||||
#ifdef USE_CAPTIVE_PORTAL
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/components/wifi/wifi_component.h"
|
||||
@@ -91,3 +92,4 @@ CaptivePortal *global_captive_portal = nullptr; // NOLINT(cppcoreguidelines-avo
|
||||
|
||||
} // namespace captive_portal
|
||||
} // namespace esphome
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/defines.h"
|
||||
#ifdef USE_CAPTIVE_PORTAL
|
||||
#include <memory>
|
||||
#ifdef USE_ARDUINO
|
||||
#include <DNSServer.h>
|
||||
@@ -71,3 +72,4 @@ extern CaptivePortal *global_captive_portal; // NOLINT(cppcoreguidelines-avoid-
|
||||
|
||||
} // namespace captive_portal
|
||||
} // namespace esphome
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "e131.h"
|
||||
#ifdef USE_NETWORK
|
||||
#include "e131_addressable_light_effect.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
@@ -118,3 +119,4 @@ bool E131Component::process_(int universe, const E131Packet &packet) {
|
||||
|
||||
} // namespace e131
|
||||
} // namespace esphome
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/defines.h"
|
||||
#ifdef USE_NETWORK
|
||||
#include "esphome/components/socket/socket.h"
|
||||
#include "esphome/core/component.h"
|
||||
|
||||
@@ -53,3 +54,4 @@ class E131Component : public esphome::Component {
|
||||
|
||||
} // namespace e131
|
||||
} // namespace esphome
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "e131_addressable_light_effect.h"
|
||||
#include "e131.h"
|
||||
#ifdef USE_NETWORK
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
@@ -90,3 +91,4 @@ bool E131AddressableLightEffect::process_(int universe, const E131Packet &packet
|
||||
|
||||
} // namespace e131
|
||||
} // namespace esphome
|
||||
#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/light/addressable_light_effect.h"
|
||||
|
||||
#ifdef USE_NETWORK
|
||||
namespace esphome {
|
||||
namespace e131 {
|
||||
|
||||
@@ -42,3 +42,4 @@ class E131AddressableLightEffect : public light::AddressableLightEffect {
|
||||
|
||||
} // namespace e131
|
||||
} // namespace esphome
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <cstring>
|
||||
#include "e131.h"
|
||||
#ifdef USE_NETWORK
|
||||
#include "esphome/components/network/ip_address.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/util.h"
|
||||
@@ -137,3 +138,4 @@ bool E131Component::packet_(const std::vector<uint8_t> &data, int &universe, E13
|
||||
|
||||
} // namespace e131
|
||||
} // namespace esphome
|
||||
#endif
|
||||
|
||||
@@ -172,6 +172,19 @@ def add_idf_component(
|
||||
KEY_COMPONENTS: components,
|
||||
KEY_SUBMODULES: submodules,
|
||||
}
|
||||
else:
|
||||
component_config = CORE.data[KEY_ESP32][KEY_COMPONENTS][name]
|
||||
if components is not None:
|
||||
component_config[KEY_COMPONENTS] = list(
|
||||
set(component_config[KEY_COMPONENTS] + components)
|
||||
)
|
||||
if submodules is not None:
|
||||
if component_config[KEY_SUBMODULES] is None:
|
||||
component_config[KEY_SUBMODULES] = submodules
|
||||
else:
|
||||
component_config[KEY_SUBMODULES] = list(
|
||||
set(component_config[KEY_SUBMODULES] + submodules)
|
||||
)
|
||||
|
||||
|
||||
def add_extra_script(stage: str, filename: str, path: str):
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "ota_esphome.h"
|
||||
|
||||
#ifdef USE_OTA
|
||||
#include "esphome/components/md5/md5.h"
|
||||
#include "esphome/components/network/util.h"
|
||||
#include "esphome/components/ota/ota_backend.h"
|
||||
@@ -410,3 +410,4 @@ float ESPHomeOTAComponent::get_setup_priority() const { return setup_priority::A
|
||||
uint16_t ESPHomeOTAComponent::get_port() const { return this->port_; }
|
||||
void ESPHomeOTAComponent::set_port(uint16_t port) { this->port_ = port; }
|
||||
} // namespace esphome
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/defines.h"
|
||||
#ifdef USE_OTA
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/preferences.h"
|
||||
#include "esphome/components/ota/ota_backend.h"
|
||||
@@ -41,3 +42,4 @@ class ESPHomeOTAComponent : public ota::OTAComponent {
|
||||
};
|
||||
|
||||
} // namespace esphome
|
||||
#endif
|
||||
|
||||
148
esphome/components/file/__init__.py
Normal file
148
esphome/components/file/__init__.py
Normal file
@@ -0,0 +1,148 @@
|
||||
import hashlib
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
from magic import Magic
|
||||
|
||||
from esphome import external_files
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
CONF_FILE,
|
||||
CONF_FORMAT,
|
||||
CONF_ID,
|
||||
CONF_PATH,
|
||||
CONF_TYPE,
|
||||
CONF_URL,
|
||||
)
|
||||
from esphome.core import CORE, HexInt
|
||||
from esphome.external_files import download_content
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
CODEOWNERS = ["@jesserockz"]
|
||||
DOMAIN = "file"
|
||||
MULTI_CONF = True
|
||||
|
||||
TYPE_LOCAL = "local"
|
||||
TYPE_WEB = "web"
|
||||
|
||||
FORMAT_RAW = "raw"
|
||||
FORMAT_WAV = "wav"
|
||||
|
||||
FORMATS = [FORMAT_RAW, FORMAT_WAV]
|
||||
|
||||
|
||||
def _compute_local_file_path(value: dict) -> Path:
|
||||
url = value[CONF_URL]
|
||||
h = hashlib.new("sha256")
|
||||
h.update(url.encode())
|
||||
key = h.hexdigest()[:8]
|
||||
base_dir = external_files.compute_local_file_dir(DOMAIN)
|
||||
_LOGGER.debug("_compute_local_file_path: base_dir=%s", base_dir / key)
|
||||
return base_dir / key
|
||||
|
||||
|
||||
def _download_web_file(value: dict) -> dict:
|
||||
url = value[CONF_URL]
|
||||
path = _compute_local_file_path(value)
|
||||
|
||||
download_content(url, path)
|
||||
_LOGGER.debug("download_web_file: path=%s", path)
|
||||
return value
|
||||
|
||||
|
||||
LOCAL_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_PATH): cv.file_,
|
||||
}
|
||||
)
|
||||
|
||||
WEB_SCHEMA = cv.All(
|
||||
{
|
||||
cv.Required(CONF_URL): cv.url,
|
||||
},
|
||||
_download_web_file,
|
||||
)
|
||||
|
||||
|
||||
def _validate_file_shorthand(value):
|
||||
value = cv.string_strict(value)
|
||||
if value.startswith("http://") or value.startswith("https://"):
|
||||
return _file_schema(
|
||||
{
|
||||
CONF_TYPE: TYPE_WEB,
|
||||
CONF_URL: value,
|
||||
}
|
||||
)
|
||||
return _file_schema(
|
||||
{
|
||||
CONF_TYPE: TYPE_LOCAL,
|
||||
CONF_PATH: value,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
TYPED_FILE_SCHEMA = cv.typed_schema(
|
||||
{
|
||||
TYPE_LOCAL: LOCAL_SCHEMA,
|
||||
TYPE_WEB: WEB_SCHEMA,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def _file_schema(value):
|
||||
if isinstance(value, str):
|
||||
return _validate_file_shorthand(value)
|
||||
return TYPED_FILE_SCHEMA(value)
|
||||
|
||||
|
||||
CONFIG_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_ID): cv.declare_id(cg.uint8),
|
||||
cv.Required(CONF_FILE): _file_schema,
|
||||
cv.Optional(CONF_FORMAT): cv.one_of(*FORMATS, lower=True),
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def _trim_wav_file(data: bytes) -> bytes:
|
||||
header = []
|
||||
index = 0
|
||||
length = len(data)
|
||||
while index < length:
|
||||
byte = data[index : index + 1]
|
||||
if byte == b"":
|
||||
raise ValueError("Could not find data in wav file")
|
||||
header.append(byte)
|
||||
index += 1
|
||||
if header[-4:] == [b"d", b"a", b"t", b"a"] or index > 100:
|
||||
break
|
||||
index += 2
|
||||
return data[index:]
|
||||
|
||||
|
||||
async def to_code(config: dict) -> None:
|
||||
conf_file: dict = config[CONF_FILE]
|
||||
file_source = conf_file[CONF_TYPE]
|
||||
if file_source == TYPE_LOCAL:
|
||||
path = CORE.relative_config_path(conf_file[CONF_PATH])
|
||||
elif file_source == TYPE_WEB:
|
||||
path = _compute_local_file_path(conf_file)
|
||||
|
||||
with open(path, "rb") as f:
|
||||
data = f.read()
|
||||
|
||||
# Get format from config or fallback to magic
|
||||
if (format := config.get(CONF_FORMAT)) is None:
|
||||
magic = Magic(mime=True)
|
||||
file_type = magic.from_buffer(data)
|
||||
if "wav" in file_type:
|
||||
format = FORMAT_WAV
|
||||
|
||||
if format == FORMAT_WAV:
|
||||
data = _trim_wav_file(data)
|
||||
|
||||
rhs = [HexInt(x) for x in data]
|
||||
cg.progmem_array(config[CONF_ID], rhs)
|
||||
2
esphome/components/hmac_md5/__init__.py
Normal file
2
esphome/components/hmac_md5/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
AUTO_LOAD = ["md5"]
|
||||
CODEOWNERS = ["@dwmw2"]
|
||||
56
esphome/components/hmac_md5/hmac_md5.cpp
Normal file
56
esphome/components/hmac_md5/hmac_md5.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include "hmac_md5.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace hmac_md5 {
|
||||
void HmacMD5::init(const uint8_t *key, size_t len) {
|
||||
uint8_t ipad[64], opad[64];
|
||||
|
||||
memset(ipad, 0, sizeof(ipad));
|
||||
if (len > 64) {
|
||||
md5::MD5Digest keymd5;
|
||||
keymd5.init();
|
||||
keymd5.add(key, len);
|
||||
keymd5.calculate();
|
||||
keymd5.get_bytes(ipad);
|
||||
} else {
|
||||
memcpy(ipad, key, len);
|
||||
}
|
||||
memcpy(opad, ipad, sizeof(opad));
|
||||
|
||||
for (int i = 0; i < 64; i++) {
|
||||
ipad[i] ^= 0x36;
|
||||
opad[i] ^= 0x5c;
|
||||
}
|
||||
|
||||
this->ihash_.init();
|
||||
this->ihash_.add(ipad, sizeof(ipad));
|
||||
|
||||
this->ohash_.init();
|
||||
this->ohash_.add(opad, sizeof(opad));
|
||||
}
|
||||
|
||||
void HmacMD5::add(const uint8_t *data, size_t len) { this->ihash_.add(data, len); }
|
||||
|
||||
void HmacMD5::calculate() {
|
||||
uint8_t ibytes[16];
|
||||
|
||||
this->ihash_.calculate();
|
||||
this->ihash_.get_bytes(ibytes);
|
||||
|
||||
this->ohash_.add(ibytes, sizeof(ibytes));
|
||||
this->ohash_.calculate();
|
||||
}
|
||||
|
||||
void HmacMD5::get_bytes(uint8_t *output) { this->ohash_.get_bytes(output); }
|
||||
|
||||
void HmacMD5::get_hex(char *output) { this->ohash_.get_hex(output); }
|
||||
|
||||
bool HmacMD5::equals_bytes(const uint8_t *expected) { return this->ohash_.equals_bytes(expected); }
|
||||
|
||||
bool HmacMD5::equals_hex(const char *expected) { return this->ohash_.equals_hex(expected); }
|
||||
|
||||
} // namespace hmac_md5
|
||||
} // namespace esphome
|
||||
48
esphome/components/hmac_md5/hmac_md5.h
Normal file
48
esphome/components/hmac_md5/hmac_md5.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/defines.h"
|
||||
#include "esphome/components/md5/md5.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace esphome {
|
||||
namespace hmac_md5 {
|
||||
|
||||
class HmacMD5 {
|
||||
public:
|
||||
HmacMD5() = default;
|
||||
~HmacMD5() = default;
|
||||
|
||||
/// Initialize a new MD5 digest computation.
|
||||
void init(const uint8_t *key, size_t len);
|
||||
void init(const char *key, size_t len) { this->init((const uint8_t *) key, len); }
|
||||
void init(const std::string &key) { this->init(key.c_str(), key.length()); }
|
||||
|
||||
/// Add bytes of data for the digest.
|
||||
void add(const uint8_t *data, size_t len);
|
||||
void add(const char *data, size_t len) { this->add((const uint8_t *) data, len); }
|
||||
|
||||
/// Compute the digest, based on the provided data.
|
||||
void calculate();
|
||||
|
||||
/// Retrieve the HMAC-MD5 digest as bytes.
|
||||
/// The output must be able to hold 16 bytes or more.
|
||||
void get_bytes(uint8_t *output);
|
||||
|
||||
/// Retrieve the HMAC-MD5 digest as hex characters.
|
||||
/// The output must be able to hold 32 bytes or more.
|
||||
void get_hex(char *output);
|
||||
|
||||
/// Compare the digest against a provided byte-encoded digest (16 bytes).
|
||||
bool equals_bytes(const uint8_t *expected);
|
||||
|
||||
/// Compare the digest against a provided hex-encoded digest (32 bytes).
|
||||
bool equals_hex(const char *expected);
|
||||
|
||||
protected:
|
||||
md5::MD5Digest ihash_;
|
||||
md5::MD5Digest ohash_;
|
||||
};
|
||||
|
||||
} // namespace hmac_md5
|
||||
} // namespace esphome
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "improv_serial_component.h"
|
||||
|
||||
#ifdef USE_WIFI
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/core/defines.h"
|
||||
#include "esphome/core/hal.h"
|
||||
@@ -313,3 +313,4 @@ ImprovSerialComponent *global_improv_serial_component = // NOLINT(cppcoreguidel
|
||||
|
||||
} // namespace improv_serial
|
||||
} // namespace esphome
|
||||
#endif
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/defines.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
|
||||
#ifdef USE_WIFI
|
||||
#include <improv.h>
|
||||
#include <vector>
|
||||
|
||||
@@ -78,3 +78,4 @@ extern ImprovSerialComponent
|
||||
|
||||
} // namespace improv_serial
|
||||
} // namespace esphome
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "esphome/components/number/number.h"
|
||||
#include "esphome/core/automation.h"
|
||||
#include "esphome/core/component.h"
|
||||
@@ -11,7 +13,7 @@ namespace lvgl {
|
||||
class LVGLNumber : public number::Number {
|
||||
public:
|
||||
void set_control_lambda(std::function<void(float)> control_lambda) {
|
||||
this->control_lambda_ = control_lambda;
|
||||
this->control_lambda_ = std::move(control_lambda);
|
||||
if (this->initial_state_.has_value()) {
|
||||
this->control_lambda_(this->initial_state_.value());
|
||||
this->initial_state_.reset();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "esphome/components/select/select.h"
|
||||
#include "esphome/core/automation.h"
|
||||
#include "esphome/core/component.h"
|
||||
@@ -28,7 +30,7 @@ static std::vector<std::string> split_string(const std::string &str) {
|
||||
class LVGLSelect : public select::Select {
|
||||
public:
|
||||
void set_control_lambda(std::function<void(size_t)> lambda) {
|
||||
this->control_lambda_ = lambda;
|
||||
this->control_lambda_ = std::move(lambda);
|
||||
if (this->initial_state_.has_value()) {
|
||||
this->control(this->initial_state_.value());
|
||||
this->initial_state_.reset();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "esphome/components/switch/switch.h"
|
||||
#include "esphome/core/automation.h"
|
||||
#include "esphome/core/component.h"
|
||||
@@ -11,7 +13,7 @@ namespace lvgl {
|
||||
class LVGLSwitch : public switch_::Switch {
|
||||
public:
|
||||
void set_control_lambda(std::function<void(bool)> state_lambda) {
|
||||
this->state_lambda_ = state_lambda;
|
||||
this->state_lambda_ = std::move(state_lambda);
|
||||
if (this->initial_state_.has_value()) {
|
||||
this->state_lambda_(this->initial_state_.value());
|
||||
this->initial_state_.reset();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "esphome/components/text/text.h"
|
||||
#include "esphome/core/automation.h"
|
||||
#include "esphome/core/component.h"
|
||||
@@ -11,7 +13,7 @@ namespace lvgl {
|
||||
class LVGLText : public text::Text {
|
||||
public:
|
||||
void set_control_lambda(std::function<void(const std::string)> control_lambda) {
|
||||
this->control_lambda_ = control_lambda;
|
||||
this->control_lambda_ = std::move(control_lambda);
|
||||
if (this->initial_state_.has_value()) {
|
||||
this->control_lambda_(this->initial_state_.value());
|
||||
this->initial_state_.reset();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "prometheus_handler.h"
|
||||
#ifdef USE_NETWORK
|
||||
#include "esphome/core/application.h"
|
||||
|
||||
namespace esphome {
|
||||
@@ -350,3 +351,4 @@ void PrometheusHandler::lock_row_(AsyncResponseStream *stream, lock::Lock *obj)
|
||||
|
||||
} // namespace prometheus
|
||||
} // namespace esphome
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/defines.h"
|
||||
#ifdef USE_NETWORK
|
||||
#include <map>
|
||||
#include <utility>
|
||||
|
||||
@@ -117,3 +118,4 @@ class PrometheusHandler : public AsyncWebHandler, public Component {
|
||||
|
||||
} // namespace prometheus
|
||||
} // namespace esphome
|
||||
#endif
|
||||
|
||||
@@ -7,8 +7,10 @@
|
||||
|
||||
#include <hardware/clocks.h>
|
||||
#include <hardware/dma.h>
|
||||
#include <hardware/irq.h>
|
||||
#include <hardware/pio.h>
|
||||
#include <pico/stdlib.h>
|
||||
#include <pico/sem.h>
|
||||
|
||||
namespace esphome {
|
||||
namespace rp2040_pio_led_strip {
|
||||
@@ -23,6 +25,19 @@ static std::map<Chipset, bool> conf_count_ = {
|
||||
{CHIPSET_WS2812, false}, {CHIPSET_WS2812B, false}, {CHIPSET_SK6812, false},
|
||||
{CHIPSET_SM16703, false}, {CHIPSET_CUSTOM, false},
|
||||
};
|
||||
static bool dma_chan_active_[12];
|
||||
static struct semaphore dma_write_complete_sem_[12];
|
||||
|
||||
// DMA interrupt service routine
|
||||
void RP2040PIOLEDStripLightOutput::dma_write_complete_handler_() {
|
||||
uint32_t channel = dma_hw->ints0;
|
||||
for (uint dma_chan = 0; dma_chan < 12; ++dma_chan) {
|
||||
if (RP2040PIOLEDStripLightOutput::dma_chan_active_[dma_chan] && (channel & (1u << dma_chan))) {
|
||||
dma_hw->ints0 = (1u << dma_chan); // Clear the interrupt
|
||||
sem_release(&RP2040PIOLEDStripLightOutput::dma_write_complete_sem_[dma_chan]); // Handle the interrupt
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RP2040PIOLEDStripLightOutput::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up RP2040 LED Strip...");
|
||||
@@ -57,22 +72,22 @@ void RP2040PIOLEDStripLightOutput::setup() {
|
||||
// but there are only 4 state machines on each PIO so we can only have 4 strips per PIO
|
||||
uint offset = 0;
|
||||
|
||||
if (num_instance_[this->pio_ == pio0 ? 0 : 1] > 4) {
|
||||
if (RP2040PIOLEDStripLightOutput::num_instance_[this->pio_ == pio0 ? 0 : 1] > 4) {
|
||||
ESP_LOGE(TAG, "Too many instances of PIO program");
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
// keep track of how many instances of the PIO program are running on each PIO
|
||||
num_instance_[this->pio_ == pio0 ? 0 : 1]++;
|
||||
RP2040PIOLEDStripLightOutput::num_instance_[this->pio_ == pio0 ? 0 : 1]++;
|
||||
|
||||
// if there are multiple strips of the same chipset, we can reuse the same PIO program and save space
|
||||
if (this->conf_count_[this->chipset_]) {
|
||||
offset = chipset_offsets_[this->chipset_];
|
||||
offset = RP2040PIOLEDStripLightOutput::chipset_offsets_[this->chipset_];
|
||||
} else {
|
||||
// Load the assembled program into the PIO and get its location in the PIO's instruction memory and save it
|
||||
offset = pio_add_program(this->pio_, this->program_);
|
||||
chipset_offsets_[this->chipset_] = offset;
|
||||
conf_count_[this->chipset_] = true;
|
||||
RP2040PIOLEDStripLightOutput::chipset_offsets_[this->chipset_] = offset;
|
||||
RP2040PIOLEDStripLightOutput::conf_count_[this->chipset_] = true;
|
||||
}
|
||||
|
||||
// Configure the state machine's PIO, and start it
|
||||
@@ -93,6 +108,9 @@ void RP2040PIOLEDStripLightOutput::setup() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Mark the DMA channel as active
|
||||
RP2040PIOLEDStripLightOutput::dma_chan_active_[this->dma_chan_] = true;
|
||||
|
||||
this->dma_config_ = dma_channel_get_default_config(this->dma_chan_);
|
||||
channel_config_set_transfer_data_size(
|
||||
&this->dma_config_,
|
||||
@@ -109,6 +127,13 @@ void RP2040PIOLEDStripLightOutput::setup() {
|
||||
false // don't start yet
|
||||
);
|
||||
|
||||
// Initialize the semaphore for this DMA channel
|
||||
sem_init(&RP2040PIOLEDStripLightOutput::dma_write_complete_sem_[this->dma_chan_], 1, 1);
|
||||
|
||||
irq_set_exclusive_handler(DMA_IRQ_0, dma_write_complete_handler_); // after DMA all data, raise an interrupt
|
||||
dma_channel_set_irq0_enabled(this->dma_chan_, true); // map DMA channel to interrupt
|
||||
irq_set_enabled(DMA_IRQ_0, true); // enable interrupt
|
||||
|
||||
this->init_(this->pio_, this->sm_, offset, this->pin_, this->max_refresh_rate_);
|
||||
}
|
||||
|
||||
@@ -126,6 +151,7 @@ void RP2040PIOLEDStripLightOutput::write_state(light::LightState *state) {
|
||||
}
|
||||
|
||||
// the bits are already in the correct order for the pio program so we can just copy the buffer using DMA
|
||||
sem_acquire_blocking(&RP2040PIOLEDStripLightOutput::dma_write_complete_sem_[this->dma_chan_]);
|
||||
dma_channel_transfer_from_buffer_now(this->dma_chan_, this->buf_, this->get_buffer_size_());
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <hardware/pio.h>
|
||||
#include <hardware/structs/pio.h>
|
||||
#include <pico/stdio.h>
|
||||
#include <pico/sem.h>
|
||||
#include <map>
|
||||
|
||||
namespace esphome {
|
||||
@@ -95,6 +96,8 @@ class RP2040PIOLEDStripLightOutput : public light::AddressableLight {
|
||||
|
||||
size_t get_buffer_size_() const { return this->num_leds_ * (3 + this->is_rgbw_); }
|
||||
|
||||
static void dma_write_complete_handler_();
|
||||
|
||||
uint8_t *buf_{nullptr};
|
||||
uint8_t *effect_data_{nullptr};
|
||||
|
||||
@@ -120,6 +123,8 @@ class RP2040PIOLEDStripLightOutput : public light::AddressableLight {
|
||||
inline static int num_instance_[2];
|
||||
inline static std::map<Chipset, bool> conf_count_;
|
||||
inline static std::map<Chipset, int> chipset_offsets_;
|
||||
inline static bool dma_chan_active_[12];
|
||||
inline static struct semaphore dma_write_complete_sem_[12];
|
||||
};
|
||||
|
||||
} // namespace rp2040_pio_led_strip
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "socket.h"
|
||||
#if defined(USE_SOCKET_IMPL_LWIP_TCP) || defined(USE_SOCKET_IMPL_LWIP_SOCKETS) || defined(USE_SOCKET_IMPL_BSD_SOCKETS)
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
@@ -74,3 +75,4 @@ socklen_t set_sockaddr_any(struct sockaddr *addr, socklen_t addrlen, uint16_t po
|
||||
}
|
||||
} // namespace socket
|
||||
} // namespace esphome
|
||||
#endif
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "esphome/core/optional.h"
|
||||
#include "headers.h"
|
||||
|
||||
#if defined(USE_SOCKET_IMPL_LWIP_TCP) || defined(USE_SOCKET_IMPL_LWIP_SOCKETS) || defined(USE_SOCKET_IMPL_BSD_SOCKETS)
|
||||
namespace esphome {
|
||||
namespace socket {
|
||||
|
||||
@@ -57,3 +58,4 @@ socklen_t set_sockaddr_any(struct sockaddr *addr, socklen_t addrlen, uint16_t po
|
||||
|
||||
} // namespace socket
|
||||
} // namespace esphome
|
||||
#endif
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
import re
|
||||
import ipaddress
|
||||
import re
|
||||
|
||||
from esphome import automation
|
||||
import esphome.codegen as cg
|
||||
from esphome.components import time
|
||||
from esphome.components.esp32 import CORE, add_idf_sdkconfig_option
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
CONF_ID,
|
||||
CONF_TIME_ID,
|
||||
CONF_ADDRESS,
|
||||
CONF_ID,
|
||||
CONF_REBOOT_TIMEOUT,
|
||||
CONF_TIME_ID,
|
||||
KEY_CORE,
|
||||
KEY_FRAMEWORK_VERSION,
|
||||
)
|
||||
from esphome.components.esp32 import CORE, add_idf_sdkconfig_option
|
||||
from esphome.components import time
|
||||
from esphome.core import TimePeriod
|
||||
from esphome import automation
|
||||
|
||||
CONF_NETMASK = "netmask"
|
||||
CONF_PRIVATE_KEY = "private_key"
|
||||
@@ -91,6 +92,8 @@ CONFIG_SCHEMA = cv.Schema(
|
||||
async def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
|
||||
cg.add_define("USE_WIREGUARD")
|
||||
|
||||
cg.add(var.set_address(str(config[CONF_ADDRESS])))
|
||||
cg.add(var.set_netmask(str(config[CONF_NETMASK])))
|
||||
cg.add(var.set_private_key(config[CONF_PRIVATE_KEY]))
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "wireguard.h"
|
||||
|
||||
#ifdef USE_WIREGUARD
|
||||
#include <cinttypes>
|
||||
#include <ctime>
|
||||
#include <functional>
|
||||
@@ -289,3 +289,4 @@ std::string mask_key(const std::string &key) { return (key.substr(0, 5) + "[...]
|
||||
|
||||
} // namespace wireguard
|
||||
} // namespace esphome
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/defines.h"
|
||||
#ifdef USE_WIREGUARD
|
||||
#include <ctime>
|
||||
#include <vector>
|
||||
#include <tuple>
|
||||
@@ -170,3 +171,4 @@ template<typename... Ts> class WireguardDisableAction : public Action<Ts...>, pu
|
||||
|
||||
} // namespace wireguard
|
||||
} // namespace esphome
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Constants used by esphome."""
|
||||
|
||||
__version__ = "2024.8.0b3"
|
||||
__version__ = "2024.9.0-dev"
|
||||
|
||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||
VALID_SUBSTITUTIONS_CHARACTERS = (
|
||||
@@ -1042,6 +1042,7 @@ UNIT_KILOVOLT_AMPS_REACTIVE = "kVAR"
|
||||
UNIT_KILOVOLT_AMPS_REACTIVE_HOURS = "kVARh"
|
||||
UNIT_KILOWATT = "kW"
|
||||
UNIT_KILOWATT_HOURS = "kWh"
|
||||
UNIT_LITRE = "L"
|
||||
UNIT_LUX = "lx"
|
||||
UNIT_METER = "m"
|
||||
UNIT_METER_PER_SECOND_SQUARED = "m/s²"
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
#define USE_VALVE
|
||||
#define USE_WIFI
|
||||
#define USE_WIFI_AP
|
||||
#define USE_WIREGUARD
|
||||
|
||||
// Arduino-specific feature flags
|
||||
#ifdef USE_ARDUINO
|
||||
|
||||
@@ -58,7 +58,7 @@ file_types = (
|
||||
)
|
||||
cpp_include = ("*.h", "*.c", "*.cpp", "*.tcc")
|
||||
py_include = ("*.py",)
|
||||
ignore_types = (".ico", ".png", ".woff", ".woff2", "", ".ttf", ".otf")
|
||||
ignore_types = (".ico", ".png", ".woff", ".woff2", "", ".ttf", ".otf", ".wav")
|
||||
|
||||
LINT_FILE_CHECKS = []
|
||||
LINT_CONTENT_CHECKS = []
|
||||
|
||||
BIN
tests/components/file/bloop.wav
Normal file
BIN
tests/components/file/bloop.wav
Normal file
Binary file not shown.
7
tests/components/file/test.esp32-idf.yaml
Normal file
7
tests/components/file/test.esp32-idf.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
file:
|
||||
- id: bloop_local
|
||||
file: ../../components/file/bloop.wav
|
||||
- id: bloop_web
|
||||
# TODO: Change to ESPHome URL after file is merged
|
||||
# file: https://github.com/esphome/esphome/raw/dev/tests/components/file/bloop.wav
|
||||
file: https://github.com/jesserockz/esphome-components/raw/main/tests/file/bloop.wav
|
||||
Reference in New Issue
Block a user