diff --git a/tasmota/xdsp_08_ILI9488.ino b/tasmota/xdsp_08_ILI9488.ino index 712491e6a..2abbf5dcb 100644 --- a/tasmota/xdsp_08_ILI9488.ino +++ b/tasmota/xdsp_08_ILI9488.ino @@ -72,6 +72,14 @@ void ILI9488_InitDriver() 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 @@ -79,14 +87,7 @@ void ILI9488_InitDriver() #define HW_SPI_MISO 19 #undef HW_SPI_CLK #define HW_SPI_CLK 18 -#else -#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 +#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)) { @@ -102,7 +103,6 @@ void ILI9488_InitDriver() ili9488->begin(); renderer = ili9488; renderer->DisplayInit(DISPLAY_INIT_MODE,Settings.display_size,Settings.display_rotate,Settings.display_font); - renderer->dim(Settings.display_dimmer); #ifdef SHOW_SPLASH // Welcome text diff --git a/tasmota/xdsp_10_RA8876.ino b/tasmota/xdsp_10_RA8876.ino index 47b909b4c..7cc87c4df 100644 --- a/tasmota/xdsp_10_RA8876.ino +++ b/tasmota/xdsp_10_RA8876.ino @@ -59,6 +59,14 @@ void RA8876_InitDriver() 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 @@ -66,14 +74,7 @@ void RA8876_InitDriver() #define HW_SPI_MISO 19 #undef HW_SPI_CLK #define HW_SPI_CLK 18 -#else -#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 +#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)) { diff --git a/tasmota/xdsp_12_ST7789.ino b/tasmota/xdsp_12_ST7789.ino index 59339e54f..cd0a20d69 100644 --- a/tasmota/xdsp_12_ST7789.ino +++ b/tasmota/xdsp_12_ST7789.ino @@ -95,17 +95,18 @@ void ST7789_InitDriver() 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 -#else -#undef HW_SPI_MOSI -#define HW_SPI_MOSI 13 -#undef HW_SPI_CLK -#define HW_SPI_CLK 14 -#endif +#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)) { @@ -121,7 +122,6 @@ void ST7789_InitDriver() st7789->init(Settings.display_width,Settings.display_height); renderer = st7789; renderer->DisplayInit(DISPLAY_INIT_MODE,Settings.display_size,Settings.display_rotate,Settings.display_font); - renderer->dim(Settings.display_dimmer); #ifdef SHOW_SPLASH // Welcome text diff --git a/tasmota/xlgt_03_sm16716.ino b/tasmota/xlgt_03_sm16716.ino index 6f29b5c7e..29ef77c23 100644 --- a/tasmota/xlgt_03_sm16716.ino +++ b/tasmota/xlgt_03_sm16716.ino @@ -150,9 +150,10 @@ void Sm16716ModuleSelected(void) if (PinUsed(GPIO_PWM1, i)) { #ifdef ESP8266 pinMode(Pin(GPIO_PWM1, i), OUTPUT); -#else // ESP32 +#endif // ESP8266 +#ifdef ESP32 analogAttach(Pin(GPIO_PWM1, i), i); -#endif +#endif // ESP32 } } */ diff --git a/tasmota/xnrg_15_teleinfo.ino b/tasmota/xnrg_15_teleinfo.ino index a052027d3..1be83a57d 100755 --- a/tasmota/xnrg_15_teleinfo.ino +++ b/tasmota/xnrg_15_teleinfo.ino @@ -463,20 +463,21 @@ void TInfoInit(void) AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: always enabled")); } -#if defined (ESP8266) +#ifdef ESP8266 // Allow GPIO3 AND GPIO13 with hardware fallback to 2 TInfoSerial = new TasmotaSerial(rx_pin, -1, 2); //pinMode(rx_pin, INPUT_PULLUP); -#else +#endif // ESP8266 +#ifdef ESP32 TInfoSerial = new TasmotaSerial(rx_pin, -1, 1); -#endif +#endif // ESP32 // Trick here even using SERIAL_7E1 or TS_SERIAL_7E1 // this is not working, need to call SetSerialConfig after if (TInfoSerial->begin(baudrate)) { -#if defined (ESP8266) +#ifdef ESP8266 if (TInfoSerial->hardwareSerial() ) { ClaimSerial(); @@ -491,10 +492,10 @@ void TInfoInit(void) } else { AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: using software serial")); } - -#elif defined (ESP32) +#endif // ESP8266 +#ifdef ESP32 AddLog_P(LOG_LEVEL_INFO, PSTR("TIC: using ESP32 hardware serial")); -#endif +#endif // ESP32 // Init teleinfo tinfo.init(tinfo_mode); // Attach needed callbacks diff --git a/tasmota/xsns_01_counter.ino b/tasmota/xsns_01_counter.ino index 811aada97..1f2861e56 100644 --- a/tasmota/xsns_01_counter.ino +++ b/tasmota/xsns_01_counter.ino @@ -253,16 +253,17 @@ void SyncACDimmer(void) timelag_ClockCycles = ((ac_zero_cross_dimmer.dimm_timeClockCycles + ac_zero_cross_dimmer.tobe_cycle_timeClockCycles) - timelag_ClockCycles)%ac_zero_cross_dimmer.tobe_cycle_timeClockCycles; delayMicroseconds(clockCyclesToMicroseconds(timelag_ClockCycles)); - #ifdef ESP8266 +#ifdef ESP8266 pinMode(Pin(GPIO_PWM1, i), OUTPUT); // short fire to ensure not to hit next sinus curve. 0.78% of duty cycle (10ms) ~4µs uint32_t high = ac_zero_cross_dimmer.current_cycle_ClockCycles / 256; uint32_t low = ac_zero_cross_dimmer.current_cycle_ClockCycles - high; // Find the first GPIO being generated by checking GCC's find-first-set (returns 1 + the bit of the first 1 in an int32_t startWaveformClockCycles(Pin(GPIO_PWM1, i), high, low, 0, -1, 0, true); - #else // ESP32 +#endif // ESP8266 +#ifdef ESP32 analogWrite(Pin(GPIO_PWM1, i), 5); - #endif // ESP8266 - ESP32 +#endif // ESP32 //AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("CNT: [%d] dimm_time_CCs %d, current_cycle_CC: %d, timelag %lu, lastcc %lu, currentSteps %d, curr %d"), i, ac_zero_cross_dimmer.dimm_timeClockCycles,ac_zero_cross_dimmer.current_cycle_ClockCycles , timelag_ClockCycles, ac_zero_cross_dimmer.currentCycleCount, ac_zero_cross_dimmer.currentSteps, Light.fade_cur_10[i]); } } diff --git a/tasmota/xsns_02_analog.ino b/tasmota/xsns_02_analog.ino index ed801b384..287f1a7b9 100644 --- a/tasmota/xsns_02_analog.ino +++ b/tasmota/xsns_02_analog.ino @@ -27,12 +27,13 @@ #ifdef ESP8266 #define ANALOG_RESOLUTION 10 // 12 = 4095, 11 = 2047, 10 = 1023 #define ANALOG_RANGE 1023 // 4095 = 12, 2047 = 11, 1023 = 10 -#else // ESP32 +#endif // ESP8266 +#ifdef ESP32 #undef ANALOG_RESOLUTION #define ANALOG_RESOLUTION 12 // 12 = 4095, 11 = 2047, 10 = 1023 #undef ANALOG_RANGE #define ANALOG_RANGE 4095 // 4095 = 12, 2047 = 11, 1023 = 10 -#endif // ESP8266 or ESP32 +#endif // ESP32 #define TO_CELSIUS(x) ((x) - 273.15) #define TO_KELVIN(x) ((x) + 273.15) diff --git a/tasmota/xsns_44_sps30.ino b/tasmota/xsns_44_sps30.ino index 271601cf6..c9316ba4c 100644 --- a/tasmota/xsns_44_sps30.ino +++ b/tasmota/xsns_44_sps30.ino @@ -99,9 +99,10 @@ uint8_t twi_buff[64]; #ifdef ESP8266 twi_readFrom(SPS30_ADDR,twi_buff,dlen,1); -#else +#endif // ESP8266 +#ifdef ESP32 Wire.readTransmission(SPS30_ADDR,twi_buff,dlen,1, NULL); -#endif +#endif // ESP32 uint8_t bind=0; while (bindsetRxBufferSize(TMSBSIZ); -#else - meter_ss[meters] = new TasmotaSerial(meter_desc_p[meters].srcpin,meter_desc_p[meters].trxpin,1,0,TMSBSIZ); -#endif +#endif // ESP32 #endif SerialConfig smode = SERIAL_8N1; @@ -2198,9 +2200,7 @@ init10: smode = SERIAL_8E2; } } -#ifdef ESP32 - meter_ss[meters]->begin(meter_desc_p[meters].params, smode, meter_desc_p[meters].srcpin, meter_desc_p[meters].trxpin); -#else +#ifdef ESP8266 if (meter_ss[meters]->begin(meter_desc_p[meters].params)) { meter_ss[meters]->flush(); } @@ -2209,7 +2209,10 @@ init10: ClaimSerial(); //Serial.setRxBufferSize(512); } -#endif +#endif // ESP8266 +#ifdef ESP32 + meter_ss[meters]->begin(meter_desc_p[meters].params, smode, meter_desc_p[meters].srcpin, meter_desc_p[meters].trxpin); +#endif // ESP32 } } @@ -2221,7 +2224,16 @@ uint32_t SML_SetBaud(uint32_t meter, uint32_t br) { if (meter<1 || meter>meters_used) return 0; meter--; if (!meter_ss[meter]) return 0; - +#ifdef ESP8266 + if (meter_ss[meter]->begin(br)) { + meter_ss[meter]->flush(); + } + if (meter_ss[meter]->hardwareSerial()) { + if (meter_desc_p[meter].type=='M') { + Serial.begin(br, SERIAL_8E1); + } + } +#endif // ESP8266 #ifdef ESP32 meter_ss[meter]->flush(); meter_ss[meter]->updateBaudRate(br); @@ -2231,16 +2243,7 @@ uint32_t SML_SetBaud(uint32_t meter, uint32_t br) { } else { meter_ss[meter]->begin(br,SERIAL_8N1,meter_desc_p[meter].srcpin,meter_desc_p[meter].trxpin); }*/ -#else - if (meter_ss[meter]->begin(br)) { - meter_ss[meter]->flush(); - } - if (meter_ss[meter]->hardwareSerial()) { - if (meter_desc_p[meter].type=='M') { - Serial.begin(br, SERIAL_8E1); - } - } -#endif +#endif // ESP32 return 1; }