mirror of https://github.com/arendst/Tasmota.git
Merge branch 'arendst:development' into venetian-patch
This commit is contained in:
commit
6e24e04df0
|
@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
|
||||||
## [10.0.0.3]
|
## [10.0.0.3]
|
||||||
### Added
|
### Added
|
||||||
- Autoconfiguration for ESP32 and variants
|
- Autoconfiguration for ESP32 and variants
|
||||||
|
- ESP32 fix leftover GPIO configuration after restart
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- ESP8266 Gratuitous ARP enabled and set to 60 seconds (#13623)
|
- ESP8266 Gratuitous ARP enabled and set to 60 seconds (#13623)
|
||||||
|
|
|
@ -100,6 +100,12 @@
|
||||||
**/
|
**/
|
||||||
#define BE_STACK_FREE_MIN 20
|
#define BE_STACK_FREE_MIN 20
|
||||||
|
|
||||||
|
/* Macro: BE_STACK_START
|
||||||
|
* Set the starting size of the stack at VM creation.
|
||||||
|
* Default: 50
|
||||||
|
**/
|
||||||
|
#define BE_STACK_START 100
|
||||||
|
|
||||||
/* Macro: BE_CONST_SEARCH_SIZE
|
/* Macro: BE_CONST_SEARCH_SIZE
|
||||||
* Constants in function are limited to 255. However the compiler
|
* Constants in function are limited to 255. However the compiler
|
||||||
* will look for a maximum of pre-existing constants to avoid
|
* will look for a maximum of pre-existing constants to avoid
|
||||||
|
|
|
@ -293,6 +293,7 @@ autoconf_module.init = def (m)
|
||||||
self._error = nil
|
self._error = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# called by the synthetic event `preinit`
|
||||||
def preinit()
|
def preinit()
|
||||||
if self._archive == nil return end
|
if self._archive == nil return end
|
||||||
# try to launch `preinit.be`
|
# try to launch `preinit.be`
|
||||||
|
@ -327,6 +328,7 @@ autoconf_module.init = def (m)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# called by the synthetic event `autoexec`
|
||||||
def autoexec()
|
def autoexec()
|
||||||
if self._archive == nil return end
|
if self._archive == nil return end
|
||||||
# try to launch `preinit.be`
|
# try to launch `preinit.be`
|
||||||
|
|
|
@ -453,8 +453,8 @@ BERRY_API bvm* be_vm_new(void)
|
||||||
be_stack_init(vm, &vm->refstack, sizeof(binstance*));
|
be_stack_init(vm, &vm->refstack, sizeof(binstance*));
|
||||||
be_stack_init(vm, &vm->exceptstack, sizeof(struct bexecptframe));
|
be_stack_init(vm, &vm->exceptstack, sizeof(struct bexecptframe));
|
||||||
be_stack_init(vm, &vm->tracestack, sizeof(bcallsnapshot));
|
be_stack_init(vm, &vm->tracestack, sizeof(bcallsnapshot));
|
||||||
vm->stack = be_malloc(vm, sizeof(bvalue) * BE_STACK_FREE_MIN);
|
vm->stack = be_malloc(vm, sizeof(bvalue) * BE_STACK_START);
|
||||||
vm->stacktop = vm->stack + BE_STACK_FREE_MIN;
|
vm->stacktop = vm->stack + BE_STACK_START;
|
||||||
vm->reg = vm->stack;
|
vm->reg = vm->stack;
|
||||||
vm->top = vm->reg;
|
vm->top = vm->reg;
|
||||||
be_globalvar_init(vm);
|
be_globalvar_init(vm);
|
||||||
|
|
|
@ -1651,6 +1651,22 @@ void ResetPwm(void)
|
||||||
|
|
||||||
/********************************************************************************************/
|
/********************************************************************************************/
|
||||||
|
|
||||||
|
#ifdef ESP32
|
||||||
|
// Since ESP-IDF 4.4, GPIO matrix or I/O is not reset during a restart
|
||||||
|
// and GPIO configuration can get stuck because of leftovers
|
||||||
|
//
|
||||||
|
// This patched version of pinMode forces a full GPIO reset before setting new mode
|
||||||
|
//
|
||||||
|
extern "C" void ARDUINO_ISR_ATTR __pinMode(uint8_t pin, uint8_t mode);
|
||||||
|
|
||||||
|
extern "C" void ARDUINO_ISR_ATTR pinMode(uint8_t pin, uint8_t mode) {
|
||||||
|
gpio_reset_pin((gpio_num_t)pin);
|
||||||
|
__pinMode(pin, mode);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/********************************************************************************************/
|
||||||
|
|
||||||
void GpioInit(void)
|
void GpioInit(void)
|
||||||
{
|
{
|
||||||
if (!ValidModule(Settings->module)) {
|
if (!ValidModule(Settings->module)) {
|
||||||
|
|
|
@ -241,34 +241,6 @@ int32_t callBerryEventDispatcher(const char *type, const char *cmd, int32_t idx,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// call a method in autoconf
|
|
||||||
int32_t callBerryAutoconf(const char * method) {
|
|
||||||
int32_t ret = 0;
|
|
||||||
bvm *vm = berry.vm;
|
|
||||||
|
|
||||||
if (nullptr == vm) { return ret; }
|
|
||||||
checkBeTop();
|
|
||||||
be_getglobal(vm, "autoconf");
|
|
||||||
if (!be_isnil(vm, -1)) {
|
|
||||||
be_getmethod(vm, -1, method);
|
|
||||||
if (!be_isnil(vm, -1)) {
|
|
||||||
be_pushvalue(vm, -2);
|
|
||||||
BrTimeoutStart();
|
|
||||||
ret = be_pcall(vm, 1); // 1 arg
|
|
||||||
BrTimeoutReset();
|
|
||||||
if (ret != 0) {
|
|
||||||
BerryDumpErrorAndClear(vm, false); // log in Tasmota console only
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
be_pop(vm, 1); // remove instance
|
|
||||||
}
|
|
||||||
be_pop(vm, 1); // remove method
|
|
||||||
}
|
|
||||||
be_pop(vm, 1); // remove instance object
|
|
||||||
checkBeTop();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* VM Observability
|
* VM Observability
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
@ -364,8 +336,8 @@ void BerryInit(void) {
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_BERRY "Berry initialized, RAM used=%u"), callBerryGC());
|
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_BERRY "Berry initialized, RAM used=%u"), callBerryGC());
|
||||||
berry_init_ok = true;
|
berry_init_ok = true;
|
||||||
|
|
||||||
// Run 'autoconf.preinit()'
|
// we generate a synthetic event `autoexec`
|
||||||
callBerryAutoconf("preinit");
|
callBerryEventDispatcher(PSTR("preinit"), nullptr, 0, nullptr);
|
||||||
|
|
||||||
// Run pre-init
|
// Run pre-init
|
||||||
BrLoad("preinit.be"); // run 'preinit.be' if present
|
BrLoad("preinit.be"); // run 'preinit.be' if present
|
||||||
|
@ -790,9 +762,6 @@ bool Xdrv52(uint8_t function)
|
||||||
// break;
|
// break;
|
||||||
case FUNC_LOOP:
|
case FUNC_LOOP:
|
||||||
if (!berry.autoexec_done) {
|
if (!berry.autoexec_done) {
|
||||||
// Run 'autoconf.preinit()'
|
|
||||||
callBerryAutoconf("autoexec");
|
|
||||||
|
|
||||||
// we generate a synthetic event `autoexec`
|
// we generate a synthetic event `autoexec`
|
||||||
callBerryEventDispatcher(PSTR("autoexec"), nullptr, 0, nullptr);
|
callBerryEventDispatcher(PSTR("autoexec"), nullptr, 0, nullptr);
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
|
|
||||||
// Parameters for equation
|
// Parameters for equation
|
||||||
#define ANALOG_V33 3.3 // ESP8266 / ESP32 Analog voltage
|
#define ANALOG_V33 3.3 // ESP8266 / ESP32 Analog voltage
|
||||||
#define ANALOG_T0 TO_KELVIN(25.0) // 25 degrees Celcius in Kelvin (= 298.15)
|
#define ANALOG_T0 TO_KELVIN(25.0) // 25 degrees Celsius in Kelvin (= 298.15)
|
||||||
|
|
||||||
// Shelly 2.5 NTC Thermistor
|
// Shelly 2.5 NTC Thermistor
|
||||||
// 3V3 --- ANALOG_NTC_BRIDGE_RESISTANCE ---v--- NTC --- Gnd
|
// 3V3 --- ANALOG_NTC_BRIDGE_RESISTANCE ---v--- NTC --- Gnd
|
||||||
|
@ -409,8 +409,15 @@ void AdcEverySecond(void) {
|
||||||
for (uint32_t idx = 0; idx < Adcs.present; idx++) {
|
for (uint32_t idx = 0; idx < Adcs.present; idx++) {
|
||||||
if (ADC_TEMP == Adc[idx].type) {
|
if (ADC_TEMP == Adc[idx].type) {
|
||||||
int adc = AdcRead(Adc[idx].pin, 2);
|
int adc = AdcRead(Adc[idx].pin, 2);
|
||||||
// Steinhart-Hart equation for thermistor as temperature sensor
|
// Steinhart-Hart equation for thermistor as temperature sensor:
|
||||||
|
// double Rt = (adc * Adc[idx].param1 * MAX_ADC_V) / (ANALOG_RANGE * ANALOG_V33 - (double)adc * MAX_ADC_V);
|
||||||
|
// MAX_ADC_V in ESP8266 is 1
|
||||||
|
// MAX_ADC_V in ESP32 is 3.3
|
||||||
|
#ifdef ESP8266
|
||||||
double Rt = (adc * Adc[idx].param1) / (ANALOG_RANGE * ANALOG_V33 - (double)adc); // Shelly param1 = 32000 (ANALOG_NTC_BRIDGE_RESISTANCE)
|
double Rt = (adc * Adc[idx].param1) / (ANALOG_RANGE * ANALOG_V33 - (double)adc); // Shelly param1 = 32000 (ANALOG_NTC_BRIDGE_RESISTANCE)
|
||||||
|
#else
|
||||||
|
double Rt = (adc * Adc[idx].param1) / (ANALOG_RANGE - (double)adc);
|
||||||
|
#endif
|
||||||
double BC = (double)Adc[idx].param3 / 10000; // Shelly param3 = 3350 (ANALOG_NTC_B_COEFFICIENT)
|
double BC = (double)Adc[idx].param3 / 10000; // Shelly param3 = 3350 (ANALOG_NTC_B_COEFFICIENT)
|
||||||
double T = BC / (BC / ANALOG_T0 + TaylorLog(Rt / (double)Adc[idx].param2)); // Shelly param2 = 10000 (ANALOG_NTC_RESISTANCE)
|
double T = BC / (BC / ANALOG_T0 + TaylorLog(Rt / (double)Adc[idx].param2)); // Shelly param2 = 10000 (ANALOG_NTC_RESISTANCE)
|
||||||
Adc[idx].temperature = ConvertTemp(TO_CELSIUS(T));
|
Adc[idx].temperature = ConvertTemp(TO_CELSIUS(T));
|
||||||
|
|
Loading…
Reference in New Issue