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]
|
||||
### Added
|
||||
- Autoconfiguration for ESP32 and variants
|
||||
- ESP32 fix leftover GPIO configuration after restart
|
||||
|
||||
### Changed
|
||||
- ESP8266 Gratuitous ARP enabled and set to 60 seconds (#13623)
|
||||
|
|
|
@ -100,6 +100,12 @@
|
|||
**/
|
||||
#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
|
||||
* Constants in function are limited to 255. However the compiler
|
||||
* will look for a maximum of pre-existing constants to avoid
|
||||
|
|
|
@ -293,6 +293,7 @@ autoconf_module.init = def (m)
|
|||
self._error = nil
|
||||
end
|
||||
|
||||
# called by the synthetic event `preinit`
|
||||
def preinit()
|
||||
if self._archive == nil return end
|
||||
# try to launch `preinit.be`
|
||||
|
@ -327,6 +328,7 @@ autoconf_module.init = def (m)
|
|||
end
|
||||
end
|
||||
|
||||
# called by the synthetic event `autoexec`
|
||||
def autoexec()
|
||||
if self._archive == nil return end
|
||||
# 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->exceptstack, sizeof(struct bexecptframe));
|
||||
be_stack_init(vm, &vm->tracestack, sizeof(bcallsnapshot));
|
||||
vm->stack = be_malloc(vm, sizeof(bvalue) * BE_STACK_FREE_MIN);
|
||||
vm->stacktop = vm->stack + BE_STACK_FREE_MIN;
|
||||
vm->stack = be_malloc(vm, sizeof(bvalue) * BE_STACK_START);
|
||||
vm->stacktop = vm->stack + BE_STACK_START;
|
||||
vm->reg = vm->stack;
|
||||
vm->top = vm->reg;
|
||||
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)
|
||||
{
|
||||
if (!ValidModule(Settings->module)) {
|
||||
|
|
|
@ -241,34 +241,6 @@ int32_t callBerryEventDispatcher(const char *type, const char *cmd, int32_t idx,
|
|||
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
|
||||
\*********************************************************************************************/
|
||||
|
@ -364,9 +336,9 @@ void BerryInit(void) {
|
|||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_BERRY "Berry initialized, RAM used=%u"), callBerryGC());
|
||||
berry_init_ok = true;
|
||||
|
||||
// Run 'autoconf.preinit()'
|
||||
callBerryAutoconf("preinit");
|
||||
|
||||
// we generate a synthetic event `autoexec`
|
||||
callBerryEventDispatcher(PSTR("preinit"), nullptr, 0, nullptr);
|
||||
|
||||
// Run pre-init
|
||||
BrLoad("preinit.be"); // run 'preinit.be' if present
|
||||
} while (0);
|
||||
|
@ -790,9 +762,6 @@ bool Xdrv52(uint8_t function)
|
|||
// break;
|
||||
case FUNC_LOOP:
|
||||
if (!berry.autoexec_done) {
|
||||
// Run 'autoconf.preinit()'
|
||||
callBerryAutoconf("autoexec");
|
||||
|
||||
// we generate a synthetic event `autoexec`
|
||||
callBerryEventDispatcher(PSTR("autoexec"), nullptr, 0, nullptr);
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
// Parameters for equation
|
||||
#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
|
||||
// 3V3 --- ANALOG_NTC_BRIDGE_RESISTANCE ---v--- NTC --- Gnd
|
||||
|
@ -409,8 +409,15 @@ void AdcEverySecond(void) {
|
|||
for (uint32_t idx = 0; idx < Adcs.present; idx++) {
|
||||
if (ADC_TEMP == Adc[idx].type) {
|
||||
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)
|
||||
#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 T = BC / (BC / ANALOG_T0 + TaylorLog(Rt / (double)Adc[idx].param2)); // Shelly param2 = 10000 (ANALOG_NTC_RESISTANCE)
|
||||
Adc[idx].temperature = ConvertTemp(TO_CELSIUS(T));
|
||||
|
|
Loading…
Reference in New Issue