Breaking change replacing SPI CS and SPI DC

Breaking change replacing SPI CS and SPI DC by device specific CS and DC
This commit is contained in:
Theo Arends 2020-12-31 16:17:30 +01:00
parent 0c7266fed1
commit 58e6ec55f1
18 changed files with 325 additions and 420 deletions

View File

@ -6,12 +6,19 @@ 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
- Command ``VirtualCT`` to simulate or fine tune CT bulbs with 3,4,5 channels
- 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)
### 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 MFRC522 13.56MHz rfid card reader GPIO selection from ``SPI CS`` by ``RC522 CS``
- Replaced NRF24L01 GPIO selection from ``SPI CS`` by ``NRF24 CS`` and ``SPI DC`` by ``NRF24 DC``
- Replaced ILI9341 GPIO selection from ``SPI CS`` by ``ILI9341 CS`` and ``SPI DC`` by ``ILI9341 DC``
- Replaced ST7789 GPIO selection from ``SPI CS`` by ``ST7789 CS`` and ``SPI DC`` by ``ST7789 DC``
- Replaced ILI9488 GPIO selection from ``SPI CS`` by ``ILI9488_CS``
- Replaced EPaper29 GPIO selection from ``SPI CS`` by ``EPaper29 CS``
- Replaced EPaper42 GPIO selection from ``SPI CS`` by ``EPaper42 CS``
- Replaced SSD1351 GPIO selection from ``SPI CS`` by ``SSD1351 CS``
- Replaced RA8876 GPIO selection from ``SPI CS`` by ``RA8876 CS``
## [9.2.0.1] 20201229
### Added

View File

@ -58,6 +58,8 @@ 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)
@ -71,8 +73,15 @@ The attached binaries can also be downloaded from http://ota.tasmota.com/tasmota
- Basic support for ESP32 Odroid Go 16MB binary tasmota32-odroidgo.bin [#8630](https://github.com/arendst/Tasmota/issues/8630)
### 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 MFRC522 13.56MHz rfid card reader GPIO selection from ``SPI CS`` by ``RC522 CS``
- Replaced NRF24L01 GPIO selection from ``SPI CS`` by ``NRF24 CS`` and ``SPI DC`` by ``NRF24 DC``
- Replaced ILI9341 GPIO selection from ``SPI CS`` by ``ILI9341 CS`` and ``SPI DC`` by ``ILI9341 DC``
- Replaced ST7789 GPIO selection from ``SPI CS`` by ``ST7789 CS`` and ``SPI DC`` by ``ST7789 DC``
- Replaced ILI9488 GPIO selection from ``SPI CS`` by ``ILI9488_CS``
- Replaced EPaper29 GPIO selection from ``SPI CS`` by ``EPaper29 CS``
- Replaced EPaper42 GPIO selection from ``SPI CS`` by ``EPaper42 CS``
- Replaced SSD1351 GPIO selection from ``SPI CS`` by ``SSD1351 CS``
- Replaced RA8876 GPIO selection from ``SPI CS`` by ``RA8876 CS``
### Changed
- Logging from heap to stack freeing 700 bytes RAM

View File

@ -1479,8 +1479,7 @@ 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
}
@ -1495,8 +1494,7 @@ 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
@ -1505,6 +1503,17 @@ 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}
@ -2106,6 +2115,25 @@ void AddLogBufferSize(uint32_t loglevel, uint8_t *buffer, uint32_t count, uint32
AddLogData(loglevel, log_data);
}
void AddLogSpi(bool hardware, uint32_t clk, uint32_t mosi, uint32_t miso) {
// Needs optimization
uint32_t enabled = (hardware) ? TasmotaGlobal.spi_enabled : TasmotaGlobal.soft_spi_enabled;
switch(enabled) {
case SPI_MOSI:
AddLog_P(LOG_LEVEL_INFO, PSTR("SPI: %s using GPIO%02d(CLK) and GPIO%02d(MOSI)"),
(hardware) ? PSTR("Hardware") : PSTR("Software"), clk, mosi);
break;
case SPI_MISO:
AddLog_P(LOG_LEVEL_INFO, PSTR("SPI: %s using GPIO%02d(CLK) and GPIO%02d(MISO)"),
(hardware) ? PSTR("Hardware") : PSTR("Software"), clk, miso);
break;
case SPI_MOSI_MISO:
AddLog_P(LOG_LEVEL_INFO, PSTR("SPI: %s using GPIO%02d(CLK), GPIO%02d(MOSI) and GPIO%02d(MISO)"),
(hardware) ? PSTR("Hardware") : PSTR("Software"), clk, mosi, miso);
break;
}
}
/*********************************************************************************************\
* Uncompress static PROGMEM strings
\*********************************************************************************************/

View File

