diff --git a/src/console.cpp b/src/console.cpp index 419eb8082..fa3992ae6 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -65,7 +65,11 @@ void EMSESPShell::display_banner() { println(); printfln(F("┌──────────────────────────────────────────┐")); +#if defined(ESP32) + printfln(F("│ %sEMS-ESP version %-10s ESP32%s │"), COLOR_BOLD_ON, settings.app_version().c_str(), COLOR_BOLD_OFF); +#else printfln(F("│ %sEMS-ESP version %-10s%s │"), COLOR_BOLD_ON, settings.app_version().c_str(), COLOR_BOLD_OFF); +#endif printfln(F("│ %s%shttps://github.com/proddy/EMS-ESP%s │"), COLOR_BRIGHT_GREEN, COLOR_UNDERLINE, COLOR_RESET); printfln(F("│ │")); diff --git a/src/console.h b/src/console.h index 69ad657f4..8035021cf 100644 --- a/src/console.h +++ b/src/console.h @@ -41,7 +41,7 @@ using uuid::log::Level; // clang-format off -#define LOG_DEBUG(...) if (logger_.enabled(Level::DEBUG)) {logger_.debug(__VA_ARGS__);} +#define LOG_DEBUG(...) logger_.debug(__VA_ARGS__) #define LOG_INFO(...) logger_.info(__VA_ARGS__) #define LOG_TRACE(...) logger_.trace(__VA_ARGS__) #define LOG_NOTICE(...) logger_.notice(__VA_ARGS__) diff --git a/src/uart/emsuart_esp32.cpp b/src/uart/emsuart_esp32.cpp index 6d0040874..4d4dee782 100644 --- a/src/uart/emsuart_esp32.cpp +++ b/src/uart/emsuart_esp32.cpp @@ -102,6 +102,12 @@ void EMSuart::start(uint8_t tx_mode) { emsTxWait = EMSUART_BIT_TIME * tx_mode; } else if(tx_mode > 5 ) { emsTxWait = EMSUART_BIT_TIME * tx_mode * 2; + } else if(tx_mode == 3) { + emsTxWait = EMSUART_BIT_TIME * 17; + } else if(tx_mode == 2) { + emsTxWait = EMSUART_BIT_TIME * 20; + } else if(tx_mode == 1) { + emsTxWait = EMSUART_BIT_TIME * 11; } if (tx_mode_ != 0xFF) { // uart already initialized tx_mode_ = tx_mode; @@ -115,19 +121,19 @@ void EMSuart::start(uint8_t tx_mode) { .parity = UART_PARITY_DISABLE, .stop_bits = UART_STOP_BITS_1, .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, - } - ESP_ERROR_CHECK(uart_param_config(EMSUART_UART, &uart_config)); + }; + uart_param_config(EMSUART_UART, &uart_config); if (tx_mode_ == 5) { EMS_UART.conf0.stop_bit_num = UART_STOP_BITS_1_5; } - ESP_ERROR_CHECK(uart_set_pin(EMSUART_UART, EMSUART_TXPIN, EMSUART_RXPIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE)); + uart_set_pin(EMSUART_UART, EMSUART_TXPIN, EMSUART_RXPIN, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); EMS_UART.int_ena.val = 0; // disable all intr. EMS_UART.int_clr.val = 0xFFFFFFFF; // clear all intr. flags EMS_UART.idle_conf.tx_brk_num = 11; // breaklength 11 bit EMS_UART.idle_conf.rx_idle_thrhd = 256; drop_next_rx = true; buf_handle = xRingbufferCreate(128, RINGBUF_TYPE_NOSPLIT); - ESP_ERROR_CHECK(uart_isr_register(EMSUART_UART, emsuart_rx_intr_handler, NULL, ESP_INTR_FLAG_IRAM, &uart_handle)); + uart_isr_register(EMSUART_UART, emsuart_rx_intr_handler, NULL, ESP_INTR_FLAG_IRAM, &uart_handle); xTaskCreate(emsuart_recvTask, "emsuart_recvTask", 2048, NULL, configMAX_PRIORITIES - 1, NULL); EMS_UART.int_ena.brk_det = 1; // activate only break @@ -167,15 +173,27 @@ void EMSuart::restart() { * Sends a 1-byte poll, ending with a */ void EMSuart::send_poll(uint8_t data) { - if (tx_mode_ == EMS_TXMODE_NEW || tx_mode_ == 5) { - EMS_UART.fifo.rw_byte = data; - EMS_UART.conf0.txd_brk = 1; // after send - } else { + if (tx_mode_ > 5 || tx_mode_ < 4) { EMS_UART.fifo.rw_byte = data; emsTxBufIdx = 0; emsTxBufLen = 1; timerAlarmWrite(timer, emsTxWait, false); timerAlarmEnable(timer); + } else if (tx_mode_ >= EMS_TXMODE_NEW) { + EMS_UART.fifo.rw_byte = data; + EMS_UART.conf0.txd_brk = 1; // after send + } else if (tx_mode_ == EMS_TXMODE_HT3) { + EMS_UART.fifo.rw_byte = data; + delayMicroseconds(EMSUART_TX_WAIT_HT3); + EMS_UART.conf0.txd_brk = 1; // + } else if (tx_mode_ == EMS_TXMODE_EMSPLUS) { + EMS_UART.fifo.rw_byte = data; + delayMicroseconds(EMSUART_TX_WAIT_PLUS); + EMS_UART.conf0.txd_brk = 1; // + } else { + EMS_UART.fifo.rw_byte = data; + delayMicroseconds(EMSUART_TX_WAIT_BRK); + EMS_UART.conf0.txd_brk = 1; // } } @@ -188,7 +206,7 @@ uint16_t EMSuart::transmit(uint8_t * buf, uint8_t len) { if (len == 0 || len >= EMS_MAXBUFFERSIZE) { return EMS_TX_STATUS_ERR; } - if (tx_mode_ > 5) { // timer controlled modes + if (tx_mode_ > 5 || tx_mode_ < 4) { // timer controlled modes for (uint8_t i = 0; i < len; i++) { emsTxBuf[i] = buf[i]; } @@ -206,15 +224,15 @@ uint16_t EMSuart::transmit(uint8_t * buf, uint8_t len) { EMS_UART.conf0.txd_brk = 1; // after send return EMS_TX_STATUS_OK; } - if (tx_mode_ >= EMS_TXMODE_EMSPLUS) { // EMS+ with long delay + if (tx_mode_ == EMS_TXMODE_EMSPLUS) { // EMS+ with long delay for (uint8_t i = 0; i < len; i++) { EMS_UART.fifo.rw_byte = buf[i]; - delaymicroseconds(EMSUART_TX_WAIT_PLUS); + delayMicroseconds(EMSUART_TX_WAIT_PLUS); } EMS_UART.conf0.txd_brk = 1; // after send, cleard by hardware after send return EMS_TX_STATUS_OK; } - if (tx_mode_ >= EMS_TXMODE_HT3) { // HT3 with 7 bittimes delay + if (tx_mode_ == EMS_TXMODE_HT3) { // HT3 with 7 bittimes delay for (uint8_t i = 0; i < len; i++) { EMS_UART.fifo.rw_byte = buf[i]; delayMicroseconds(EMSUART_TX_WAIT_HT3);