mirror of https://github.com/arendst/Tasmota.git
v5.9.1g - Add Pow Energy set and Clock tuning
5.9.1g * Fix typo ALIRFRCV into ARIRFRCV * Add nicer clock support for larger hand widths * Add better clock support for different pixel counts (#1226) * Remove command EnergyReset 1..3 * Add commands EnergyReset1 0..42500, EnergyReset2 0..42500 and EnergyReset3 0..42500000 * to (Re)set Energy Today, Yesterday or Total respectively in Wh (#406, #685, #1202) * Add SettingsSaveAll routine to command SaveData to be used before controlled power down (#1202)
This commit is contained in:
parent
299bed1c05
commit
8366ee116a
|
@ -1,7 +1,7 @@
|
|||
## Sonoff-Tasmota
|
||||
Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE.
|
||||
|
||||
Current version is **5.9.1f** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
|
||||
Current version is **5.9.1g** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/development/sonoff/_releasenotes.ino) for change information.
|
||||
|
||||
### ATTENTION All versions
|
||||
|
||||
|
|
|
@ -1,4 +1,13 @@
|
|||
/* 5.9.1f
|
||||
/* 5.9.1g
|
||||
* Fix typo ALIRFRCV into ARIRFRCV
|
||||
* Add nicer clock support for larger hand widths
|
||||
* Add better clock support for different pixel counts (#1226)
|
||||
* Remove command EnergyReset 1..3
|
||||
* Add commands EnergyReset1 0..42500, EnergyReset2 0..42500 and EnergyReset3 0..42500000
|
||||
* to (Re)set Energy Today, Yesterday or Total respectively in Wh (#406, #685, #1202)
|
||||
* Add SettingsSaveAll routine to command SaveData to be used before controlled power down (#1202)
|
||||
*
|
||||
* 5.9.1f
|
||||
* Upgrade library ArduinoJson to 5.11.2
|
||||
* Upgrade library IRRemoteEsp8266 to 2.2.1 + 2 commits but tweaked some protocols to keep code usage small
|
||||
* Upgrade library NeoPixelBus to 2.2.9
|
||||
|
|
|
@ -175,6 +175,20 @@ uint32_t GetSettingsHash()
|
|||
return hash;
|
||||
}
|
||||
|
||||
void SettingsSaveAll()
|
||||
{
|
||||
if (Settings.flag.save_state) {
|
||||
Settings.power = power;
|
||||
} else {
|
||||
Settings.power = 0;
|
||||
}
|
||||
if (hlw_flg) {
|
||||
HlwSaveState();
|
||||
}
|
||||
CounterSaveState();
|
||||
SettingsSave(0);
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Config Save - Save parameters to Flash ONLY if any parameter has changed
|
||||
\*********************************************************************************************/
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
- Select IDE Tools - Flash Size: "1M (no SPIFFS)"
|
||||
====================================================*/
|
||||
|
||||
#define VERSION 0x05090106 // 5.9.1f
|
||||
#define VERSION 0x05090107 // 5.9.1g
|
||||
|
||||
// Location specific includes
|
||||
#include "sonoff.h" // Enumaration used in user_config.h
|
||||
|
@ -979,10 +979,7 @@ void MqttDataCallback(char* topic, byte* data, unsigned int data_len)
|
|||
Settings.save_data = payload;
|
||||
save_data_counter = Settings.save_data;
|
||||
}
|
||||
if (Settings.flag.save_state) {
|
||||
Settings.power = power;
|
||||
}
|
||||
SettingsSave(0);
|
||||
SettingsSaveAll();
|
||||
if (Settings.save_data > 1) {
|
||||
snprintf_P(stemp1, sizeof(stemp1), PSTR(D_EVERY " %d " D_UNIT_SECOND), Settings.save_data);
|
||||
}
|
||||
|
@ -2316,25 +2313,15 @@ void StateLoop()
|
|||
}
|
||||
}
|
||||
if (restart_flag && (backlog_pointer == backlog_index)) {
|
||||
if (212 == restart_flag) {
|
||||
SettingsErase();
|
||||
restart_flag--;
|
||||
}
|
||||
if (211 == restart_flag) {
|
||||
SettingsDefault();
|
||||
restart_flag = 2;
|
||||
}
|
||||
if (212 == restart_flag) {
|
||||
SettingsErase();
|
||||
SettingsDefault();
|
||||
restart_flag = 2;
|
||||
}
|
||||
if (Settings.flag.save_state) {
|
||||
Settings.power = power;
|
||||
} else {
|
||||
Settings.power = 0;
|
||||
}
|
||||
if (hlw_flg) {
|
||||
HlwSaveState();
|
||||
}
|
||||
CounterSaveState();
|
||||
SettingsSave(0);
|
||||
SettingsSaveAll();
|
||||
restart_flag--;
|
||||
if (restart_flag <= 0) {
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_RESTARTING));
|
||||
|
@ -2763,7 +2750,7 @@ void loop()
|
|||
#endif // USE_EMULATION
|
||||
|
||||
#ifdef USE_ARILUX_RF
|
||||
if (pin[GPIO_ALIRFRCV] < 99) {
|
||||
if (pin[GPIO_ARIRFRCV] < 99) {
|
||||
AriluxRfHandler();
|
||||
}
|
||||
#endif // USE_ARILUX_RF
|
||||
|
|
|
@ -150,7 +150,7 @@ enum ProgramSelectablePins {
|
|||
GPIO_ADC0, // ADC
|
||||
GPIO_DI, // my92x1 PWM input
|
||||
GPIO_DCKI, // my92x1 CLK input
|
||||
GPIO_ALIRFRCV, // AliLux RF Receive input
|
||||
GPIO_ARIRFRCV, // AliLux RF Receive input
|
||||
GPIO_USER, // User configurable
|
||||
GPIO_MAX };
|
||||
|
||||
|
@ -739,7 +739,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
|
|||
0,
|
||||
GPIO_LED2_INV, // GPIO02 RF receiver control
|
||||
0,
|
||||
GPIO_ALIRFRCV, // GPIO04 IR or RF receiver (optional)
|
||||
GPIO_ARIRFRCV, // GPIO04 IR or RF receiver (optional)
|
||||
GPIO_PWM1, // GPIO05 RGB LED Red
|
||||
0, 0, 0, 0, 0, 0, // Flash connection
|
||||
GPIO_PWM2, // GPIO12 RGB LED Green
|
||||
|
@ -759,7 +759,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
|
|||
GPIO_PWM5, // GPIO12 RGBCW LED Warm
|
||||
GPIO_PWM4, // GPIO13 RGBW LED Cold
|
||||
GPIO_PWM3, // GPIO14 RGB LED Blue
|
||||
GPIO_ALIRFRCV, // GPIO15 RF receiver input
|
||||
GPIO_ARIRFRCV, // GPIO15 RF receiver input
|
||||
0, 0
|
||||
}
|
||||
};
|
||||
|
|
|
@ -230,7 +230,7 @@ void AriluxRfHandler()
|
|||
|
||||
void AriluxRfInit()
|
||||
{
|
||||
if ((pin[GPIO_ALIRFRCV] < 99) && (pin[GPIO_LED2] < 99)) {
|
||||
if ((pin[GPIO_ARIRFRCV] < 99) && (pin[GPIO_LED2] < 99)) {
|
||||
if (Settings.last_module != Settings.module) {
|
||||
Settings.rf_code[1][6] = 0;
|
||||
Settings.rf_code[1][7] = 0;
|
||||
|
@ -238,7 +238,7 @@ void AriluxRfInit()
|
|||
}
|
||||
arilux_rf_received_value = 0;
|
||||
digitalWrite(pin[GPIO_LED2], !bitRead(led_inverted, 1)); // Turn on RF
|
||||
attachInterrupt(pin[GPIO_ALIRFRCV], AriluxRfInterrupt, CHANGE);
|
||||
attachInterrupt(pin[GPIO_ARIRFRCV], AriluxRfInterrupt, CHANGE);
|
||||
}
|
||||
}
|
||||
#endif // USE_ARILUX_RF
|
||||
|
@ -349,7 +349,7 @@ void LightInit(void)
|
|||
digitalWrite(14, LOW);
|
||||
}
|
||||
}
|
||||
if (pin[GPIO_ALIRFRCV] < 99) {
|
||||
if (pin[GPIO_ARIRFRCV] < 99) {
|
||||
#ifdef USE_ARILUX_RF
|
||||
AriluxRfInit();
|
||||
#else
|
||||
|
|
|
@ -122,7 +122,7 @@ int mod(int a, int b)
|
|||
|
||||
#define cmin(a,b) ((a)<(b)?(a):(b))
|
||||
|
||||
void Ws2812UpdatePixelColor(int position, struct WsColor hand_color, uint8_t hand)
|
||||
void Ws2812UpdatePixelColor(int position, struct WsColor hand_color, float offset)
|
||||
{
|
||||
#if (USE_WS2812_CTYPE > 1)
|
||||
RgbwColor color;
|
||||
|
@ -134,10 +134,9 @@ void Ws2812UpdatePixelColor(int position, struct WsColor hand_color, uint8_t han
|
|||
|
||||
color = strip->GetPixelColor(mod_position);
|
||||
float dimmer = 100 / (float)Settings.light_dimmer;
|
||||
uint8_t offset = 1 << hand;
|
||||
color.R = cmin(color.R + ((hand_color.red / dimmer) / offset), 255);
|
||||
color.G = cmin(color.G + ((hand_color.green / dimmer) / offset), 255);
|
||||
color.B = cmin(color.B + ((hand_color.blue / dimmer) / offset), 255);
|
||||
color.R = cmin(color.R + ((hand_color.red / dimmer) * offset), 255);
|
||||
color.G = cmin(color.G + ((hand_color.green / dimmer) * offset), 255);
|
||||
color.B = cmin(color.B + ((hand_color.blue / dimmer) * offset), 255);
|
||||
strip->SetPixelColor(mod_position, color);
|
||||
}
|
||||
|
||||
|
@ -148,20 +147,22 @@ void Ws2812UpdateHand(int position, uint8_t index)
|
|||
}
|
||||
WsColor hand_color = { Settings.ws_color[index][WS_RED], Settings.ws_color[index][WS_GREEN], Settings.ws_color[index][WS_BLUE] };
|
||||
|
||||
Ws2812UpdatePixelColor(position, hand_color, 0);
|
||||
for (uint8_t h = 1; h <= ((Settings.ws_width[index] -1) / 2); h++) {
|
||||
Ws2812UpdatePixelColor(position -h, hand_color, h);
|
||||
Ws2812UpdatePixelColor(position +h, hand_color, h);
|
||||
Ws2812UpdatePixelColor(position, hand_color, 1);
|
||||
uint8_t range = ((Settings.ws_width[index] -1) / 2) +1;
|
||||
for (uint8_t h = 1; h < range; h++) {
|
||||
float offset = (float)(range - h) / (float)range;
|
||||
Ws2812UpdatePixelColor(position -h, hand_color, offset);
|
||||
Ws2812UpdatePixelColor(position +h, hand_color, offset);
|
||||
}
|
||||
}
|
||||
|
||||
void Ws2812Clock()
|
||||
{
|
||||
strip->ClearTo(0); // Reset strip
|
||||
int clksize = 600 / (int)Settings.light_pixels;
|
||||
Ws2812UpdateHand((RtcTime.second * 10) / clksize, WS_SECOND);
|
||||
Ws2812UpdateHand((RtcTime.minute * 10) / clksize, WS_MINUTE);
|
||||
Ws2812UpdateHand(((RtcTime.hour % 12) * (50 / clksize)) + ((RtcTime.minute * 10) / (12 * clksize)), WS_HOUR);
|
||||
int clksize = 60000 / (int)Settings.light_pixels;
|
||||
Ws2812UpdateHand((RtcTime.second * 1000) / clksize, WS_SECOND);
|
||||
Ws2812UpdateHand((RtcTime.minute * 1000) / clksize, WS_MINUTE);
|
||||
Ws2812UpdateHand(((RtcTime.hour % 12) * (5000 / clksize)) + ((RtcTime.minute * 1000) / (12 * clksize)), WS_HOUR);
|
||||
|
||||
Ws2812StripShow();
|
||||
}
|
||||
|
|
|
@ -506,7 +506,8 @@ boolean HlwCommand(char *type, uint16_t index, char *dataBuf, uint16_t data_len,
|
|||
nvalue = Settings.hlw_imax;
|
||||
unit = UNIT_MILLIAMPERE;
|
||||
}
|
||||
else if (CMND_ENERGYRESET == command_code) {
|
||||
else if ((CMND_ENERGYRESET == command_code) && (index > 0) && (index <= 3)) {
|
||||
/*
|
||||
if ((payload >= 1) && (payload <= 3)) {
|
||||
switch (payload) {
|
||||
case 1:
|
||||
|
@ -523,6 +524,26 @@ boolean HlwCommand(char *type, uint16_t index, char *dataBuf, uint16_t data_len,
|
|||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
char *p;
|
||||
long lnum = strtol(dataBuf, &p, 10);
|
||||
if (p != dataBuf) {
|
||||
lnum *= 100;
|
||||
switch (index) {
|
||||
case 1:
|
||||
hlw_kWhtoday = lnum *1000;
|
||||
RtcSettings.hlw_kWhtoday = hlw_kWhtoday;
|
||||
Settings.hlw_kWhtoday = hlw_kWhtoday;
|
||||
break;
|
||||
case 2:
|
||||
Settings.hlw_kWhyesterday = lnum *1000;
|
||||
break;
|
||||
case 3:
|
||||
RtcSettings.hlw_kWhtotal = lnum;
|
||||
Settings.hlw_kWhtotal = RtcSettings.hlw_kWhtotal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
char syesterday_energy[10];
|
||||
char stoday_energy[10];
|
||||
char stotal_energy[10];
|
||||
|
|
Loading…
Reference in New Issue