[ESPEasySerial] Add shortName option to be used as eventname

This commit is contained in:
Ton Huisman
2023-06-24 15:22:40 +02:00
parent fb853a4639
commit e3f8adf83e
2 changed files with 13 additions and 12 deletions
+12 -11
View File
@@ -1,31 +1,32 @@
#include "ESPEasySerialPort.h"
const __FlashStringHelper* ESPEasySerialPort_toString(ESPEasySerialPort port)
const __FlashStringHelper* ESPEasySerialPort_toString(ESPEasySerialPort port, bool shortName)
{
switch (port) {
case ESPEasySerialPort::not_set: break;
#if USES_I2C_SC16IS752
case ESPEasySerialPort::sc16is752: return F("I2C Serial");
case ESPEasySerialPort::sc16is752: return shortName ? F("seriali2c") : F("I2C Serial");
#endif // if USES_I2C_SC16IS752
#ifdef ESP8266
case ESPEasySerialPort::serial0_swap: return F("HW Serial0 swap");
case ESPEasySerialPort::serial0_swap: return shortName ? F("serial0swap") : F("HW Serial0 swap");
#endif // ifdef ESP8266
case ESPEasySerialPort::serial0: return F("HW Serial0");
case ESPEasySerialPort::serial0: return shortName ? F("serial0") : F("HW Serial0");
#if SOC_UART_NUM > 1
case ESPEasySerialPort::serial1: return F("HW Serial1");
case ESPEasySerialPort::serial1: return shortName ? F("serial1") : F("HW Serial1");
#endif // if SOC_UART_NUM > 1
#if SOC_UART_NUM > 2
case ESPEasySerialPort::serial2: return F("HW Serial2");
case ESPEasySerialPort::serial2: return shortName ? F("serial2") : F("HW Serial2");
#endif // if SOC_UART_NUM > 2
#if USES_SW_SERIAL
case ESPEasySerialPort::software: return F("SW Serial");
case ESPEasySerialPort::software: return shortName ? F("serialsw") : F("SW Serial");
#endif // if USES_SW_SERIAL
#if USES_HWCDC
case ESPEasySerialPort::usb_hw_cdc: return F("USB HWCDC");
case ESPEasySerialPort::usb_hw_cdc: return shortName ? F("serialhwcdc") : F("USB HWCDC");
#endif // if USES_HWCDC
#if USES_USBCDC
case ESPEasySerialPort::usb_cdc_0: return F("USB CDC");
// case ESPEasySerialPort::usb_cdc_1: return F("USB CDC1");
case ESPEasySerialPort::usb_cdc_0: return shortName ? F("serialcdc") : F("USB CDC");
// case ESPEasySerialPort::usb_cdc_1: return F("USB CDC1");
#endif // if USES_USBCDC
case ESPEasySerialPort::MAX_SERIAL_TYPE: break;
@@ -103,7 +104,7 @@ bool validSerialPort(ESPEasySerialPort port)
#endif // if USES_HWCDC
#if USES_USBCDC
case ESPEasySerialPort::usb_cdc_0:
// case ESPEasySerialPort::usb_cdc_1:
// case ESPEasySerialPort::usb_cdc_1:
#endif // if USES_USBCDC
return true;
+1 -1
View File
@@ -36,7 +36,7 @@ enum class ESPEasySerialPort : uint8_t {
};
const __FlashStringHelper* ESPEasySerialPort_toString(ESPEasySerialPort port);
const __FlashStringHelper* ESPEasySerialPort_toString(ESPEasySerialPort port, bool shortName = false);
bool isHWserial(ESPEasySerialPort port);