From 14788a4e742327c8ec17cbc0f7ef74b5cef1e063 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 20 Jan 2021 15:06:34 +0100 Subject: [PATCH] Fix core2 compilation --- tasmota/sendemail.ino | 4 ++-- tasmota/tasmota_globals.h | 6 ++++++ tasmota/xdrv_10_scripter.ino | 8 +------- tasmota/xdrv_13_display.ino | 8 ++++---- tasmota/xdrv_42_i2s_audio.ino | 2 +- tasmota/xdrv_50_filesystem.ino | 3 --- tasmota/xlgt_01_ws2812.ino | 17 +++++++++++------ 7 files changed, 25 insertions(+), 23 deletions(-) diff --git a/tasmota/sendemail.ino b/tasmota/sendemail.ino index 6d075599b..788a52a5c 100644 --- a/tasmota/sendemail.ino +++ b/tasmota/sendemail.ino @@ -389,7 +389,7 @@ void xsend_message_txt(char *msg) { #ifdef DEBUG_EMAIL_PORT AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),msg); #endif -#if (defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)) || defined(UFILESYSTEM) +#if (defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)) || defined(USE_UFILESYS) if (*msg=='@') { msg++; attach_File(msg); @@ -415,7 +415,7 @@ void xsend_message_txt(char *msg) { #endif } -#if (defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)) || defined(UFILESYSTEM) +#if (defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)) || defined(USE_UFILESYS) #include extern FS *ufsp; diff --git a/tasmota/tasmota_globals.h b/tasmota/tasmota_globals.h index 4524410dd..be38261b7 100644 --- a/tasmota/tasmota_globals.h +++ b/tasmota/tasmota_globals.h @@ -225,6 +225,12 @@ const uint16_t LOG_BUFFER_SIZE = 4000; // Max number of characters in lo #error "Arduino ESP8266 Core versions before 2.7.1 are not supported" #endif +#define UFS_FILE_WRITE "w" +#define UFS_FILE_READ "r" +#define FS_FILE_WRITE "w" +#define FS_FILE_READ "r" +#define FS_FILE_APPEND "a" + #define TASM_FILE_SETTINGS "/.settings" // Settings binary blob #define TASM_FILE_SETTINGS_LKG "/.settings.lkg" // Last Known Good Settings binary blob #define TASM_FILE_ZIGBEE "/zb" // Zigbee settings blob as used by CC2530 on ESP32 diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index 24e3fb6fc..85463bdb7 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -196,12 +196,6 @@ void alt_eeprom_readBytes(uint32_t adr, uint32_t len, uint8_t *buf) { #include "FS.h" -#define FS_FILE_WRITE "w" -#define FS_FILE_READ "r" -#define FS_FILE_APPEND "a" - - - #if USE_SCRIPT_FATFS==-1 #ifdef ESP32 //#include "FS.h" @@ -7491,7 +7485,7 @@ bool Xdrv10(uint8_t function) #endif -#endif // UFILESYSTEM +#endif // USE_UFILESYS // indicates scripter enabled (use rules[][] as single array) diff --git a/tasmota/xdrv_13_display.ino b/tasmota/xdrv_13_display.ino index 2eb3c942d..a85fda316 100755 --- a/tasmota/xdrv_13_display.ino +++ b/tasmota/xdrv_13_display.ino @@ -497,7 +497,7 @@ void DisplayText(void) cp += var; linebuf[fill] = 0; break; -#if (defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)) || defined(UFILESYSTEM) +#if (defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)) || defined(USE_UFILESYS) case 'P': { char *ep=strchr(cp,':'); if (ep) { @@ -682,7 +682,7 @@ void DisplayText(void) RedrawGraph(temp,temp1); break; } -#if (defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)) || defined(UFILESYSTEM) +#if (defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)) || defined(USE_UFILESYS) if (*cp=='s') { cp++; var=atoiv(cp,&temp); @@ -1575,7 +1575,7 @@ char get_jpeg_size(unsigned char* data, unsigned int data_size, unsigned short * #endif // JPEG_PICTS #endif // ESP32 -#if (defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)) || defined(UFILESYSTEM) +#if (defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)) || defined(USE_UFILESYS) extern FS *ufsp; #define XBUFF_LEN 128 void Draw_RGB_Bitmap(char *file,uint16_t xp, uint16_t yp, bool inverted ) { @@ -1920,7 +1920,7 @@ void DisplayCheckGraph() { } -#if (defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)) || defined(UFILESYSTEM) +#if (defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)) || defined(USE_UFILESYS) #ifdef ESP32 #include #endif diff --git a/tasmota/xdrv_42_i2s_audio.ino b/tasmota/xdrv_42_i2s_audio.ino index a239d9fe8..db19cf369 100644 --- a/tasmota/xdrv_42_i2s_audio.ino +++ b/tasmota/xdrv_42_i2s_audio.ino @@ -572,7 +572,7 @@ void I2S_WR_Show(void) { #ifdef ESP32 void Play_mp3(const char *path) { -#if (defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)) || defined(UFILESYSTEM) +#if (defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)) || defined(USE_UFILESYS) if (decoder || mp3) return; if (!out) return; diff --git a/tasmota/xdrv_50_filesystem.ino b/tasmota/xdrv_50_filesystem.ino index dfca83cef..0e200deef 100644 --- a/tasmota/xdrv_50_filesystem.ino +++ b/tasmota/xdrv_50_filesystem.ino @@ -50,9 +50,6 @@ ufsfree free size in kB #define UFS_TFAT 2 #define UFS_TLFS 3 -#define UFS_FILE_WRITE "w" -#define UFS_FILE_READ "r" - #ifdef ESP8266 #include #include diff --git a/tasmota/xlgt_01_ws2812.ino b/tasmota/xlgt_01_ws2812.ino index e479d3573..fcd685931 100644 --- a/tasmota/xlgt_01_ws2812.ino +++ b/tasmota/xlgt_01_ws2812.ino @@ -171,6 +171,11 @@ struct WS2812 { /********************************************************************************************/ +// For some reason map fails to compile so renamed to wsmap +long wsmap(long x, long in_min, long in_max, long out_min, long out_max) { + return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; +} + void Ws2812StripShow(void) { #if (USE_WS2812_CTYPE > NEO_3LED) @@ -276,9 +281,9 @@ void Ws2812GradientColor(uint32_t schemenr, struct WsColor* mColor, uint32_t ran end = (scheme.count -1) - end; } float dimmer = 100 / (float)Settings.light_dimmer; - float fmyRed = (float)map(rangeIndex % gradRange, 0, gradRange, scheme.colors[start].red, scheme.colors[end].red) / dimmer; - float fmyGrn = (float)map(rangeIndex % gradRange, 0, gradRange, scheme.colors[start].green, scheme.colors[end].green) / dimmer; - float fmyBlu = (float)map(rangeIndex % gradRange, 0, gradRange, scheme.colors[start].blue, scheme.colors[end].blue) / dimmer; + float fmyRed = (float)wsmap(rangeIndex % gradRange, 0, gradRange, scheme.colors[start].red, scheme.colors[end].red) / dimmer; + float fmyGrn = (float)wsmap(rangeIndex % gradRange, 0, gradRange, scheme.colors[start].green, scheme.colors[end].green) / dimmer; + float fmyBlu = (float)wsmap(rangeIndex % gradRange, 0, gradRange, scheme.colors[start].blue, scheme.colors[end].blue) / dimmer; mColor->red = (uint8_t)fmyRed; mColor->green = (uint8_t)fmyGrn; mColor->blue = (uint8_t)fmyBlu; @@ -316,9 +321,9 @@ void Ws2812Gradient(uint32_t schemenr) Ws2812GradientColor(schemenr, ¤tColor, range, gradRange, i + offset + 1); } // Blend old and current color based on time for smooth movement. - c.R = map(Light.strip_timer_counter % speed, 0, speed, oldColor.red, currentColor.red); - c.G = map(Light.strip_timer_counter % speed, 0, speed, oldColor.green, currentColor.green); - c.B = map(Light.strip_timer_counter % speed, 0, speed, oldColor.blue, currentColor.blue); + c.R = wsmap(Light.strip_timer_counter % speed, 0, speed, oldColor.red, currentColor.red); + c.G = wsmap(Light.strip_timer_counter % speed, 0, speed, oldColor.green, currentColor.green); + c.B = wsmap(Light.strip_timer_counter % speed, 0, speed, oldColor.blue, currentColor.blue); strip->SetPixelColor(i, c); oldColor = currentColor; }