Merge pull request #9456 from gemu2015/scripter_fix

Scripter fix
This commit is contained in:
Theo Arends 2020-10-04 09:16:44 +02:00 committed by GitHub
commit eecfbd990a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 77 additions and 31 deletions

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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) {

View File

@ -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();
}
}