mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-27 19:57:38 +00:00
[I2C] Fix issues with GPIO 21 & 22 when no I2C is configured
This commit is contained in:
@@ -74,7 +74,7 @@ bool AS_BH1750A::begin(sensors_resolution_t mode, bool autoPowerDown) {
|
||||
_virtualMode = mode;
|
||||
_autoPowerDown = autoPowerDown;
|
||||
|
||||
Wire.begin();
|
||||
// Wire.begin();
|
||||
|
||||
defineMTReg(BH1750_MTREG_DEFAULT); // eigentlich normalerweise unnötig, da standard
|
||||
|
||||
|
||||
@@ -652,10 +652,19 @@ void createAndSetPortStatus_Mode_State(uint32_t key, uint8_t newMode, int8_t new
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
auto it = globalMapPortStatus.find(key);
|
||||
if (it == globalMapPortStatus.end()) {
|
||||
#ifdef ESP32
|
||||
if (getPluginFromKey(key).value == PLUGIN_GPIO_INT) {
|
||||
gpio_reset_pin((gpio_num_t)getPortFromKey(key));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
// If it doesn't exist, it is now created.
|
||||
globalMapPortStatus[key].mode = newMode;
|
||||
auto it = globalMapPortStatus.find(key);
|
||||
if (it == globalMapPortStatus.end()) {
|
||||
it = globalMapPortStatus.find(key);
|
||||
}
|
||||
|
||||
if (it != globalMapPortStatus.end()) {
|
||||
// Should always be true, as it would be created if it didn't exist.
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "../Helpers/PortStatus.h"
|
||||
|
||||
|
||||
#include <GPIO_Direct_Access.h>
|
||||
|
||||
|
||||
//********************************************************************************
|
||||
// Internal GPIO write
|
||||
@@ -23,8 +25,11 @@ void GPIO_Internal_Write(int pin, uint8_t value)
|
||||
if (it->second.mode == PIN_MODE_PWM) {
|
||||
set_Gpio_PWM(pin, value);
|
||||
} else {
|
||||
pinMode(pin, OUTPUT);
|
||||
digitalWrite(pin, value);
|
||||
//gpio_reset_pin(static_cast<gpio_num_t>(pin));
|
||||
//pinMode(pin, OUTPUT);
|
||||
//digitalWrite(pin, value);
|
||||
DIRECT_PINMODE_OUTPUT(pin);
|
||||
DIRECT_pinWrite(pin, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,7 +41,7 @@ void GPIO_Internal_Write(int pin, uint8_t value)
|
||||
bool GPIO_Internal_Read(int pin)
|
||||
{
|
||||
if (checkValidPortRange(PLUGIN_GPIO, pin))
|
||||
return digitalRead(pin)==HIGH;
|
||||
return DIRECT_pinRead(pin) != 0u;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -81,7 +86,7 @@ bool GPIO_Read_Switch_State(int pin, uint8_t pinMode) {
|
||||
|
||||
// Do not read from the pin while mode is set to PWM or servo.
|
||||
// See https://github.com/letscontrolit/ESPEasy/issues/2117#issuecomment-443516794
|
||||
return digitalRead(pin) == HIGH;
|
||||
return DIRECT_pinRead(pin) != 0u;
|
||||
}
|
||||
|
||||
#ifdef USES_P009
|
||||
|
||||
@@ -148,6 +148,14 @@ void I2CBegin(int8_t sda, int8_t scl, uint32_t clockFreq, uint32_t clockStretch)
|
||||
// No need to change the clock speed.
|
||||
return;
|
||||
}
|
||||
if (sda == -1 || scl == -1) {
|
||||
Wire.end();
|
||||
last_sda = sda;
|
||||
last_scl = scl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#ifdef ESP32
|
||||
|
||||
if (((sda != last_sda) || (scl != last_scl)) && (last_sda != -1) && (last_scl != -1)) {
|
||||
|
||||
Reference in New Issue
Block a user