Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into feature/Cleanup-and-provisioning-fallback-cmds

This commit is contained in:
Ton Huisman
2026-02-14 16:25:36 +01:00
42 changed files with 523 additions and 134 deletions
+104
View File
@@ -246,11 +246,13 @@ lib_ignore = ESP32_ping
extends = ir
build_flags = ${ir.build_flags}
-DPLUGIN_BUILD_MINIMAL_IR
-DFEATURE_I2C=1
[minimal_ir_extended]
extends = ir
build_flags = ${ir.build_flags}
-DPLUGIN_BUILD_MINIMAL_IRext
-DFEATURE_I2C=1
[normal_ir]
extends = ir
@@ -305,6 +307,108 @@ build_flags = ${esp82xx_1M.build_flags}
-DDISABLE_SC16IS752_Serial
-DFEATURE_GPIO_USE_ESP8266_WAVEFORM=0
extra_scripts = ${esp82xx_1M.extra_scripts}
lib_ignore = ESP32_ping
ESP32WebServer
ESP32HTTPUpdateServer
ServoESP32
TinyWireM
ESP8266SdFat
SD(esp8266)
SD
SDFS
LittleFS(esp8266)
LittleFS
ArduinoOTA
ESP8266mDNS
I2C AXP192 Power management
EspSoftwareSerial
AXP2101 Power management (I2C)
AM2320
AS3935MI
AS5600
AS_BH1750
Adafruit BME680 Library
Adafruit BMP3XX Library
Adafruit GFX Library
Adafruit HMC5883 Unified
Adafruit ILI9341 ESPEasy
Adafruit MPR121
Adafruit Motor Shield V2 Library
Adafruit NeoMatrix via NeoPixelBus
Adafruit PCD8544 Nokia 5110 LCD library
Adafruit SGP30 Sensor
Adafruit SI1145 Library
Adafruit TCS34725
Adafruit TSL2591 Library
Adafruit Unified Sensor
Adafruit VEML7700 Library
Adafruit seesaw Library
Adafruit_ST77xx
AnyRtttl
; ArduinoJson
Blynk
CHT16K33 LED Matrix Library
CircularBuffer
ClimateGuard RadSens
DFRobot_GP8403_ESPEasy
DNSServer
; ESP8266HTTPClient
; ESP8266HTTPUpdateServer
; ESP8266WebServer
; ESP8266WiFi
ESP8266_SSD1306
; ESPeasySerial
ESPping
ESP8266 and ESP32 Oled Driver for SSD1306 display
FrogmoreScd30
; GPIO_DirectAccess
HLW8012
HeatpumpIR
I2Cdevlib-Core
ILI9488
IRremoteESP8266
ITG3205
Improv WiFi Library
IthoCC1101
LOLIN_EPD
LiquidCrystal_I2C
MD_MAX72XX
MD_Parola
MFRC522
MechInputs
Multi Channel Relay Arduino Library
NeoPixelBus
NeoPixelBus_wrapper
NewPing
Noiasca NeopixelDisplay
PZEM-004T-v30
; PubSubClient3
RAK12019_LTR390_UV_Light
RN2xx3 Arduino Library
RTClib
Regexp
SC16IS752
SDM
SPI
Sensirion Gas Index Algorithm
SerialSensors
Servo
ShiftRegister74HC595_NonTemplate
SparkFun ADXL345 Arduino Library
SparkFun APDS9960 RGB and Gesture Sensor
SparkFun MAX1704x Fuel Gauge Arduino Library
SparkFun SCD4x Arduino Library
SparkFun VL53L1X 4m Laser Distance Sensor
SparkFun_AS7265x
TinyGPSPlus
VL53L0X
WakeOnLan
Wire
XPT2046_Touchscreen
bb_captouch
htcw_ip5306
ld2410
supertinycron
;lib_ignore = ${esp82xx_1M.lib_ignore}
; Adding the libs below to the lib_ignore will even increase build size
; Adafruit TCS34725
+7 -3
View File
@@ -375,21 +375,21 @@ build_flags = ${esp8266_1M_OTA.build_flags}
extends = esp8266_1M_OTA, core274_platform
build_flags = ${core274_platform.build_flags}
${minimal_OTA_domoticz.build_flags}
lib_ignore = ${core274_platform.lib_ignore}
lib_ignore = ${esp8266_1M_OTA.lib_ignore}
[env:minimal_core_274_ESP8266_1M_OTA_Domoticz_MQTT]
extends = esp8266_1M_OTA, core274_platform
build_flags = ${core274_platform.build_flags}
${minimal_OTA_domoticz_MQTT.build_flags}
lib_ignore = ${core274_platform.lib_ignore}
lib_ignore = ${esp8266_1M_OTA.lib_ignore}
[env:minimal_core_274_ESP8266_1M_OTA_FHEM_HA]
extends = esp8266_1M_OTA, core274_platform
build_flags = ${core274_platform.build_flags}
${minimal_OTA_FHEM_HA.build_flags}
lib_ignore = ${core274_platform.lib_ignore}
lib_ignore = ${esp8266_1M_OTA.lib_ignore}
[env:minimal_core_312_ESP8266_1M_OTA_Domoticz]
@@ -397,6 +397,8 @@ extends = esp8266_1M_OTA, core312_platform
build_flags = ${core312_platform.build_flags}
${minimal_OTA_domoticz.build_flags}
build_unflags = ${core312_platform.build_unflags}
lib_ignore = ${esp8266_1M_OTA.lib_ignore}
[env:minimal_core_312_ESP8266_1M_OTA_Domoticz_MQTT]
@@ -404,6 +406,7 @@ extends = esp8266_1M_OTA, core312_platform
build_flags = ${core312_platform.build_flags}
${minimal_OTA_domoticz_MQTT.build_flags}
build_unflags = ${core312_platform.build_unflags}
lib_ignore = ${esp8266_1M_OTA.lib_ignore}
[env:minimal_core_312_ESP8266_1M_OTA_FHEM_HA]
@@ -411,6 +414,7 @@ extends = esp8266_1M_OTA, core312_platform
build_flags = ${core312_platform.build_flags}
${minimal_OTA_FHEM_HA.build_flags}
build_unflags = ${core312_platform.build_unflags}
lib_ignore = ${esp8266_1M_OTA.lib_ignore}
+2
View File
@@ -326,7 +326,9 @@ bool InternalCommands::executeInternalCommand()
#if FEATURE_WIFI
case ESPEasy_cmd_e::hiddenssid: COMMAND_CASE_R(Command_Wifi_HiddenSSID, 1); // wifi.h
#endif
#if FEATURE_I2C
case ESPEasy_cmd_e::i2cscanner: COMMAND_CASE_R(Command_i2c_Scanner, -1); // i2c.h
#endif
case ESPEasy_cmd_e::inc: COMMAND_CASE_A(Command_Rules_Inc, -1); // Rules.h
case ESPEasy_cmd_e::ip: COMMAND_CASE_R(Command_IP, 1); // Network Command
#if FEATURE_USE_IPV6
+2
View File
@@ -11,6 +11,7 @@
#include "../../ESPEasy_common.h"
#if FEATURE_I2C
void i2c_scanI2Cbus(bool dbg, int8_t channel, uint8_t i2cBus) {
uint8_t error, address;
@@ -70,3 +71,4 @@ const __FlashStringHelper* Command_i2c_Scanner(struct EventStruct *event, const
I2CSelectHighClockSpeed(0); // By default the bus is in standard speed
return return_see_serial(event);
}
#endif
+2 -2
View File
@@ -2,12 +2,12 @@
#define COMMAND_I2C_H
#include "../../ESPEasy_common.h"
#if FEATURE_I2C
void i2c_scanI2Cbus(bool dbg,
int8_t channel,
uint8_t i2cBus);
const __FlashStringHelper* Command_i2c_Scanner(struct EventStruct *event,
const char *Line);
#endif
#endif // COMMAND_I2C_H
+53
View File
@@ -55,8 +55,10 @@ To create/register a plugin, you have to :
#define WEBSERVER_INCLUDE_JS
#endif
#ifndef WEBSERVER_LOG
#ifndef PLUGIN_BUILD_MINIMAL_OTA
#define WEBSERVER_LOG
#endif
#endif
#ifndef WEBSERVER_JSON
#define WEBSERVER_JSON
#endif
@@ -4471,4 +4473,55 @@ To create/register a plugin, you have to :
#endif
#endif
#ifndef FEATURE_I2C
#ifdef ESP32
#define FEATURE_I2C 1
#else
// TODO TD-er: Add check for plugins requiring I2C
// Checks:
// FEATURE_I2CMULTIPLEXER
// FEATURE_PLUGIN_PRIORITY
// FEATURE_I2C_MULTIPLE
// FEATURE_CLEAR_I2C_STUCK
// FEATURE_I2C_GET_ADDRESS
// FEATURE_EXT_RTC
// I2C Watchdog???? Settings.WDI2CAddress
#ifdef PLUGIN_BUILD_MINIMAL_OTA
#ifdef USES_P180
#define FEATURE_I2C 1
#else
#define FEATURE_I2C 0
#endif
#else
#define FEATURE_I2C 1
#endif
#endif
#endif
#if !FEATURE_I2C
# ifdef WEBSERVER_I2C_SCANNER
# undef WEBSERVER_I2C_SCANNER
# endif
#endif
#ifndef FEATURE_SPI
#if FEATURE_SD
#define FEATURE_SPI 1
// TODO TD-er: Add check for plugins requiring SPI
#else
#if defined(USES_NW004) || defined(USES_P039) || defined(USES_P046) || defined(USES_P095) || defined(USES_P096) || defined(USES_P099) || defined(USES_P104) || defined(USES_P111) || defined(USES_P116) || defined(USES_P118) || defined(USES_P125) || defined(USES_P141) || defined(USES_P162) || defined(USES_P172)
#define FEATURE_SPI 1
#else
#define FEATURE_SPI 0
#endif
#endif
#endif
#if !FEATURE_SPI && !FEATURE_I2C
#ifdef WEBSERVER_INTERFACES
#undef WEBSERVER_INTERFACES
#endif
#endif
#endif // CUSTOMBUILD_DEFINE_PLUGIN_SETS_H
+12 -1
View File
@@ -57,17 +57,23 @@ void DeviceStruct::clear() {
bool DeviceStruct::connectedToGPIOpins() const {
switch(Type) {
case DEVICE_TYPE_SINGLE: // Single GPIO
#if FEATURE_SPI
case DEVICE_TYPE_SPI:
#endif
case DEVICE_TYPE_CUSTOM1:
case DEVICE_TYPE_DUAL: // Dual GPIOs
case DEVICE_TYPE_SERIAL:
#if FEATURE_SPI
case DEVICE_TYPE_SPI2:
#endif
case DEVICE_TYPE_CUSTOM2:
case DEVICE_TYPE_TRIPLE: // Triple GPIOs
case DEVICE_TYPE_SERIAL_PLUS1:
#if FEATURE_SPI
case DEVICE_TYPE_SPI3:
#endif
case DEVICE_TYPE_CUSTOM3:
return true;
default:
@@ -81,12 +87,16 @@ bool DeviceStruct::usesTaskDevicePin(int pin) const {
if (pin == 2)
return connectedToGPIOpins() &&
!(Type == DEVICE_TYPE_SINGLE ||
#if FEATURE_SPI
Type == DEVICE_TYPE_SPI ||
#endif
Type == DEVICE_TYPE_CUSTOM1);
if (pin == 3)
return Type == DEVICE_TYPE_TRIPLE ||
Type == DEVICE_TYPE_SERIAL_PLUS1 ||
#if FEATURE_SPI
Type == DEVICE_TYPE_SPI3 ||
#endif
Type == DEVICE_TYPE_CUSTOM3;
return false;
}
@@ -95,12 +105,13 @@ bool DeviceStruct::isSerial() const {
return (Type == DEVICE_TYPE_SERIAL) ||
(Type == DEVICE_TYPE_SERIAL_PLUS1);
}
#if FEATURE_SPI
bool DeviceStruct::isSPI() const {
return (Type == DEVICE_TYPE_SPI) ||
(Type == DEVICE_TYPE_SPI2) ||
(Type == DEVICE_TYPE_SPI3);
}
#endif
bool DeviceStruct::isCustom() const {
return (Type == DEVICE_TYPE_CUSTOM0) ||
+6 -1
View File
@@ -17,12 +17,16 @@
#define DEVICE_TYPE_DUAL 2 // connected through 2 datapins
#define DEVICE_TYPE_TRIPLE 3 // connected through 3 datapins
#define DEVICE_TYPE_ANALOG 10 // AIN/tout pin
#if FEATURE_I2C
#define DEVICE_TYPE_I2C 20 // connected through I2C
#endif
#define DEVICE_TYPE_SERIAL 21 // connected through UART/Serial
#define DEVICE_TYPE_SERIAL_PLUS1 22 // connected through UART/Serial + 1 extra signal pin
#if FEATURE_SPI
#define DEVICE_TYPE_SPI 23 // connected through SPI
#define DEVICE_TYPE_SPI2 24 // connected through SPI, 2 GPIOs
#define DEVICE_TYPE_SPI3 25 // connected through SPI, 3 GPIOs
#endif
#define DEVICE_TYPE_CUSTOM0 30 // Custom labels, Not using TaskDevicePin1 ... TaskDevicePin3
#define DEVICE_TYPE_CUSTOM1 31 // Custom labels, 1 GPIO
#define DEVICE_TYPE_CUSTOM2 32 // Custom labels, 2 GPIOs
@@ -73,8 +77,9 @@ struct DeviceStruct
}
bool isSerial() const;
#if FEATURE_SPI
bool isSPI() const;
#endif
bool isCustom() const;
+9 -5
View File
@@ -366,6 +366,7 @@ public:
PinBootState getPinBootState(int8_t gpio_pin) const;
void setPinBootState(int8_t gpio_pin, PinBootState state);
#if FEATURE_SPI
bool getSPI_pins(int8_t spi_gpios[3],
uint8_t spi_bus = 0,
bool noCheck = false) const;
@@ -383,9 +384,6 @@ public:
// Return true when SPI enabled and opt. user defined pins valid.
bool isSPI_valid(uint8_t spi_bus) const;
// Return true when pin is one of the configured I2C pins.
bool isI2C_pin(int8_t pin) const;
uint8_t getSPIBusForTask(taskIndex_t TaskIndex) const;
void setSPIBusForTask(taskIndex_t TaskIndex, uint8_t spi_bus);
@@ -393,6 +391,11 @@ public:
uint8_t getSPIBusForSDCard() const;
void setSPIBusForSDCard(uint8_t spi_bus);
#endif // if FEATURE_SD
#endif
#if FEATURE_I2C
// Return true when pin is one of the configured I2C pins.
bool isI2C_pin(int8_t pin) const;
// Return true if I2C settings are correct
bool isI2CEnabled(uint8_t i2cBus) const;
@@ -417,13 +420,14 @@ public:
int8_t getI2CMultiplexerAddr(uint8_t i2cBus) const;
int8_t getI2CMultiplexerResetPin(uint8_t i2cBus) const;
#endif // if FEATURE_I2CMULTIPLEXER
#endif
#if FEATURE_ETHERNET
// Return true when pin is one of the fixed Ethernet pins and Ethernet is enabled
bool isEthernetPin(int8_t pin) const;
// Return true when pin is one of the optional Ethernet pins and Ethernet is enabled
bool isEthernetPinOptional(int8_t pin) const;
#endif
// Access to TaskDevicePin1 ... TaskDevicePin3
// @param pinnr 1 = TaskDevicePin1, ..., 3 = TaskDevicePin3
int8_t getTaskDevicePin(taskIndex_t taskIndex, uint8_t pinnr) const;
+10 -4
View File
@@ -986,7 +986,7 @@ void SettingsStruct_tmpl<N_TASKS>::setPinBootState(int8_t gpio_pin, PinBootState
}
# endif // ifdef ESP32
}
#if FEATURE_SPI
template<uint32_t N_TASKS>
bool SettingsStruct_tmpl<N_TASKS>::isSPI_enabled(uint8_t spi_bus) const {
const SPI_Options_e SPI_selection = static_cast<SPI_Options_e>(0 == spi_bus ? InitSPI : InitSPI1);
@@ -1190,7 +1190,8 @@ bool SettingsStruct_tmpl<N_TASKS>::isSPI_valid(uint8_t spi_bus) const {
#endif // ifdef ESP32
return result;
}
#endif
#if FEATURE_I2C
template<uint32_t N_TASKS>
bool SettingsStruct_tmpl<N_TASKS>::isI2C_pin(int8_t pin) const {
if (pin < 0) { return false; }
@@ -1232,7 +1233,8 @@ uint8_t SettingsStruct_tmpl<N_TASKS>::getNrConfiguredI2C_buses() const
return isI2CEnabled(0) ? 1 : 0;
#endif
}
#endif
#if FEATURE_SPI
// stored in I2C_SPI_bus_Flags per Task
template<uint32_t N_TASKS>
uint8_t SettingsStruct_tmpl<N_TASKS>::getSPIBusForTask(taskIndex_t TaskIndex) const {
@@ -1256,7 +1258,9 @@ void SettingsStruct_tmpl<N_TASKS>::setSPIBusForSDCard(uint8_t spi_bus) {
set2BitToUL(I2C_SPI_bus_Flags[0], SPI_FLAGS_SDCARD_BUS_NUMBER, spi_bus);
}
#endif // if FEATURE_SD
#endif
#if FEATURE_I2C
template<uint32_t N_TASKS>
uint8_t SettingsStruct_tmpl<N_TASKS>::getI2CInterface(taskIndex_t TaskIndex) const {
return get3BitFromUL(I2C_SPI_bus_Flags[TaskIndex], I2C_FLAGS_BUS_NUMBER);
@@ -1400,7 +1404,8 @@ int8_t SettingsStruct_tmpl<N_TASKS>::getI2CMultiplexerResetPin(uint8_t i2cBus) c
return -1;
}
#endif // if FEATURE_I2CMULTIPLEXER
#endif
#if FEATURE_ETHERNET
template<uint32_t N_TASKS>
bool SettingsStruct_tmpl<N_TASKS>::isEthernetPin(int8_t pin) const {
#if FEATURE_ETHERNET
@@ -1455,6 +1460,7 @@ bool SettingsStruct_tmpl<N_TASKS>::isEthernetPinOptional(int8_t pin) const {
#endif // if FEATURE_ETHERNET
return false;
}
#endif
template<uint32_t N_TASKS>
int8_t SettingsStruct_tmpl<N_TASKS>::getTaskDevicePin(taskIndex_t taskIndex, uint8_t pinnr) const {
+2
View File
@@ -108,6 +108,7 @@ void ESPEasy_loop()
setWebserverRunning(ESPEasy::net::NWPluginCall(NWPlugin::Function::NWPLUGIN_WEBSERVER_SHOULD_RUN));
// ESPEasy::net::processNetworkEvents();
#if FEATURE_I2C
#if FEATURE_CLEAR_I2C_STUCK
if (Settings.EnableClearHangingI2Cbus())
{
@@ -143,6 +144,7 @@ void ESPEasy_loop()
}
}
#endif
#endif
// Work around for nodes that do not have WiFi connection for a long time and may reboot after N unsuccessful connect attempts
+2
View File
@@ -1,4 +1,6 @@
#include "../Globals/I2Cdev.h"
#if FEATURE_I2C
I2Cdev i2cdev;
#endif
+3
View File
@@ -1,11 +1,14 @@
#ifndef GLOBALS_I2CDEV_H
#define GLOBALS_I2CDEV_H
#include "../../ESPEasy_common.h"
#if FEATURE_I2C
#include <I2Cdev.h>
extern I2Cdev i2cdev;
#endif
#endif // ifndef GLOBALS_I2CDEV_H
+10 -4
View File
@@ -205,7 +205,7 @@ uint8_t getTaskI2CAddress(taskIndex_t taskIndex) {
// Functions to assist changing I2C multiplexer port or clock speed
// when addressing a task
// ********************************************************************************
#if FEATURE_I2C
bool prepare_I2C_by_taskIndex(taskIndex_t taskIndex, deviceIndex_t DeviceIndex) {
if (!validTaskIndex(taskIndex) || !validDeviceIndex(DeviceIndex)) {
return false;
@@ -264,6 +264,7 @@ void post_I2C_by_taskIndex(taskIndex_t taskIndex, deviceIndex_t DeviceIndex) {
I2CSelectHighClockSpeed(i2cBus); // Reset, stay on current bus
}
#endif
// Add an event to the event queue.
// event value 1 = taskIndex (first task = 1)
@@ -362,10 +363,11 @@ bool PluginCallForTask(taskIndex_t taskIndex, uint8_t Function, EventStruct *Tem
if (event != nullptr) {
TempEvent->OriginTaskIndex = event->TaskIndex;
}
#if FEATURE_I2C
if (!prepare_I2C_by_taskIndex(taskIndex, DeviceIndex)) {
return false;
}
#endif
#ifndef BUILD_NO_RAM_TRACKER
if (Settings.EnableRAMTracking()) {
@@ -456,8 +458,9 @@ bool PluginCallForTask(taskIndex_t taskIndex, uint8_t Function, EventStruct *Tem
#if FEATURE_I2C_DEVICE_CHECK
}
#endif // if FEATURE_I2C_DEVICE_CHECK
#if FEATURE_I2C
post_I2C_by_taskIndex(taskIndex, DeviceIndex);
#endif
delay(0); // SMY: call delay(0) unconditionally
} else {
#if FEATURE_PLUGIN_STATS
@@ -833,10 +836,11 @@ bool PluginCall(uint8_t Function, struct EventStruct *event, String& str)
#ifndef BUILD_NO_RAM_TRACKER
checkRAM_PluginCall_task(event->TaskIndex, Function);
#endif // ifndef BUILD_NO_RAM_TRACKER
#if FEATURE_I2C
if (!prepare_I2C_by_taskIndex(event->TaskIndex, DeviceIndex)) {
return false;
}
#endif
bool retval = false;
const bool performPluginCall =
(Function != PLUGIN_READ && Function != PLUGIN_INIT) ||
@@ -976,7 +980,9 @@ bool PluginCall(uint8_t Function, struct EventStruct *event, String& str)
#if FEATURE_I2C_DEVICE_CHECK
}
#endif // if FEATURE_I2C_DEVICE_CHECK
#if FEATURE_I2C
post_I2C_by_taskIndex(event->TaskIndex, DeviceIndex);
#endif
delay(0); // SMY: call delay(0) unconditionally
return retval;
+2 -2
View File
@@ -97,12 +97,12 @@ uint8_t getTaskI2CAddress(taskIndex_t taskIndex);
String getPluginNameFromPluginID(pluginID_t pluginID);
#if FEATURE_I2C
// Prepare I2C bus for next call to task
// Return false if task is I2C, but I2C bus is not ready
bool prepare_I2C_by_taskIndex(taskIndex_t taskIndex, deviceIndex_t DeviceIndex);
void post_I2C_by_taskIndex(taskIndex_t taskIndex, deviceIndex_t DeviceIndex);
#endif
void loadDefaultTaskValueNames_ifEmpty(taskIndex_t TaskIndex);
/*********************************************************************************************\
+4
View File
@@ -159,15 +159,19 @@ void hardwareInit()
}
// Initialize I2C buses
#if FEATURE_I2C
initI2C();
#endif
#if FEATURE_PLUGIN_PRIORITY
String dummy;
PluginCall(PLUGIN_PRIORITY_INIT_ALL, nullptr, dummy);
#endif // if FEATURE_PLUGIN_PRIORITY
#if FEATURE_SPI
// Initialize SPI buses, also initializes SD-card when available in build and configured
initializeSPIBuses();
#endif
}
void checkResetFactoryPin() {
+3 -1
View File
@@ -7,6 +7,7 @@
#include "../Helpers/I2C_access.h"
#include "../Helpers/StringConverter.h"
#if FEATURE_I2C
#include <Wire.h>
@@ -319,4 +320,5 @@ bool I2CMultiplexerPortSelectedForTask(taskIndex_t taskIndex) {
|| (bitRead(Settings.I2C_SPI_bus_Flags[taskIndex], I2C_FLAGS_MUX_MULTICHANNEL) && Settings.I2C_Multiplexer_Channel[taskIndex] != 0);
}
#endif // if FEATURE_I2CMULTIPLEXER
#endif
#endif
+3 -1
View File
@@ -3,6 +3,8 @@
#include "../../ESPEasy_common.h"
#if FEATURE_I2C
#include "../DataTypes/TaskIndex.h"
void initI2C();
@@ -37,5 +39,5 @@ void I2CMultiplexerReset(uint8_t i2cBus);
bool I2CMultiplexerPortSelectedForTask(taskIndex_t taskIndex);
#endif // if FEATURE_I2CMULTIPLEXER
#endif
#endif // ifndef HELPERS_HARDWARE_I2C_H
+2
View File
@@ -3,6 +3,7 @@
#include "../Helpers/Hardware_SPI.h"
#include "../Globals/Settings.h"
#if FEATURE_SPI
#if FEATURE_SD
# include <SD.h>
#endif // if FEATURE_SD
@@ -138,3 +139,4 @@ bool initSDcard() {
}
#endif // if FEATURE_SD
#endif
+2 -1
View File
@@ -2,9 +2,10 @@
#include "../../ESPEasy_common.h"
#if FEATURE_SPI
void initializeSPIBuses();
#if FEATURE_SD
bool initSDcard();
#endif // if FEATURE_SD
#endif
+2
View File
@@ -7,6 +7,7 @@
* outputToHtml = false: no html output is generated
* Outputs an error message and returns false if not correct
**********************************************************************/
#if FEATURE_I2C
bool checkI2CConfigValid_toHtml(taskIndex_t taskIndex,
bool outputToHtml) {
#if FEATURE_I2C_MULTIPLE
@@ -28,3 +29,4 @@ bool checkI2CConfigValid_toHtml(taskIndex_t taskIndex,
#endif // if FEATURE_I2CMULTIPLEXER
return true;
}
#endif
+3
View File
@@ -4,6 +4,8 @@
#include "../../ESPEasy_common.h"
#if FEATURE_I2C
#include "../Globals/Plugins.h"
#include "../Globals/Settings.h"
#include "../Helpers/Hardware_I2C.h"
@@ -13,4 +15,5 @@
bool checkI2CConfigValid_toHtml(taskIndex_t taskIndex,
bool outputToHtml = true);
#endif
#endif // ifndef _SRC_HELPERS_I2C_PLUGIN_HELPER_H
+3
View File
@@ -1,5 +1,7 @@
#include "../Helpers/I2C_access.h"
#if FEATURE_I2C
#include "../DataStructs/TimingStats.h"
#include "../Globals/I2Cdev.h"
#include "../Globals/Settings.h"
@@ -557,3 +559,4 @@ void I2CInterfaceSelector(String label,
}
#endif // if FEATURE_I2C_MULTIPLE
#endif
+3
View File
@@ -1,6 +1,8 @@
#ifndef HELPERS_I2C_ACCESS_H
#define HELPERS_I2C_ACCESS_H
#include "../../ESPEasy_common.h"
#if FEATURE_I2C
#include "../DataStructs/I2CTypes.h"
#include "../DataTypes/TaskIndex.h"
@@ -201,4 +203,5 @@ void I2CInterfaceSelector(String label,
bool reloadWhenNeeded);
#endif // if FEATURE_I2C_MULTIPLE
#endif
#endif // HELPERS_I2C_ACCESS_H
+3
View File
@@ -1,5 +1,7 @@
#include "../Helpers/OLed_helper.h"
#if defined(USES_P023) || defined(USES_P036) || defined(USES_P109)
/**************************************************************************
* Select controller type, SSD1306 or SH1106
*************************************************************************/
@@ -126,3 +128,4 @@ bool OLedI2CAddressCheck(uint8_t function,
}
return success;
}
#endif
+5 -2
View File
@@ -1,8 +1,6 @@
#ifndef HELPERS_OLED_HELPER_H
#define HELPERS_OLED_HELPER_H
#include "../../_Plugin_Helper.h"
#include "SSD1306.h"
#include "SH1106Wire.h"
/**
* Helper with OLed related functions
@@ -14,6 +12,10 @@
* and generic function OLedSetContrast
*/
#if defined(USES_P023) || defined(USES_P036) || defined(USES_P109)
#include "SSD1306.h"
#include "SH1106Wire.h"
#define OLED_CONTRAST_OFF 0x01
#define OLED_CONTRAST_LOW 0x40
#define OLED_CONTRAST_MED 0xCF
@@ -37,4 +39,5 @@ bool OLedI2CAddressCheck(uint8_t function,
const __FlashStringHelper *id,
int8_t deviceAddress);
#endif
#endif // ifndef HELPERS_OLED_HELPER_H
+2
View File
@@ -212,6 +212,7 @@ void runOncePerSecond()
#endif
// I2C Watchdog feed
#if FEATURE_I2C
if (Settings.WDI2CAddress != 0)
{
#if FEATURE_I2C_MULTIPLE
@@ -219,6 +220,7 @@ void runOncePerSecond()
#endif // if FEATURE_I2C_MULTIPLE
I2C_write8(Settings.WDI2CAddress, 0xA5);
}
#endif
#if FEATURE_MDNS
#ifdef ESP8266
+2
View File
@@ -1,5 +1,6 @@
#include "../Helpers/SPI_Helper.h"
#if FEATURE_SPI
void SPIInterfaceSelector(String label,
String id,
uint8_t choice,
@@ -39,3 +40,4 @@ void SPIInterfaceSelector(String label,
selector.addFormSelector(label, id, choice);
}
}
#endif
+2
View File
@@ -8,7 +8,9 @@
#include "../WebServer/Markup_Forms.h"
#if FEATURE_SPI
void SPIInterfaceSelector(String label,
String id,
uint8_t choice,
bool disabled = false);
#endif
+18 -4
View File
@@ -232,11 +232,14 @@ const __FlashStringHelper* getConflictingUse_flashstr(int gpio, PinSelectPurpose
static_assert(false, "Implement processor architecture");
#endif // ifdef ESP32S2
#if FEATURE_I2C
bool includeI2C = true;
#endif
#if FEATURE_SPI
bool includeSPI = true;
#if FEATURE_SD
bool includeSDCard = true;
#endif
#endif
bool includeSerial = Settings.UseSerial; // Only need to check if Serial Port Console is enabled
bool includeStatusLed = true;
@@ -244,6 +247,7 @@ const __FlashStringHelper* getConflictingUse_flashstr(int gpio, PinSelectPurpose
switch (purpose)
{
#if FEATURE_I2C
case PinSelectPurpose::I2C:
#if FEATURE_I2C_MULTIPLE
case PinSelectPurpose::I2C_2:
@@ -253,10 +257,13 @@ const __FlashStringHelper* getConflictingUse_flashstr(int gpio, PinSelectPurpose
#endif // if FEATURE_I2C_MULTIPLE
includeI2C = false;
break;
#endif
#if FEATURE_SPI
case PinSelectPurpose::SPI:
case PinSelectPurpose::SPI_MISO:
includeSPI = false;
break;
#endif
case PinSelectPurpose::Serial_input:
case PinSelectPurpose::Serial_output:
includeSerial = false;
@@ -282,7 +289,7 @@ const __FlashStringHelper* getConflictingUse_flashstr(int gpio, PinSelectPurpose
includeResetPin = false;
break;
}
#if FEATURE_I2C
if (includeI2C && Settings.isI2C_pin(gpio)) {
for (uint8_t i2cBus = 0; i2cBus < getI2CBusCount(); ++i2cBus)
{
@@ -319,7 +326,9 @@ const __FlashStringHelper* getConflictingUse_flashstr(int gpio, PinSelectPurpose
}
}
}
#endif
#if FEATURE_SPI
#ifdef ESP32
if (includeSPI) {
if (Settings.isSPI_pin(gpio, 0u)) {
@@ -331,10 +340,11 @@ const __FlashStringHelper* getConflictingUse_flashstr(int gpio, PinSelectPurpose
}
#endif // ifdef ESP32
#ifdef ESP8266
if (includeSPI && Settings.isSPI_pin(gpio)) {
if (includeSPI && Settings.isSPI_pin(gpio)) {
return F("SPI");
}
#endif // ifdef ESP8266
#endif
#endif
if (includeStatusLed && (Settings.Pin_status_led == gpio) && (-1 != gpio)) {
return F("Wifi Status LED");
@@ -414,6 +424,7 @@ String getConflictingUse_fromPeriman(int gpio, PinSelectPurpose purpose, bool ig
{
switch (purpose)
{
#if FEATURE_I2C
case PinSelectPurpose::I2C:
# if FEATURE_I2C_MULTIPLE
case PinSelectPurpose::I2C_2:
@@ -428,6 +439,8 @@ String getConflictingUse_fromPeriman(int gpio, PinSelectPurpose purpose, bool ig
(bus_type == ESP32_BUS_TYPE_I2C_SLAVE_SCL))
{ return conflict; }
break;
#endif
#if FEATURE_SPI
case PinSelectPurpose::SPI:
case PinSelectPurpose::SPI_MISO:
@@ -437,6 +450,7 @@ String getConflictingUse_fromPeriman(int gpio, PinSelectPurpose purpose, bool ig
(bus_type == ESP32_BUS_TYPE_SPI_MASTER_SS))
{ return conflict; }
break;
#endif
case PinSelectPurpose::Serial_input:
case PinSelectPurpose::Serial_output:
+4
View File
@@ -22,6 +22,7 @@ enum class PinSelectPurpose : uint8_t {
Generic_input,
Generic_output,
Generic_bidir,
#if FEATURE_I2C
I2C,
#if FEATURE_I2C_MULTIPLE
I2C_2,
@@ -29,8 +30,11 @@ enum class PinSelectPurpose : uint8_t {
I2C_3,
#endif
#endif
#endif
#if FEATURE_SPI
SPI,
SPI_MISO,
#endif
#if FEATURE_ETHERNET
Ethernet,
#endif
+53 -11
View File
@@ -156,6 +156,7 @@ void handle_devices() {
{
// change of device: cleanup old device and reset default settings
setTaskDevice_to_TaskIndex(taskdevicenumber, taskIndex);
#if FEATURE_I2C
const deviceIndex_t DeviceIndex = getDeviceIndex(taskdevicenumber);
if (validDeviceIndex(DeviceIndex)) {
@@ -165,6 +166,7 @@ void handle_devices() {
bitWrite(Settings.I2C_SPI_bus_Flags[taskIndex], I2C_FLAGS_SLOW_SPEED, 1); // Then: Enable Force Slow I2C speed checkbox by default
}
}
#endif
}
else if (taskdevicenumber != INVALID_PLUGIN_ID) // save settings
{
@@ -283,11 +285,13 @@ void handle_devices_CopySubmittedSettings(taskIndex_t taskIndex, pluginID_t task
Settings.TaskDeviceNumber[taskIndex] = taskdevicenumber.value;
#ifdef ESP32
#if FEATURE_SPI
if (device.isSPI()) {
Settings.setSPIBusForTask(taskIndex, getFormItemInt(F("pspibus"), 0));
}
#endif
#endif // ifdef ESP32
#if FEATURE_I2C
if (device.Type == DEVICE_TYPE_I2C) {
uint8_t flags = 0;
bitWrite(flags, I2C_FLAGS_SLOW_SPEED, isFormItemChecked(F("taskdeviceflags0")));
@@ -331,6 +335,7 @@ void handle_devices_CopySubmittedSettings(taskIndex_t taskIndex, pluginID_t task
Settings.I2C_SPI_bus_Flags[taskIndex] = flags;
}
#endif
// Must load from file system to make sure all caches and checksums match.
ExtraTaskSettings.clear();
@@ -624,7 +629,9 @@ void handle_devicess_ShowAllTasksTable(uint8_t page)
if (pluginID_set)
{
// LoadTaskSettings(x);
#if FEATURE_SPI
int8_t spi_gpios[3] { -1, -1, -1 };
#endif
struct EventStruct TempEvent(x);
addEnabled(Settings.TaskDeviceEnabled[x] && validDeviceIndex(DeviceIndex));
@@ -649,12 +656,17 @@ void handle_devicess_ShowAllTasksTable(uint8_t page)
addHtml(portDescr);
} else {
const DeviceStruct& device = Device[DeviceIndex];
#if FEATURE_I2C
if (device.Type == DEVICE_TYPE_I2C) {
format_I2C_port_description(x);
} else if (device.isSPI()) {
} else
#endif
#if FEATURE_SPI
if (device.isSPI()) {
format_SPI_port_description(spi_gpios, Settings.getSPIBusForTask(x));
} else if (device.isSerial()) {
} else
#endif
if (device.isSerial()) {
# ifdef PLUGIN_USES_SERIAL
addHtml(serialHelper_getSerialTypeLabel(&TempEvent));
# else // ifdef PLUGIN_USES_SERIAL
@@ -723,12 +735,15 @@ void handle_devicess_ShowAllTasksTable(uint8_t page)
switch (device.Type)
{
#if FEATURE_I2C
case DEVICE_TYPE_I2C:
{
format_I2C_pin_description(x);
html_BR();
break;
}
#endif
#if FEATURE_SPI
case DEVICE_TYPE_SPI3:
showpin3 = !pluginHasGPIODescription;
@@ -740,6 +755,7 @@ void handle_devicess_ShowAllTasksTable(uint8_t page)
case DEVICE_TYPE_SPI:
format_SPI_pin_description(spi_gpios, x, !pluginHasGPIODescription);
break;
#endif
case DEVICE_TYPE_ANALOG:
{
# ifdef ESP8266
@@ -978,6 +994,7 @@ void format_originating_node(uint8_t remoteUnit) {
# endif // if FEATURE_ESPEASY_P2P
#if FEATURE_I2C
void format_I2C_port_description(taskIndex_t x)
{
addHtml(F("I2C"));
@@ -1024,7 +1041,9 @@ void format_I2C_port_description(taskIndex_t x)
}
# endif // if FEATURE_I2CMULTIPLEXER
}
#endif
#if FEATURE_SPI
void format_SPI_port_description(int8_t spi_gpios[3], uint8_t spi_bus)
{
if (!Settings.getSPI_pins(spi_gpios, spi_bus)) {
@@ -1038,7 +1057,9 @@ void format_SPI_port_description(int8_t spi_gpios[3], uint8_t spi_bus)
addHtml(F("SPI"));
# endif // ifdef ESP8266
}
#endif
#if FEATURE_I2C
void format_I2C_pin_description(taskIndex_t x)
{
# if FEATURE_I2C_MULTIPLE
@@ -1053,7 +1074,9 @@ void format_I2C_pin_description(taskIndex_t x)
Label_Gpio_toHtml(F("SCL"), formatGpioLabel(Settings.getI2CSclPin(i2cBus), false));
}
}
#endif
#if FEATURE_SPI
void format_SPI_pin_description(int8_t spi_gpios[3], taskIndex_t x, bool showCSpin)
{
const uint8_t spi_bus = Settings.getSPIBusForTask(x);
@@ -1074,6 +1097,7 @@ void format_SPI_pin_description(int8_t spi_gpios[3], taskIndex_t x, bool showCSp
}
}
}
#endif
// ********************************************************************************
// Show the task settings page
@@ -1203,7 +1227,11 @@ void handle_devices_TaskSettingsPage(taskIndex_t taskIndex, uint8_t page)
addPinConfig = true;
}
if (addPinConfig || (device.Type == DEVICE_TYPE_I2C)) {
if (addPinConfig
#if FEATURE_I2C
|| (device.Type == DEVICE_TYPE_I2C)
#endif
) {
if (device.isSerial()) {
# ifdef PLUGIN_USES_SERIAL
devicePage_show_serial_config(taskIndex);
@@ -1215,15 +1243,18 @@ void handle_devices_TaskSettingsPage(taskIndex_t taskIndex, uint8_t page)
addPinConfig = false;
html_add_script(F("document.getElementById('serPort').onchange();"), false);
} else if (device.Type == DEVICE_TYPE_I2C) {
} else
#if FEATURE_I2C
if (device.Type == DEVICE_TYPE_I2C) {
devicePage_show_pin_config(taskIndex, DeviceIndex);
addPinConfig = false;
#if FEATURE_I2C
if (Settings.TaskDeviceDataFeed[taskIndex] == 0) {
devicePage_show_I2C_config(taskIndex, DeviceIndex);
}
#endif
}
#endif
if (addPinConfig) {
devicePage_show_pin_config(taskIndex, DeviceIndex);
}
@@ -1329,9 +1360,11 @@ void devicePage_show_pin_config(taskIndex_t taskIndex, deviceIndex_t DeviceIndex
addFormNote(F("Will go into effect on next input change."));
}
#if FEATURE_SPI
if (device.isSPI()) {
devicePage_show_SPI_config(taskIndex, DeviceIndex);
}
#endif
if (device.connectedToGPIOpins()) {
// get descriptive GPIO-names from plugin
@@ -1350,11 +1383,14 @@ void devicePage_show_pin_config(taskIndex_t taskIndex, deviceIndex_t DeviceIndex
{
// Pin1 = GPIO <--- TX
purpose = PinSelectPurpose::Serial_input;
} else if (device.isSPI())
}
#if FEATURE_SPI
else if (device.isSPI())
{
// All selectable SPI pins are output only
purpose = PinSelectPurpose::Generic_output;
}
#endif
addFormPinSelect(purpose, TempEvent.String1, F("taskdevicepin1"), Settings.TaskDevicePin1[taskIndex]);
}
@@ -1367,23 +1403,25 @@ void devicePage_show_pin_config(taskIndex_t taskIndex, deviceIndex_t DeviceIndex
// Serial Pin2 = GPIO ---> RX
purpose = PinSelectPurpose::Serial_output;
}
#if FEATURE_SPI
if (device.isSPI())
{
// SPI only needs output pins
purpose = PinSelectPurpose::Generic_output;
}
#endif
addFormPinSelect(purpose, TempEvent.String2, F("taskdevicepin2"), Settings.TaskDevicePin2[taskIndex]);
}
if (device.usesTaskDevicePin(3)) {
PinSelectPurpose purpose = device.getPinSelectPurpose(3); // PinSelectPurpose::Generic;
#if FEATURE_SPI
if (device.isSPI())
{
// SPI only needs output pins
purpose = PinSelectPurpose::Generic_output;
}
#endif
addFormPinSelect(purpose, TempEvent.String3, F("taskdevicepin3"), Settings.TaskDevicePin3[taskIndex]);
}
}
@@ -1406,6 +1444,7 @@ void devicePage_show_serial_config(taskIndex_t taskIndex)
# endif // ifdef PLUGIN_USES_SERIAL
#if FEATURE_SPI
void devicePage_show_SPI_config(taskIndex_t taskIndex, deviceIndex_t DeviceIndex)
{
if (Device[DeviceIndex].isSPI()
@@ -1421,7 +1460,9 @@ void devicePage_show_SPI_config(taskIndex_t taskIndex, deviceIndex_t DeviceIndex
}
#endif // ifdef ESP32
}
#endif
#if FEATURE_I2C
void devicePage_show_I2C_config(taskIndex_t taskIndex, deviceIndex_t DeviceIndex)
{
struct EventStruct TempEvent(taskIndex);
@@ -1525,6 +1566,7 @@ void devicePage_show_I2C_config(taskIndex_t taskIndex, deviceIndex_t DeviceIndex
}
# endif // if FEATURE_I2CMULTIPLEXER
}
#endif
void devicePage_show_output_data_type(taskIndex_t taskIndex, deviceIndex_t DeviceIndex)
{
+12 -1
View File
@@ -35,13 +35,20 @@ void handle_devicess_ShowAllTasksTable(uint8_t page);
#if FEATURE_ESPEASY_P2P
void format_originating_node(uint8_t remoteUnit);
#endif
#if FEATURE_I2C
void format_I2C_port_description(taskIndex_t x);
#endif
#if FEATURE_SPI
void format_SPI_port_description(int8_t spi_gpios[3], uint8_t spi_bus);
#endif
#if FEATURE_I2C
void format_I2C_pin_description(taskIndex_t x);
#endif
#if FEATURE_SPI
void format_SPI_pin_description(int8_t spi_gpios[3], taskIndex_t x, bool showCSpin = true);
#endif
@@ -56,9 +63,13 @@ void devicePage_show_pin_config(taskIndex_t taskIndex, deviceIndex_t DeviceIndex
void devicePage_show_serial_config(taskIndex_t taskIndex);
#endif
#if FEATURE_SPI
void devicePage_show_SPI_config(taskIndex_t taskIndex, deviceIndex_t DeviceIndex);
#endif
#if FEATURE_I2C
void devicePage_show_I2C_config(taskIndex_t taskIndex, deviceIndex_t DeviceIndex);
#endif
void devicePage_show_output_data_type(taskIndex_t taskIndex, deviceIndex_t DeviceIndex);
+2
View File
@@ -285,8 +285,10 @@ void WebServerInit()
#ifdef WEBSERVER_CSVVAL
web_server.on(F("/csv"), handle_csvval);
#endif
#ifdef WEBSERVER_LOG
web_server.on(F("/log"), handle_log);
web_server.on(F("/logjson"), handle_log_JSON); // Also part of WEBSERVER_NEW_UI
#endif
#if FEATURE_NOTIFIER
web_server.on(F("/notifications"), handle_notifications);
#endif // if FEATURE_NOTIFIER
+10 -2
View File
@@ -598,10 +598,18 @@ void addGpioHtml(int8_t pin) {
if (pin == -1) { return; }
addHtml(formatGpioLabel(pin, false));
if (Settings.isSPI_pin(pin) ||
if (
#if FEATURE_SPI
Settings.isSPI_pin(pin) ||
#endif
#if FEATURE_I2C
Settings.isI2C_pin(pin) ||
#endif
#if FEATURE_ETHERNET
Settings.isEthernetPin(pin) ||
Settings.isEthernetPinOptional(pin)) {
Settings.isEthernetPinOptional(pin)||
#endif
false) {
addHtml(' ');
addHtml(F(HTML_SYMBOL_WARNING));
}
+124 -80
View File
@@ -27,12 +27,85 @@
# include "../Helpers/Hardware_device_info.h"
# endif // if FEATURE_I2C_MULTIPLE
// ********************************************************************************
// Web Interface hardware page
// ********************************************************************************
void handle_interfaces() {
# ifndef BUILD_NO_RAM_TRACKER
checkRAM(F("handle_interfaces"));
# endif
if (!isLoggedIn()) { return; }
navMenuIndex = MENU_INDEX_INTERFACES;
TXBuffer.startStream();
sendHeadandTail_stdtemplate(_HEAD);
save_interfaces();
addHtml(F("<form method='post'>"));
html_table_class_normal();
addFormHeader(F("Interfaces Settings"), F(""), F("Interfaces/Interfaces.html"));
#if FEATURE_I2C
interfaces_show_I2C();
#endif
#if FEATURE_SPI
interfaces_show_SPI();
#endif
addFormSeparator(2);
html_TR_TD();
html_TD();
addSubmitButton();
html_TR_TD();
html_end_table();
html_end_form();
sendHeadandTail_stdtemplate(_TAIL);
TXBuffer.endStream();
}
void save_interfaces() {
String error;
bool updated{};
#if FEATURE_I2C
if (save_I2C(error)) { updated = true; }
#endif
#if FEATURE_SPI
if (save_SPI(error)) { updated = true; }
#endif
if (updated) {
error += SaveSettings();
addHtmlError(error);
if (error.isEmpty()) {
#if FEATURE_I2C
// Apply I2C settings.
initI2C();
#endif
#if FEATURE_SPI
// Apply SPI settings
initializeSPIBuses();
#endif
}
}
}
#if FEATURE_I2C
bool save_I2C(String& error) {
bool updated{};
if (isFormItem(F("pi2csp0"))) {
updated = true;
# if FEATURE_PLUGIN_PRIORITY
@@ -117,79 +190,54 @@ void save_interfaces() {
}
# endif // if FEATURE_I2C_MULTIPLE
{
# ifdef ESP32
bool SPI_updated{};
if (update_whenset_FormItemInt(F("initspi0"), Settings.InitSPI)) {
SPI_updated = true;
// User-defined SPI bus 0 GPIO pins
Settings.SPI_SCLK_pin = getFormItemInt(F("spipinsclk0"), -1);
Settings.SPI_MISO_pin = getFormItemInt(F("spipinmiso0"), -1);
Settings.SPI_MOSI_pin = getFormItemInt(F("spipinmosi0"), -1);
}
if (update_whenset_FormItemInt(F("initspi1"), Settings.InitSPI1)) {
SPI_updated = true;
// User-defined SPI bus 1 GPIO pins
Settings.SPI1_SCLK_pin = getFormItemInt(F("spipinsclk1"), -1);
Settings.SPI1_MISO_pin = getFormItemInt(F("spipinmiso1"), -1);
Settings.SPI1_MOSI_pin = getFormItemInt(F("spipinmosi1"), -1);
}
if (SPI_updated) {
updated = true;
for (uint8_t spi_bus = 0; spi_bus < getSPIBusCount(); ++spi_bus) {
if (Settings.isSPI_enabled(spi_bus) && !Settings.isSPI_valid(spi_bus)) { // Checks
error += strformat(F("SPI bus %u pins not configured correctly!<BR>"), spi_bus);
}
}
}
# else // for ESP8266 we keep the old UI
Settings.InitSPI = isFormItemChecked(F("initspi")); // SPI Init
updated = true;
# endif // ifdef ESP32
}
if (updated) {
error += SaveSettings();
addHtmlError(error);
if (error.isEmpty()) {
// Apply I2C settings.
initI2C();
// Apply SPI settings
initializeSPIBuses();
}
}
return updated;
}
// ********************************************************************************
// Web Interface hardware page
// ********************************************************************************
void handle_interfaces() {
# ifndef BUILD_NO_RAM_TRACKER
checkRAM(F("handle_interfaces"));
# endif
if (!isLoggedIn()) { return; }
navMenuIndex = MENU_INDEX_INTERFACES;
TXBuffer.startStream();
sendHeadandTail_stdtemplate(_HEAD);
save_interfaces();
#endif
addHtml(F("<form method='post'>"));
html_table_class_normal();
addFormHeader(F("Interfaces Settings"), F(""), F("Interfaces/Interfaces.html"));
#if FEATURE_SPI
bool save_SPI(String& error) {
# ifdef ESP32
bool SPI_updated{};
if (update_whenset_FormItemInt(F("initspi0"), Settings.InitSPI)) {
SPI_updated = true;
// User-defined SPI bus 0 GPIO pins
Settings.SPI_SCLK_pin = getFormItemInt(F("spipinsclk0"), -1);
Settings.SPI_MISO_pin = getFormItemInt(F("spipinmiso0"), -1);
Settings.SPI_MOSI_pin = getFormItemInt(F("spipinmosi0"), -1);
}
if (update_whenset_FormItemInt(F("initspi1"), Settings.InitSPI1)) {
SPI_updated = true;
// User-defined SPI bus 1 GPIO pins
Settings.SPI1_SCLK_pin = getFormItemInt(F("spipinsclk1"), -1);
Settings.SPI1_MISO_pin = getFormItemInt(F("spipinmiso1"), -1);
Settings.SPI1_MOSI_pin = getFormItemInt(F("spipinmosi1"), -1);
}
if (SPI_updated) {
for (uint8_t spi_bus = 0; spi_bus < getSPIBusCount(); ++spi_bus) {
if (Settings.isSPI_enabled(spi_bus) && !Settings.isSPI_valid(spi_bus)) { // Checks
error += strformat(F("SPI bus %u pins not configured correctly!<BR>"), spi_bus);
}
}
}
return SPI_updated;
# else // for ESP8266 we keep the old UI
const auto old_initSPI = Settings.InitSPI;
Settings.InitSPI = isFormItemChecked(F("initspi")); // SPI Init
return old_initSPI != Settings.InitSPI;
# endif // ifdef ESP32
}
#endif
#if FEATURE_I2C
void interfaces_show_I2C() {
# if FEATURE_I2CMULTIPLEXER
const __FlashStringHelper *i2c_muxtype_options[] = {
F("- None -"),
@@ -306,6 +354,11 @@ void handle_interfaces() {
}
# endif // if FEATURE_I2C_MULTIPLE
}
#endif
#if FEATURE_SPI
void interfaces_show_SPI() {
# ifdef ESP32
@@ -369,20 +422,10 @@ void handle_interfaces() {
addFormNote(F("CLK=GPIO-14 (D5), MISO=GPIO-12 (D6), MOSI=GPIO-13 (D7)"));
addFormNote(F("Chip Select (CS) config must be done in the plugin"));
# endif // ifdef ESP32
addFormSeparator(2);
html_TR_TD();
html_TD();
addSubmitButton();
html_TR_TD();
html_end_table();
html_end_form();
sendHeadandTail_stdtemplate(_TAIL);
TXBuffer.endStream();
}
#endif
#if FEATURE_I2C
# if FEATURE_PLUGIN_PRIORITY
bool isI2CPriorityTaskActive(uint8_t i2cBus) {
@@ -408,5 +451,6 @@ void I2CShowSdaSclReadonly(int8_t i2c_sda, int8_t i2c_scl, uint8_t i2cBus) {
}
# endif // if FEATURE_PLUGIN_PRIORITY
#endif
#endif // ifdef WEBSERVER_INTERFACES
+12
View File
@@ -9,10 +9,22 @@
// ********************************************************************************
void handle_interfaces();
void save_interfaces();
#if FEATURE_I2C
bool save_I2C(String& error);
void interfaces_show_I2C();
#endif
#if FEATURE_SPI
bool save_SPI(String& error);
void interfaces_show_SPI();
#endif
#if FEATURE_I2C
# if FEATURE_PLUGIN_PRIORITY
bool isI2CPriorityTaskActive(uint8_t i2cBus);
void I2CShowSdaSclReadonly(int8_t i2c_sda,
int8_t i2c_scl,
uint8_t i2cBus);
# endif
#endif
#endif
+3
View File
@@ -1,5 +1,7 @@
#include "../WebServer/Log.h"
#ifdef WEBSERVER_LOG
#include "../WebServer/ESPEasy_WebServer.h"
#include "../WebServer/404.h"
#include "../WebServer/HTML_wrappers.h"
@@ -150,3 +152,4 @@ void handle_log_JSON() {
handleNotFound();
#endif // ifdef WEBSERVER_LOG
}
#endif
+2 -2
View File
@@ -3,7 +3,7 @@
#include "../WebServer/common.h"
#ifdef WEBSERVER_LOG
// ********************************************************************************
// Web Interface log page
// ********************************************************************************
@@ -13,7 +13,7 @@ void handle_log();
// Web Interface JSON log page
// ********************************************************************************
void handle_log_JSON();
#endif
#endif
+12 -4
View File
@@ -115,8 +115,12 @@ void addPinSelector_Item(PinSelectPurpose purpose, const String& gpio_label, int
bool input, output, warning;
if (getGpioInfo(gpio, pinnr, input, output, warning)) {
#if FEATURE_I2C
bool includeI2C = true;
#endif
#if FEATURE_SPI
bool includeSPI = true;
#endif
bool includeSerial = true;
#if FEATURE_ETHERNET
bool includeEthernet = true;
@@ -128,6 +132,7 @@ void addPinSelector_Item(PinSelectPurpose purpose, const String& gpio_label, int
// bool includeResetPin = true;
switch (purpose) {
#if FEATURE_SPI
case PinSelectPurpose::SPI:
case PinSelectPurpose::SPI_MISO:
includeSPI = false;
@@ -135,6 +140,7 @@ void addPinSelector_Item(PinSelectPurpose purpose, const String& gpio_label, int
return;
}
break;
#endif
#if FEATURE_ETHERNET
case PinSelectPurpose::Ethernet:
includeEthernet = false;
@@ -161,7 +167,7 @@ void addPinSelector_Item(PinSelectPurpose purpose, const String& gpio_label, int
return;
}
break;
#if FEATURE_I2C
case PinSelectPurpose::I2C:
#if FEATURE_I2C_MULTIPLE
case PinSelectPurpose::I2C_2:
@@ -170,6 +176,7 @@ void addPinSelector_Item(PinSelectPurpose purpose, const String& gpio_label, int
#endif
#endif
includeI2C = false;
#endif
// fallthrough
case PinSelectPurpose::Generic_bidir:
@@ -218,19 +225,20 @@ void addPinSelector_Item(PinSelectPurpose purpose, const String& gpio_label, int
break;
}
#if FEATURE_I2C
if (includeI2C && Settings.isI2C_pin(gpio)) {
disabled = true;
}
#endif
if (includeSerial && isSerialConsolePin(gpio)) {
disabled = true;
}
#if FEATURE_SPI
if (includeSPI && Settings.isSPI_pin(gpio)) {
disabled = true;
}
#endif
// Not blocking these GPIO pins, as they may already be in dual-purpose use, just a place-holder
// if (includeStatusLed && (Settings.Pin_status_led == gpio)) {
// disabled = true;
+4 -2
View File
@@ -497,7 +497,7 @@ void addFormPinSelect(const String& label, const String & id, int choice)
addPinSelect(PinSelectPurpose::Generic, id, choice);
}
*/
#if FEATURE_I2C
void addFormPinSelectI2C(const String& label, const String& id, uint8_t i2cBus, int choice)
{
addRowLabel_tr_id(label, id);
@@ -535,7 +535,7 @@ void addFormSelectorI2C(const String& id,
}
addSelector_Foot();
}
#endif
void addFormSelector_YesNo(const __FlashStringHelper * label,
const __FlashStringHelper * id,
int selectedIndex,
@@ -569,10 +569,12 @@ void addFormPinStateSelect(int gpio, int choice)
// do not add the pin state select for these pins.
enabled = false;
}
#if FEATURE_ETHERNET
if (Settings.isEthernetPin(gpio)) {
// do not add the pin state select for non-optional Ethernet pins
enabled = false;
}
#endif
int pinnr = -1;
bool input, output, warning;
+2 -1
View File
@@ -274,7 +274,7 @@ void addFormPinSelect(PinSelectPurpose purpose, const String& label, const __Fla
void addFormPinSelect(PinSelectPurpose purpose, const String& label, const String& id, int choice);
void addFormPinSelect(PinSelectPurpose purpose, const __FlashStringHelper * label, const __FlashStringHelper * id, int choice);
#if FEATURE_I2C
void addFormPinSelectI2C(const String& label,
const String& id,
uint8_t i2cBus,
@@ -290,6 +290,7 @@ void addFormSelectorI2C(const String& id,
const String& tooltip = EMPTY_STRING
#endif
);
#endif
void addFormSelector_YesNo(const __FlashStringHelper * label,
const __FlashStringHelper * id,