1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-30 06:33:51 +00:00

Force braces around multi-line statements (#3094)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Oxan van Leeuwen
2022-01-24 20:56:36 +01:00
committed by GitHub
parent 6b27f2d2cf
commit 80d03a631e
125 changed files with 770 additions and 504 deletions

View File

@@ -41,10 +41,11 @@ uint32_t ESP32ArduinoUARTComponent::get_config() {
* tick_ref_always_on:27 select the clock.1apb clockref_tick
*/
if (this->parity_ == UART_CONFIG_PARITY_EVEN)
if (this->parity_ == UART_CONFIG_PARITY_EVEN) {
config |= UART_PARITY_EVEN | UART_PARITY_ENABLE;
else if (this->parity_ == UART_CONFIG_PARITY_ODD)
} else if (this->parity_ == UART_CONFIG_PARITY_ODD) {
config |= UART_PARITY_ODD | UART_PARITY_ENABLE;
}
switch (this->data_bits_) {
case 5:
@@ -61,10 +62,11 @@ uint32_t ESP32ArduinoUARTComponent::get_config() {
break;
}
if (this->stop_bits_ == 1)
if (this->stop_bits_ == 1) {
config |= UART_NB_STOP_BIT_1;
else
} else {
config |= UART_NB_STOP_BIT_2;
}
config |= UART_TICK_APB_CLOCK;

View File

@@ -18,12 +18,13 @@ bool ESP8266UartComponent::serial0_in_use = false; // NOLINT(cppcoreguidelines-
uint32_t ESP8266UartComponent::get_config() {
uint32_t config = 0;
if (this->parity_ == UART_CONFIG_PARITY_NONE)
if (this->parity_ == UART_CONFIG_PARITY_NONE) {
config |= UART_PARITY_NONE;
else if (this->parity_ == UART_CONFIG_PARITY_EVEN)
} else if (this->parity_ == UART_CONFIG_PARITY_EVEN) {
config |= UART_PARITY_EVEN;
else if (this->parity_ == UART_CONFIG_PARITY_ODD)
} else if (this->parity_ == UART_CONFIG_PARITY_ODD) {
config |= UART_PARITY_ODD;
}
switch (this->data_bits_) {
case 5:
@@ -40,10 +41,11 @@ uint32_t ESP8266UartComponent::get_config() {
break;
}
if (this->stop_bits_ == 1)
if (this->stop_bits_ == 1) {
config |= UART_NB_STOP_BIT_1;
else
} else {
config |= UART_NB_STOP_BIT_2;
}
if (this->tx_pin_ != nullptr && this->tx_pin_->is_inverted())
config |= BIT(22);
@@ -234,12 +236,13 @@ void IRAM_ATTR HOT ESP8266SoftwareSerial::write_byte(uint8_t data) {
}
bool parity_bit = false;
bool need_parity_bit = true;
if (this->parity_ == UART_CONFIG_PARITY_EVEN)
if (this->parity_ == UART_CONFIG_PARITY_EVEN) {
parity_bit = false;
else if (this->parity_ == UART_CONFIG_PARITY_ODD)
} else if (this->parity_ == UART_CONFIG_PARITY_ODD) {
parity_bit = true;
else
} else {
need_parity_bit = false;
}
{
InterruptLock lock;

View File

@@ -16,10 +16,11 @@ static const char *const TAG = "uart.idf";
uart_config_t IDFUARTComponent::get_config_() {
uart_parity_t parity = UART_PARITY_DISABLE;
if (this->parity_ == UART_CONFIG_PARITY_EVEN)
if (this->parity_ == UART_CONFIG_PARITY_EVEN) {
parity = UART_PARITY_EVEN;
else if (this->parity_ == UART_CONFIG_PARITY_ODD)
} else if (this->parity_ == UART_CONFIG_PARITY_ODD) {
parity = UART_PARITY_ODD;
}
uart_word_length_t data_bits;
switch (this->data_bits_) {
@@ -141,9 +142,9 @@ bool IDFUARTComponent::peek_byte(uint8_t *data) {
if (!this->check_read_timeout_())
return false;
xSemaphoreTake(this->lock_, portMAX_DELAY);
if (this->has_peek_)
if (this->has_peek_) {
*data = this->peek_byte_;
else {
} else {
int len = uart_read_bytes(this->uart_num_, data, 1, 20 / portTICK_RATE_MS);
if (len == 0) {
*data = 0;