mirror of https://github.com/arendst/Tasmota.git
Fix PCF8574 mode2 init using scripts
Fix PCF8574 mode2 init using scripts (#18934)
This commit is contained in:
parent
58e13edea0
commit
1e3b41dd2d
|
@ -444,7 +444,7 @@ struct SCRIPT_SPI {
|
|||
#include <OneWire.h>
|
||||
#include <DS2480B.h>
|
||||
|
||||
#ifndef MAX_DS_SENSORS
|
||||
#ifndef MAX_DS_SENSORS
|
||||
#define MAX_DS_SENSORS 20
|
||||
#endif
|
||||
|
||||
|
@ -722,7 +722,7 @@ char *script;
|
|||
}
|
||||
uint16_t maxvars = maxsvars + maxnvars;
|
||||
//AddLog(LOG_LEVEL_INFO, PSTR("Script: svar = %d, nvars = %d"), maxsvars, maxnvars);
|
||||
|
||||
|
||||
// scan lines for >DEF
|
||||
uint16_t lines = 0;
|
||||
uint16_t nvars = 0;
|
||||
|
@ -867,7 +867,7 @@ char *script;
|
|||
} else {
|
||||
vtypes[vars].bits.is_filter = 0;
|
||||
}
|
||||
|
||||
|
||||
*vnp_p++ = vnames_p;
|
||||
while (lp < op) {
|
||||
if (*lp == ' ') {
|
||||
|
@ -4447,7 +4447,7 @@ extern void W8960_SetGain(uint8_t sel, uint16_t value);
|
|||
goto nfuncexit;
|
||||
}
|
||||
break;
|
||||
#endif // USE_SCRIPT_ONEWIRE
|
||||
#endif // USE_SCRIPT_ONEWIRE
|
||||
|
||||
case 'p':
|
||||
if (!strncmp_XP(lp, XPSTR("pin["), 4)) {
|
||||
|
@ -4985,7 +4985,7 @@ extern char *SML_GetSVal(uint32_t index);
|
|||
|
||||
Settings->serial_config = sconfig;
|
||||
uint8_t uart = 0;
|
||||
#ifdef ESP32
|
||||
#ifdef ESP32
|
||||
uart = glob_script_mem.sp->getUart();
|
||||
#endif
|
||||
AddLog(LOG_LEVEL_INFO, PSTR("Serial port set to %s %d bit/s at rx=%d tx=%d rbu=%d uart=%d"), GetSerialConfig().c_str(), (uint32_t)br, (uint32_t)rxpin, (uint32_t)txpin, (uint32_t)rxbsiz, uart);
|
||||
|
@ -5554,7 +5554,7 @@ extern char *SML_GetSVal(uint32_t index);
|
|||
uint32_t cycles;
|
||||
uint64_t accu = 0;
|
||||
char sbuffer[32];
|
||||
|
||||
|
||||
GT911_Touch_Init(&Wire1, -1, -1, 960, 540);
|
||||
|
||||
/*
|
||||
|
@ -5965,12 +5965,12 @@ char *getop(char *lp, uint8_t *operand) {
|
|||
#ifdef USE_SCRIPT_FATFS_EXT
|
||||
#ifdef USE_UFILESYS
|
||||
int32_t script_logfile_write(char *path, char *payload, uint32_t size) {
|
||||
|
||||
|
||||
File rfd = ufsp->open(path, FS_FILE_APPEND);
|
||||
if (rfd == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
uint32_t fsize = rfd.size();
|
||||
// append string
|
||||
rfd.write((uint8_t*)payload, strlen(payload));
|
||||
|
@ -5994,7 +5994,7 @@ int32_t script_logfile_write(char *path, char *payload, uint32_t size) {
|
|||
wfd.close();
|
||||
ufsp->remove(path);
|
||||
ufsp->rename("/ltmp", path);
|
||||
|
||||
|
||||
return fsize;
|
||||
}
|
||||
#endif // USE_UFILESYS
|
||||
|
@ -7447,7 +7447,7 @@ getnext:
|
|||
default:
|
||||
// error
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
switch (lastop) {
|
||||
case OPER_EQU:
|
||||
|
@ -7492,7 +7492,7 @@ getnext:
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// var was changed
|
||||
if (globvindex >= 0) SetChanged(globvindex);
|
||||
#ifdef USE_SCRIPT_GLOBVARS
|
||||
|
@ -7763,7 +7763,7 @@ ScriptOneWire *ow = &glob_script_mem.ow;
|
|||
|
||||
ow->ts->begin(9600);
|
||||
|
||||
#ifdef ESP8266
|
||||
#ifdef ESP8266
|
||||
if (ow->ts->hardwareSerial()) {
|
||||
ClaimSerial();
|
||||
#ifdef ALLOW_OW_INVERT
|
||||
|
@ -7783,7 +7783,7 @@ ScriptOneWire *ow = &glob_script_mem.ow;
|
|||
}
|
||||
#endif
|
||||
#endif // ESP32
|
||||
|
||||
|
||||
ow->dsh = new DS2480B(ow->ts);
|
||||
ow->dsh->begin();
|
||||
}
|
||||
|
@ -7878,7 +7878,7 @@ ScriptOneWire *ow = &glob_script_mem.ow;
|
|||
if (val < 1 || val > MAX_DS_SENSORS) {
|
||||
val = 1;
|
||||
}
|
||||
|
||||
|
||||
if (ow->ds) {
|
||||
uint8_t data[9];
|
||||
ow->ds->reset();
|
||||
|
@ -8552,7 +8552,7 @@ void SaveScriptEnd(void) {
|
|||
glob_script_mem.script_mem_size = 0;
|
||||
#ifdef USE_SCRIPT_SERIAL
|
||||
Script_Close_Serial();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
if (bitRead(Settings->rule_enabled, 0)) {
|
||||
|
@ -10605,7 +10605,7 @@ const char *gc_str;
|
|||
}
|
||||
|
||||
bool dogui = ((!mc && (*lin != '$')) || (mc == 'w' && (*lin != '$'))) && (!(specopt & WSO_FORCEMAIN));
|
||||
|
||||
|
||||
if ((dogui && !(specopt & WSO_FORCEGUI)) || (!dogui && (specopt & WSO_FORCEGUI))) {
|
||||
//if ( ((!mc && (*lin != '$')) || (mc == 'w' && (*lin != '$'))) && (!(specopt & WSO_FORCEMAIN)) || (specopt & WSO_FORCEGUI)) {
|
||||
// normal web section
|
||||
|
@ -10784,7 +10784,7 @@ const char *gc_str;
|
|||
} else {
|
||||
WSContentSend_P(SCRIPT_MSG_RADIOa, center, tsiz, pulabel);
|
||||
}
|
||||
|
||||
|
||||
// get pu labels
|
||||
uint8_t index = 1;
|
||||
while (*lp) {
|
||||
|
@ -11872,7 +11872,7 @@ int32_t call2pwl(const char *url) {
|
|||
if (*url == 'N') {
|
||||
url++;
|
||||
cookie = "";
|
||||
}
|
||||
}
|
||||
String result = powerwall.GetRequest(String(url), cookie);
|
||||
//AddLog(LOG_LEVEL_INFO, PSTR("PWL: result: %s"), result.c_str());
|
||||
|
||||
|
@ -12510,7 +12510,8 @@ bool Xdrv10(uint32_t function)
|
|||
|
||||
switch (function) {
|
||||
//case FUNC_PRE_INIT:
|
||||
case FUNC_INIT:
|
||||
//case FUNC_INIT:
|
||||
case FUNC_SETUP_RING1: // We need to setup SCRIPT before call to ScriptLoadSection()
|
||||
|
||||
//bitWrite(Settings->rule_enabled, 0, 0); // >>>>>>>>>>>
|
||||
#ifndef NO_SCRIPT_STOP_ON_ERROR
|
||||
|
@ -12671,8 +12672,8 @@ bool Xdrv10(uint32_t function)
|
|||
|
||||
if (bitRead(Settings->rule_enabled, 0)) Init_Scripter();
|
||||
|
||||
// break;
|
||||
//case FUNC_INIT:
|
||||
break;
|
||||
case FUNC_INIT:
|
||||
if (bitRead(Settings->rule_enabled, 0)) {
|
||||
set_callbacks();
|
||||
Run_Scripter1(">B\n", 3, 0);
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
*
|
||||
* Prepare a template to be loaded either by:
|
||||
* - a rule like: rule3 on file#pcf8574.dat do {"NAME":"PCF8574 A=Ri8-1, B=B1-8","GPIO":[263,262,261,260,259,258,257,256,32,33,34,35,36,37,38,39]} endon
|
||||
* - a script like: -y{"NAME":"PCF8574 A=Ri8-1, B=B1-8","GPIO":[263,262,261,260,259,258,257,256,32,33,34,35,36,37,38,39]}
|
||||
* - a script like: >y{"NAME":"PCF8574 A=Ri8-1, B=B1-8","GPIO":[263,262,261,260,259,258,257,256,32,33,34,35,36,37,38,39]}#
|
||||
* - file called pcf8574.dat with contents: {"NAME":"PCF8574 A=Ri8-1, B=B1-8","GPIO":[263,262,261,260,259,258,257,256,32,33,34,35,36,37,38,39]}
|
||||
*
|
||||
* Inverted relays and buttons Ri8 Ri7 Ri6 Ri5 Ri4 Ri3 Ri2 Ri1 B1 B2 B3 B4 B5 B6 B7 B8
|
||||
|
|
Loading…
Reference in New Issue