mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-28 13:16:32 +00:00
Remove gpio to pin support
This commit is contained in:
parent
5d18ad1c74
commit
892be892fa
@ -1079,9 +1079,6 @@ uint32_t Pin(uint32_t gpio, uint32_t index) ICACHE_RAM_ATTR;
|
|||||||
|
|
||||||
uint32_t Pin(uint32_t gpio, uint32_t index = 0);
|
uint32_t Pin(uint32_t gpio, uint32_t index = 0);
|
||||||
uint32_t Pin(uint32_t gpio, uint32_t index) {
|
uint32_t Pin(uint32_t gpio, uint32_t index) {
|
||||||
#ifdef LEGACY_GPIO_ARRAY
|
|
||||||
return pin_gpio[gpio + index]; // Pin number configured for gpio or 99 if not used
|
|
||||||
#else // No LEGACY_GPIO_ARRAY
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
uint16_t real_gpio = gpio + index;
|
uint16_t real_gpio = gpio + index;
|
||||||
#else // ESP32
|
#else // ESP32
|
||||||
@ -1093,7 +1090,6 @@ uint32_t Pin(uint32_t gpio, uint32_t index) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 99; // No pin used for gpio
|
return 99; // No pin used for gpio
|
||||||
#endif // No LEGACY_GPIO_ARRAY
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean PinUsed(uint32_t gpio, uint32_t index = 0);
|
boolean PinUsed(uint32_t gpio, uint32_t index = 0);
|
||||||
@ -1102,21 +1098,9 @@ boolean PinUsed(uint32_t gpio, uint32_t index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SetPin(uint32_t lpin, uint32_t gpio) {
|
void SetPin(uint32_t lpin, uint32_t gpio) {
|
||||||
#ifdef LEGACY_GPIO_ARRAY
|
|
||||||
pin_gpio[gpio] = lpin;
|
|
||||||
#else
|
|
||||||
gpio_pin[lpin] = gpio;
|
gpio_pin[lpin] = gpio;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LEGACY_GPIO_ARRAY
|
|
||||||
void InitAllPins(void) {
|
|
||||||
for (uint32_t i = 0; i < ARRAY_SIZE(pin_gpio); i++) {
|
|
||||||
SetPin(99, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void DigitalWrite(uint32_t gpio_pin, uint32_t index, uint32_t state)
|
void DigitalWrite(uint32_t gpio_pin, uint32_t index, uint32_t state)
|
||||||
{
|
{
|
||||||
if (PinUsed(gpio_pin, index)) {
|
if (PinUsed(gpio_pin, index)) {
|
||||||
|
@ -1385,9 +1385,6 @@ void GpioInit(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LEGACY_GPIO_ARRAY
|
|
||||||
InitAllPins();
|
|
||||||
#endif
|
|
||||||
for (uint32_t i = 0; i < ARRAY_SIZE(my_module.io); i++) {
|
for (uint32_t i = 0; i < ARRAY_SIZE(my_module.io); i++) {
|
||||||
uint32_t mpin = ValidPin(i, my_module.io[i]);
|
uint32_t mpin = ValidPin(i, my_module.io[i]);
|
||||||
|
|
||||||
@ -1440,9 +1437,7 @@ void GpioInit(void)
|
|||||||
if (mpin) { SetPin(i, mpin); } // Anything above GPIO_NONE and below GPIO_SENSOR_END
|
if (mpin) { SetPin(i, mpin); } // Anything above GPIO_NONE and below GPIO_SENSOR_END
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef LEGACY_GPIO_ARRAY
|
|
||||||
// AddLogBufferSize(LOG_LEVEL_DEBUG, (uint8_t*)gpio_pin, ARRAY_SIZE(gpio_pin), sizeof(gpio_pin[0]));
|
// AddLogBufferSize(LOG_LEVEL_DEBUG, (uint8_t*)gpio_pin, ARRAY_SIZE(gpio_pin), sizeof(gpio_pin[0]));
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
if ((2 == Pin(GPIO_TXD)) || (H801 == my_module_type)) { Serial.set_tx(2); }
|
if ((2 == Pin(GPIO_TXD)) || (H801 == my_module_type)) { Serial.set_tx(2); }
|
||||||
@ -1454,11 +1449,6 @@ void GpioInit(void)
|
|||||||
#ifdef USE_SPI
|
#ifdef USE_SPI
|
||||||
spi_flg = (((PinUsed(GPIO_SPI_CS) && (Pin(GPIO_SPI_CS) > 14)) || (Pin(GPIO_SPI_CS) < 12)) || ((PinUsed(GPIO_SPI_DC) && (Pin(GPIO_SPI_DC) > 14)) || (Pin(GPIO_SPI_DC) < 12)));
|
spi_flg = (((PinUsed(GPIO_SPI_CS) && (Pin(GPIO_SPI_CS) > 14)) || (Pin(GPIO_SPI_CS) < 12)) || ((PinUsed(GPIO_SPI_DC) && (Pin(GPIO_SPI_DC) > 14)) || (Pin(GPIO_SPI_DC) < 12)));
|
||||||
if (spi_flg) {
|
if (spi_flg) {
|
||||||
#ifdef LEGACY_GPIO_ARRAY
|
|
||||||
for (uint32_t i = 0; i < GPIO_MAX; i++) {
|
|
||||||
if ((Pin(i) >= 12) && (Pin(i) <=14)) { SetPin(99, i); }
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
my_module.io[12] = GPIO_SPI_MISO;
|
my_module.io[12] = GPIO_SPI_MISO;
|
||||||
SetPin(12, GPIO_SPI_MISO);
|
SetPin(12, GPIO_SPI_MISO);
|
||||||
my_module.io[13] = GPIO_SPI_MOSI;
|
my_module.io[13] = GPIO_SPI_MOSI;
|
||||||
@ -1544,9 +1534,6 @@ void GpioInit(void)
|
|||||||
#ifdef USE_ARILUX_RF
|
#ifdef USE_ARILUX_RF
|
||||||
if ((3 == i) && (leds_present < 2) && !PinUsed(GPIO_ARIRFSEL)) {
|
if ((3 == i) && (leds_present < 2) && !PinUsed(GPIO_ARIRFSEL)) {
|
||||||
SetPin(Pin(GPIO_LED4), GPIO_ARIRFSEL); // Legacy support where LED4 was Arilux RF enable
|
SetPin(Pin(GPIO_LED4), GPIO_ARIRFSEL); // Legacy support where LED4 was Arilux RF enable
|
||||||
#ifdef LEGACY_GPIO_ARRAY
|
|
||||||
SetPin(99, GPIO_LED4);
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
pinMode(Pin(GPIO_LED1, i), OUTPUT);
|
pinMode(Pin(GPIO_LED1, i), OUTPUT);
|
||||||
|
@ -133,11 +133,7 @@ uint8_t ssleep; // Current copy of Settings.sleep
|
|||||||
uint8_t blinkspeed = 1; // LED blink rate
|
uint8_t blinkspeed = 1; // LED blink rate
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
#ifdef LEGACY_GPIO_ARRAY
|
|
||||||
uint8_t pin_gpio[GPIO_MAX]; // Pin numbers indexed by GPIO function
|
|
||||||
#else // No LEGACY_GPIO_ARRAY
|
|
||||||
uint8_t gpio_pin[MAX_GPIO_PIN] = { 0 }; // GPIO functions indexed by pin number
|
uint8_t gpio_pin[MAX_GPIO_PIN] = { 0 }; // GPIO functions indexed by pin number
|
||||||
#endif // LEGACY_GPIO_ARRAY
|
|
||||||
#endif // ESP8266 - ESP32
|
#endif // ESP8266 - ESP32
|
||||||
|
|
||||||
uint8_t active_device = 1; // Active device in ExecuteCommandPower
|
uint8_t active_device = 1; // Active device in ExecuteCommandPower
|
||||||
|
@ -49,20 +49,10 @@ extern "C" void resetPins();
|
|||||||
|
|
||||||
#include "tasmota_configurations.h" // Preconfigured configurations
|
#include "tasmota_configurations.h" // Preconfigured configurations
|
||||||
|
|
||||||
/*********************************************************************************************\
|
|
||||||
* Theo transition defines - DO NOT TOUCH
|
|
||||||
\*********************************************************************************************/
|
|
||||||
|
|
||||||
//#define LEGACY_GPIO_ARRAY // Uncomment to use legacy GPIO array instead of new PIN array
|
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* Mandatory defines satisfying disabled defines
|
* Mandatory defines satisfying disabled defines
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
#ifndef MODULE
|
|
||||||
#define MODULE SONOFF_BASIC // [Module] Select default model
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_EMULATION_HUE
|
#ifdef USE_EMULATION_HUE
|
||||||
#define USE_EMULATION
|
#define USE_EMULATION
|
||||||
#endif
|
#endif
|
||||||
@ -284,6 +274,10 @@ const char kWebColors[] PROGMEM =
|
|||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
|
|
||||||
|
#ifndef MODULE
|
||||||
|
#define MODULE SONOFF_BASIC // [Module] Select default model
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef ARDUINO_ESP8266_RELEASE
|
#ifndef ARDUINO_ESP8266_RELEASE
|
||||||
#define ARDUINO_CORE_RELEASE "STAGE"
|
#define ARDUINO_CORE_RELEASE "STAGE"
|
||||||
#else
|
#else
|
||||||
@ -294,6 +288,10 @@ const char kWebColors[] PROGMEM =
|
|||||||
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
|
|
||||||
|
#ifndef MODULE
|
||||||
|
#define MODULE WEMOS // [Module] Select default model
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef ARDUINO_ESP32_RELEASE
|
#ifndef ARDUINO_ESP32_RELEASE
|
||||||
#define ARDUINO_CORE_RELEASE "STAGE"
|
#define ARDUINO_CORE_RELEASE "STAGE"
|
||||||
#else
|
#else
|
||||||
@ -301,7 +299,7 @@ const char kWebColors[] PROGMEM =
|
|||||||
#endif // ARDUINO_ESP32_RELEASE
|
#endif // ARDUINO_ESP32_RELEASE
|
||||||
|
|
||||||
#undef USE_HM10 // Disable support for HM-10 as a BLE-bridge as an alternative is using the internal ESP32 BLE
|
#undef USE_HM10 // Disable support for HM-10 as a BLE-bridge as an alternative is using the internal ESP32 BLE
|
||||||
#undef USE_KEELOQ // Disable support for Jarolift rollers by Keeloq algorithm ss it's library cc1101 is not compatible with ESP32
|
#undef USE_KEELOQ // Disable support for Jarolift rollers by Keeloq algorithm as it's library cc1101 is not compatible with ESP32
|
||||||
#undef USE_DISPLAY_ILI9488 // Disable as it's library JaretBurkett_ILI9488-gemu-1.0 is not compatible with ESP32
|
#undef USE_DISPLAY_ILI9488 // Disable as it's library JaretBurkett_ILI9488-gemu-1.0 is not compatible with ESP32
|
||||||
#undef USE_DISPLAY_SSD1351 // Disable as it's library Adafruit_SSD1351_gemu-1.0 is not compatible with ESP32
|
#undef USE_DISPLAY_SSD1351 // Disable as it's library Adafruit_SSD1351_gemu-1.0 is not compatible with ESP32
|
||||||
|
|
||||||
|
@ -1582,7 +1582,7 @@ chknext:
|
|||||||
if (!strncmp(vname,"pd[",3)) {
|
if (!strncmp(vname,"pd[",3)) {
|
||||||
GetNumericResult(vname+3,OPER_EQU,&fvar,0);
|
GetNumericResult(vname+3,OPER_EQU,&fvar,0);
|
||||||
uint8_t gpiopin=fvar;
|
uint8_t gpiopin=fvar;
|
||||||
#ifdef LEGACY_GPIO_ARRAY
|
/*
|
||||||
for (uint8_t i=0;i<GPIO_SENSOR_END;i++) {
|
for (uint8_t i=0;i<GPIO_SENSOR_END;i++) {
|
||||||
// if (pin_gpio[i]==gpiopin) {
|
// if (pin_gpio[i]==gpiopin) {
|
||||||
if (Pin(i)==gpiopin) {
|
if (Pin(i)==gpiopin) {
|
||||||
@ -1592,14 +1592,13 @@ chknext:
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
*/
|
||||||
if ((gpiopin < ARRAY_SIZE(gpio_pin)) && (gpio_pin[gpiopin] > 0)) {
|
if ((gpiopin < ARRAY_SIZE(gpio_pin)) && (gpio_pin[gpiopin] > 0)) {
|
||||||
fvar = gpio_pin[gpiopin];
|
fvar = gpio_pin[gpiopin];
|
||||||
// skip ] bracket
|
// skip ] bracket
|
||||||
len++;
|
len++;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
fvar=999;
|
fvar=999;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -447,9 +447,6 @@ void TasmotaSlave_Init(void)
|
|||||||
TasmotaSlave_Serial->setTimeout(50);
|
TasmotaSlave_Serial->setTimeout(50);
|
||||||
if (PinUsed(GPIO_TASMOTASLAVE_RST_INV)) {
|
if (PinUsed(GPIO_TASMOTASLAVE_RST_INV)) {
|
||||||
SetPin(Pin(GPIO_TASMOTASLAVE_RST_INV), GPIO_TASMOTASLAVE_RST);
|
SetPin(Pin(GPIO_TASMOTASLAVE_RST_INV), GPIO_TASMOTASLAVE_RST);
|
||||||
#ifdef LEGACY_GPIO_ARRAY
|
|
||||||
SetPin(99, GPIO_TASMOTASLAVE_RST_INV);
|
|
||||||
#endif
|
|
||||||
TSlave.inverted = HIGH;
|
TSlave.inverted = HIGH;
|
||||||
}
|
}
|
||||||
pinMode(Pin(GPIO_TASMOTASLAVE_RST), OUTPUT);
|
pinMode(Pin(GPIO_TASMOTASLAVE_RST), OUTPUT);
|
||||||
|
@ -250,9 +250,6 @@ void HlwDrvInit(void)
|
|||||||
Hlw.model_type = 0; // HLW8012
|
Hlw.model_type = 0; // HLW8012
|
||||||
if (PinUsed(GPIO_HJL_CF)) {
|
if (PinUsed(GPIO_HJL_CF)) {
|
||||||
SetPin(Pin(GPIO_HJL_CF), GPIO_HLW_CF);
|
SetPin(Pin(GPIO_HJL_CF), GPIO_HLW_CF);
|
||||||
#ifdef LEGACY_GPIO_ARRAY
|
|
||||||
SetPin(99, GPIO_HJL_CF);
|
|
||||||
#endif
|
|
||||||
Hlw.model_type = 1; // HJL-01/BL0937
|
Hlw.model_type = 1; // HJL-01/BL0937
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,9 +258,6 @@ void HlwDrvInit(void)
|
|||||||
Hlw.ui_flag = true; // Voltage on high
|
Hlw.ui_flag = true; // Voltage on high
|
||||||
if (PinUsed(GPIO_NRG_SEL_INV)) {
|
if (PinUsed(GPIO_NRG_SEL_INV)) {
|
||||||
SetPin(Pin(GPIO_NRG_SEL_INV), GPIO_NRG_SEL);
|
SetPin(Pin(GPIO_NRG_SEL_INV), GPIO_NRG_SEL);
|
||||||
#ifdef LEGACY_GPIO_ARRAY
|
|
||||||
SetPin(99, GPIO_NRG_SEL_INV);
|
|
||||||
#endif
|
|
||||||
Hlw.ui_flag = false; // Voltage on low
|
Hlw.ui_flag = false; // Voltage on low
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1831,18 +1831,17 @@ uint8_t *script_meter;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool Gpio_used(uint8_t gpiopin) {
|
bool Gpio_used(uint8_t gpiopin) {
|
||||||
#ifdef LEGACY_GPIO_ARRAY
|
/*
|
||||||
for (uint16_t i=0;i<GPIO_SENSOR_END;i++) { // Theo/Gemu: This needs to change when pin[] has becomes real pin array
|
for (uint16_t i=0;i<GPIO_SENSOR_END;i++) {
|
||||||
// if (pin_gpio[i]==gpiopin) {
|
// if (pin_gpio[i]==gpiopin) {
|
||||||
if (Pin(i)==gpiopin) {
|
if (Pin(i)==gpiopin) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
*/
|
||||||
if ((gpiopin < ARRAY_SIZE(gpio_pin)) && (gpio_pin[gpiopin] > 0)) {
|
if ((gpiopin < ARRAY_SIZE(gpio_pin)) && (gpio_pin[gpiopin] > 0)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user