diff --git a/tasmota/language/af_AF.h b/tasmota/language/af_AF.h index bfd4177e3..4eab30241 100644 --- a/tasmota/language/af_AF.h +++ b/tasmota/language/af_AF.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/bg_BG.h b/tasmota/language/bg_BG.h index f8e3c705c..e9003a386 100644 --- a/tasmota/language/bg_BG.h +++ b/tasmota/language/bg_BG.h @@ -775,6 +775,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/cs_CZ.h b/tasmota/language/cs_CZ.h index 983524bbf..159d00878 100644 --- a/tasmota/language/cs_CZ.h +++ b/tasmota/language/cs_CZ.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/de_DE.h b/tasmota/language/de_DE.h index f1bad46a7..cdbc1f994 100644 --- a/tasmota/language/de_DE.h +++ b/tasmota/language/de_DE.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/el_GR.h b/tasmota/language/el_GR.h index 5820512d6..8e2e3f093 100644 --- a/tasmota/language/el_GR.h +++ b/tasmota/language/el_GR.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/en_GB.h b/tasmota/language/en_GB.h index 77a325d30..2d6a47f43 100644 --- a/tasmota/language/en_GB.h +++ b/tasmota/language/en_GB.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/es_ES.h b/tasmota/language/es_ES.h index e04f2b256..31640385e 100644 --- a/tasmota/language/es_ES.h +++ b/tasmota/language/es_ES.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/fr_FR.h b/tasmota/language/fr_FR.h index 65c14a58d..7bb645751 100644 --- a/tasmota/language/fr_FR.h +++ b/tasmota/language/fr_FR.h @@ -772,6 +772,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/he_HE.h b/tasmota/language/he_HE.h index 6e9a6ef8e..ab7ff6d77 100644 --- a/tasmota/language/he_HE.h +++ b/tasmota/language/he_HE.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/hu_HU.h b/tasmota/language/hu_HU.h index 82fe0b4a4..e2d335ce6 100644 --- a/tasmota/language/hu_HU.h +++ b/tasmota/language/hu_HU.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/it_IT.h b/tasmota/language/it_IT.h index 91ae9a830..9aa08db46 100644 --- a/tasmota/language/it_IT.h +++ b/tasmota/language/it_IT.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 - CS" #define D_SENSOR_ST7789_CS "ST7789 - CS" #define D_SENSOR_ST7789_DC "ST7789 - DC" +#define D_SENSOR_SSD1331_CS "SSD1331 - CS" +#define D_SENSOR_SSD1331_DC "SSD1331 - DC" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/ko_KO.h b/tasmota/language/ko_KO.h index 6ab2f1421..0d9f91af4 100644 --- a/tasmota/language/ko_KO.h +++ b/tasmota/language/ko_KO.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/nl_NL.h b/tasmota/language/nl_NL.h index 682fbec90..8087a8770 100644 --- a/tasmota/language/nl_NL.h +++ b/tasmota/language/nl_NL.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/pl_PL.h b/tasmota/language/pl_PL.h index f5497d91d..5919b35b5 100644 --- a/tasmota/language/pl_PL.h +++ b/tasmota/language/pl_PL.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/pt_BR.h b/tasmota/language/pt_BR.h index 99d38f192..8069a265f 100644 --- a/tasmota/language/pt_BR.h +++ b/tasmota/language/pt_BR.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/pt_PT.h b/tasmota/language/pt_PT.h index 5e7c74f36..af9ee37a0 100644 --- a/tasmota/language/pt_PT.h +++ b/tasmota/language/pt_PT.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/ro_RO.h b/tasmota/language/ro_RO.h index bb1a09185..bf23a7c8d 100644 --- a/tasmota/language/ro_RO.h +++ b/tasmota/language/ro_RO.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/ru_RU.h b/tasmota/language/ru_RU.h index df1d5b50e..965f5f5d7 100644 --- a/tasmota/language/ru_RU.h +++ b/tasmota/language/ru_RU.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "А" diff --git a/tasmota/language/sk_SK.h b/tasmota/language/sk_SK.h index 8f5490a19..20a691be6 100644 --- a/tasmota/language/sk_SK.h +++ b/tasmota/language/sk_SK.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/sv_SE.h b/tasmota/language/sv_SE.h index 6935fa102..18822f2b8 100644 --- a/tasmota/language/sv_SE.h +++ b/tasmota/language/sv_SE.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/tr_TR.h b/tasmota/language/tr_TR.h index 01b73bc75..f307a9e73 100644 --- a/tasmota/language/tr_TR.h +++ b/tasmota/language/tr_TR.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/uk_UA.h b/tasmota/language/uk_UA.h index 11fbdac99..2626572ae 100644 --- a/tasmota/language/uk_UA.h +++ b/tasmota/language/uk_UA.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "А" diff --git a/tasmota/language/vi_VN.h b/tasmota/language/vi_VN.h index cc666ec82..d8d9d5124 100644 --- a/tasmota/language/vi_VN.h +++ b/tasmota/language/vi_VN.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "A" diff --git a/tasmota/language/zh_CN.h b/tasmota/language/zh_CN.h index 2e6baa64d..1895fc690 100644 --- a/tasmota/language/zh_CN.h +++ b/tasmota/language/zh_CN.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "安" diff --git a/tasmota/language/zh_TW.h b/tasmota/language/zh_TW.h index 2a2078266..2f2ec544e 100644 --- a/tasmota/language/zh_TW.h +++ b/tasmota/language/zh_TW.h @@ -776,6 +776,8 @@ #define D_SENSOR_RA8876_CS "RA8876 CS" #define D_SENSOR_ST7789_CS "ST7789 CS" #define D_SENSOR_ST7789_DC "ST7789 DC" +#define D_SENSOR_SSD1331_CS "SSD1331 CS" +#define D_SENSOR_SSD1331_DC "SSD1331 DC" // Units #define D_UNIT_AMPERE "安培" diff --git a/tasmota/my_user_config.h b/tasmota/my_user_config.h index 63db85b25..fb9c30774 100644 --- a/tasmota/my_user_config.h +++ b/tasmota/my_user_config.h @@ -629,6 +629,7 @@ // #define USE_DISPLAY_SSD1351 // [DisplayModel 9] Enable SSD1351 module // #define USE_DISPLAY_RA8876 // [DisplayModel 10] [I2cDriver39] (Touch) // #define USE_DISPLAY_ST7789 // [DisplayModel 12] Enable ST7789 module +// #define USE_DISPLAY_SSD1331 // [DisplayModel 14] Enable SSD1331 module // #define USE_RC522 // Add support for MFRC522 13.56Mhz Rfid reader (+6k code) // #define USE_RC522_DATA_FUNCTION // Add support for reading data block content (+0k4 code) // #define USE_RC522_TYPE_INFORMATION // Add support for showing card type (+0k4 code) diff --git a/tasmota/support_features.ino b/tasmota/support_features.ino index d86544aac..1def3db1c 100644 --- a/tasmota/support_features.ino +++ b/tasmota/support_features.ino @@ -686,8 +686,9 @@ void ResponseAppendFeatures(void) #if defined(USE_SPI) && defined(USE_DISPLAY) && defined(USE_DISPLAY_ST7789) feature7 |= 0x00080000; // xdsp_12_ST7789.ino #endif - -// feature7 |= 0x00100000; +#if defined(USE_SPI) && defined(USE_DISPLAY) && defined(USE_DISPLAY_SSD1331) + feature7 |= 0x00100000; // xdsp_14_SSD1331.ino +#endif // feature7 |= 0x00200000; // feature7 |= 0x00400000; // feature7 |= 0x00800000; diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index c76896f73..84bc2dd53 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -1614,12 +1614,14 @@ void GpioInit(void) ValidSpiPinUsed(GPIO_SSD1351_CS) || ValidSpiPinUsed(GPIO_RA8876_CS) || ValidSpiPinUsed(GPIO_ST7789_DC) || // ST7789 CS may be omitted so chk DC too - ValidSpiPinUsed(GPIO_ST7789_CS) + ValidSpiPinUsed(GPIO_ST7789_CS) || + ValidSpiPinUsed(GPIO_SSD1331_CS) ); bool valid_dc = (ValidSpiPinUsed(GPIO_SPI_DC) || ValidSpiPinUsed(GPIO_NRF24_DC) || ValidSpiPinUsed(GPIO_ILI9341_DC) || - ValidSpiPinUsed(GPIO_ST7789_DC) + ValidSpiPinUsed(GPIO_ST7789_DC) || + ValidSpiPinUsed(GPIO_SSD1331_DC) ); // If SPI_CS and/or SPI_DC is used they must be valid TasmotaGlobal.spi_enabled = (valid_cs && valid_dc) ? SPI_MOSI_MISO : SPI_NONE; @@ -1644,7 +1646,8 @@ void GpioInit(void) PinUsed(GPIO_SSD1351_CS) || PinUsed(GPIO_RA8876_CS) || PinUsed(GPIO_ST7789_DC) || // ST7789 CS may be omitted so chk DC too - PinUsed(GPIO_ST7789_CS) + PinUsed(GPIO_ST7789_CS) || + PinUsed(GPIO_SSD1331_CS) ) { uint32_t spi_mosi = (PinUsed(GPIO_SPI_CLK) && PinUsed(GPIO_SPI_MOSI)) ? SPI_MOSI : SPI_NONE; uint32_t spi_miso = (PinUsed(GPIO_SPI_CLK) && PinUsed(GPIO_SPI_MISO)) ? SPI_MISO : SPI_NONE; diff --git a/tasmota/tasmota_configurations.h b/tasmota/tasmota_configurations.h index 86078c8ab..142045bab 100644 --- a/tasmota/tasmota_configurations.h +++ b/tasmota/tasmota_configurations.h @@ -310,6 +310,7 @@ #define USE_DISPLAY_SSD1351 // [DisplayModel 9] #define USE_DISPLAY_RA8876 // [DisplayModel 10] #define USE_DISPLAY_ST7789 // [DisplayModel 12] Enable ST7789 module +// #define USE_DISPLAY_SSD1331 // [DisplayModel 14] Enable SSD1331 module #undef DEBUG_THEO // Disable debug code #undef USE_DEBUG_DRIVER // Disable debug code diff --git a/tasmota/tasmota_template.h b/tasmota/tasmota_template.h index 714ca0f77..874f5ab2f 100644 --- a/tasmota/tasmota_template.h +++ b/tasmota/tasmota_template.h @@ -141,6 +141,7 @@ enum UserSelectablePins { GPIO_SSD1351_CS, GPIO_RA8876_CS, GPIO_ST7789_CS, GPIO_ST7789_DC, + GPIO_SSD1331_CS, GPIO_SSD1331_DC, GPIO_SENSOR_END }; enum ProgramSelectablePins { @@ -302,6 +303,7 @@ const char kSensorNames[] PROGMEM = D_SENSOR_SSD1351_CS "|" D_SENSOR_RA8876_CS "|" D_SENSOR_ST7789_CS "|" D_SENSOR_ST7789_DC "|" + D_SENSOR_SSD1331_CS "|" D_SENSOR_SSD1331_DC "|" ; const char kSensorNamesFixed[] PROGMEM = @@ -403,7 +405,11 @@ const uint16_t kGpioNiceList[] PROGMEM = { #ifdef USE_DISPLAY_ST7789 AGPIO(GPIO_ST7789_CS), AGPIO(GPIO_ST7789_DC), -#endif //f USE_DISPLAY_ST7789 +#endif // USE_DISPLAY_ST7789 +#ifdef USE_DISPLAY_SSD1331 + AGPIO(GPIO_SSD1331_CS), + AGPIO(GPIO_SSD1331_DC), +#endif // USE_DISPLAY_SSD1331 AGPIO(GPIO_BACKLIGHT), // Display backlight control AGPIO(GPIO_OLED_RESET), // OLED Display Reset #endif diff --git a/tasmota/xdsp_09_SSD1351.ino b/tasmota/xdsp_09_SSD1351.ino index b0318b0ed..f3ad53b29 100644 --- a/tasmota/xdsp_09_SSD1351.ino +++ b/tasmota/xdsp_09_SSD1351.ino @@ -90,8 +90,7 @@ void SSD1351_InitDriver() { #ifdef USE_DISPLAY_MODES1TO5 -void SSD1351PrintLog(void) -{ +void SSD1351PrintLog(void) { disp_refresh--; if (!disp_refresh) { disp_refresh = Settings.display_refresh; @@ -119,8 +118,7 @@ void SSD1351PrintLog(void) } } -void SSD1351Time(void) -{ +void SSD1351Time(void) { char line[12]; renderer->clearDisplay(); @@ -133,8 +131,7 @@ void SSD1351Time(void) renderer->Updateframe(); } -void SSD1351Refresh(void) // Every second -{ +void SSD1351Refresh(void) { // Every second if (Settings.display_mode) { // Mode 0 is User text switch (Settings.display_mode) { case 1: // Time @@ -151,12 +148,12 @@ void SSD1351Refresh(void) // Every second } #endif // USE_DISPLAY_MODES1TO5 -/*********************************************************************************************/ + /*********************************************************************************************\ * Interface \*********************************************************************************************/ -bool Xdsp09(uint8_t function) -{ + +bool Xdsp09(uint8_t function) { bool result = false; if (FUNC_DISPLAY_INIT_DRIVER == function) { diff --git a/tasmota/xdsp_14_SSD1331.ino b/tasmota/xdsp_14_SSD1331.ino index cae0c9aa2..be5417426 100644 --- a/tasmota/xdsp_14_SSD1331.ino +++ b/tasmota/xdsp_14_SSD1331.ino @@ -1,7 +1,7 @@ /* xdsp_14_SSD1331.ino - Display SSD1331 support for Tasmota - Copyright (C) 2020 Jeroen Vermeulen, Gerhard Mutz and Theo Arends + Copyright (C) 2021 Jeroen Vermeulen, Gerhard Mutz and Theo Arends This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -35,6 +35,7 @@ #include #include +bool ssd1331_init_done = false; extern uint8_t *buffer; extern uint8_t color_type; Adafruit_SSD1331 *ssd1331; @@ -42,11 +43,10 @@ Adafruit_SSD1331 *ssd1331; /*********************************************************************************************/ void SSD1331_InitDriver() { - if (!Settings.display_model) { - Settings.display_model = XDSP_14; - } + if (PinUsed(GPIO_SSD1331_CS) && PinUsed(GPIO_SSD1331_DC) && + ((TasmotaGlobal.soft_spi_enabled & SPI_MOSI) || (TasmotaGlobal.spi_enabled & SPI_MOSI))) { - if (XDSP_14 == Settings.display_model) { + Settings.display_model = XDSP_14; if (Settings.display_width != Adafruit_SSD1331::TFTWIDTH) { Settings.display_width = Adafruit_SSD1331::TFTWIDTH; @@ -55,26 +55,30 @@ void SSD1331_InitDriver() { Settings.display_height = Adafruit_SSD1331::TFTHEIGHT; } - buffer=0; + buffer = 0; // default colors fg_color = SSD1331_WHITE; bg_color = SSD1331_BLACK; + int8_t reset = -1; + if (PinUsed(GPIO_OLED_RESET)) { + reset = Pin(GPIO_OLED_RESET); + } + // init renderer - if (PinUsed(GPIO_SSPI_CS) && PinUsed(GPIO_SSPI_DC) && PinUsed(GPIO_SSPI_MOSI) && PinUsed(GPIO_SSPI_SCLK) && PinUsed(GPIO_OLED_RESET)) { - ssd1331 = new Adafruit_SSD1331(Pin(GPIO_SSPI_CS),Pin(GPIO_SSPI_DC),Pin(GPIO_SSPI_MOSI),Pin(GPIO_SSPI_SCLK),Pin(GPIO_OLED_RESET)); - } else if (PinUsed(GPIO_SPI_CS) && PinUsed(GPIO_SPI_DC)) { - ssd1331 = new Adafruit_SSD1331(&SPI,Pin(GPIO_SPI_CS),Pin(GPIO_SPI_DC),Pin(GPIO_OLED_RESET)); - } else { - return; + if (TasmotaGlobal.soft_spi_enabled) { + ssd1331 = new Adafruit_SSD1331(Pin(GPIO_SSD1331_CS), Pin(GPIO_SSD1331_DC), Pin(GPIO_SSPI_MOSI), Pin(GPIO_SSPI_SCLK), reset); + } + else if (TasmotaGlobal.spi_enabled) { + ssd1331 = new Adafruit_SSD1331(&SPI, Pin(GPIO_SSD1331_CS), Pin(GPIO_SSD1331_DC), reset); } delay(100); ssd1331->begin(); renderer = ssd1331; // Rotation is currently broken, https://github.com/adafruit/Adafruit-SSD1331-OLED-Driver-Library-for-Arduino/issues/26 - renderer->DisplayInit(DISPLAY_INIT_MODE,Settings.display_size,Settings.display_rotate,Settings.display_font); + renderer->DisplayInit(DISPLAY_INIT_MODE, Settings.display_size, Settings.display_rotate, Settings.display_font); renderer->dim(Settings.display_dimmer); #ifdef SHOW_SPLASH @@ -86,13 +90,15 @@ void SSD1331_InitDriver() { #endif color_type = COLOR_COLOR; + + ssd1331_init_done = true; + AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: SSD1331")); } } #ifdef USE_DISPLAY_MODES1TO5 -void SSD1331PrintLog(bool withDateTime) -{ +void SSD1331PrintLog(bool withDateTime) { disp_refresh--; if (!disp_refresh) { disp_refresh = Settings.display_refresh; @@ -129,8 +135,7 @@ void SSD1331PrintLog(bool withDateTime) } } -void SSD1331Time(void) -{ +void SSD1331Time(void) { char line[12]; renderer->clearDisplay(); @@ -142,8 +147,7 @@ void SSD1331Time(void) renderer->Updateframe(); } -void SSD1331Refresh(void) // Every second -{ +void SSD1331Refresh(void) { // Every second if (Settings.display_mode) { // Mode 0 is User text switch (Settings.display_mode) { case 1: // Time @@ -162,18 +166,18 @@ void SSD1331Refresh(void) // Every second } #endif // USE_DISPLAY_MODES1TO5 -/*********************************************************************************************/ + /*********************************************************************************************\ * Interface \*********************************************************************************************/ -bool Xdsp14(uint8_t function) -{ + +bool Xdsp14(uint8_t function) { bool result = false; if (FUNC_DISPLAY_INIT_DRIVER == function) { SSD1331_InitDriver(); } - else if (XDSP_14 == Settings.display_model) { + else if (ssd1331_init_done && (XDSP_14 == Settings.display_model)) { switch (function) { case FUNC_DISPLAY_MODEL: result = true; diff --git a/tools/decode-status.py b/tools/decode-status.py index c4c4309c0..ba5ead287 100755 --- a/tools/decode-status.py +++ b/tools/decode-status.py @@ -241,7 +241,7 @@ a_features = [[ "USE_EZODO","USE_EZORGB","USE_EZOPMP","USE_AS608", "USE_SHELLY_DIMMER","USE_RC522","USE_FTC532","USE_DISPLAY_EPAPER_42", "USE_DISPLAY_ILI9488","USE_DISPLAY_SSD1351","USE_DISPLAY_RA8876","USE_DISPLAY_ST7789", - "","","","", + "USE_DISPLAY_SSD1331","","","", "","","","", "","","","" ]]