Merge pull request #10419 from gemu2015/scripter-update

Scripter update
This commit is contained in:
Theo Arends 2021-01-05 17:16:09 +01:00 committed by GitHub
commit 6b80ea0085
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 279 additions and 603 deletions

View File

@ -3723,6 +3723,8 @@ void IMAPData::setFetchUID(const String &fetchUID)
std::string().swap(tmp); std::string().swap(tmp);
} }
extern FS *ufsp;
void IMAPData::setFileStorageType(uint8_t storageType) void IMAPData::setFileStorageType(uint8_t storageType)
{ {
_storageType = storageType; _storageType = storageType;
@ -3736,6 +3738,9 @@ void IMAPData::setFileStorageType(uint8_t storageType)
case MailClientStorageType::FFat: case MailClientStorageType::FFat:
fsp = &FFat; fsp = &FFat;
break; break;
case MailClientStorageType::Univ:
fsp = ufsp;
break;
} }
} }
@ -4766,6 +4771,9 @@ void SMTPData::setFileStorageType(uint8_t storageType)
case MailClientStorageType::FFat: case MailClientStorageType::FFat:
fsp = &FFat; fsp = &FFat;
break; break;
case MailClientStorageType::Univ:
fsp = ufsp;
break;
} }
} }

View File

@ -92,6 +92,7 @@ struct MailClientStorageType
static const uint8_t SPIFFS = 0; static const uint8_t SPIFFS = 0;
static const uint8_t SD = 1; static const uint8_t SD = 1;
static const uint8_t FFat = 2; static const uint8_t FFat = 2;
static const uint8_t Univ = 3;
}; };
static const char ESP32_MAIL_STR_1[] PROGMEM = "Content-Type: multipart/mixed; boundary=\""; static const char ESP32_MAIL_STR_1[] PROGMEM = "Content-Type: multipart/mixed; boundary=\"";

View File

