From ef63b21d99c23ca292dd0ad696fc09acbb2c1aa2 Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Sat, 3 Oct 2020 18:30:18 +0200 Subject: [PATCH 1/4] fix scripter json decode crash --- tasmota/xdrv_10_scripter.ino | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tasmota/xdrv_10_scripter.ino b/tasmota/xdrv_10_scripter.ino index a3cba3385..40961770d 100755 --- a/tasmota/xdrv_10_scripter.ino +++ b/tasmota/xdrv_10_scripter.ino @@ -3708,6 +3708,7 @@ void esp32_beep(int32_t freq ,uint32_t len) { #define IF_NEST 8 // execute section of scripter int16_t Run_Scripter(const char *type, int8_t tlen, char *js) { +int16_t retval; if (!glob_script_mem.scriptptr) { return -99; @@ -3717,12 +3718,15 @@ int16_t Run_Scripter(const char *type, int8_t tlen, char *js) { JsonParserObject jo; if (js) { - String jss = js; // copy the string to a new buffer, not sure we can change the original buffer - JsonParser parser((char*)jss.c_str()); + //String jss = js; // copy the string to a new buffer, not sure we can change the original buffer + //JsonParser parser((char*)jss.c_str()); + JsonParser parser(js); jo = parser.getRootObject(); + retval = Run_script_sub(type, tlen, &jo); + } else { + retval = Run_script_sub(type, tlen, 0); } - - return Run_script_sub(type, tlen, &jo); + return retval; } int16_t Run_script_sub(const char *type, int8_t tlen, JsonParserObject *jo) { From e2983e3f1be342dd5476645111a7dd81cd8a223b Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Sat, 3 Oct 2020 18:30:39 +0200 Subject: [PATCH 2/4] sendmail allow array attachment --- tasmota/sendemail.ino | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tasmota/sendemail.ino b/tasmota/sendemail.ino index bc080bd7f..a93c51358 100644 --- a/tasmota/sendemail.ino +++ b/tasmota/sendemail.ino @@ -402,10 +402,15 @@ void xsend_message_txt(char *msg) { g_client->print(F("\r\n--frontier\r\n")); } #else - g_client->print(F("--frontier\r\n")); - g_client->print(F("Content-Type: text/plain\r\n\r\n")); - g_client->println(msg); - g_client->print(F("\r\n--frontier\r\n")); + if (*msg=='&') { + msg++; + attach_Array(msg); + } else { + g_client->print(F("--frontier\r\n")); + g_client->print(F("Content-Type: text/plain\r\n\r\n")); + g_client->println(msg); + g_client->print(F("\r\n--frontier\r\n")); + } #endif } @@ -439,6 +444,8 @@ void attach_File(char *path) { g_client->print(F("\r\n--frontier\r\n")); } +#endif // defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT) + float *get_array_by_name(char *name, uint16_t *alen); void flt2char(float num, char *nbuff); @@ -473,8 +480,6 @@ void attach_Array(char *aname) { g_client->print(F("\r\n--frontier\r\n")); } -#endif // defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT) - #else From 1cb4964a4ee5c7d306d23eb3082d125633c45a4b Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Sat, 3 Oct 2020 18:31:14 +0200 Subject: [PATCH 3/4] fix i2saudio when file not found --- tasmota/xdrv_42_i2s_audio.ino | 39 ++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/tasmota/xdrv_42_i2s_audio.ino b/tasmota/xdrv_42_i2s_audio.ino index 4a3bd91b0..aa0979797 100644 --- a/tasmota/xdrv_42_i2s_audio.ino +++ b/tasmota/xdrv_42_i2s_audio.ino @@ -54,6 +54,8 @@ AudioFileSourceID3 *id3; AudioGeneratorMP3 *decoder = NULL; void *mp3ram = NULL; +#define I2SAUDIO_TASK_STACK_SIZE 8192 + #ifdef ESP8266 const int preallocateBufferSize = 5*1024; @@ -189,6 +191,7 @@ void sayTime(int hour, int minutes, AudioGeneratorTalkie *talkie) { } else { talkie->say(spA_M_, sizeof(spA_M_)); } + out->stop(); delete talkie; TTGO_PWR_OFF } @@ -293,7 +296,7 @@ void Webradio(const char *url) { retryms = millis() + 2000; } - xTaskCreatePinnedToCore(mp3_task2, "MP3-2", 8192, NULL, 3, &mp3_task_h, 1); + xTaskCreatePinnedToCore(mp3_task2, "MP3-2", I2SAUDIO_TASK_STACK_SIZE, NULL, 3, &mp3_task_h, 1); } void mp3_task2(void *arg){ @@ -373,25 +376,27 @@ void Play_mp3(const char *path) { } file = new AudioFileSourceFS(*fsp,path); - id3 = new AudioFileSourceID3(file); + if (file->isOpen()) { + id3 = new AudioFileSourceID3(file); - if (mp3ram) { - mp3 = new AudioGeneratorMP3(mp3ram, preallocateCodecSize); - } else { - mp3 = new AudioGeneratorMP3(); - } - mp3->begin(id3, out); + if (mp3ram) { + mp3 = new AudioGeneratorMP3(mp3ram, preallocateCodecSize); + } else { + mp3 = new AudioGeneratorMP3(); + } + mp3->begin(id3, out); - if (I2S_Task) { - xTaskCreatePinnedToCore(mp3_task, "MP3", 8192, NULL, 3, &mp3_task_h, 1); - } else { - while (mp3->isRunning()) { - if (!mp3->loop()) { - mp3->stop(); - mp3_delete(); - break; + if (I2S_Task) { + xTaskCreatePinnedToCore(mp3_task, "MP3", I2SAUDIO_TASK_STACK_SIZE, NULL, 3, &mp3_task_h, 1); + } else { + while (mp3->isRunning()) { + if (!mp3->loop()) { + mp3->stop(); + mp3_delete(); + break; + } + OsWatchLoop(); } - OsWatchLoop(); } } From 51bf7bcd7d454c1e813fb4415860e76d1b8efdff Mon Sep 17 00:00:00 2001 From: gemu2015 Date: Sat, 3 Oct 2020 18:31:40 +0200 Subject: [PATCH 4/4] ili9488 esp32 dimmer --- lib/JaretBurkett_ILI9488-gemu-1.0/ILI9488.cpp | 37 +++++++++++++++++-- lib/JaretBurkett_ILI9488-gemu-1.0/ILI9488.h | 3 +- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/lib/JaretBurkett_ILI9488-gemu-1.0/ILI9488.cpp b/lib/JaretBurkett_ILI9488-gemu-1.0/ILI9488.cpp index c7cdeba0a..357000a69 100644 --- a/lib/JaretBurkett_ILI9488-gemu-1.0/ILI9488.cpp +++ b/lib/JaretBurkett_ILI9488-gemu-1.0/ILI9488.cpp @@ -20,6 +20,11 @@ // if using software spi this optimizes the code +#ifdef ESP32 +#define ILI9488_DIMMER +#undef ESP32_PWM_CHANNEL +#define ESP32_PWM_CHANNEL 1 +#endif #define ILI9488_START start(); #define ILI9488_STOP stop(); @@ -322,8 +327,13 @@ void ILI9488::DisplayInit(int8_t p,int8_t size,int8_t rot,int8_t font) { void ILI9488::DisplayOnff(int8_t on) { if (on) { writecommand(ILI9488_DISPON); //Display on + if (_bp>=0) { + #ifdef ILI9488_DIMMER + ledcWrite(ESP32_PWM_CHANNEL,dimmer); + #else digitalWrite(_bp,HIGH); + #endif /* writecommand(ILI9488_WRCTRLD); writedata(0x0c); @@ -332,15 +342,30 @@ void ILI9488::DisplayOnff(int8_t on) { } } else { writecommand(ILI9488_DISPOFF); + if (_bp>=0) { +#ifdef ILI9488_DIMMER + ledcWrite(ESP32_PWM_CHANNEL,0); +#else digitalWrite(_bp,LOW); +#endif + } //writecommand(ILI9488_WRCTRLD); //writedata(0x04); - } + } ILI9488_STOP } +// dimmer 0-100 +void ILI9488::dim(uint8_t dim) { + dimmer = dim; + if (dimmer>15) dimmer=15; + dimmer=((float)dimmer/15.0)*255.0; +#ifdef ESP32 + ledcWrite(ESP32_PWM_CHANNEL,dimmer); +#endif +} void ILI9488::begin(void) { pinMode(_cs, OUTPUT); @@ -348,8 +373,14 @@ void ILI9488::begin(void) { pinMode(_sclk, OUTPUT); pinMode(_mosi, OUTPUT); if (_bp>=0) { - pinMode(_bp, OUTPUT); - digitalWrite(_bp,HIGH); +#ifdef ILI9488_DIMMER + ledcSetup(ESP32_PWM_CHANNEL,4000,8); + ledcAttachPin(_bp,ESP32_PWM_CHANNEL); + ledcWrite(ESP32_PWM_CHANNEL,128); +#else + pinMode(_bp, OUTPUT); + digitalWrite(_bp,HIGH); +#endif } #ifndef ESP32 diff --git a/lib/JaretBurkett_ILI9488-gemu-1.0/ILI9488.h b/lib/JaretBurkett_ILI9488-gemu-1.0/ILI9488.h index 89c7a909b..5fd2e39e5 100644 --- a/lib/JaretBurkett_ILI9488-gemu-1.0/ILI9488.h +++ b/lib/JaretBurkett_ILI9488-gemu-1.0/ILI9488.h @@ -157,10 +157,11 @@ class ILI9488 : public Renderer { void write16BitColor(uint16_t color); void commandList(uint8_t *addr); void hw_spi_init(); - + void dim(uint8_t contrast); private: uint8_t tabcolor; + uint8_t dimmer; void fastSPIwrite(uint8_t d,uint8_t dc); void spi_lcd_mode_init(void); void start(void);