mirror of
https://github.com/esphome/esphome.git
synced 2025-11-08 02:51:49 +00:00
Compare commits
22 Commits
2024.8.0b3
...
2024.8.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2d8ab62dd | ||
|
|
cb4bede6d8 | ||
|
|
39b2f30b16 | ||
|
|
5cb1d18574 | ||
|
|
e5e06a12ef | ||
|
|
c9c5ca28d2 | ||
|
|
04ec6c5677 | ||
|
|
816b060edc | ||
|
|
8b6c95f723 | ||
|
|
28eda4b220 | ||
|
|
9975e8b544 | ||
|
|
c1774c42c2 | ||
|
|
8677763492 | ||
|
|
388abaf09f | ||
|
|
1f21e419aa | ||
|
|
5d4bf5f8e5 | ||
|
|
813d517076 | ||
|
|
4ed6a64869 | ||
|
|
aaae8f4a87 | ||
|
|
436c6282da | ||
|
|
c043bbe598 | ||
|
|
8fae609316 |
@@ -34,8 +34,8 @@ RUN \
|
||||
python3-wheel=0.38.4-2 \
|
||||
iputils-ping=3:20221126-1 \
|
||||
git=1:2.39.2-1.1 \
|
||||
curl=7.88.1-10+deb12u6 \
|
||||
openssh-client=1:9.2p1-2+deb12u2 \
|
||||
curl=7.88.1-10+deb12u7 \
|
||||
openssh-client=1:9.2p1-2+deb12u3 \
|
||||
python3-cffi=1.15.1-5 \
|
||||
libcairo2=1.16.0-7 \
|
||||
libmagic1=1:5.44-3 \
|
||||
@@ -49,7 +49,7 @@ RUN \
|
||||
zlib1g-dev=1:1.2.13.dfsg-1 \
|
||||
libjpeg-dev=1:2.1.5-2 \
|
||||
libfreetype-dev=2.12.1+dfsg-5+deb12u3 \
|
||||
libssl-dev=3.0.13-1~deb12u1 \
|
||||
libssl-dev=3.0.14-1~deb12u1 \
|
||||
libffi-dev=3.4.4-1 \
|
||||
libopenjp2-7=2.5.0-2 \
|
||||
libtiff6=4.5.0-6+deb12u1 \
|
||||
|
||||
@@ -179,6 +179,7 @@ void APIConnection::loop() {
|
||||
SubscribeHomeAssistantStateResponse resp;
|
||||
resp.entity_id = it.entity_id;
|
||||
resp.attribute = it.attribute.value();
|
||||
resp.once = it.once;
|
||||
if (this->send_subscribe_home_assistant_state_response(resp)) {
|
||||
state_subs_at_++;
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ async def datetime_date_set_to_code(config, action_id, template_arg, args):
|
||||
|
||||
date_config = config[CONF_DATE]
|
||||
if cg.is_template(date_config):
|
||||
template_ = await cg.templatable(date_config, [], cg.ESPTime)
|
||||
template_ = await cg.templatable(date_config, args, cg.ESPTime)
|
||||
cg.add(action_var.set_date(template_))
|
||||
else:
|
||||
date_struct = cg.StructInitializer(
|
||||
@@ -217,7 +217,7 @@ async def datetime_time_set_to_code(config, action_id, template_arg, args):
|
||||
|
||||
time_config = config[CONF_TIME]
|
||||
if cg.is_template(time_config):
|
||||
template_ = await cg.templatable(time_config, [], cg.ESPTime)
|
||||
template_ = await cg.templatable(time_config, args, cg.ESPTime)
|
||||
cg.add(action_var.set_time(template_))
|
||||
else:
|
||||
time_struct = cg.StructInitializer(
|
||||
@@ -248,7 +248,7 @@ async def datetime_datetime_set_to_code(config, action_id, template_arg, args):
|
||||
|
||||
datetime_config = config[CONF_DATETIME]
|
||||
if cg.is_template(datetime_config):
|
||||
template_ = await cg.templatable(datetime_config, [], cg.ESPTime)
|
||||
template_ = await cg.templatable(datetime_config, args, cg.ESPTime)
|
||||
cg.add(action_var.set_datetime(template_))
|
||||
else:
|
||||
datetime_struct = cg.StructInitializer(
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -472,13 +472,13 @@ void EthernetComponent::start_connect_() {
|
||||
if (err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STARTED) {
|
||||
ESPHL_ERROR_CHECK(err, "DHCPC start error");
|
||||
}
|
||||
}
|
||||
#if USE_NETWORK_IPV6
|
||||
err = esp_netif_create_ip6_linklocal(this->eth_netif_);
|
||||
if (err != ESP_OK) {
|
||||
ESPHL_ERROR_CHECK(err, "Enable IPv6 link local failed");
|
||||
}
|
||||
#endif /* USE_NETWORK_IPV6 */
|
||||
}
|
||||
|
||||
this->connect_begin_ = millis();
|
||||
this->status_set_warning();
|
||||
|
||||
@@ -266,7 +266,10 @@ async def to_code(config):
|
||||
await add_top_layer(config)
|
||||
await msgboxes_to_code(config)
|
||||
await disp_update(f"{lv_component}->get_disp()", config)
|
||||
# At this point only the setup code should be generated
|
||||
assert LvContext.added_lambda_count == 1
|
||||
Widget.set_completed()
|
||||
async with LvContext(lv_component):
|
||||
await generate_triggers(lv_component)
|
||||
for conf in config.get(CONF_ON_IDLE, ()):
|
||||
templ = await cg.templatable(conf[CONF_TIMEOUT], [], cg.uint32)
|
||||
|
||||
@@ -5,6 +5,7 @@ from esphome import automation
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_ID, CONF_TIMEOUT
|
||||
from esphome.cpp_generator import RawExpression
|
||||
from esphome.cpp_types import nullptr
|
||||
|
||||
from .defines import (
|
||||
@@ -26,6 +27,7 @@ from .lvcode import (
|
||||
add_line_marks,
|
||||
lv,
|
||||
lv_add,
|
||||
lv_expr,
|
||||
lv_obj,
|
||||
lvgl_comp,
|
||||
)
|
||||
@@ -38,7 +40,13 @@ from .types import (
|
||||
lv_disp_t,
|
||||
lv_obj_t,
|
||||
)
|
||||
from .widgets import Widget, get_widgets, lv_scr_act, set_obj_properties
|
||||
from .widgets import (
|
||||
Widget,
|
||||
get_widgets,
|
||||
lv_scr_act,
|
||||
set_obj_properties,
|
||||
wait_for_widgets,
|
||||
)
|
||||
|
||||
|
||||
async def action_to_code(
|
||||
@@ -48,9 +56,11 @@ async def action_to_code(
|
||||
template_arg,
|
||||
args,
|
||||
):
|
||||
await wait_for_widgets()
|
||||
async with LambdaContext(parameters=args, where=action_id) as context:
|
||||
with LvConditional(lv_expr.is_pre_initialise()):
|
||||
context.add(RawExpression("return"))
|
||||
for widget in widgets:
|
||||
with LvConditional(widget.obj != nullptr):
|
||||
await action(widget)
|
||||
var = cg.new_Pvariable(action_id, template_arg, await context.get_lambda())
|
||||
return var
|
||||
|
||||
@@ -10,7 +10,7 @@ from ..defines import CONF_LVGL_ID, CONF_WIDGET
|
||||
from ..lvcode import EVENT_ARG, LambdaContext, LvContext
|
||||
from ..schemas import LVGL_SCHEMA
|
||||
from ..types import LV_EVENT, lv_pseudo_button_t
|
||||
from ..widgets import Widget, get_widgets
|
||||
from ..widgets import Widget, get_widgets, wait_for_widgets
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
binary_sensor_schema(BinarySensor)
|
||||
@@ -29,6 +29,7 @@ async def to_code(config):
|
||||
widget = await get_widgets(config, CONF_WIDGET)
|
||||
widget = widget[0]
|
||||
assert isinstance(widget, Widget)
|
||||
await wait_for_widgets()
|
||||
async with LambdaContext(EVENT_ARG) as pressed_ctx:
|
||||
pressed_ctx.add(sensor.publish_state(widget.is_pressed()))
|
||||
async with LvContext(paren) as ctx:
|
||||
|
||||
@@ -8,7 +8,7 @@ from ..defines import CONF_LVGL_ID
|
||||
from ..lvcode import LvContext
|
||||
from ..schemas import LVGL_SCHEMA
|
||||
from ..types import LvType, lvgl_ns
|
||||
from ..widgets import get_widgets
|
||||
from ..widgets import get_widgets, wait_for_widgets
|
||||
|
||||
lv_led_t = LvType("lv_led_t")
|
||||
LVLight = lvgl_ns.class_("LVLight", LightOutput)
|
||||
@@ -28,5 +28,6 @@ async def to_code(config):
|
||||
paren = await cg.get_variable(config[CONF_LVGL_ID])
|
||||
widget = await get_widgets(config, CONF_LED)
|
||||
widget = widget[0]
|
||||
await wait_for_widgets()
|
||||
async with LvContext(paren) as ctx:
|
||||
ctx.add(var.set_obj(widget.obj))
|
||||
|
||||
@@ -176,6 +176,8 @@ class LvContext(LambdaContext):
|
||||
Code generation into the LVGL initialisation code (called in `setup()`)
|
||||
"""
|
||||
|
||||
added_lambda_count = 0
|
||||
|
||||
def __init__(self, lv_component, args=None):
|
||||
self.args = args or LVGL_COMP_ARG
|
||||
super().__init__(parameters=self.args)
|
||||
@@ -183,6 +185,7 @@ class LvContext(LambdaContext):
|
||||
|
||||
async def add_init_lambda(self):
|
||||
cg.add(self.lv_component.add_init_lambda(await self.get_lambda()))
|
||||
LvContext.added_lambda_count += 1
|
||||
|
||||
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
||||
await super().__aexit__(exc_type, exc_val, exc_tb)
|
||||
|
||||
@@ -294,6 +294,13 @@ void LvglComponent::loop() {
|
||||
}
|
||||
lv_timer_handler_run_in_period(5);
|
||||
}
|
||||
bool lv_is_pre_initialise() {
|
||||
if (!lv_is_initialized()) {
|
||||
ESP_LOGE(TAG, "LVGL call before component is initialised");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef USE_LVGL_IMAGE
|
||||
lv_img_dsc_t *lv_img_from(image::Image *src, lv_img_dsc_t *img_dsc) {
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace lvgl {
|
||||
|
||||
extern lv_event_code_t lv_api_event; // NOLINT
|
||||
extern lv_event_code_t lv_update_event; // NOLINT
|
||||
extern bool lv_is_pre_initialise();
|
||||
#ifdef USE_LVGL_COLOR
|
||||
inline lv_color_t lv_color_from(Color color) { return lv_color_make(color.red, color.green, color.blue); }
|
||||
#endif // USE_LVGL_COLOR
|
||||
|
||||
@@ -16,7 +16,7 @@ from ..lvcode import (
|
||||
)
|
||||
from ..schemas import LVGL_SCHEMA
|
||||
from ..types import LV_EVENT, LvNumber, lvgl_ns
|
||||
from ..widgets import get_widgets
|
||||
from ..widgets import get_widgets, wait_for_widgets
|
||||
|
||||
LVGLNumber = lvgl_ns.class_("LVGLNumber", number.Number)
|
||||
|
||||
@@ -44,6 +44,7 @@ async def to_code(config):
|
||||
step=widget.get_step(),
|
||||
)
|
||||
|
||||
await wait_for_widgets()
|
||||
async with LambdaContext([(cg.float_, "v")]) as control:
|
||||
await widget.set_property(
|
||||
"value", MockObj("v") * MockObj(widget.get_scale()), config[CONF_ANIMATED]
|
||||
|
||||
@@ -15,7 +15,7 @@ from ..lvcode import (
|
||||
)
|
||||
from ..schemas import LVGL_SCHEMA
|
||||
from ..types import LV_EVENT, LvSelect, lvgl_ns
|
||||
from ..widgets import get_widgets
|
||||
from ..widgets import get_widgets, wait_for_widgets
|
||||
|
||||
LVGLSelect = lvgl_ns.class_("LVGLSelect", select.Select)
|
||||
|
||||
@@ -37,6 +37,7 @@ async def to_code(config):
|
||||
options = widget.config.get(CONF_OPTIONS, [])
|
||||
selector = await select.new_select(config, options=options)
|
||||
paren = await cg.get_variable(config[CONF_LVGL_ID])
|
||||
await wait_for_widgets()
|
||||
async with LambdaContext(EVENT_ARG) as pub_ctx:
|
||||
pub_ctx.add(selector.publish_index(widget.get_value()))
|
||||
async with LambdaContext([(cg.uint16, "v")]) as control:
|
||||
|
||||
@@ -14,7 +14,7 @@ from ..lvcode import (
|
||||
)
|
||||
from ..schemas import LVGL_SCHEMA
|
||||
from ..types import LV_EVENT, LvNumber
|
||||
from ..widgets import Widget, get_widgets
|
||||
from ..widgets import Widget, get_widgets, wait_for_widgets
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
sensor_schema(Sensor)
|
||||
@@ -33,6 +33,7 @@ async def to_code(config):
|
||||
widget = await get_widgets(config, CONF_WIDGET)
|
||||
widget = widget[0]
|
||||
assert isinstance(widget, Widget)
|
||||
await wait_for_widgets()
|
||||
async with LambdaContext(EVENT_ARG) as lamb:
|
||||
lv_add(sensor.publish_state(widget.get_value()))
|
||||
async with LvContext(paren, LVGL_COMP_ARG):
|
||||
|
||||
@@ -16,7 +16,7 @@ from ..lvcode import (
|
||||
)
|
||||
from ..schemas import LVGL_SCHEMA
|
||||
from ..types import LV_EVENT, LV_STATE, lv_pseudo_button_t, lvgl_ns
|
||||
from ..widgets import get_widgets
|
||||
from ..widgets import get_widgets, wait_for_widgets
|
||||
|
||||
LVGLSwitch = lvgl_ns.class_("LVGLSwitch", Switch)
|
||||
CONFIG_SCHEMA = (
|
||||
@@ -35,6 +35,7 @@ async def to_code(config):
|
||||
paren = await cg.get_variable(config[CONF_LVGL_ID])
|
||||
widget = await get_widgets(config, CONF_WIDGET)
|
||||
widget = widget[0]
|
||||
await wait_for_widgets()
|
||||
async with LambdaContext(EVENT_ARG) as checked_ctx:
|
||||
checked_ctx.add(switch.publish_state(widget.get_value()))
|
||||
async with LambdaContext([(cg.bool_, "v")]) as control:
|
||||
|
||||
@@ -15,7 +15,7 @@ from ..lvcode import (
|
||||
)
|
||||
from ..schemas import LVGL_SCHEMA
|
||||
from ..types import LV_EVENT, LvText, lvgl_ns
|
||||
from ..widgets import get_widgets
|
||||
from ..widgets import get_widgets, wait_for_widgets
|
||||
|
||||
LVGLText = lvgl_ns.class_("LVGLText", text.Text)
|
||||
|
||||
@@ -32,6 +32,7 @@ async def to_code(config):
|
||||
paren = await cg.get_variable(config[CONF_LVGL_ID])
|
||||
widget = await get_widgets(config, CONF_WIDGET)
|
||||
widget = widget[0]
|
||||
await wait_for_widgets()
|
||||
async with LambdaContext([(cg.std_string, "text_value")]) as control:
|
||||
await widget.set_property("text", "text_value.c_str())")
|
||||
lv.event_send(widget.obj, API_EVENT, None)
|
||||
|
||||
@@ -10,7 +10,7 @@ from ..defines import CONF_LVGL_ID, CONF_WIDGET
|
||||
from ..lvcode import API_EVENT, EVENT_ARG, UPDATE_EVENT, LambdaContext, LvContext
|
||||
from ..schemas import LVGL_SCHEMA
|
||||
from ..types import LV_EVENT, LvText
|
||||
from ..widgets import get_widgets
|
||||
from ..widgets import get_widgets, wait_for_widgets
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
text_sensor_schema(TextSensor)
|
||||
@@ -28,6 +28,7 @@ async def to_code(config):
|
||||
paren = await cg.get_variable(config[CONF_LVGL_ID])
|
||||
widget = await get_widgets(config, CONF_WIDGET)
|
||||
widget = widget[0]
|
||||
await wait_for_widgets()
|
||||
async with LambdaContext(EVENT_ARG) as pressed_ctx:
|
||||
pressed_ctx.add(sensor.publish_state(widget.get_value()))
|
||||
async with LvContext(paren) as ctx:
|
||||
|
||||
@@ -223,6 +223,19 @@ async def get_widget_(wid: Widget):
|
||||
return await FakeAwaitable(get_widget_generator(wid))
|
||||
|
||||
|
||||
def widgets_wait_generator():
|
||||
while True:
|
||||
if Widget.widgets_completed:
|
||||
return
|
||||
yield
|
||||
|
||||
|
||||
async def wait_for_widgets():
|
||||
if Widget.widgets_completed:
|
||||
return
|
||||
await FakeAwaitable(widgets_wait_generator())
|
||||
|
||||
|
||||
async def get_widgets(config: Union[dict, list], id: str = CONF_ID) -> list[Widget]:
|
||||
if not config:
|
||||
return []
|
||||
|
||||
@@ -3,7 +3,7 @@ import functools
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
|
||||
from ..defines import CONF_MAIN, literal
|
||||
from ..defines import CONF_MAIN
|
||||
from ..lvcode import lv
|
||||
from ..types import LvType
|
||||
from . import Widget, WidgetType
|
||||
@@ -38,11 +38,13 @@ LINE_SCHEMA = {
|
||||
|
||||
class LineType(WidgetType):
|
||||
def __init__(self):
|
||||
super().__init__(CONF_LINE, LvType("lv_line_t"), (CONF_MAIN,), LINE_SCHEMA)
|
||||
super().__init__(
|
||||
CONF_LINE, LvType("lv_line_t"), (CONF_MAIN,), LINE_SCHEMA, modify_schema={}
|
||||
)
|
||||
|
||||
async def to_code(self, w: Widget, config):
|
||||
"""For a line object, create and add the points"""
|
||||
data = literal(config[CONF_POINTS])
|
||||
if data := config.get(CONF_POINTS):
|
||||
points = cg.static_const_array(config[CONF_POINT_LIST_ID], data)
|
||||
lv.line_set_points(w.obj, points, len(data))
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ from ..defines import (
|
||||
TYPE_FLEX,
|
||||
literal,
|
||||
)
|
||||
from ..helpers import add_lv_use
|
||||
from ..helpers import add_lv_use, lvgl_components_required
|
||||
from ..lv_validation import lv_bool, lv_pct, lv_text
|
||||
from ..lvcode import (
|
||||
EVENT_ARG,
|
||||
@@ -72,6 +72,7 @@ async def msgbox_to_code(conf):
|
||||
*buttonmatrix_spec.get_uses(),
|
||||
*button_spec.get_uses(),
|
||||
)
|
||||
lvgl_components_required.add("BUTTONMATRIX")
|
||||
messagebox_id = conf[CONF_ID]
|
||||
outer = lv_Pvariable(lv_obj_t, messagebox_id.id)
|
||||
buttonmatrix = new_Pvariable(
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -32,7 +32,7 @@ void Rtttl::play(std::string rtttl) {
|
||||
if (this->state_ != State::STATE_STOPPED && this->state_ != State::STATE_STOPPING) {
|
||||
int pos = this->rtttl_.find(':');
|
||||
auto name = this->rtttl_.substr(0, pos);
|
||||
ESP_LOGW(TAG, "RTTL Component is already playing: %s", name.c_str());
|
||||
ESP_LOGW(TAG, "RTTTL Component is already playing: %s", name.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -122,6 +122,7 @@ void Rtttl::stop() {
|
||||
#ifdef USE_OUTPUT
|
||||
if (this->output_ != nullptr) {
|
||||
this->output_->set_level(0.0);
|
||||
this->set_state_(STATE_STOPPED);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_SPEAKER
|
||||
@@ -129,10 +130,10 @@ void Rtttl::stop() {
|
||||
if (this->speaker_->is_running()) {
|
||||
this->speaker_->stop();
|
||||
}
|
||||
this->set_state_(STATE_STOPPING);
|
||||
}
|
||||
#endif
|
||||
this->note_duration_ = 0;
|
||||
this->set_state_(STATE_STOPPING);
|
||||
}
|
||||
|
||||
void Rtttl::loop() {
|
||||
@@ -342,6 +343,7 @@ void Rtttl::finish_() {
|
||||
#ifdef USE_OUTPUT
|
||||
if (this->output_ != nullptr) {
|
||||
this->output_->set_level(0.0);
|
||||
this->set_state_(State::STATE_STOPPED);
|
||||
}
|
||||
#endif
|
||||
#ifdef USE_SPEAKER
|
||||
@@ -354,9 +356,9 @@ void Rtttl::finish_() {
|
||||
this->speaker_->play((uint8_t *) (&sample), 8);
|
||||
|
||||
this->speaker_->finish();
|
||||
this->set_state_(State::STATE_STOPPING);
|
||||
}
|
||||
#endif
|
||||
this->set_state_(State::STATE_STOPPING);
|
||||
this->note_duration_ = 0;
|
||||
this->on_finished_playback_callback_.call();
|
||||
ESP_LOGD(TAG, "Playback finished");
|
||||
|
||||
@@ -480,7 +480,7 @@ void HOT WaveshareEPaperTypeA::display() {
|
||||
this->start_data_();
|
||||
switch (this->model_) {
|
||||
case TTGO_EPAPER_2_13_IN_B1: { // block needed because of variable initializations
|
||||
int16_t wb = ((this->get_width_internal()) >> 3);
|
||||
int16_t wb = ((this->get_width_controller()) >> 3);
|
||||
for (int i = 0; i < this->get_height_internal(); i++) {
|
||||
for (int j = 0; j < wb; j++) {
|
||||
int idx = j + (this->get_height_internal() - 1 - i) * wb;
|
||||
@@ -766,7 +766,7 @@ void WaveshareEPaper2P7InV2::initialize() {
|
||||
// XRAM_START_AND_END_POSITION
|
||||
this->command(0x44);
|
||||
this->data(0x00);
|
||||
this->data(((get_width_internal() - 1) >> 3) & 0xFF);
|
||||
this->data(((this->get_width_controller() - 1) >> 3) & 0xFF);
|
||||
// YRAM_START_AND_END_POSITION
|
||||
this->command(0x45);
|
||||
this->data(0x00);
|
||||
@@ -928,8 +928,8 @@ void HOT WaveshareEPaper2P7InB::display() {
|
||||
|
||||
// TCON_RESOLUTION
|
||||
this->command(0x61);
|
||||
this->data(this->get_width_internal() >> 8);
|
||||
this->data(this->get_width_internal() & 0xff); // 176
|
||||
this->data(this->get_width_controller() >> 8);
|
||||
this->data(this->get_width_controller() & 0xff); // 176
|
||||
this->data(this->get_height_internal() >> 8);
|
||||
this->data(this->get_height_internal() & 0xff); // 264
|
||||
|
||||
@@ -994,7 +994,7 @@ void WaveshareEPaper2P7InBV2::initialize() {
|
||||
// self.SetWindows(0, 0, self.width-1, self.height-1)
|
||||
// SetWindows(self, Xstart, Ystart, Xend, Yend):
|
||||
|
||||
uint32_t xend = this->get_width_internal() - 1;
|
||||
uint32_t xend = this->get_width_controller() - 1;
|
||||
uint32_t yend = this->get_height_internal() - 1;
|
||||
this->command(0x44);
|
||||
this->data(0x00);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Constants used by esphome."""
|
||||
|
||||
__version__ = "2024.8.0b3"
|
||||
__version__ = "2024.8.3"
|
||||
|
||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||
VALID_SUBSTITUTIONS_CHARACTERS = (
|
||||
|
||||
@@ -48,6 +48,8 @@ class StorageJSON:
|
||||
firmware_bin_path: str,
|
||||
loaded_integrations: set[str],
|
||||
no_mdns: bool,
|
||||
framework: str | None = None,
|
||||
core_platform: str | None = None,
|
||||
) -> None:
|
||||
# Version of the storage JSON schema
|
||||
assert storage_version is None or isinstance(storage_version, int)
|
||||
@@ -78,6 +80,10 @@ class StorageJSON:
|
||||
self.loaded_integrations = loaded_integrations
|
||||
# Is mDNS disabled
|
||||
self.no_mdns = no_mdns
|
||||
# The framework used to compile the firmware
|
||||
self.framework = framework
|
||||
# The core platform of this firmware. Like "esp32", "rp2040", "host" etc.
|
||||
self.core_platform = core_platform
|
||||
|
||||
def as_dict(self):
|
||||
return {
|
||||
@@ -94,6 +100,8 @@ class StorageJSON:
|
||||
"firmware_bin_path": self.firmware_bin_path,
|
||||
"loaded_integrations": sorted(self.loaded_integrations),
|
||||
"no_mdns": self.no_mdns,
|
||||
"framework": self.framework,
|
||||
"core_platform": self.core_platform,
|
||||
}
|
||||
|
||||
def to_json(self):
|
||||
@@ -127,6 +135,8 @@ class StorageJSON:
|
||||
and CONF_DISABLED in esph.config[CONF_MDNS]
|
||||
and esph.config[CONF_MDNS][CONF_DISABLED] is True
|
||||
),
|
||||
framework=esph.target_framework,
|
||||
core_platform=esph.target_platform,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
@@ -147,6 +157,8 @@ class StorageJSON:
|
||||
firmware_bin_path=None,
|
||||
loaded_integrations=set(),
|
||||
no_mdns=False,
|
||||
framework=None,
|
||||
core_platform=platform.lower(),
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
@@ -168,6 +180,8 @@ class StorageJSON:
|
||||
firmware_bin_path = storage.get("firmware_bin_path")
|
||||
loaded_integrations = set(storage.get("loaded_integrations", []))
|
||||
no_mdns = storage.get("no_mdns", False)
|
||||
framework = storage.get("framework")
|
||||
core_platform = storage.get("core_platform")
|
||||
return StorageJSON(
|
||||
storage_version,
|
||||
name,
|
||||
@@ -182,6 +196,8 @@ class StorageJSON:
|
||||
firmware_bin_path,
|
||||
loaded_integrations,
|
||||
no_mdns,
|
||||
framework,
|
||||
core_platform,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -9,6 +9,7 @@ from esphome.config import iter_component_configs, iter_components
|
||||
from esphome.const import (
|
||||
ENV_NOGITIGNORE,
|
||||
HEADER_FILE_EXTENSIONS,
|
||||
PLATFORM_ESP32,
|
||||
SOURCE_FILE_EXTENSIONS,
|
||||
__version__,
|
||||
)
|
||||
@@ -106,6 +107,11 @@ def storage_should_clean(old: StorageJSON, new: StorageJSON) -> bool:
|
||||
return True
|
||||
if old.build_path != new.build_path:
|
||||
return True
|
||||
if old.loaded_integrations != new.loaded_integrations:
|
||||
if new.core_platform == PLATFORM_ESP32:
|
||||
from esphome.components.esp32 import FRAMEWORK_ESP_IDF
|
||||
|
||||
return new.framework == FRAMEWORK_ESP_IDF
|
||||
return False
|
||||
|
||||
|
||||
@@ -117,7 +123,9 @@ def update_storage_json():
|
||||
return
|
||||
|
||||
if storage_should_clean(old, new):
|
||||
_LOGGER.info("Core config or version changed, cleaning build files...")
|
||||
_LOGGER.info(
|
||||
"Core config, version or integrations changed, cleaning build files..."
|
||||
)
|
||||
clean_build()
|
||||
|
||||
new.save(path)
|
||||
|
||||
@@ -379,6 +379,7 @@ lvgl:
|
||||
format: "bar value %f"
|
||||
args: [x]
|
||||
- line:
|
||||
id: lv_line_id
|
||||
align: center
|
||||
points:
|
||||
- 5, 5
|
||||
@@ -387,7 +388,10 @@ lvgl:
|
||||
- 180, 60
|
||||
- 240, 10
|
||||
on_click:
|
||||
lvgl.page.next:
|
||||
- lvgl.widget.update:
|
||||
id: lv_line_id
|
||||
line_color: 0xFFFF
|
||||
- lvgl.page.next:
|
||||
- switch:
|
||||
align: right_mid
|
||||
- checkbox:
|
||||
|
||||
Reference in New Issue
Block a user