mirror of https://github.com/arendst/Tasmota.git
Merge branch 'arendst:development' into development
This commit is contained in:
commit
5e9765bc9f
|
@ -113,7 +113,8 @@ bool analogAttach(uint32_t pin) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void analogWrite(uint8_t pin, int val)
|
// void analogWrite(uint8_t pin, int val);
|
||||||
|
extern "C" void __wrap__Z11analogWritehi(uint8_t pin, int val)
|
||||||
{
|
{
|
||||||
uint32_t channel = _analog_pin2chan(pin);
|
uint32_t channel = _analog_pin2chan(pin);
|
||||||
if ( val >> (_pwm_bit_num-1) ) ++val;
|
if ( val >> (_pwm_bit_num-1) ) ++val;
|
||||||
|
|
|
@ -32,19 +32,20 @@ build_flags = ${esp_defaults.build_flags}
|
||||||
-include "esp32x_fixes.h"
|
-include "esp32x_fixes.h"
|
||||||
; wrappers for the crash-recorder
|
; wrappers for the crash-recorder
|
||||||
-Wl,--wrap=panicHandler -Wl,--wrap=xt_unhandled_exception
|
-Wl,--wrap=panicHandler -Wl,--wrap=xt_unhandled_exception
|
||||||
|
-Wl,--wrap=_Z11analogWritehi ; `analogWrite(unsigned char, int)` use the Tasmota version of analogWrite for deeper integration and phase control
|
||||||
extra_scripts = pre:pio-tools/add_c_flags.py
|
extra_scripts = pre:pio-tools/add_c_flags.py
|
||||||
post:pio-tools/post_esp32.py
|
post:pio-tools/post_esp32.py
|
||||||
${esp_defaults.extra_scripts}
|
${esp_defaults.extra_scripts}
|
||||||
|
|
||||||
[core32]
|
[core32]
|
||||||
platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2.1/platform-tasmota-espressif32-2.0.2.1.zip
|
platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2.2/platform-tasmota-espressif32-2.0.2.zip
|
||||||
platform_packages =
|
platform_packages =
|
||||||
build_unflags = ${esp32_defaults.build_unflags}
|
build_unflags = ${esp32_defaults.build_unflags}
|
||||||
build_flags = ${esp32_defaults.build_flags}
|
build_flags = ${esp32_defaults.build_flags}
|
||||||
|
|
||||||
|
|
||||||
[core32solo1]
|
[core32solo1]
|
||||||
platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2.1solo1/platform-tasmota-espressif32-2.0.2.1solo1.zip
|
platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.2.2solo1/platform-tasmota-espressif32-2.0.2solo1.zip
|
||||||
platform_packages =
|
platform_packages =
|
||||||
build_unflags = ${esp32_defaults.build_unflags}
|
build_unflags = ${esp32_defaults.build_unflags}
|
||||||
build_flags = ${esp32_defaults.build_flags}
|
build_flags = ${esp32_defaults.build_flags}
|
||||||
|
|
|
@ -95,7 +95,7 @@ void DeepSleepPrepare(void)
|
||||||
if ((RtcSettings.nextwakeup == 0) ||
|
if ((RtcSettings.nextwakeup == 0) ||
|
||||||
(RtcSettings.deepsleep_slip < 9000) ||
|
(RtcSettings.deepsleep_slip < 9000) ||
|
||||||
(RtcSettings.deepsleep_slip > 11000) ||
|
(RtcSettings.deepsleep_slip > 11000) ||
|
||||||
(RtcSettings.nextwakeup > (UtcTime() + Settings->deepsleep))) {
|
(RtcSettings.nextwakeup > (LocalTime() + Settings->deepsleep))) {
|
||||||
AddLog(LOG_LEVEL_ERROR, PSTR("DSL: Reset wrong settings wakeup: %ld, slip %ld"), RtcSettings.nextwakeup, RtcSettings.deepsleep_slip );
|
AddLog(LOG_LEVEL_ERROR, PSTR("DSL: Reset wrong settings wakeup: %ld, slip %ld"), RtcSettings.nextwakeup, RtcSettings.deepsleep_slip );
|
||||||
RtcSettings.nextwakeup = 0;
|
RtcSettings.nextwakeup = 0;
|
||||||
RtcSettings.deepsleep_slip = 10000;
|
RtcSettings.deepsleep_slip = 10000;
|
||||||
|
@ -103,13 +103,13 @@ void DeepSleepPrepare(void)
|
||||||
|
|
||||||
// Timeslip in 0.1 seconds between the real wakeup and the calculated wakeup
|
// Timeslip in 0.1 seconds between the real wakeup and the calculated wakeup
|
||||||
// Because deepsleep is in second and timeslip in 0.1 sec the compare always check if the slip is in the 10% range
|
// Because deepsleep is in second and timeslip in 0.1 sec the compare always check if the slip is in the 10% range
|
||||||
int16_t timeslip = (int16_t)(RtcSettings.nextwakeup + millis() / 1000 - UtcTime()) * 10;
|
int16_t timeslip = (int16_t)(RtcSettings.nextwakeup + millis() / 1000 - LocalTime()) * 10;
|
||||||
|
|
||||||
// Allow 10% of deepsleep error to count as valid deepsleep; expecting 3-4%
|
// Allow 10% of deepsleep error to count as valid deepsleep; expecting 3-4%
|
||||||
// if more then 10% timeslip = 0 == non valid wakeup; maybe manual
|
// if more then 10% timeslip = 0 == non valid wakeup; maybe manual
|
||||||
timeslip = (timeslip < -(int32_t)Settings->deepsleep) ? 0 : (timeslip > (int32_t)Settings->deepsleep) ? 0 : 1;
|
timeslip = (timeslip < -(int32_t)Settings->deepsleep) ? 0 : (timeslip > (int32_t)Settings->deepsleep) ? 0 : 1;
|
||||||
if (timeslip) {
|
if (timeslip) {
|
||||||
RtcSettings.deepsleep_slip = (Settings->deepsleep + RtcSettings.nextwakeup - UtcTime()) * RtcSettings.deepsleep_slip / tmax((Settings->deepsleep - (millis() / 1000)),5);
|
RtcSettings.deepsleep_slip = (Settings->deepsleep + RtcSettings.nextwakeup - LocalTime()) * RtcSettings.deepsleep_slip / tmax((Settings->deepsleep - (millis() / 1000)),5);
|
||||||
// Avoid crazy numbers. Again maximum 10% deviation.
|
// Avoid crazy numbers. Again maximum 10% deviation.
|
||||||
RtcSettings.deepsleep_slip = tmin(tmax(RtcSettings.deepsleep_slip, 9000), 11000);
|
RtcSettings.deepsleep_slip = tmin(tmax(RtcSettings.deepsleep_slip, 9000), 11000);
|
||||||
RtcSettings.nextwakeup += Settings->deepsleep;
|
RtcSettings.nextwakeup += Settings->deepsleep;
|
||||||
|
@ -117,15 +117,15 @@ void DeepSleepPrepare(void)
|
||||||
|
|
||||||
// It may happen that wakeup in just <5 seconds in future
|
// It may happen that wakeup in just <5 seconds in future
|
||||||
// In this case also add deepsleep to nextwakeup
|
// In this case also add deepsleep to nextwakeup
|
||||||
if (RtcSettings.nextwakeup <= (UtcTime() - DEEPSLEEP_MIN_TIME)) {
|
if (RtcSettings.nextwakeup <= (LocalTime() - DEEPSLEEP_MIN_TIME)) {
|
||||||
// ensure nextwakeup is at least in the future
|
// ensure nextwakeup is at least in the future
|
||||||
RtcSettings.nextwakeup += (((UtcTime() + DEEPSLEEP_MIN_TIME - RtcSettings.nextwakeup) / Settings->deepsleep) + 1) * Settings->deepsleep;
|
RtcSettings.nextwakeup += (((LocalTime() + DEEPSLEEP_MIN_TIME - RtcSettings.nextwakeup) / Settings->deepsleep) + 1) * Settings->deepsleep;
|
||||||
}
|
}
|
||||||
|
|
||||||
String dt = GetDT(RtcSettings.nextwakeup + LocalTime() - UtcTime()); // 2017-03-07T11:08:02
|
String dt = GetDT(RtcSettings.nextwakeup); // 2017-03-07T11:08:02
|
||||||
// Limit sleeptime to DEEPSLEEP_MAX_CYCLE
|
// Limit sleeptime to DEEPSLEEP_MAX_CYCLE
|
||||||
// uint32_t deepsleep_sleeptime = DEEPSLEEP_MAX_CYCLE < (RtcSettings.nextwakeup - UtcTime()) ? (uint32_t)DEEPSLEEP_MAX_CYCLE : RtcSettings.nextwakeup - UtcTime();
|
// uint32_t deepsleep_sleeptime = DEEPSLEEP_MAX_CYCLE < (RtcSettings.nextwakeup - LocalTime()) ? (uint32_t)DEEPSLEEP_MAX_CYCLE : RtcSettings.nextwakeup - LocalTime();
|
||||||
deepsleep_sleeptime = tmin((uint32_t)DEEPSLEEP_MAX_CYCLE ,RtcSettings.nextwakeup - UtcTime());
|
deepsleep_sleeptime = tmin((uint32_t)DEEPSLEEP_MAX_CYCLE ,RtcSettings.nextwakeup - LocalTime());
|
||||||
|
|
||||||
// stat/tasmota/DEEPSLEEP = {"DeepSleep":{"Time":"2019-11-12T21:33:45","Epoch":1573590825}}
|
// stat/tasmota/DEEPSLEEP = {"DeepSleep":{"Time":"2019-11-12T21:33:45","Epoch":1573590825}}
|
||||||
Response_P(PSTR("{\"" D_PRFX_DEEPSLEEP "\":{\"" D_JSON_TIME "\":\"%s\",\"Epoch\":%d}}"), (char*)dt.c_str(), RtcSettings.nextwakeup);
|
Response_P(PSTR("{\"" D_PRFX_DEEPSLEEP "\":{\"" D_JSON_TIME "\":\"%s\",\"Epoch\":%d}}"), (char*)dt.c_str(), RtcSettings.nextwakeup);
|
||||||
|
@ -140,7 +140,7 @@ void DeepSleepStart(void)
|
||||||
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "Sleeping")); // Won't show in GUI
|
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "Sleeping")); // Won't show in GUI
|
||||||
|
|
||||||
WifiShutdown();
|
WifiShutdown();
|
||||||
RtcSettings.ultradeepsleep = RtcSettings.nextwakeup - UtcTime();
|
RtcSettings.ultradeepsleep = RtcSettings.nextwakeup - LocalTime();
|
||||||
RtcSettingsSave();
|
RtcSettingsSave();
|
||||||
RtcRebootReset();
|
RtcRebootReset();
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
|
|
|
@ -325,10 +325,17 @@ extern "C" {
|
||||||
int32_t wc_tcp_read(struct bvm *vm);
|
int32_t wc_tcp_read(struct bvm *vm);
|
||||||
int32_t wc_tcp_read(struct bvm *vm) {
|
int32_t wc_tcp_read(struct bvm *vm) {
|
||||||
WiFiClient * tcp = wc_getwificlient(vm);
|
WiFiClient * tcp = wc_getwificlient(vm);
|
||||||
|
int32_t max_read = -1; // by default read as much as we can
|
||||||
|
if (be_top(vm) >= 2 && be_isint(vm, 2)) {
|
||||||
|
max_read = be_toint(vm, 2);
|
||||||
|
}
|
||||||
int32_t btr = tcp->available();
|
int32_t btr = tcp->available();
|
||||||
if (btr <= 0) {
|
if (btr <= 0) {
|
||||||
be_pushstring(vm, "");
|
be_pushstring(vm, "");
|
||||||
} else {
|
} else {
|
||||||
|
if ((max_read >= 0) && (btr > max_read)) {
|
||||||
|
btr = max_read;
|
||||||
|
}
|
||||||
char * buf = (char*) be_pushbuffer(vm, btr);
|
char * buf = (char*) be_pushbuffer(vm, btr);
|
||||||
int32_t btr2 = tcp->read((uint8_t*) buf, btr);
|
int32_t btr2 = tcp->read((uint8_t*) buf, btr);
|
||||||
be_pushnstring(vm, buf, btr2);
|
be_pushnstring(vm, buf, btr2);
|
||||||
|
@ -340,10 +347,17 @@ extern "C" {
|
||||||
int32_t wc_tcp_readbytes(struct bvm *vm);
|
int32_t wc_tcp_readbytes(struct bvm *vm);
|
||||||
int32_t wc_tcp_readbytes(struct bvm *vm) {
|
int32_t wc_tcp_readbytes(struct bvm *vm) {
|
||||||
WiFiClient * tcp = wc_getwificlient(vm);
|
WiFiClient * tcp = wc_getwificlient(vm);
|
||||||
|
int32_t max_read = -1; // by default read as much as we can
|
||||||
|
if (be_top(vm) >= 2 && be_isint(vm, 2)) {
|
||||||
|
max_read = be_toint(vm, 2);
|
||||||
|
}
|
||||||
int32_t btr = tcp->available();
|
int32_t btr = tcp->available();
|
||||||
if (btr <= 0) {
|
if (btr <= 0) {
|
||||||
be_pushbytes(vm, nullptr, 0);
|
be_pushbytes(vm, nullptr, 0);
|
||||||
} else {
|
} else {
|
||||||
|
if ((max_read >= 0) && (btr > max_read)) {
|
||||||
|
btr = max_read;
|
||||||
|
}
|
||||||
uint8_t * buf = (uint8_t*) be_pushbuffer(vm, btr);
|
uint8_t * buf = (uint8_t*) be_pushbuffer(vm, btr);
|
||||||
int32_t btr2 = tcp->read(buf, btr);
|
int32_t btr2 = tcp->read(buf, btr);
|
||||||
be_pushbytes(vm, buf, btr2);
|
be_pushbytes(vm, buf, btr2);
|
||||||
|
|
Loading…
Reference in New Issue