mirror of
https://github.com/esphome/esphome.git
synced 2026-09-28 15:30:21 +00:00
[tinyusb] Use register_apply_condition for tinyusb.is_mounted (#19702)
This commit is contained in:
@@ -36,7 +36,6 @@ _USB_CLASS_COMPONENTS = ("usb_cdc_acm",)
|
||||
|
||||
tinyusb_ns = cg.esphome_ns.namespace("tinyusb")
|
||||
TinyUSB = tinyusb_ns.class_("TinyUSB", cg.Component)
|
||||
IsMountedCondition = tinyusb_ns.class_("IsMountedCondition", automation.Condition)
|
||||
|
||||
_CALLBACK_AUTOMATIONS = (
|
||||
automation.CallbackAutomation(
|
||||
@@ -134,8 +133,8 @@ async def to_code(config: ConfigType) -> None:
|
||||
add_idf_sdkconfig_option("CONFIG_TINYUSB_DESC_BCD_DEVICE", 0x0100)
|
||||
|
||||
|
||||
automation.register_simple_condition(
|
||||
automation.register_apply_condition(
|
||||
"tinyusb.is_mounted",
|
||||
IsMountedCondition,
|
||||
cv.Schema({cv.GenerateID(): cv.use_id(TinyUSB)}),
|
||||
"is_mounted()",
|
||||
)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
#if defined(USE_ESP32_VARIANT_ESP32P4) || defined(USE_ESP32_VARIANT_ESP32S2) || defined(USE_ESP32_VARIANT_ESP32S3) || \
|
||||
defined(USE_ESP32_VARIANT_ESP32S31) || defined(USE_ESP32_VARIANT_ESP32H4)
|
||||
#include "esphome/core/automation.h"
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
|
||||
@@ -87,15 +86,6 @@ class TinyUSB final : public Component {
|
||||
};
|
||||
};
|
||||
|
||||
template<typename... Ts> class IsMountedCondition final : public Condition<Ts...> {
|
||||
public:
|
||||
explicit IsMountedCondition(TinyUSB *parent) : parent_(parent) {}
|
||||
bool check(const Ts &...) override { return this->parent_->is_mounted(); }
|
||||
|
||||
protected:
|
||||
TinyUSB *parent_;
|
||||
};
|
||||
|
||||
} // namespace esphome::tinyusb
|
||||
#endif // USE_ESP32_VARIANT_ESP32P4 || USE_ESP32_VARIANT_ESP32S2 || USE_ESP32_VARIANT_ESP32S3 ||
|
||||
// USE_ESP32_VARIANT_ESP32S31 || USE_ESP32_VARIANT_ESP32H4
|
||||
|
||||
Reference in New Issue
Block a user