@ -389,7 +389,7 @@ void xsend_message_txt(char *msg) {
#ifdef DEBUG_EMAIL_PORT #ifdef DEBUG_EMAIL_PORT
AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),msg); AddLog_P(LOG_LEVEL_INFO, PSTR("%s"),msg);
#endif #endif
#if defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT) #if (defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)) || defined(UFILESYSTEM)
if (*msg=='@') { if (*msg=='@') {
msg++; msg++;
attach_File(msg); attach_File(msg);
@ -415,9 +415,9 @@ void xsend_message_txt(char *msg) {
#endif #endif
} }
#if defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT) #if (defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)) || defined(UFILESYSTEM)
#include <LittleFS.h> #include <LittleFS.h>
extern FS *fsp; extern FS *ufsp;
void attach_File(char *path) { void attach_File(char *path) {
g_client->print(F("--frontier\r\n")); g_client->print(F("--frontier\r\n"));
@ -425,7 +425,7 @@ void attach_File(char *path) {
char buff[64]; char buff[64];
char *cp = path; char *cp = path;
while (*cp=='/') cp++; while (*cp=='/') cp++;
File file = fsp->open(path, "r"); File file = ufsp->open(path, "r");
if (file) { if (file) {
sprintf_P(buff,PSTR("Content-Disposition: attachment; filename=\"%s\"\r\n\r\n"), cp); sprintf_P(buff,PSTR("Content-Disposition: attachment; filename=\"%s\"\r\n\r\n"), cp);
g_client->write(buff); g_client->write(buff);
@ -717,6 +717,8 @@ uint16_t SendMail(char *buffer) {
//Set the storage types to read the attach files (SD is default) //Set the storage types to read the attach files (SD is default)
//smtpData.setFileStorageType(MailClientStorageType::SPIFFS); //smtpData.setFileStorageType(MailClientStorageType::SPIFFS);
/*
#ifdef USE_SCRIPT_FATFS #ifdef USE_SCRIPT_FATFS
#if USE_SCRIPT_FATFS<0 #if USE_SCRIPT_FATFS<0
smtpData.setFileStorageType(MailClientStorageType::FFat); smtpData.setFileStorageType(MailClientStorageType::FFat);
@ -724,6 +726,9 @@ uint16_t SendMail(char *buffer) {
smtpData.setFileStorageType(MailClientStorageType::SD); smtpData.setFileStorageType(MailClientStorageType::SD);
#endif #endif
#endif #endif
*/
smtpData.setFileStorageType(MailClientStorageType::Univ);
//smtpData.setSendCallback(sendCallback); //smtpData.setSendCallback(sendCallback);

File diff suppressed because it is too large Load Diff

20
tasmota/xdrv_13_display.ino Normal file → Executable file
View File

@ -497,7 +497,7 @@ void DisplayText(void)
cp += var; cp += var;
linebuf[fill] = 0; linebuf[fill] = 0;
break; break;
#if defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT) #if (defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)) || defined(UFILESYSTEM)
case 'P': case 'P':
{ char *ep=strchr(cp,':'); { char *ep=strchr(cp,':');
if (ep) { if (ep) {
@ -682,7 +682,7 @@ void DisplayText(void)
RedrawGraph(temp,temp1); RedrawGraph(temp,temp1);
break; break;
} }
#if defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT) #if (defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)) || defined(UFILESYSTEM)
if (*cp=='s') { if (*cp=='s') {
cp++; cp++;
var=atoiv(cp,&temp); var=atoiv(cp,&temp);
@ -1569,8 +1569,8 @@ char get_jpeg_size(unsigned char* data, unsigned int data_size, unsigned short *
#endif // JPEG_PICTS #endif // JPEG_PICTS
#endif // ESP32 #endif // ESP32
#if defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT) && defined(USE_DISPLAY) #if (defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)) || defined(UFILESYSTEM)
extern FS *fsp; extern FS *ufsp;
#define XBUFF_LEN 128 #define XBUFF_LEN 128
void Draw_RGB_Bitmap(char *file,uint16_t xp, uint16_t yp, bool inverted ) { void Draw_RGB_Bitmap(char *file,uint16_t xp, uint16_t yp, bool inverted ) {
if (!renderer) return; if (!renderer) return;
@ -1586,7 +1586,7 @@ void Draw_RGB_Bitmap(char *file,uint16_t xp, uint16_t yp, bool inverted ) {
if (!strcmp(estr,"rgb")) { if (!strcmp(estr,"rgb")) {
// special rgb format // special rgb format
fp=fsp->open(file,FILE_READ); fp=ufsp->open(file,FS_FILE_READ);
if (!fp) return; if (!fp) return;
uint16_t xsize; uint16_t xsize;
fp.read((uint8_t*)&xsize,2); fp.read((uint8_t*)&xsize,2);
@ -1621,7 +1621,7 @@ void Draw_RGB_Bitmap(char *file,uint16_t xp, uint16_t yp, bool inverted ) {
// jpeg files on ESP32 with more memory // jpeg files on ESP32 with more memory
#ifdef ESP32 #ifdef ESP32
#ifdef JPEG_PICTS #ifdef JPEG_PICTS
fp=fsp->open(file,FILE_READ); fp=ufsp->open(file,FS_FILE_READ);
if (!fp) return; if (!fp) return;
uint32_t size = fp.size(); uint32_t size = fp.size();
uint8_t *mem = (uint8_t *)special_malloc(size+4); uint8_t *mem = (uint8_t *)special_malloc(size+4);
@ -1914,7 +1914,7 @@ void DisplayCheckGraph() {
} }
#if defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT) #if (defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)) || defined(UFILESYSTEM)
#ifdef ESP32 #ifdef ESP32
#include <SD.h> #include <SD.h>
#endif #endif
@ -1925,8 +1925,8 @@ void Save_graph(uint8_t num, char *path) {
struct GRAPH *gp=graph[index]; struct GRAPH *gp=graph[index];
if (!gp) return; if (!gp) return;
File fp; File fp;
fsp->remove(path); ufsp->remove(path);
fp=fsp->open(path,FILE_WRITE); fp=ufsp->open(path,FS_FILE_WRITE);
if (!fp) return; if (!fp) return;
char str[32]; char str[32];
sprintf_P(str,PSTR("%d\t%d\t%d\t"),gp->xcnt,gp->xs,gp->ys); sprintf_P(str,PSTR("%d\t%d\t%d\t"),gp->xcnt,gp->xs,gp->ys);
@ -1951,7 +1951,7 @@ void Restore_graph(uint8_t num, char *path) {
struct GRAPH *gp=graph[index]; struct GRAPH *gp=graph[index];
if (!gp) return; if (!gp) return;
File fp; File fp;
fp=fsp->open(path,FILE_READ); fp=ufsp->open(path,FS_FILE_READ);
if (!fp) return; if (!fp) return;
char vbuff[32]; char vbuff[32];
char *cp=vbuff; char *cp=vbuff;

View File

@ -69,6 +69,8 @@ AudioGeneratorMP3 *decoder = NULL;
void *mp3ram = NULL; void *mp3ram = NULL;
extern FS *ufsp;
#ifdef ESP8266 #ifdef ESP8266
const int preallocateBufferSize = 5*1024; const int preallocateBufferSize = 5*1024;
const int preallocateCodecSize = 29192; // MP3 codec max mem needed const int preallocateCodecSize = 29192; // MP3 codec max mem needed
@ -391,7 +393,7 @@ static const uint8_t wavHTemplate[] PROGMEM = { // Hardcoded simple WAV header w
0x64, 0x61, 0x74, 0x61, 0xff, 0xff, 0xff, 0xff }; 0x64, 0x61, 0x74, 0x61, 0xff, 0xff, 0xff, 0xff };
bool SaveWav(char *path, uint8_t *buff, uint32_t size) { bool SaveWav(char *path, uint8_t *buff, uint32_t size) {
File fwp = fsp->open(path, FILE_WRITE); File fwp = ufsp->open(path, FILE_WRITE);
uint8_t wavHeader[sizeof(wavHTemplate)]; uint8_t wavHeader[sizeof(wavHTemplate)];
memcpy_P(wavHeader, wavHTemplate, sizeof(wavHTemplate)); memcpy_P(wavHeader, wavHTemplate, sizeof(wavHTemplate));
@ -552,7 +554,7 @@ void I2S_WR_Show(void) {
#ifdef ESP32 #ifdef ESP32
void Play_mp3(const char *path) { void Play_mp3(const char *path) {
#if defined(USE_SCRIPT) && defined(USE_SCRIPT_FATFS) #if (defined(USE_SCRIPT_FATFS) && defined(USE_SCRIPT)) || defined(UFILESYSTEM)
if (decoder || mp3) return; if (decoder || mp3) return;
if (!out) return; if (!out) return;
@ -566,7 +568,7 @@ void Play_mp3(const char *path) {
I2S_Task = false; I2S_Task = false;
} }
file = new AudioFileSourceFS(*fsp,path); file = new AudioFileSourceFS(*ufsp,path);
id3 = new AudioFileSourceID3(file); id3 = new AudioFileSourceID3(file);
if (mp3ram) { if (mp3ram) {

View File

@ -98,7 +98,7 @@ void UFSInit(void) {
if (SD.begin(cs)) { if (SD.begin(cs)) {
#ifdef ESP8266 #ifdef ESP8266
ufsp = (FS*)&SD; ufsp = &SDFS;
#endif // ESP8266 #endif // ESP8266
#ifdef ESP32 #ifdef ESP32
ufsp = &SD; ufsp = &SD;