mirror of
https://github.com/esphome/esphome.git
synced 2024-11-12 10:16:02 +01:00
Apparently no TX buffer for esp8266, and fix whitespace
This commit is contained in:
parent
4dd7d61049
commit
408a212eef
@ -84,7 +84,7 @@ class UARTComponent {
|
|||||||
|
|
||||||
// Sets the size of the TX buffer.
|
// Sets the size of the TX buffer.
|
||||||
// @param tx_buffer_size Size of the TX buffer in bytes.
|
// @param tx_buffer_size Size of the TX buffer in bytes.
|
||||||
void set_tx_buffer_size(size_t tx_buffer_size) { this->tx_buffer_size_ = tx_buffer_size; }
|
void set_tx_buffer_size(size_t tx_buffer_size) { this->tx_buffer_size_ = tx_buffer_size; }
|
||||||
|
|
||||||
// Sets the size of the RX buffer.
|
// Sets the size of the RX buffer.
|
||||||
// @param rx_buffer_size Size of the RX buffer in bytes.
|
// @param rx_buffer_size Size of the RX buffer in bytes.
|
||||||
@ -92,7 +92,7 @@ class UARTComponent {
|
|||||||
|
|
||||||
// Gets the size of the TX buffer.
|
// Gets the size of the TX buffer.
|
||||||
// @return Size of the TX buffer in bytes.
|
// @return Size of the TX buffer in bytes.
|
||||||
size_t get_tx_buffer_size() { return this->tx_buffer_size_; }
|
size_t get_tx_buffer_size() { return this->tx_buffer_size_; }
|
||||||
|
|
||||||
// Gets the size of the RX buffer.
|
// Gets the size of the RX buffer.
|
||||||
// @return Size of the RX buffer in bytes.
|
// @return Size of the RX buffer in bytes.
|
||||||
|
@ -72,7 +72,6 @@ void ESP8266UartComponent::setup() {
|
|||||||
) {
|
) {
|
||||||
this->hw_serial_ = &Serial;
|
this->hw_serial_ = &Serial;
|
||||||
this->hw_serial_->begin(this->baud_rate_, config);
|
this->hw_serial_->begin(this->baud_rate_, config);
|
||||||
this->hw_serial_->setTxBufferSize(this->tx_buffer_size_);
|
|
||||||
this->hw_serial_->setRxBufferSize(this->rx_buffer_size_);
|
this->hw_serial_->setRxBufferSize(this->rx_buffer_size_);
|
||||||
ESP8266UartComponent::serial0_in_use = true;
|
ESP8266UartComponent::serial0_in_use = true;
|
||||||
} else if (!ESP8266UartComponent::serial0_in_use && (tx_pin_ == nullptr || tx_pin_->get_pin() == 15) &&
|
} else if (!ESP8266UartComponent::serial0_in_use && (tx_pin_ == nullptr || tx_pin_->get_pin() == 15) &&
|
||||||
@ -85,14 +84,12 @@ void ESP8266UartComponent::setup() {
|
|||||||
) {
|
) {
|
||||||
this->hw_serial_ = &Serial;
|
this->hw_serial_ = &Serial;
|
||||||
this->hw_serial_->begin(this->baud_rate_, config);
|
this->hw_serial_->begin(this->baud_rate_, config);
|
||||||
this->hw_serial_->setTxBufferSize(this->tx_buffer_size_);
|
|
||||||
this->hw_serial_->setRxBufferSize(this->rx_buffer_size_);
|
this->hw_serial_->setRxBufferSize(this->rx_buffer_size_);
|
||||||
this->hw_serial_->swap();
|
this->hw_serial_->swap();
|
||||||
ESP8266UartComponent::serial0_in_use = true;
|
ESP8266UartComponent::serial0_in_use = true;
|
||||||
} else if ((tx_pin_ == nullptr || tx_pin_->get_pin() == 2) && (rx_pin_ == nullptr || rx_pin_->get_pin() == 8)) {
|
} else if ((tx_pin_ == nullptr || tx_pin_->get_pin() == 2) && (rx_pin_ == nullptr || rx_pin_->get_pin() == 8)) {
|
||||||
this->hw_serial_ = &Serial1;
|
this->hw_serial_ = &Serial1;
|
||||||
this->hw_serial_->begin(this->baud_rate_, config);
|
this->hw_serial_->begin(this->baud_rate_, config);
|
||||||
this->hw_serial_->setTxBufferSize(this->tx_buffer_size_);
|
|
||||||
this->hw_serial_->setRxBufferSize(this->rx_buffer_size_);
|
this->hw_serial_->setRxBufferSize(this->rx_buffer_size_);
|
||||||
} else {
|
} else {
|
||||||
this->sw_serial_ = new ESP8266SoftwareSerial(); // NOLINT
|
this->sw_serial_ = new ESP8266SoftwareSerial(); // NOLINT
|
||||||
@ -106,7 +103,6 @@ void ESP8266UartComponent::load_settings(bool dump_config) {
|
|||||||
if (this->hw_serial_ != nullptr) {
|
if (this->hw_serial_ != nullptr) {
|
||||||
SerialConfig config = static_cast<SerialConfig>(get_config());
|
SerialConfig config = static_cast<SerialConfig>(get_config());
|
||||||
this->hw_serial_->begin(this->baud_rate_, config);
|
this->hw_serial_->begin(this->baud_rate_, config);
|
||||||
this->hw_serial_->setTxBufferSize(this->tx_buffer_size_);
|
|
||||||
this->hw_serial_->setRxBufferSize(this->rx_buffer_size_);
|
this->hw_serial_->setRxBufferSize(this->rx_buffer_size_);
|
||||||
} else {
|
} else {
|
||||||
this->sw_serial_->setup(this->tx_pin_, this->rx_pin_, this->baud_rate_, this->stop_bits_, this->data_bits_,
|
this->sw_serial_->setup(this->tx_pin_, this->rx_pin_, this->baud_rate_, this->stop_bits_, this->data_bits_,
|
||||||
@ -122,9 +118,6 @@ void ESP8266UartComponent::dump_config() {
|
|||||||
ESP_LOGCONFIG(TAG, "UART Bus:");
|
ESP_LOGCONFIG(TAG, "UART Bus:");
|
||||||
LOG_PIN(" TX Pin: ", this->tx_pin_);
|
LOG_PIN(" TX Pin: ", this->tx_pin_);
|
||||||
LOG_PIN(" RX Pin: ", this->rx_pin_);
|
LOG_PIN(" RX Pin: ", this->rx_pin_);
|
||||||
if (this->tx_pin_ != nullptr) {
|
|
||||||
ESP_LOGCONFIG(TAG, " TX Buffer Size: %u", this->tx_buffer_size_); // NOLINT
|
|
||||||
}
|
|
||||||
if (this->rx_pin_ != nullptr) {
|
if (this->rx_pin_ != nullptr) {
|
||||||
ESP_LOGCONFIG(TAG, " RX Buffer Size: %u", this->rx_buffer_size_); // NOLINT
|
ESP_LOGCONFIG(TAG, " RX Buffer Size: %u", this->rx_buffer_size_); // NOLINT
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user