mirror of
https://github.com/esphome/esphome.git
synced 2024-12-02 19:54:14 +01:00
fix s3 implementation
This commit is contained in:
parent
46b6ca0f02
commit
e2f23fd799
2 changed files with 24 additions and 3 deletions
|
@ -2,7 +2,12 @@
|
||||||
#include "usb_device.h"
|
#include "usb_device.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
#include "USB.h"
|
#include "USB.h"
|
||||||
|
// based on defines in HWCDC.cpp
|
||||||
|
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3
|
||||||
|
#if ARDUINO_USB_MODE
|
||||||
|
#include "HWCDC.h"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
bool configured;
|
bool configured;
|
||||||
|
@ -26,20 +31,35 @@ void UsbDevice::update() {
|
||||||
#ifdef USE_BINARY_SENSOR
|
#ifdef USE_BINARY_SENSOR
|
||||||
if (configured_ != nullptr) {
|
if (configured_ != nullptr) {
|
||||||
// bool configured = USB;
|
// bool configured = USB;
|
||||||
configured_->publish_state(configured);
|
configured_->publish_state(get_configured_());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void UsbDevice::dump_config() {
|
void UsbDevice::dump_config() {
|
||||||
// bool configured = USB;
|
// bool configured = USB;
|
||||||
ESP_LOGCONFIG(TAG, "USB device - configured: %s", YESNO(configured));
|
ESP_LOGCONFIG(TAG, "USB device - configured: %s", YESNO(get_configured_()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_BINARY_SENSOR
|
#ifdef USE_BINARY_SENSOR
|
||||||
void UsbDevice::set_configured_binary_sensor(binary_sensor::BinarySensor *sensor) { configured_ = sensor; };
|
void UsbDevice::set_configured_binary_sensor(binary_sensor::BinarySensor *sensor) { configured_ = sensor; };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool UsbDevice::get_configured_() {
|
||||||
|
// based on defines in HWCDC.cpp
|
||||||
|
#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3
|
||||||
|
#if ARDUINO_USB_MODE
|
||||||
|
#if ARDUINO_USB_CDC_ON_BOOT//Serial used for USB CDC
|
||||||
|
return Serial;
|
||||||
|
#else
|
||||||
|
return USBSerial;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace usb_device
|
} // namespace usb_device
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -19,6 +19,7 @@ class UsbDevice : public PollingComponent {
|
||||||
#ifdef USE_BINARY_SENSOR
|
#ifdef USE_BINARY_SENSOR
|
||||||
binary_sensor::BinarySensor *configured_;
|
binary_sensor::BinarySensor *configured_;
|
||||||
#endif
|
#endif
|
||||||
|
bool get_configured_();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace usb_device
|
} // namespace usb_device
|
||||||
|
|
Loading…
Reference in a new issue