@ -1596,29 +1596,33 @@ void GpioInit(void)
if ((2 == Pin(GPIO_TXD)) || (H801 == TasmotaGlobal.module_type)) { Serial.set_tx(2); }
#endif
TasmotaGlobal.soft_spi_enabled = (PinUsed(GPIO_SSPI_SCLK) && (PinUsed(GPIO_SSPI_MOSI) || PinUsed(GPIO_SSPI_MISO)));
uint32_t sspi_mosi = (PinUsed(GPIO_SSPI_SCLK) && PinUsed(GPIO_SSPI_MOSI)) ? SPI_MOSI : SPI_NONE;
uint32_t sspi_miso = (PinUsed(GPIO_SSPI_SCLK) && PinUsed(GPIO_SSPI_MISO)) ? SPI_MISO : SPI_NONE;
TasmotaGlobal.soft_spi_enabled = sspi_mosi + sspi_miso;
AddLogSpi(0, Pin(GPIO_SSPI_SCLK), Pin(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) {
// 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));
}
bool valid_cs = (ValidSpiGPIO(GPIO_SPI_CS) &&
ValidSpiGPIO(GPIO_RC522_CS) &&
ValidSpiGPIO(GPIO_NRF24_CS) &&
ValidSpiGPIO(GPIO_ILI9341_CS) &&
ValidSpiGPIO(GPIO_EPAPER29_CS) &&
ValidSpiGPIO(GPIO_EPAPER42_CS) &&
ValidSpiGPIO(GPIO_ILI9488_CS) &&
ValidSpiGPIO(GPIO_SSD1351_CS) &&
ValidSpiGPIO(GPIO_RA8876_CS) &&
ValidSpiGPIO(GPIO_ST7789_CS)
);
bool valid_dc = (ValidSpiGPIO(GPIO_SPI_DC) &&
ValidSpiGPIO(GPIO_NRF24_DC) &&
ValidSpiGPIO(GPIO_ILI9341_DC) &&
ValidSpiGPIO(GPIO_ST7789_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;
if (TasmotaGlobal.spi_enabled) {
TasmotaGlobal.my_module.io[12] = AGPIO(GPIO_SPI_MISO);
SetPin(12, AGPIO(GPIO_SPI_MISO));
@ -1626,65 +1630,27 @@ void GpioInit(void)
SetPin(13, AGPIO(GPIO_SPI_MOSI));
TasmotaGlobal.my_module.io[14] = AGPIO(GPIO_SPI_CLK);
SetPin(14, AGPIO(GPIO_SPI_CLK));
AddLog_P(LOG_LEVEL_DEBUG, PSTR("SPI: Using GPIO12(MISO), GPIO13(MOSI) and GPIO14(CLK)"));
}
}
#endif // ESP8266
#ifdef ESP32
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 ((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 ((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));
}
}
if (PinUsed(GPIO_SPI_CS) ||
PinUsed(GPIO_RC522_CS) ||
PinUsed(GPIO_NRF24_CS) ||
PinUsed(GPIO_ILI9341_CS) ||
PinUsed(GPIO_EPAPER29_CS) ||
PinUsed(GPIO_EPAPER42_CS) ||
PinUsed(GPIO_ILI9488_CS) ||
PinUsed(GPIO_SSD1351_CS) ||
PinUsed(GPIO_RA8876_CS) ||
PinUsed(GPIO_ST7789_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;
TasmotaGlobal.spi_enabled = spi_mosi + spi_miso;
}
#endif // ESP32
AddLogSpi(1, Pin(GPIO_SPI_CLK), Pin(GPIO_SPI_MOSI), Pin(GPIO_SPI_MISO));
#endif // USE_SPI
for (uint32_t i = 0; i < ARRAY_SIZE(TasmotaGlobal.my_module.io); i++) {

View File

@ -313,6 +313,8 @@ enum SettingsTextIndex { SET_OTAURL,
SET_SHD_PARAM,
SET_MAX };
enum SpiInterfaces { SPI_NONE, SPI_MOSI, SPI_MISO, SPI_MOSI_MISO };
enum DevGroupMessageType { DGR_MSGTYP_FULL_STATUS, DGR_MSGTYP_PARTIAL_UPDATE, DGR_MSGTYP_UPDATE, DGR_MSGTYP_UPDATE_MORE_TO_COME, DGR_MSGTYP_UPDATE_DIRECT, DGR_MSGTYPE_UPDATE_COMMAND, DGR_MSGTYPFLAG_WITH_LOCAL = 128 };
enum DevGroupMessageFlag { DGR_FLAG_RESET = 1, DGR_FLAG_STATUS_REQUEST = 2, DGR_FLAG_FULL_STATUS = 4, DGR_FLAG_ACK = 8, DGR_FLAG_MORE_TO_COME = 16, DGR_FLAG_DIRECT = 32, DGR_FLAG_ANNOUNCEMENT = 64, DGR_FLAG_LOCAL = 128 };

View File

@ -119,8 +119,6 @@ struct {
bool blinkstate; // LED state
bool pwm_present; // Any PWM channel configured with SetOption15 0
bool i2c_enabled; // I2C configured
bool spi_enabled; // SPI configured
bool soft_spi_enabled; // Software SPI configured
bool ntp_force_sync; // Force NTP sync
bool is_8285; // Hardware device ESP8266EX (0) or ESP8285 (1)
bool skip_light_fade; // Temporarily skip light fading
@ -128,6 +126,8 @@ struct {
bool module_changed; // Indicate module changed since last restart
StateBitfield global_state; // Global states (currently Wifi and Mqtt) (8 bits)
uint8_t spi_enabled; // SPI configured
uint8_t soft_spi_enabled; // Software SPI configured
uint8_t blinks; // Number of LED blinks
uint8_t restart_flag; // Tasmota restart flag
uint8_t ota_state_flag; // OTA state flag

View File

@ -46,6 +46,11 @@
#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

View File

@ -365,8 +365,8 @@ const uint16_t kGpioNiceList[] PROGMEM = {
AGPIO(GPIO_SPI_CS), // SPI Chip Select
AGPIO(GPIO_SPI_DC), // SPI Data Direction
#ifdef USE_NRF24
// AGPIO(GPIO_NRF24_CS),
// AGPIO(GPIO_NRF24_DC),
AGPIO(GPIO_NRF24_CS),
AGPIO(GPIO_NRF24_DC),
#endif
#ifdef USE_RC522
AGPIO(GPIO_RC522_CS), // RC522 Rfid Chip Select
@ -386,23 +386,23 @@ const uint16_t kGpioNiceList[] PROGMEM = {
AGPIO(GPIO_SSPI_DC), // Software SPI Data or Command
#ifdef USE_DISPLAY
#ifdef USE_DISPLAY_ILI9488
// AGPIO(GPIO_ILI9488_CS),
AGPIO(GPIO_ILI9488_CS),
#endif // USE_DISPLAY_ILI9488
#ifdef USE_DISPLAY_EPAPER_29
// AGPIO(GPIO_EPAPER29_CS),
AGPIO(GPIO_EPAPER29_CS),
#endif // USE_DISPLAY_EPAPER_29
#ifdef USE_DISPLAY_EPAPER_42
// AGPIO(GPIO_EPAPER42_CS),
AGPIO(GPIO_EPAPER42_CS),
#endif // USE_DISPLAY_EPAPER_42
#ifdef USE_DISPLAY_SSD1351
// AGPIO(GPIO_SSD1351_CS),
AGPIO(GPIO_SSD1351_CS),
#endif // USE_DISPLAY_SSD1351
#ifdef USE_DISPLAY_RA8876
// AGPIO(GPIO_RA8876_CS),
AGPIO(GPIO_RA8876_CS),
#endif // USE_DISPLAY_RA8876
#ifdef USE_DISPLAY_ST7789
// AGPIO(GPIO_ST7789_CS),
// AGPIO(GPIO_ST7789_DC),
AGPIO(GPIO_ST7789_CS),
AGPIO(GPIO_ST7789_DC),
#endif //f USE_DISPLAY_ST7789
AGPIO(GPIO_BACKLIGHT), // Display backlight control
AGPIO(GPIO_OLED_RESET), // OLED Display Reset

View File

@ -34,7 +34,7 @@
/*********************************************************************************************\
* NRF24l01(+)
*
* Usage: 5 SPI-data-wires plus VVC/ground, use hardware SPI, select GPIO_SPI_CS/GPIO_SPI_DC
* Usage: 5 SPI-data-wires plus VVC/ground, use hardware SPI, select GPIO_NRF24_CS/GPIO_NRF24_DC
\*********************************************************************************************/
#define XDRV_33 33
@ -51,45 +51,40 @@ struct {
RF24 NRF24radio;
bool NRF24initRadio()
{
NRF24radio.begin(Pin(GPIO_SPI_CS),Pin(GPIO_SPI_DC));
bool NRF24initRadio() {
NRF24radio.begin(Pin(GPIO_NRF24_CS), Pin(GPIO_NRF24_DC));
NRF24radio.powerUp();
if(NRF24radio.isChipConnected()){
DEBUG_DRIVER_LOG(PSTR("NRF24 chip connected"));
if (NRF24radio.isChipConnected()) {
DEBUG_DRIVER_LOG(PSTR("NRF: Chip connected"));
return true;
}
DEBUG_DRIVER_LOG(PSTR("NRF24 chip NOT !!!! connected"));
DEBUG_DRIVER_LOG(PSTR("NRF: Chip NOT !!!! connected"));
return false;
}
bool NRF24Detect(void)
{
if (PinUsed(GPIO_SPI_CS) && PinUsed(GPIO_SPI_DC)) {
if(NRF24initRadio()){
void NRF24Detect(void) {
if (PinUsed(GPIO_NRF24_CS) && PinUsed(GPIO_NRF24_DC) && TasmotaGlobal.spi_enabled) {
if (NRF24initRadio()) {
NRF24.chipType = 32; // SPACE
AddLog_P(LOG_LEVEL_INFO,PSTR("NRF24L01 initialized"));
if(NRF24radio.isPVariant()){
AddLog_P(LOG_LEVEL_INFO, PSTR("NRF: Model 24L01 initialized"));
if (NRF24radio.isPVariant()) {
NRF24.chipType = 43; // +
AddLog_P(LOG_LEVEL_INFO,PSTR("NRF24L01+ detected"));
AddLog_P(LOG_LEVEL_INFO, PSTR("NRF: Model 24L01+ detected"));
}
return true;
}
}
return false;
}
/*********************************************************************************************\
* Interface
\*********************************************************************************************/
bool Xdrv33(uint8_t function)
{
bool Xdrv33(uint8_t function) {
bool result = false;
if (FUNC_INIT == function) {
result = NRF24Detect();
NRF24Detect();
}
return result;
}

View File

@ -38,6 +38,7 @@ uint16_t tft_top = TFT_TOP;
uint16_t tft_bottom = TFT_BOTTOM;
uint16_t tft_scroll = TFT_TOP;
uint16_t tft_cols = 0;
bool tft_init_done = false;
/*********************************************************************************************/
@ -57,8 +58,7 @@ 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);
@ -78,8 +78,7 @@ void Ili9341InitMode(void)
}
}
void Ili9341Init(uint8_t mode)
{
void Ili9341Init(uint8_t mode) {
switch(mode) {
case DISPLAY_INIT_MODE:
Ili9341InitMode();
@ -95,24 +94,11 @@ void Ili9341Init(uint8_t mode)
}
}
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;
}
void Ili9341InitDriver(void) {
if (PinUsed(GPIO_ILI9341_CS) && PinUsed(GPIO_ILI9341_DC) && TasmotaGlobal.spi_enabled) {
// Legacy
Settings.display_model = XDSP_04;
}
if (XDSP_04 == Settings.display_model) {
if (Settings.display_width != ILI9341_TFTWIDTH) {
Settings.display_width = ILI9341_TFTWIDTH;
}
@ -120,7 +106,7 @@ void Ili9341InitDriver(void)
Settings.display_height = ILI9341_TFTHEIGHT;
}
tft = new Adafruit_ILI9341(pin_cs, pin_dc);
tft = new Adafruit_ILI9341(Pin(GPIO_ILI9341_CS), Pin(GPIO_ILI9341_DC));
tft->begin();
#ifdef USE_DISPLAY_MODES1TO5
@ -131,18 +117,17 @@ void Ili9341InitDriver(void)
Ili9341InitMode();
tft_init_done = true;
AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: ILI9341"));
}
}
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);
@ -156,8 +141,7 @@ 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)) {
@ -170,8 +154,7 @@ void Ili9341DisplayOnOff()
#ifdef USE_DISPLAY_MODES1TO5
void Ili9341PrintLog(void)
{
void Ili9341PrintLog(void) {
disp_refresh--;
if (!disp_refresh) {
disp_refresh = Settings.display_refresh;
@ -217,8 +200,7 @@ 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
@ -263,73 +245,70 @@ void Ili9341Refresh(void) // Every second
* Interface
\*********************************************************************************************/
bool Xdsp04(uint8_t function)
{
bool Xdsp04(uint8_t function) {
bool result = false;
if (TasmotaGlobal.spi_enabled) {
if (FUNC_DISPLAY_INIT_DRIVER == function) {
Ili9341InitDriver();
}
else if (XDSP_04 == Settings.display_model) {
if (FUNC_DISPLAY_INIT_DRIVER == function) {
Ili9341InitDriver();
}
else if (tft_init_done && (XDSP_04 == Settings.display_model)) {
if (!dsp_color) { dsp_color = ILI9341_WHITE; }
if (!dsp_color) { dsp_color = ILI9341_WHITE; }
switch (function) {
case FUNC_DISPLAY_MODEL:
result = true;
break;
case FUNC_DISPLAY_INIT:
Ili9341Init(dsp_init);
break;
case FUNC_DISPLAY_POWER:
Ili9341DisplayOnOff();
break;
case FUNC_DISPLAY_CLEAR:
Ili9341Clear();
break;
case FUNC_DISPLAY_DRAW_HLINE:
tft->writeFastHLine(dsp_x, dsp_y, dsp_len, dsp_color);
break;
case FUNC_DISPLAY_DRAW_VLINE:
tft->writeFastVLine(dsp_x, dsp_y, dsp_len, dsp_color);
break;
case FUNC_DISPLAY_DRAW_LINE:
tft->writeLine(dsp_x, dsp_y, dsp_x2, dsp_y2, dsp_color);
break;
case FUNC_DISPLAY_DRAW_CIRCLE:
tft->drawCircle(dsp_x, dsp_y, dsp_rad, dsp_color);
break;
case FUNC_DISPLAY_FILL_CIRCLE:
tft->fillCircle(dsp_x, dsp_y, dsp_rad, dsp_color);
break;
case FUNC_DISPLAY_DRAW_RECTANGLE:
tft->drawRect(dsp_x, dsp_y, dsp_x2, dsp_y2, dsp_color);
break;
case FUNC_DISPLAY_FILL_RECTANGLE:
tft->fillRect(dsp_x, dsp_y, dsp_x2, dsp_y2, dsp_color);
break;
switch (function) {
case FUNC_DISPLAY_MODEL:
result = true;
break;
case FUNC_DISPLAY_INIT:
Ili9341Init(dsp_init);
break;
case FUNC_DISPLAY_POWER:
Ili9341DisplayOnOff();
break;
case FUNC_DISPLAY_CLEAR:
Ili9341Clear();
break;
case FUNC_DISPLAY_DRAW_HLINE:
tft->writeFastHLine(dsp_x, dsp_y, dsp_len, dsp_color);
break;
case FUNC_DISPLAY_DRAW_VLINE:
tft->writeFastVLine(dsp_x, dsp_y, dsp_len, dsp_color);
break;
case FUNC_DISPLAY_DRAW_LINE:
tft->writeLine(dsp_x, dsp_y, dsp_x2, dsp_y2, dsp_color);
break;
case FUNC_DISPLAY_DRAW_CIRCLE:
tft->drawCircle(dsp_x, dsp_y, dsp_rad, dsp_color);
break;
case FUNC_DISPLAY_FILL_CIRCLE:
tft->fillCircle(dsp_x, dsp_y, dsp_rad, dsp_color);
break;
case FUNC_DISPLAY_DRAW_RECTANGLE:
tft->drawRect(dsp_x, dsp_y, dsp_x2, dsp_y2, dsp_color);
break;
case FUNC_DISPLAY_FILL_RECTANGLE:
tft->fillRect(dsp_x, dsp_y, dsp_x2, dsp_y2, dsp_color);
break;
// case FUNC_DISPLAY_DRAW_FRAME:
// oled->display();
// break;
case FUNC_DISPLAY_TEXT_SIZE:
tft->setTextSize(Settings.display_size);
break;
case FUNC_DISPLAY_FONT_SIZE:
case FUNC_DISPLAY_TEXT_SIZE:
tft->setTextSize(Settings.display_size);
break;
case FUNC_DISPLAY_FONT_SIZE:
// tft->setTextSize(Settings.display_font);
break;
case FUNC_DISPLAY_DRAW_STRING:
Ili9341DrawStringAt(dsp_x, dsp_y, dsp_str, dsp_color, dsp_flag);
break;
case FUNC_DISPLAY_ROTATION:
tft->setRotation(Settings.display_rotate);
break;
break;
case FUNC_DISPLAY_DRAW_STRING:
Ili9341DrawStringAt(dsp_x, dsp_y, dsp_str, dsp_color, dsp_flag);
break;
case FUNC_DISPLAY_ROTATION:
tft->setRotation(Settings.display_rotate);
break;
#ifdef USE_DISPLAY_MODES1TO5
case FUNC_DISPLAY_EVERY_SECOND:
Ili9341Refresh();
break;
case FUNC_DISPLAY_EVERY_SECOND:
Ili9341Refresh();
break;
#endif // USE_DISPLAY_MODES1TO5
}
}
}
return result;

View File

@ -39,18 +39,18 @@
//unsigned char image[(EPD_HEIGHT * EPD_WIDTH) / 8];
extern uint8_t *buffer;
uint16_t epd_scroll;
bool epd_init_done = false;
Epd *epd;
/*********************************************************************************************/
void EpdInitDriver29()
{
if (!Settings.display_model) {
Settings.display_model = XDSP_05;
}
void EpdInitDriver29(void) {
if (PinUsed(GPIO_EPAPER29_CS) &&
((TasmotaGlobal.soft_spi_enabled & SPI_MOSI) || (TasmotaGlobal.spi_enabled & SPI_MOSI))) {
Settings.display_model = XDSP_05;
if (XDSP_05 == Settings.display_model) {
if (Settings.display_width != EPD_WIDTH) {
Settings.display_width = EPD_WIDTH;
}
@ -64,19 +64,14 @@ void EpdInitDriver29()
if (!buffer) return;
// init renderer
epd = new Epd(EPD_WIDTH,EPD_HEIGHT);
epd = new Epd(EPD_WIDTH, EPD_HEIGHT);
// whiten display with full update, takes 3 seconds
if (PinUsed(GPIO_SPI_CS) && PinUsed(GPIO_SPI_CLK) && PinUsed(GPIO_SPI_MOSI)) {
epd->Begin(Pin(GPIO_SPI_CS),Pin(GPIO_SPI_MOSI),Pin(GPIO_SPI_CLK));
AddLog_P(LOG_LEVEL_DEBUG, PSTR("EPD: HardSPI CS %d, CLK %d, MOSI %d"),Pin(GPIO_SPI_CS), Pin(GPIO_SPI_CLK), Pin(GPIO_SPI_MOSI));
if (TasmotaGlobal.soft_spi_enabled) {
epd->Begin(Pin(GPIO_EPAPER29_CS), Pin(GPIO_SSPI_MOSI), Pin(GPIO_SSPI_SCLK));
}
else if (PinUsed(GPIO_SSPI_CS) && PinUsed(GPIO_SSPI_SCLK) && PinUsed(GPIO_SSPI_MOSI)) {
epd->Begin(Pin(GPIO_SSPI_CS),Pin(GPIO_SSPI_MOSI),Pin(GPIO_SSPI_SCLK));
AddLog_P(LOG_LEVEL_DEBUG, PSTR("EPD: SoftSPI CS %d, CLK %d, MOSI %d"),Pin(GPIO_SSPI_CS), Pin(GPIO_SSPI_SCLK), Pin(GPIO_SSPI_MOSI));
} else {
free(buffer);
return;
else if (TasmotaGlobal.spi_enabled) {
epd->Begin(Pin(GPIO_EPAPER29_CS), Pin(GPIO_SPI_MOSI), Pin(GPIO_SPI_CLK));
}
renderer = epd;
@ -95,6 +90,8 @@ void EpdInitDriver29()
renderer->fillScreen(0);
#endif
epd_init_done = true;
AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: E-Paper 2.9"));
}
}
@ -186,21 +183,22 @@ void EpdRefresh29(void) // Every second
bool Xdsp05(uint8_t function)
{
bool result = false;
if (FUNC_DISPLAY_INIT_DRIVER == function) {
EpdInitDriver29();
}
else if (XDSP_05 == Settings.display_model) {
switch (function) {
case FUNC_DISPLAY_MODEL:
result = true;
break;
if (FUNC_DISPLAY_INIT_DRIVER == function) {
EpdInitDriver29();
}
else if (epd_init_done && (XDSP_05 == Settings.display_model)) {
switch (function) {
case FUNC_DISPLAY_MODEL:
result = true;
break;
#ifdef USE_DISPLAY_MODES1TO5
case FUNC_DISPLAY_EVERY_SECOND:
EpdRefresh29();
break;
case FUNC_DISPLAY_EVERY_SECOND:
EpdRefresh29();
break;
#endif // USE_DISPLAY_MODES1TO5
}
}
}
return result;
}

View File

@ -35,19 +35,18 @@
#include <epdpaint.h>
extern uint8_t *buffer;
bool epd42_init_done = false;
Epd42 *epd42;
/*********************************************************************************************/
void EpdInitDriver42()
{
if (!Settings.display_model) {
Settings.display_model = XDSP_06;
}
void EpdInitDriver42() {
if (PinUsed(GPIO_EPAPER42_CS) &&
((TasmotaGlobal.soft_spi_enabled & SPI_MOSI) || (TasmotaGlobal.spi_enabled & SPI_MOSI))) {
if (XDSP_06 == Settings.display_model) {
Settings.display_model = XDSP_06;
if (Settings.display_width != EPD_WIDTH42) {
Settings.display_width = EPD_WIDTH42;
@ -62,23 +61,14 @@ void EpdInitDriver42()
if (!buffer) return;
// init renderer
epd42 = new Epd42(EPD_WIDTH42,EPD_HEIGHT42);
epd42 = new Epd42(EPD_WIDTH42, EPD_HEIGHT42);
#ifdef USE_SPI
if (PinUsed(GPIO_SSPI_CS) && PinUsed(GPIO_SSPI_MOSI) && PinUsed(GPIO_SSPI_SCLK)) {
epd42->Begin(Pin(GPIO_SSPI_CS),Pin(GPIO_SSPI_MOSI),Pin(GPIO_SSPI_SCLK));
} else {
free(buffer);
return;
}
#else
if (PinUsed(GPIO_SPI_CS) && PinUsed(GPIO_SPI_MOSI) && PinUsed(GPIO_SPI_CLK)) {
epd42->Begin(Pin(GPIO_SPI_CS),Pin(GPIO_SPI_MOSI),Pin(GPIO_SPI_CLK));
} else {
free(buffer);
return;
}
#endif
if (TasmotaGlobal.soft_spi_enabled) {
epd42->Begin(Pin(GPIO_EPAPER42_CS), Pin(GPIO_SSPI_MOSI), Pin(GPIO_SSPI_SCLK));
}
else if (TasmotaGlobal.spi_enabled) {
epd42->Begin(Pin(GPIO_EPAPER42_CS), Pin(GPIO_SPI_MOSI), Pin(GPIO_SPI_CLK));
}
renderer = epd42;
@ -105,6 +95,8 @@ void EpdInitDriver42()
renderer->fillScreen(0);
#endif
epd42_init_done = true;
AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: E-Paper 4.2"));
}
}
@ -134,27 +126,24 @@ bool Xdsp06(uint8_t function)
{
bool result = false;
if (FUNC_DISPLAY_INIT_DRIVER == function) {
EpdInitDriver42();
}
else if (XDSP_06 == Settings.display_model) {
switch (function) {
case FUNC_DISPLAY_MODEL:
result = true;
break;
if (FUNC_DISPLAY_INIT_DRIVER == function) {
EpdInitDriver42();
}
else if (epd42_init_done && (XDSP_06 == Settings.display_model)) {
switch (function) {
case FUNC_DISPLAY_MODEL:
result = true;
break;
#ifdef USE_DISPLAY_MODES1TO5
case FUNC_DISPLAY_EVERY_SECOND:
EpdRefresh42();
break;
case FUNC_DISPLAY_EVERY_SECOND:
EpdRefresh42();
break;
#endif // USE_DISPLAY_MODES1TO5
}
}
}
return result;
}
#endif // USE_DISPLAY_EPAPER42
#endif // USE_DISPLAY
#endif // USE_SPI

View File

@ -34,6 +34,7 @@
#include <ILI9488.h>
uint8_t ili9488_ctouch_counter = 0;
bool ili9488_init_done = false;
// currently fixed
#define BACKPLANE_PIN 2
@ -45,13 +46,10 @@ extern const uint16_t picture[];
/*********************************************************************************************/
void ILI9488_InitDriver()
{
if (!Settings.display_model) {
Settings.display_model = XDSP_08;
}
void ILI9488_InitDriver(void) {
if (PinUsed(GPIO_ILI9488_CS) && (TasmotaGlobal.spi_enabled & SPI_MOSI)) {
if (XDSP_08 == Settings.display_model) {
Settings.display_model = XDSP_08;
if (Settings.display_width != ILI9488_TFTWIDTH) {
Settings.display_width = ILI9488_TFTWIDTH;
@ -61,44 +59,19 @@ void ILI9488_InitDriver()
}
// disable screen buffer
buffer=NULL;
buffer = NULL;
// default colors
fg_color = ILI9488_WHITE;
bg_color = ILI9488_BLACK;
uint8_t bppin=BACKPLANE_PIN;
if (PinUsed(GPIO_BACKLIGHT)) {
bppin=Pin(GPIO_BACKLIGHT);
uint8_t bppin = BACKPLANE_PIN;
if (PinUsed(GPIO_BACKLIGHT)) {
bppin = Pin(GPIO_BACKLIGHT);
}
#ifdef ESP8266
#undef HW_SPI_MOSI
#define HW_SPI_MOSI 13
#undef HW_SPI_MISO
#define HW_SPI_MISO 12
#undef HW_SPI_CLK
#define HW_SPI_CLK 14
#endif // ESP8266
#ifdef ESP32
#undef HW_SPI_MOSI
#define HW_SPI_MOSI 23
#undef HW_SPI_MISO
#define HW_SPI_MISO 19
#undef HW_SPI_CLK
#define HW_SPI_CLK 18
#endif // ESP32
// init renderer, must use hardware spi
if (PinUsed(GPIO_SSPI_CS) && (Pin(GPIO_SSPI_MOSI)==HW_SPI_MOSI) && (Pin(GPIO_SSPI_SCLK)==HW_SPI_CLK)) {
ili9488 = new ILI9488(Pin(GPIO_SSPI_CS),Pin(GPIO_SSPI_MOSI),Pin(GPIO_SSPI_SCLK),bppin);
} else {
if (PinUsed(GPIO_SPI_CS) && (Pin(GPIO_SPI_MOSI)==HW_SPI_MOSI) && (Pin(GPIO_SPI_CLK)==HW_SPI_CLK)) {
ili9488 = new ILI9488(Pin(GPIO_SPI_CS),Pin(GPIO_SPI_MOSI),Pin(GPIO_SPI_CLK),bppin);
} else {
return;
}
}
ili9488 = new ILI9488(Pin(GPIO_ILI9488_CS), Pin(GPIO_SPI_MOSI), Pin(GPIO_SPI_CLK), bppin);
ili9488->begin();
renderer = ili9488;
@ -120,6 +93,9 @@ void ILI9488_InitDriver()
#ifdef USE_FT5206
Touch_Init(Wire);
#endif
ili9488_init_done = true;
AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: ILI9488"));
}
}
@ -170,25 +146,23 @@ bool Xdsp08(uint8_t function)
{
bool result = false;
if (FUNC_DISPLAY_INIT_DRIVER == function) {
ILI9488_InitDriver();
}
else if (XDSP_08 == Settings.display_model) {
switch (function) {
case FUNC_DISPLAY_MODEL:
result = true;
break;
case FUNC_DISPLAY_EVERY_50_MSECOND:
if (FUNC_DISPLAY_INIT_DRIVER == function) {
ILI9488_InitDriver();
}
else if (ili9488_init_done && (XDSP_08 == Settings.display_model)) {
switch (function) {
case FUNC_DISPLAY_MODEL:
result = true;
break;
case FUNC_DISPLAY_EVERY_50_MSECOND:
#ifdef USE_TOUCH_BUTTONS
if (FT5206_found) {
ILI9488_CheckTouch();
}
if (FT5206_found) {
ILI9488_CheckTouch();
}
#endif
break;
}
break;
}
//}
}
return result;
}

View File

@ -33,6 +33,7 @@
#include <SSD1351.h>
bool ssd1351_init_done = false;
extern uint8_t *buffer;
extern uint8_t color_type;
SSD1351 *ssd1351;
@ -40,11 +41,10 @@ SSD1351 *ssd1351;
/*********************************************************************************************/
void SSD1351_InitDriver() {
if (!Settings.display_model) {
Settings.display_model = XDSP_09;
}
if (PinUsed(GPIO_SSD1351_CS) &&
((TasmotaGlobal.soft_spi_enabled & SPI_MOSI) || (TasmotaGlobal.spi_enabled & SPI_MOSI))) {
if (XDSP_09 == Settings.display_model) {
Settings.display_model = XDSP_09;
if (Settings.display_width != SSD1351_WIDTH) {
Settings.display_width = SSD1351_WIDTH;
@ -53,21 +53,18 @@ void SSD1351_InitDriver() {
Settings.display_height = SSD1351_HEIGHT;
}
buffer=0;
buffer = 0;
// default colors
fg_color = SSD1351_WHITE;
bg_color = SSD1351_BLACK;
// init renderer
if (PinUsed(GPIO_SSPI_CS) && PinUsed(GPIO_SSPI_MOSI) && PinUsed(GPIO_SSPI_SCLK)){
ssd1351 = new SSD1351(Pin(GPIO_SSPI_CS),Pin(GPIO_SSPI_MOSI),Pin(GPIO_SSPI_SCLK));
} else {
if (PinUsed(GPIO_SPI_CS) && PinUsed(GPIO_SPI_MOSI) && PinUsed(GPIO_SPI_CLK)) {
ssd1351 = new SSD1351(Pin(GPIO_SPI_CS),Pin(GPIO_SPI_MOSI),Pin(GPIO_SPI_CLK));
} else {
return;
}
if (TasmotaGlobal.soft_spi_enabled){
ssd1351 = new SSD1351(Pin(GPIO_SSD1351_CS), Pin(GPIO_SSPI_MOSI), Pin(GPIO_SSPI_SCLK));
}
else if (TasmotaGlobal.spi_enabled) {
ssd1351 = new SSD1351(Pin(GPIO_SSD1351_CS), Pin(GPIO_SPI_MOSI), Pin(GPIO_SPI_CLK));
}
delay(100);
@ -85,6 +82,9 @@ void SSD1351_InitDriver() {
#endif
color_type = COLOR_COLOR;
ssd1351_init_done = true;
AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: SSD1351"));
}
}
@ -162,7 +162,7 @@ bool Xdsp09(uint8_t function)
if (FUNC_DISPLAY_INIT_DRIVER == function) {
SSD1351_InitDriver();
}
else if (XDSP_09 == Settings.display_model) {
else if (ssd1351_init_done && (XDSP_09 == Settings.display_model)) {
switch (function) {
case FUNC_DISPLAY_MODEL:
result = true;

View File

@ -33,19 +33,17 @@
#include <RA8876.h>
bool ra8876_init_done = false;
uint8_t ra8876_ctouch_counter = 0;
extern uint8_t *buffer;
extern uint8_t color_type;
RA8876 *ra8876;
/*********************************************************************************************/
void RA8876_InitDriver()
{
if (!Settings.display_model) {
Settings.display_model = XDSP_10;
}
void RA8876_InitDriver(void) {
if (PinUsed(GPIO_RA8876_CS) && (SPI_MOSI_MISO == TasmotaGlobal.spi_enabled)) {
if (XDSP_10 == Settings.display_model) {
Settings.display_model = XDSP_10;
if (Settings.display_width != RA8876_TFTWIDTH) {
Settings.display_width = RA8876_TFTWIDTH;
@ -53,39 +51,15 @@ void RA8876_InitDriver()
if (Settings.display_height != RA8876_TFTHEIGHT) {
Settings.display_height = RA8876_TFTHEIGHT;
}
buffer=0;
buffer = 0;
// default colors
fg_color = RA8876_WHITE;
bg_color = RA8876_BLACK;
#ifdef ESP8266
#undef HW_SPI_MOSI
#define HW_SPI_MOSI 13
#undef HW_SPI_MISO
#define HW_SPI_MISO 12
#undef HW_SPI_CLK
#define HW_SPI_CLK 14
#endif // ESP8266
#ifdef ESP32
#undef HW_SPI_MOSI
#define HW_SPI_MOSI 23
#undef HW_SPI_MISO
#define HW_SPI_MISO 19
#undef HW_SPI_CLK
#define HW_SPI_CLK 18
#endif // ESP32
// init renderer, must use hardware spi
if (PinUsed(GPIO_SSPI_CS) && (Pin(GPIO_SSPI_MOSI)==HW_SPI_MOSI) && (Pin(GPIO_SSPI_MISO)==HW_SPI_MISO) && (Pin(GPIO_SSPI_SCLK)==HW_SPI_CLK)) {
ra8876 = new RA8876(Pin(GPIO_SSPI_CS),Pin(GPIO_SSPI_MOSI),Pin(GPIO_SSPI_MISO),Pin(GPIO_SSPI_SCLK),Pin(GPIO_BACKLIGHT));
} else {
if (PinUsed(GPIO_SPI_CS) && (Pin(GPIO_SPI_MOSI)==HW_SPI_MOSI) && (Pin(GPIO_SPI_MISO)==HW_SPI_MISO) && (Pin(GPIO_SPI_CLK)==HW_SPI_CLK)) {
ra8876 = new RA8876(Pin(GPIO_SPI_CS),Pin(GPIO_SPI_MOSI),Pin(GPIO_SPI_MISO),Pin(GPIO_SPI_CLK),Pin(GPIO_BACKLIGHT));
} else {
return;
}
}
ra8876 = new RA8876(Pin(GPIO_RA8876_CS), Pin(GPIO_SPI_MOSI), Pin(GPIO_SPI_MISO), Pin(GPIO_SPI_CLK), Pin(GPIO_BACKLIGHT));
ra8876->begin();
renderer = ra8876;
@ -107,6 +81,8 @@ void RA8876_InitDriver()
Touch_Init(Wire);
#endif
ra8876_init_done = true;
AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: RA8876"));
}
}
@ -329,7 +305,7 @@ bool Xdsp10(uint8_t function)
if (FUNC_DISPLAY_INIT_DRIVER == function) {
RA8876_InitDriver();
}
else if (XDSP_10 == Settings.display_model) {
else if (ra8876_init_done && (XDSP_10 == Settings.display_model)) {
switch (function) {
case FUNC_DISPLAY_MODEL:
result = true;

View File

@ -53,16 +53,15 @@ Arduino_ST7789 *st7789;
#ifdef USE_FT5206
uint8_t st7789_ctouch_counter = 0;
#endif // USE_FT5206
bool st7789_init_done = false;
/*********************************************************************************************/
void ST7789_InitDriver()
{
if (!Settings.display_model) {
Settings.display_model = XDSP_12;
}
void ST7789_InitDriver(void) {
if (PinUsed(GPIO_ST7789_CS) && PinUsed(GPIO_ST7789_DC) &&
((TasmotaGlobal.soft_spi_enabled & SPI_MOSI) || (TasmotaGlobal.spi_enabled & SPI_MOSI))) {
if (XDSP_12 == Settings.display_model) {
Settings.display_model = XDSP_12;
if (!Settings.display_width) {
Settings.display_width = 240;
@ -72,57 +71,30 @@ void ST7789_InitDriver()
}
// disable screen buffer
buffer=NULL;
buffer = NULL;
// default colors
fg_color = ST7789_WHITE;
bg_color = ST7789_BLACK;
int8_t bppin=BACKPLANE_PIN;
if (PinUsed(GPIO_BACKLIGHT)) {
bppin=Pin(GPIO_BACKLIGHT);
int8_t bppin = BACKPLANE_PIN;
if (PinUsed(GPIO_BACKLIGHT)) {
bppin = Pin(GPIO_BACKLIGHT);
}
int8_t reset = -1;
if (PinUsed(GPIO_OLED_RESET)) {
reset=Pin(GPIO_OLED_RESET);
if (PinUsed(GPIO_OLED_RESET)) {
reset = Pin(GPIO_OLED_RESET);
}
int8_t cs = -1;
if (PinUsed(GPIO_SSPI_CS)) {
cs=Pin(GPIO_SSPI_CS);
} else if (PinUsed(GPIO_SPI_CS)) {
cs=Pin(GPIO_SPI_CS);
}
#ifdef ESP8266
#undef HW_SPI_MOSI
#define HW_SPI_MOSI 13
#undef HW_SPI_CLK
#define HW_SPI_CLK 14
#endif // ESP8266
#ifdef ESP32
#undef HW_SPI_MOSI
#define HW_SPI_MOSI 23
#undef HW_SPI_CLK
#define HW_SPI_CLK 18
#endif // ESP32
// init renderer, may use hardware spi
//if (PinUsed(GPIO_SPI_CS) && (Pin(GPIO_SPI_MOSI)==HW_SPI_MOSI) && (Pin(GPIO_SPI_CLK)==HW_SPI_CLK) && PinUsed(GPIO_SPI_DC)) {
if ((Pin(GPIO_SPI_MOSI)==HW_SPI_MOSI) && (Pin(GPIO_SPI_CLK)==HW_SPI_CLK) && PinUsed(GPIO_SPI_DC)) {
st7789 = new Arduino_ST7789(Pin(GPIO_SPI_DC), reset, cs, bppin);
} else {
if ((PinUsed(GPIO_SSPI_CS) || PinUsed(GPIO_OLED_RESET)) && PinUsed(GPIO_SSPI_MOSI) && PinUsed(GPIO_SSPI_SCLK) && PinUsed(GPIO_SSPI_DC)) {
if ((Pin(GPIO_SSPI_MOSI)==HW_SPI_MOSI) && (Pin(GPIO_SSPI_SCLK)==HW_SPI_CLK)) {
st7789 = new Arduino_ST7789(Pin(GPIO_SSPI_DC), reset, cs, bppin);
} else {
st7789 = new Arduino_ST7789(Pin(GPIO_SSPI_DC), reset, Pin(GPIO_SSPI_MOSI), Pin(GPIO_SSPI_SCLK), cs, bppin);
}
} else {
return;
}
if (TasmotaGlobal.soft_spi_enabled) {
st7789 = new Arduino_ST7789(Pin(GPIO_ST7789_DC), reset, Pin(GPIO_SSPI_MOSI), Pin(GPIO_SSPI_SCLK), Pin(GPIO_ST7789_CS), bppin);
}
else if (TasmotaGlobal.spi_enabled) {
st7789 = new Arduino_ST7789(Pin(GPIO_ST7789_DC), reset, Pin(GPIO_ST7789_CS), bppin);
}
st7789->init(Settings.display_width,Settings.display_height);
renderer = st7789;
renderer->DisplayInit(DISPLAY_INIT_MODE,Settings.display_size,Settings.display_rotate,Settings.display_font);
@ -154,6 +126,8 @@ void ST7789_InitDriver()
#endif // USE_FT5206
#endif // ESP32
st7789_init_done = true;
AddLog_P(LOG_LEVEL_INFO, PSTR("DSP: ST7789"));
}
}
@ -212,7 +186,7 @@ bool Xdsp12(uint8_t function)
if (FUNC_DISPLAY_INIT_DRIVER == function) {
ST7789_InitDriver();
}
else if (XDSP_12 == Settings.display_model) {
else if (st7789_init_done && (XDSP_12 == Settings.display_model)) {
switch (function) {
case FUNC_DISPLAY_MODEL:
result = true;

View File

@ -409,14 +409,18 @@ static union{
/********************************************************************************************/
void MINRFinit(void){
MINRFinitBLE(1);
void MINRFinit(void) {
if (PinUsed(GPIO_NRF24_CS) && PinUsed(GPIO_NRF24_DC) && TasmotaGlobal.spi_enabled) {
MINRFinitBLE(1);
MINRF.option.allwaysAggregate = 1;
// MINRF.option.ignoreBogusBattery = 1; // from advertisements
MINRF.option.noSummary = 0;
MINRF.option.minimalSummary = 0;
MINRF.option.directBridgeMode = 0;
MINRF.option.allwaysAggregate = 1;
// MINRF.option.ignoreBogusBattery = 1; // from advertisements
MINRF.option.noSummary = 0;
MINRF.option.minimalSummary = 0;
MINRF.option.directBridgeMode = 0;
AddLog_P(LOG_LEVEL_INFO, PSTR("NRF: Started"));
}
}
/********************************************************************************************/
@ -431,7 +435,7 @@ void MINRFinit(void){
bool MINRFinitBLE(uint8_t _mode)
{
if (MINRF.timer%1000 == 0){ // only re-init every 20 seconds
NRF24radio.begin(Pin(GPIO_SPI_CS),Pin(GPIO_SPI_DC));
NRF24radio.begin(Pin(GPIO_NRF24_CS),Pin(GPIO_NRF24_DC));
NRF24radio.setAutoAck(false);
NRF24radio.setDataRate(RF24_1MBPS);
NRF24radio.disableCRC();
@ -1958,7 +1962,6 @@ bool Xsns61(uint8_t function)
switch (function) {
case FUNC_INIT:
MINRFinit();
AddLog_P(LOG_LEVEL_INFO,PSTR("NRF: started"));
break;
case FUNC_EVERY_50_MSECOND:
MINRF_EVERY_50_MSECOND();

View File

@ -98,7 +98,7 @@ void RC522ScanForTag(void) {
}
void RC522Init(void) {
if (PinUsed(GPIO_RC522_CS) && PinUsed(GPIO_RC522_RST)) {
if (PinUsed(GPIO_RC522_CS) && PinUsed(GPIO_RC522_RST) && TasmotaGlobal.spi_enabled) {
Mfrc522 = new MFRC522(Pin(GPIO_RC522_CS), Pin(GPIO_RC522_RST));
SPI.begin();
Mfrc522->PCD_Init();