diff --git a/CHANGELOG.md b/CHANGELOG.md index c39ba0abf..d542934fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,13 +6,12 @@ All notable changes to this project will be documented in this file. ## [9.2.0.2] ### Added - Basic support for ESP32 Odroid Go 16MB binary tasmota32-odroidgo.bin (#8630) -- Command ``CTRange`` to specify the visible CT range the bulb is capable of (#10311) -- Command ``VirtualCT`` to simulate or fine tune CT bulbs with 3,4,5 channels (#10311) +- Command ``CTRange`` to specify the visible CT range the bulb is capable of +- Command ``VirtualCT`` to simulate or fine tune CT bulbs with 3,4,5 channels ### Breaking Changed - Replaced MFRC522 13.56MHz rfid card reader GPIO selection from ``GPIO_SPI_CS`` by ``GPIO_RC522_CS`` - Replaced ILI9341 GPIO selection from ``GPIO_SPI_CS`` by ``GPIO_ILI9341_CS`` and ``GPIO_SPI_DC`` by ``GPIO_ILI9341_DC`` -- Replaced NRF24L01 GPIO selection from ``GPIO_SPI_CS`` by ``GPIO_NRF24_CS`` and ``GPIO_SPI_DC`` by ``GPIO_NRF24_DC`` ## [9.2.0.1] 20201229 ### Added diff --git a/RELEASENOTES.md b/RELEASENOTES.md index f7d6c073d..6f02fa36f 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -58,8 +58,6 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota ## Changelog v9.2.0.2 ### Added -- Command ``CTRange`` to specify the visible CT range the bulb is capable of [#10311](https://github.com/arendst/Tasmota/issues/10311) -- Command ``VirtualCT`` to simulate or fine tune CT bulbs with 3,4,5 channels [#10311](https://github.com/arendst/Tasmota/issues/10311) - Milliseconds to console output [#10152](https://github.com/arendst/Tasmota/issues/10152) - Gpio ``Option_a1`` enabling PWM2 high impedance if powered off as used by Wyze bulbs [#10196](https://github.com/arendst/Tasmota/issues/10196) - BSSID and Signal Strength Indicator to GUI wifi scan result [#10253](https://github.com/arendst/Tasmota/issues/10253) @@ -75,7 +73,6 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota ### Breaking Changed - Replaced MFRC522 13.56MHz rfid card reader GPIO selection from ``GPIO_SPI_CS`` by ``GPIO_RC522_CS`` - Replaced ILI9341 GPIO selection from ``GPIO_SPI_CS`` by ``GPIO_ILI9341_CS`` and ``GPIO_SPI_DC`` by ``GPIO_ILI9341_DC`` -- Replaced NRF24L01 GPIO selection from ``GPIO_SPI_CS`` by ``GPIO_NRF24_CS`` and ``GPIO_SPI_DC`` by ``GPIO_NRF24_DC`` ### Changed - Logging from heap to stack freeing 700 bytes RAM diff --git a/tasmota/support.ino b/tasmota/support.ino index 81e826365..fcf21a014 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -1479,7 +1479,8 @@ bool FlashPin(uint32_t pin) return (((pin > 5) && (pin < 9)) || (11 == pin)); } -uint32_t ValidPin(uint32_t pin, uint32_t gpio) { +uint32_t ValidPin(uint32_t pin, uint32_t gpio) +{ if (FlashPin(pin)) { return GPIO_NONE; // Disable flash pins GPIO6, GPIO7, GPIO8 and GPIO11 } @@ -1494,7 +1495,8 @@ uint32_t ValidPin(uint32_t pin, uint32_t gpio) { return gpio; } -bool ValidGPIO(uint32_t pin, uint32_t gpio) { +bool ValidGPIO(uint32_t pin, uint32_t gpio) +{ #ifdef ESP8266 #ifdef USE_ADC_VCC if (ADC0_PIN == pin) { return false; } // ADC0 = GPIO17 @@ -1503,17 +1505,6 @@ bool ValidGPIO(uint32_t pin, uint32_t gpio) { return (GPIO_USER == ValidPin(pin, BGPIO(gpio))); // Only allow GPIO_USER pins } -bool ValidSpiGPIO(uint32_t gpio) { - // ESP8266: If SPI pin selected chk if it's not one of the three Hardware SPI pins (12..14) - bool result = true; // Not used and therefore valid - uint32_t pin; - if (PinUsed(gpio)) { - pin = Pin(gpio); - result = ((pin < 12) || (pin > 14)); - } - return result; -} - bool JsonTemplate(char* dataBuf) { // Old: {"NAME":"Shelly 2.5","GPIO":[56,0,17,0,21,83,0,0,6,82,5,22,156],"FLAG":2,"BASE":18} diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index 325ad3b2e..58b79e905 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -1599,20 +1599,26 @@ void GpioInit(void) TasmotaGlobal.soft_spi_enabled = (PinUsed(GPIO_SSPI_SCLK) && (PinUsed(GPIO_SSPI_MOSI) || PinUsed(GPIO_SSPI_MISO))); #ifdef USE_SPI + uint32_t pin_cs = Pin(GPIO_SPI_CS); + uint32_t pin_dc = Pin(GPIO_SPI_DC); + if (PinUsed(GPIO_RC522_CS)) { + pin_cs = Pin(GPIO_RC522_CS); + } + if (PinUsed(GPIO_ILI9341_CS)) { + pin_cs = Pin(GPIO_ILI9341_CS); + if (PinUsed(GPIO_ILI9341_DC)) { + pin_dc = Pin(GPIO_ILI9341_DC); + } + } + #ifdef ESP8266 if (!TasmotaGlobal.soft_spi_enabled) { - bool valid_cs = (ValidSpiGPIO(GPIO_SPI_CS) && - ValidSpiGPIO(GPIO_RC522_CS) && - ValidSpiGPIO(GPIO_NRF24_CS) && - ValidSpiGPIO(GPIO_ILI9341_CS) - ); - bool valid_dc = (ValidSpiGPIO(GPIO_SPI_DC) && - ValidSpiGPIO(GPIO_NRF24_DC) && - ValidSpiGPIO(GPIO_ILI9341_DC) - ); - - // If SPI_CS and/or SPI_DC is used they must be valid - TasmotaGlobal.spi_enabled = (valid_cs && valid_dc); + // If SPI_CS is used it must be valid + TasmotaGlobal.spi_enabled = ((pin_cs < 99) && ((pin_cs > 14) || (pin_cs < 12))); + if (TasmotaGlobal.spi_enabled && (pin_dc < 99)) { + // If SPI_DC is used it must be valid + TasmotaGlobal.spi_enabled = ((pin_dc > 14) || (pin_dc < 12)); + } if (TasmotaGlobal.spi_enabled) { TasmotaGlobal.my_module.io[12] = AGPIO(GPIO_SPI_MISO); SetPin(12, AGPIO(GPIO_SPI_MISO)); @@ -1625,26 +1631,57 @@ void GpioInit(void) } #endif // ESP8266 #ifdef ESP32 - if (PinUsed(GPIO_SPI_CS) || - PinUsed(GPIO_RC522_CS) || - PinUsed(GPIO_NRF24_CS) || - PinUsed(GPIO_ILI9341_CS) - ) { - TasmotaGlobal.spi_enabled = true; - if (PinUsed(GPIO_SPI_MOSI) && PinUsed(GPIO_SPI_MISO) && PinUsed(GPIO_SPI_CLK)) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SPI: Using GPIO%02d(MISO), GPIO%02d(MOSI) and GPIO%02d(CLK)"), - Pin(GPIO_SPI_MISO), Pin(GPIO_SPI_MOSI), Pin(GPIO_SPI_CLK)); + if (pin_cs < 99) { +/* + // Do not do this as ESP32 can have SPI_CS everywhere + if ((15 == pin_cs) && (!GetPin(12) && !GetPin(13) && !GetPin(14))) { // HSPI + TasmotaGlobal.my_module.io[12] = AGPIO(GPIO_SPI_MISO); + SetPin(12, AGPIO(GPIO_SPI_MISO)); + TasmotaGlobal.my_module.io[13] = AGPIO(GPIO_SPI_MOSI); + SetPin(13, AGPIO(GPIO_SPI_MOSI)); + TasmotaGlobal.my_module.io[14] = AGPIO(GPIO_SPI_CLK); + SetPin(14, AGPIO(GPIO_SPI_CLK)); } - else if (PinUsed(GPIO_SPI_MOSI) && PinUsed(GPIO_SPI_CLK)) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SPI: Using GPIO%02d(MOSI) and GPIO%02d(CLK)"), - Pin(GPIO_SPI_MOSI), Pin(GPIO_SPI_CLK)); + else if ((5 == pin_cs) && (!GetPin(19) && !GetPin(23) && !GetPin(18))) { // VSPI + TasmotaGlobal.my_module.io[19] = AGPIO(GPIO_SPI_MISO); + SetPin(19, AGPIO(GPIO_SPI_MISO)); + TasmotaGlobal.my_module.io[23] = AGPIO(GPIO_SPI_MOSI); + SetPin(23, AGPIO(GPIO_SPI_MOSI)); + TasmotaGlobal.my_module.io[18] = AGPIO(GPIO_SPI_CLK); + SetPin(18, AGPIO(GPIO_SPI_CLK)); } - else if (PinUsed(GPIO_SPI_MISO) && PinUsed(GPIO_SPI_CLK)) { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SPI: Using GPIO%02d(MISO) and GPIO%02d(CLK)"), - Pin(GPIO_SPI_MISO), Pin(GPIO_SPI_CLK)); - } else { - AddLog_P(LOG_LEVEL_DEBUG, PSTR("SPI: Failed as no CLK and MISO and/or MOSI GPIO defined")); - TasmotaGlobal.spi_enabled = false; + else if ((12 == Pin(GPIO_SPI_MISO)) || (13 == Pin(GPIO_SPI_MOSI)) || (14 == Pin(GPIO_SPI_CLK))) { // HSPI + TasmotaGlobal.my_module.io[12] = AGPIO(GPIO_SPI_MISO); + SetPin(12, AGPIO(GPIO_SPI_MISO)); + TasmotaGlobal.my_module.io[13] = AGPIO(GPIO_SPI_MOSI); + SetPin(13, AGPIO(GPIO_SPI_MOSI)); + TasmotaGlobal.my_module.io[14] = AGPIO(GPIO_SPI_CLK); + SetPin(14, AGPIO(GPIO_SPI_CLK)); + } + else if ((19 == Pin(GPIO_SPI_MISO)) || (23 == Pin(GPIO_SPI_MOSI)) || (18 == Pin(GPIO_SPI_CLK))) { // VSPI + TasmotaGlobal.my_module.io[19] = AGPIO(GPIO_SPI_MISO); + SetPin(19, AGPIO(GPIO_SPI_MISO)); + TasmotaGlobal.my_module.io[23] = AGPIO(GPIO_SPI_MOSI); + SetPin(23, AGPIO(GPIO_SPI_MOSI)); + TasmotaGlobal.my_module.io[18] = AGPIO(GPIO_SPI_CLK); + SetPin(18, AGPIO(GPIO_SPI_CLK)); + } + TasmotaGlobal.spi_enabled = (PinUsed(GPIO_SPI_CLK) && (PinUsed(GPIO_SPI_MOSI) || PinUsed(GPIO_SPI_MISO))); +*/ + TasmotaGlobal.spi_enabled = (pin_cs < 99); + if (TasmotaGlobal.spi_enabled) { + if (PinUsed(GPIO_SPI_MOSI) && PinUsed(GPIO_SPI_MISO) && PinUsed(GPIO_SPI_CLK)) { + AddLog_P(LOG_LEVEL_DEBUG, PSTR("SPI: Using GPIO%02d(MISO), GPIO%02d(MOSI) and GPIO%02d(CLK)"), + Pin(GPIO_SPI_MISO), Pin(GPIO_SPI_MOSI), Pin(GPIO_SPI_CLK)); + } + else if (PinUsed(GPIO_SPI_MOSI) && PinUsed(GPIO_SPI_CLK)) { + AddLog_P(LOG_LEVEL_DEBUG, PSTR("SPI: Using GPIO%02d(MOSI) and GPIO%02d(CLK)"), + Pin(GPIO_SPI_MOSI), Pin(GPIO_SPI_CLK)); + } + else if (PinUsed(GPIO_SPI_MISO) && PinUsed(GPIO_SPI_CLK)) { + AddLog_P(LOG_LEVEL_DEBUG, PSTR("SPI: Using GPIO%02d(MISO) and GPIO%02d(CLK)"), + Pin(GPIO_SPI_MISO), Pin(GPIO_SPI_CLK)); + } } } #endif // ESP32 diff --git a/tasmota/tasmota_configurations_ESP32.h b/tasmota/tasmota_configurations_ESP32.h index 2f21ed0aa..c3bb7044b 100644 --- a/tasmota/tasmota_configurations_ESP32.h +++ b/tasmota/tasmota_configurations_ESP32.h @@ -46,11 +46,6 @@ #undef CODE_IMAGE_STR #define CODE_IMAGE_STR "odroid-go" -#undef MODULE -#define MODULE ODROID_GO // [Module] Select default module from tasmota_template.h -#undef FALLBACK_MODULE -#define FALLBACK_MODULE ODROID_GO // [Module2] Select default module on fast reboot where USER_MODULE is user template - #define USE_ODROID_GO // Add support for Odroid Go #define USE_ADC #define USE_SPI diff --git a/tasmota/xdrv_33_nrf24l01.ino b/tasmota/xdrv_33_nrf24l01.ino index 1b3c5b8c8..7c4d1b843 100644 --- a/tasmota/xdrv_33_nrf24l01.ino +++ b/tasmota/xdrv_33_nrf24l01.ino @@ -34,7 +34,7 @@ /*********************************************************************************************\ * NRF24l01(+) * -* Usage: 5 SPI-data-wires plus VVC/ground, use hardware SPI, select GPIO_NRF24_CS/GPIO_NRF24_DC +* Usage: 5 SPI-data-wires plus VVC/ground, use hardware SPI, select GPIO_SPI_CS/GPIO_SPI_DC \*********************************************************************************************/ #define XDRV_33 33 @@ -51,26 +51,28 @@ struct { RF24 NRF24radio; -bool NRF24initRadio() { - NRF24radio.begin(Pin(GPIO_NRF24_CS), Pin(GPIO_NRF24_DC)); +bool NRF24initRadio() +{ + NRF24radio.begin(Pin(GPIO_SPI_CS),Pin(GPIO_SPI_DC)); NRF24radio.powerUp(); - if (NRF24radio.isChipConnected()) { - DEBUG_DRIVER_LOG(PSTR("NRF: Chip connected")); + if(NRF24radio.isChipConnected()){ + DEBUG_DRIVER_LOG(PSTR("NRF24 chip connected")); return true; } - DEBUG_DRIVER_LOG(PSTR("NRF: Chip NOT !!!! connected")); + DEBUG_DRIVER_LOG(PSTR("NRF24 chip NOT !!!! connected")); return false; } -bool NRF24Detect(void) { - if (PinUsed(GPIO_NRF24_CS) && PinUsed(GPIO_NRF24_DC)) { - if (NRF24initRadio()) { +bool NRF24Detect(void) +{ + if (PinUsed(GPIO_SPI_CS) && PinUsed(GPIO_SPI_DC)) { + if(NRF24initRadio()){ NRF24.chipType = 32; // SPACE - AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: Model 24L01 initialized")); - if (NRF24radio.isPVariant()) { + AddLog_P(LOG_LEVEL_INFO,PSTR("NRF24L01 initialized")); + if(NRF24radio.isPVariant()){ NRF24.chipType = 43; // + - AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: Model 24L01+ detected")); + AddLog_P(LOG_LEVEL_INFO,PSTR("NRF24L01+ detected")); } return true; } @@ -82,13 +84,12 @@ bool NRF24Detect(void) { * Interface \*********************************************************************************************/ -bool Xdrv33(uint8_t function) { +bool Xdrv33(uint8_t function) +{ bool result = false; - if (TasmotaGlobal.spi_enabled) { - if (FUNC_INIT == function) { - result = NRF24Detect(); - } + if (FUNC_INIT == function) { + result = NRF24Detect(); } return result; } diff --git a/tasmota/xdsp_04_ili9341.ino b/tasmota/xdsp_04_ili9341.ino index 005f048eb..adabfe6b0 100644 --- a/tasmota/xdsp_04_ili9341.ino +++ b/tasmota/xdsp_04_ili9341.ino @@ -57,7 +57,8 @@ bool Ili9341Header(void) { return (tft_cols > 17); } -void Ili9341InitMode(void) { +void Ili9341InitMode(void) +{ tft->setRotation(Settings.display_rotate); // 0 tft->invertDisplay(0); tft->fillScreen(ILI9341_BLACK); @@ -77,7 +78,8 @@ void Ili9341InitMode(void) { } } -void Ili9341Init(uint8_t mode) { +void Ili9341Init(uint8_t mode) +{ switch(mode) { case DISPLAY_INIT_MODE: Ili9341InitMode(); @@ -93,11 +95,24 @@ void Ili9341Init(uint8_t mode) { } } -void Ili9341InitDriver(void) { - if (PinUsed(GPIO_ILI9341_CS) && PinUsed(GPIO_ILI9341_DC)) { +void Ili9341InitDriver(void) +{ + uint32_t pin_cs = Pin(GPIO_SPI_CS); + uint32_t pin_dc = Pin(GPIO_SPI_DC); + if (!Settings.display_model) { + if (PinUsed(GPIO_ILI9341_CS)) { + pin_cs = Pin(GPIO_ILI9341_CS); + if (PinUsed(GPIO_ILI9341_DC)) { + pin_dc = Pin(GPIO_ILI9341_DC); + } + Settings.display_model = XDSP_04; + } + // Legacy Settings.display_model = XDSP_04; + } + if (XDSP_04 == Settings.display_model) { if (Settings.display_width != ILI9341_TFTWIDTH) { Settings.display_width = ILI9341_TFTWIDTH; } @@ -105,7 +120,7 @@ void Ili9341InitDriver(void) { Settings.display_height = ILI9341_TFTHEIGHT; } - tft = new Adafruit_ILI9341(Pin(GPIO_ILI9341_CS), Pin(GPIO_ILI9341_DC)); + tft = new Adafruit_ILI9341(pin_cs, pin_dc); tft->begin(); #ifdef USE_DISPLAY_MODES1TO5 @@ -120,12 +135,14 @@ void Ili9341InitDriver(void) { } } -void Ili9341Clear(void) { +void Ili9341Clear(void) +{ tft->fillScreen(ILI9341_BLACK); tft->setCursor(0, 0); } -void Ili9341DrawStringAt(uint16_t x, uint16_t y, char *str, uint16_t color, uint8_t flag) { +void Ili9341DrawStringAt(uint16_t x, uint16_t y, char *str, uint16_t color, uint8_t flag) +{ uint16_t active_color = ILI9341_WHITE; tft->setTextSize(Settings.display_size); @@ -139,7 +156,8 @@ void Ili9341DrawStringAt(uint16_t x, uint16_t y, char *str, uint16_t color, uint tft->println(str); } -void Ili9341DisplayOnOff() { +void Ili9341DisplayOnOff() +{ // tft->showDisplay(disp_power); // tft->invertDisplay(disp_power); if (PinUsed(GPIO_BACKLIGHT)) { @@ -152,7 +170,8 @@ void Ili9341DisplayOnOff() { #ifdef USE_DISPLAY_MODES1TO5 -void Ili9341PrintLog(void) { +void Ili9341PrintLog(void) +{ disp_refresh--; if (!disp_refresh) { disp_refresh = Settings.display_refresh; @@ -198,7 +217,8 @@ void Ili9341PrintLog(void) { } } -void Ili9341Refresh(void) { // Every second +void Ili9341Refresh(void) // Every second +{ if (Settings.display_mode) { // Mode 0 is User text // 24-04-2017 13:45:43 = 19 + 1 ('\0') = 20 // 24-04-2017 13:45 = 16 + 1 ('\0') = 17 @@ -243,7 +263,8 @@ void Ili9341Refresh(void) { // Every second * Interface \*********************************************************************************************/ -bool Xdsp04(uint8_t function) { +bool Xdsp04(uint8_t function) +{ bool result = false; if (TasmotaGlobal.spi_enabled) {