1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-24 22:22:22 +01:00

Store strings only used for logging in flash (#2274)

Co-authored-by: Otto winter <otto@otto-winter.com>
This commit is contained in:
Oxan van Leeuwen
2021-09-13 09:48:52 +02:00
committed by GitHub
parent e18dfdd656
commit d594a6fcbc
25 changed files with 241 additions and 251 deletions

View File

@@ -58,21 +58,21 @@ void UARTDevice::check_uart_settings(uint32_t baud_rate, uint8_t stop_bits, UART
this->parent_->data_bits_);
}
if (this->parent_->parity_ != parity) {
ESP_LOGE(TAG, " Invalid parity: Integration requested parity %s but you have %s!", parity_to_str(parity),
parity_to_str(this->parent_->parity_));
ESP_LOGE(TAG, " Invalid parity: Integration requested parity %s but you have %s!",
LOG_STR_ARG(parity_to_str(parity)), LOG_STR_ARG(parity_to_str(this->parent_->parity_)));
}
}
const char *parity_to_str(UARTParityOptions parity) {
const LogString *parity_to_str(UARTParityOptions parity) {
switch (parity) {
case UART_CONFIG_PARITY_NONE:
return "NONE";
return LOG_STR("NONE");
case UART_CONFIG_PARITY_EVEN:
return "EVEN";
return LOG_STR("EVEN");
case UART_CONFIG_PARITY_ODD:
return "ODD";
return LOG_STR("ODD");
default:
return "UNKNOWN";
return LOG_STR("UNKNOWN");
}
}

View File

@@ -4,6 +4,7 @@
#include <HardwareSerial.h>
#include "esphome/core/esphal.h"
#include "esphome/core/component.h"
#include "esphome/core/log.h"
namespace esphome {
namespace uart {
@@ -14,7 +15,7 @@ enum UARTParityOptions {
UART_CONFIG_PARITY_ODD,
};
const char *parity_to_str(UARTParityOptions parity);
const LogString *parity_to_str(UARTParityOptions parity);
#ifdef ARDUINO_ARCH_ESP8266
class ESP8266SoftwareSerial {

View File

@@ -104,7 +104,7 @@ void UARTComponent::dump_config() {
}
ESP_LOGCONFIG(TAG, " Baud Rate: %u baud", this->baud_rate_);
ESP_LOGCONFIG(TAG, " Data Bits: %u", this->data_bits_);
ESP_LOGCONFIG(TAG, " Parity: %s", parity_to_str(this->parity_));
ESP_LOGCONFIG(TAG, " Parity: %s", LOG_STR_ARG(parity_to_str(this->parity_)));
ESP_LOGCONFIG(TAG, " Stop bits: %u", this->stop_bits_);
if (this->hw_serial_ != nullptr) {
ESP_LOGCONFIG(TAG, " Using hardware serial interface.");