mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-27 19:57:38 +00:00
[Serial] Implement enable/disable HWSerial in serial selector
This commit is contained in:
@@ -115,13 +115,13 @@ void C018_ConfigStruct::webform_load(C018_data_struct *C018_data) {
|
||||
|
||||
addTableSeparator(F("Serial Port Configuration"), 2, 3);
|
||||
|
||||
serialHelper_webformLoad(port, rxpin, txpin, INCLUDE_SW_SERIAL | INCLUDE_HW_SERIAL | INCLUDE_I2C_SERIAL);
|
||||
serialHelper_webformLoad(port, rxpin, txpin);
|
||||
|
||||
// Show serial port selection
|
||||
addFormPinSelect(PinSelectPurpose::Generic_input, formatGpioName_serialRX(false), F("taskdevicepin1"), rxpin);
|
||||
addFormPinSelect(PinSelectPurpose::Generic_output, formatGpioName_serialTX(false), F("taskdevicepin2"), txpin);
|
||||
|
||||
html_add_script(F("document.getElementById('serPort').onchange();"), false);
|
||||
html_add_script(F("elId('serPort').onchange();"), false);
|
||||
|
||||
addFormNumericBox(F("Baudrate"), F(C018_BAUDRATE_LABEL), baudrate, 2400, 115200);
|
||||
addUnit(F("baud"));
|
||||
|
||||
@@ -121,13 +121,13 @@ void C023_ConfigStruct::webform_load(C023_data_struct *C023_data) {
|
||||
|
||||
addTableSeparator(F("Serial Port Configuration"), 2, 3);
|
||||
|
||||
serialHelper_webformLoad(port, rxpin, txpin, INCLUDE_SW_SERIAL | INCLUDE_HW_SERIAL | INCLUDE_I2C_SERIAL);
|
||||
serialHelper_webformLoad(port, rxpin, txpin);
|
||||
|
||||
// Show serial port selection
|
||||
addFormPinSelect(PinSelectPurpose::Generic_input, formatGpioName_serialRX(false), F("taskdevicepin1"), rxpin);
|
||||
addFormPinSelect(PinSelectPurpose::Generic_output, formatGpioName_serialTX(false), F("taskdevicepin2"), txpin);
|
||||
|
||||
html_add_script(F("document.getElementById('serPort').onchange();"), false);
|
||||
html_add_script(F("elId('serPort').onchange();"), false);
|
||||
|
||||
addFormNumericBox(F("Baudrate"), F(C023_BAUDRATE_LABEL), baudrate, 2400, 115200);
|
||||
addUnit(F("baud"));
|
||||
|
||||
@@ -178,7 +178,7 @@ void serialHelper_addI2CuartSelectors(int address, int channel, String id, Strin
|
||||
#endif // ifndef DISABLE_SC16IS752_Serial
|
||||
|
||||
void serialHelper_webformLoad(struct EventStruct *event) {
|
||||
serialHelper_webformLoad(event, INCLUDE_SW_SERIAL | INCLUDE_HW_SERIAL | INCLUDE_I2C_SERIAL);
|
||||
serialHelper_webformLoad(event, INCLUDE_DEFAULT_SERIAL);
|
||||
}
|
||||
|
||||
// These helper functions were made to create a generic interface to setup serial port config.
|
||||
@@ -366,17 +366,19 @@ void serialHelper_webformLoad(ESPEasySerialPort port,
|
||||
}
|
||||
#endif
|
||||
options[i] = option;
|
||||
// FIXME tonhuisman Check for INCLUDE_HW_SERIAL not implemented yet
|
||||
if ((allowedSerial & INCLUDE_SW_SERIAL) && (serType == ESPEasySerialPort::software)) {
|
||||
if (!(allowedSerial & INCLUDE_HW_SERIAL) && isHWserial(serType)) {
|
||||
attr[i] = F("disabled");
|
||||
}
|
||||
if (!(allowedSerial & INCLUDE_SW_SERIAL) && (serType == ESPEasySerialPort::software)) {
|
||||
attr[i] = F("disabled");
|
||||
}
|
||||
#if USES_I2C_SC16IS752
|
||||
if ((allowedSerial & INCLUDE_I2C_SERIAL) && (serType == ESPEasySerialPort::sc16is752)) {
|
||||
if (!(allowedSerial & INCLUDE_I2C_SERIAL) && (serType == ESPEasySerialPort::sc16is752)) {
|
||||
attr[i] = F("disabled");
|
||||
}
|
||||
#endif // if USES_I2C_SC16IS752
|
||||
#if USES_HWCDC || USES_USBCDC
|
||||
if ((allowedSerial & INCLUDE_CDC_SERIAL)
|
||||
if (!(allowedSerial & INCLUDE_CDC_SERIAL)
|
||||
#if USES_HWCDC
|
||||
&& (serType == ESPEasySerialPort::usb_hw_cdc)
|
||||
#endif // if USES_HWCDC
|
||||
|
||||
@@ -8,10 +8,12 @@
|
||||
|
||||
#include <ESPeasySerial.h>
|
||||
|
||||
#define INCLUDE_SW_SERIAL (1 << 0)
|
||||
#define INCLUDE_HW_SERIAL (1 << 1) // Ignored for now, always enabled
|
||||
#define INCLUDE_I2C_SERIAL (1 << 2)
|
||||
#define INCLUDE_CDC_SERIAL (1 << 3)
|
||||
constexpr uint8_t INCLUDE_SW_SERIAL = (1 << 0);
|
||||
constexpr uint8_t INCLUDE_HW_SERIAL = (1 << 1); // Ignored for now, always enabled
|
||||
constexpr uint8_t INCLUDE_I2C_SERIAL = (1 << 2);
|
||||
constexpr uint8_t INCLUDE_CDC_SERIAL = (1 << 3);
|
||||
constexpr uint8_t INCLUDE_ALL_SERIAL = (INCLUDE_SW_SERIAL | INCLUDE_HW_SERIAL | INCLUDE_I2C_SERIAL | INCLUDE_CDC_SERIAL);
|
||||
constexpr uint8_t INCLUDE_DEFAULT_SERIAL = INCLUDE_ALL_SERIAL;
|
||||
|
||||
struct ESPeasySerialType;
|
||||
|
||||
@@ -62,7 +64,7 @@ void serialHelper_webformLoad(struct EventStruct *event,
|
||||
void serialHelper_webformLoad(ESPEasySerialPort port,
|
||||
int rxPinDef,
|
||||
int txPinDef,
|
||||
uint8_t allowedSerial);
|
||||
uint8_t allowedSerial = INCLUDE_DEFAULT_SERIAL);
|
||||
|
||||
void serialHelper_webformLoad(ESPEasySerialPort port,
|
||||
int rxPinDef,
|
||||
|
||||
@@ -253,8 +253,7 @@ void handle_advanced() {
|
||||
serialHelper_webformLoad(
|
||||
static_cast<ESPEasySerialPort>(Settings.console_serial_port),
|
||||
Settings.console_serial_rxpin,
|
||||
Settings.console_serial_txpin,
|
||||
INCLUDE_SW_SERIAL | INCLUDE_HW_SERIAL | INCLUDE_I2C_SERIAL);
|
||||
Settings.console_serial_txpin);
|
||||
|
||||
// Show serial port selection
|
||||
addFormPinSelect(
|
||||
@@ -268,7 +267,7 @@ void handle_advanced() {
|
||||
F("taskdevicepin2"),
|
||||
Settings.console_serial_txpin);
|
||||
|
||||
html_add_script(F("document.getElementById('serPort').onchange();"), false);
|
||||
html_add_script(F("elId('serPort').onchange();"), false);
|
||||
#if USES_ESPEASY_CONSOLE_FALLBACK_PORT
|
||||
addFormCheckBox(LabelType::CONSOLE_FALLBACK_TO_SERIAL0);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user