Merge pull request #7 from arendst/development

Revisit Timers off/on
This commit is contained in:
andrethomas 2018-07-20 20:05:51 +02:00 committed by GitHub
commit e6f67997af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 8 deletions

View File

@ -15,7 +15,7 @@ If you like **Sonoff-Tasmota**, give it a star, or fork it and contribute!
### Development ### Development
[![Build Status](https://img.shields.io/travis/arendst/Sonoff-Tasmota.svg)](https://travis-ci.org/arendst/Sonoff-Tasmota) [![Build Status](https://img.shields.io/travis/arendst/Sonoff-Tasmota.svg)](https://travis-ci.org/arendst/Sonoff-Tasmota)
Current version is **6.1.1b** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for release information and [sonoff/_changelog.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_changelog.ino) for change information. Current version is **6.1.1c** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for release information and [sonoff/_changelog.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_changelog.ino) for change information.
### Disclaimer ### Disclaimer
:warning: **DANGER OF ELECTROCUTION** :warning: :warning: **DANGER OF ELECTROCUTION** :warning:

View File

@ -1,4 +1,7 @@
/* 6.1.1b /* 6.1.1c
* Add command Timers 0/1 to globally disable or enable armed timers (#3270)
*
* 6.1.1b
* Add support for MPR121 controller in input mode for touch buttons (#3142) * Add support for MPR121 controller in input mode for touch buttons (#3142)
* Add support for MCP230xx for general purpose input expansion and command Sensor29 (#3188) * Add support for MCP230xx for general purpose input expansion and command Sensor29 (#3188)
* Fix command Scale buffer overflow (#3236) * Fix command Scale buffer overflow (#3236)

View File

@ -63,7 +63,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
typedef union { // Restricted by MISRA-C Rule 18.4 but so usefull... typedef union { // Restricted by MISRA-C Rule 18.4 but so usefull...
uint32_t data; // Allow bit manipulation using SetOption uint32_t data; // Allow bit manipulation using SetOption
struct { // SetOption50 .. SetOption81 struct { // SetOption50 .. SetOption81
uint32_t spare00 : 1; uint32_t timers_enable : 1; // bit 0 (v6.1.1b)
uint32_t spare01 : 1; uint32_t spare01 : 1;
uint32_t spare02 : 1; uint32_t spare02 : 1;
uint32_t spare03 : 1; uint32_t spare03 : 1;

View File

@ -782,6 +782,9 @@ void SettingsDelta()
Settings.flag.rules_once = 0; Settings.flag.rules_once = 0;
Settings.flag3.data = 0; Settings.flag3.data = 0;
} }
if (Settings.version < 0x06010103) {
Settings.flag3.timers_enable = 1;
}
Settings.version = VERSION; Settings.version = VERSION;
SettingsSave(1); SettingsSave(1);

View File

@ -25,7 +25,7 @@
- Select IDE Tools - Flash Size: "1M (no SPIFFS)" - Select IDE Tools - Flash Size: "1M (no SPIFFS)"
====================================================*/ ====================================================*/
#define VERSION 0x06010102 // 6.1.1b #define VERSION 0x06010103 // 6.1.1c
// Location specific includes // Location specific includes
#include <core_version.h> // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0) #include <core_version.h> // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0)

View File

@ -262,7 +262,7 @@ void TimerEverySecond()
{ {
if (RtcTime.valid) { if (RtcTime.valid) {
if (!RtcTime.hour && !RtcTime.minute && !RtcTime.second) { TimerSetRandomWindows(); } // Midnight if (!RtcTime.hour && !RtcTime.minute && !RtcTime.second) { TimerSetRandomWindows(); } // Midnight
if ((uptime > 60) && (RtcTime.minute != timer_last_minute)) { // Execute from one minute after restart every minute only once if (Settings.flag3.timers_enable && (uptime > 60) && (RtcTime.minute != timer_last_minute)) { // Execute from one minute after restart every minute only once
timer_last_minute = RtcTime.minute; timer_last_minute = RtcTime.minute;
int16_t time = (RtcTime.hour *60) + RtcTime.minute; int16_t time = (RtcTime.hour *60) + RtcTime.minute;
uint8_t days = 1 << (RtcTime.day_of_week -1); uint8_t days = 1 << (RtcTime.day_of_week -1);
@ -451,11 +451,15 @@ boolean TimerCommand()
} }
} }
else if (CMND_TIMERS == command_code) { else if (CMND_TIMERS == command_code) {
if (XdrvMailbox.data_len && (XdrvMailbox.payload == 0)) { if (XdrvMailbox.data_len) {
for (byte i = 0; i < MAX_TIMERS; i++) { if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 1)) {
Settings.timer[i].arm = 0; // Disable all timers Settings.flag3.timers_enable = XdrvMailbox.payload;
} }
} }
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, GetStateText(Settings.flag3.timers_enable));
MqttPublishPrefixTopic_P(RESULT_OR_STAT, command);
byte jsflg = 0; byte jsflg = 0;
byte lines = 1; byte lines = 1;
for (byte i = 0; i < MAX_TIMERS; i++) { for (byte i = 0; i < MAX_TIMERS; i++) {