mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 20:56:35 +00:00
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
|
## 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.
|
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
|
### 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 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 IRRemoteEsp8266 to 2.2.1 + 2 commits but tweaked some protocols to keep code usage small
|
||||||
* Upgrade library NeoPixelBus to 2.2.9
|
* Upgrade library NeoPixelBus to 2.2.9
|
||||||
|
@ -175,6 +175,20 @@ uint32_t GetSettingsHash()
|
|||||||
return hash;
|
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
|
* Config Save - Save parameters to Flash ONLY if any parameter has changed
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
- Select IDE Tools - Flash Size: "1M (no SPIFFS)"
|
- Select IDE Tools - Flash Size: "1M (no SPIFFS)"
|
||||||
====================================================*/
|
====================================================*/
|
||||||
|
|
||||||
#define VERSION 0x05090106 // 5.9.1f
|
#define VERSION 0x05090107 // 5.9.1g
|
||||||
|
|
||||||
// Location specific includes
|
// Location specific includes
|
||||||
#include "sonoff.h" // Enumaration used in user_config.h
|
#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;
|
Settings.save_data = payload;
|
||||||
save_data_counter = Settings.save_data;
|
save_data_counter = Settings.save_data;
|
||||||
}
|
}
|
||||||
if (Settings.flag.save_state) {
|
SettingsSaveAll();
|
||||||
Settings.power = power;
|
|
||||||
}
|
|
||||||
SettingsSave(0);
|
|
||||||
if (Settings.save_data > 1) {
|
if (Settings.save_data > 1) {
|
||||||
snprintf_P(stemp1, sizeof(stemp1), PSTR(D_EVERY " %d " D_UNIT_SECOND), Settings.save_data);
|
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 (restart_flag && (backlog_pointer == backlog_index)) {
|
||||||
|
if (212 == restart_flag) {
|
||||||
|
SettingsErase();
|
||||||
|
restart_flag--;
|
||||||
|
}
|
||||||
if (211 == restart_flag) {
|
if (211 == restart_flag) {
|
||||||
SettingsDefault();
|
SettingsDefault();
|
||||||
restart_flag = 2;
|
restart_flag = 2;
|
||||||
}
|
}
|
||||||
if (212 == restart_flag) {
|
SettingsSaveAll();
|
||||||
SettingsErase();
|
|
||||||
SettingsDefault();
|
|
||||||
restart_flag = 2;
|
|
||||||
}
|
|
||||||
if (Settings.flag.save_state) {
|
|
||||||
Settings.power = power;
|
|
||||||
} else {
|
|
||||||
Settings.power = 0;
|
|
||||||
}
|
|
||||||
if (hlw_flg) {
|
|
||||||
HlwSaveState();
|
|
||||||
}
|
|
||||||
CounterSaveState();
|
|
||||||
SettingsSave(0);
|
|
||||||
restart_flag--;
|
restart_flag--;
|
||||||
if (restart_flag <= 0) {
|
if (restart_flag <= 0) {
|
||||||
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_RESTARTING));
|
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_RESTARTING));
|
||||||
@ -2763,7 +2750,7 @@ void loop()
|
|||||||
#endif // USE_EMULATION
|
#endif // USE_EMULATION
|
||||||
|
|
||||||
#ifdef USE_ARILUX_RF
|
#ifdef USE_ARILUX_RF
|
||||||
if (pin[GPIO_ALIRFRCV] < 99) {
|
if (pin[GPIO_ARIRFRCV] < 99) {
|
||||||
AriluxRfHandler();
|
AriluxRfHandler();
|
||||||
}
|
}
|
||||||
#endif // USE_ARILUX_RF
|
#endif // USE_ARILUX_RF
|
||||||
|
@ -150,7 +150,7 @@ enum ProgramSelectablePins {
|
|||||||
GPIO_ADC0, // ADC
|
GPIO_ADC0, // ADC
|
||||||
GPIO_DI, // my92x1 PWM input
|
GPIO_DI, // my92x1 PWM input
|
||||||
GPIO_DCKI, // my92x1 CLK input
|
GPIO_DCKI, // my92x1 CLK input
|
||||||
GPIO_ALIRFRCV, // AliLux RF Receive input
|
GPIO_ARIRFRCV, // AliLux RF Receive input
|
||||||
GPIO_USER, // User configurable
|
GPIO_USER, // User configurable
|
||||||
GPIO_MAX };
|
GPIO_MAX };
|
||||||
|
|
||||||
@ -739,7 +739,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
|
|||||||
0,
|
0,
|
||||||
GPIO_LED2_INV, // GPIO02 RF receiver control
|
GPIO_LED2_INV, // GPIO02 RF receiver control
|
||||||
0,
|
0,
|
||||||
GPIO_ALIRFRCV, // GPIO04 IR or RF receiver (optional)
|
GPIO_ARIRFRCV, // GPIO04 IR or RF receiver (optional)
|
||||||
GPIO_PWM1, // GPIO05 RGB LED Red
|
GPIO_PWM1, // GPIO05 RGB LED Red
|
||||||
0, 0, 0, 0, 0, 0, // Flash connection
|
0, 0, 0, 0, 0, 0, // Flash connection
|
||||||
GPIO_PWM2, // GPIO12 RGB LED Green
|
GPIO_PWM2, // GPIO12 RGB LED Green
|
||||||
@ -759,7 +759,7 @@ const mytmplt kModules[MAXMODULE] PROGMEM = {
|
|||||||
GPIO_PWM5, // GPIO12 RGBCW LED Warm
|
GPIO_PWM5, // GPIO12 RGBCW LED Warm
|
||||||
GPIO_PWM4, // GPIO13 RGBW LED Cold
|
GPIO_PWM4, // GPIO13 RGBW LED Cold
|
||||||
GPIO_PWM3, // GPIO14 RGB LED Blue
|
GPIO_PWM3, // GPIO14 RGB LED Blue
|
||||||
GPIO_ALIRFRCV, // GPIO15 RF receiver input
|
GPIO_ARIRFRCV, // GPIO15 RF receiver input
|
||||||
0, 0
|
0, 0
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -230,7 +230,7 @@ void AriluxRfHandler()
|
|||||||
|
|
||||||
void AriluxRfInit()
|
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) {
|
if (Settings.last_module != Settings.module) {
|
||||||
Settings.rf_code[1][6] = 0;
|
Settings.rf_code[1][6] = 0;
|
||||||
Settings.rf_code[1][7] = 0;
|
Settings.rf_code[1][7] = 0;
|
||||||
@ -238,7 +238,7 @@ void AriluxRfInit()
|
|||||||
}
|
}
|
||||||
arilux_rf_received_value = 0;
|
arilux_rf_received_value = 0;
|
||||||
digitalWrite(pin[GPIO_LED2], !bitRead(led_inverted, 1)); // Turn on RF
|
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
|
#endif // USE_ARILUX_RF
|
||||||
@ -349,7 +349,7 @@ void LightInit(void)
|
|||||||
digitalWrite(14, LOW);
|
digitalWrite(14, LOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pin[GPIO_ALIRFRCV] < 99) {
|
if (pin[GPIO_ARIRFRCV] < 99) {
|
||||||
#ifdef USE_ARILUX_RF
|
#ifdef USE_ARILUX_RF
|
||||||
AriluxRfInit();
|
AriluxRfInit();
|
||||||
#else
|
#else
|
||||||
|
@ -122,7 +122,7 @@ int mod(int a, int b)
|
|||||||
|
|
||||||
#define cmin(a,b) ((a)<(b)?(a):(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)
|
#if (USE_WS2812_CTYPE > 1)
|
||||||
RgbwColor color;
|
RgbwColor color;
|
||||||
@ -134,10 +134,9 @@ void Ws2812UpdatePixelColor(int position, struct WsColor hand_color, uint8_t han
|
|||||||
|
|
||||||
color = strip->GetPixelColor(mod_position);
|
color = strip->GetPixelColor(mod_position);
|
||||||
float dimmer = 100 / (float)Settings.light_dimmer;
|
float dimmer = 100 / (float)Settings.light_dimmer;
|
||||||
uint8_t offset = 1 << hand;
|
color.R = cmin(color.R + ((hand_color.red / 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.G = cmin(color.G + ((hand_color.green / dimmer) / offset), 255);
|
color.B = cmin(color.B + ((hand_color.blue / dimmer) * offset), 255);
|
||||||
color.B = cmin(color.B + ((hand_color.blue / dimmer) / offset), 255);
|
|
||||||
strip->SetPixelColor(mod_position, color);
|
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] };
|
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);
|
Ws2812UpdatePixelColor(position, hand_color, 1);
|
||||||
for (uint8_t h = 1; h <= ((Settings.ws_width[index] -1) / 2); h++) {
|
uint8_t range = ((Settings.ws_width[index] -1) / 2) +1;
|
||||||
Ws2812UpdatePixelColor(position -h, hand_color, h);
|
for (uint8_t h = 1; h < range; h++) {
|
||||||
Ws2812UpdatePixelColor(position +h, hand_color, h);
|
float offset = (float)(range - h) / (float)range;
|
||||||
|
Ws2812UpdatePixelColor(position -h, hand_color, offset);
|
||||||
|
Ws2812UpdatePixelColor(position +h, hand_color, offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ws2812Clock()
|
void Ws2812Clock()
|
||||||
{
|
{
|
||||||
strip->ClearTo(0); // Reset strip
|
strip->ClearTo(0); // Reset strip
|
||||||
int clksize = 600 / (int)Settings.light_pixels;
|
int clksize = 60000 / (int)Settings.light_pixels;
|
||||||
Ws2812UpdateHand((RtcTime.second * 10) / clksize, WS_SECOND);
|
Ws2812UpdateHand((RtcTime.second * 1000) / clksize, WS_SECOND);
|
||||||
Ws2812UpdateHand((RtcTime.minute * 10) / clksize, WS_MINUTE);
|
Ws2812UpdateHand((RtcTime.minute * 1000) / clksize, WS_MINUTE);
|
||||||
Ws2812UpdateHand(((RtcTime.hour % 12) * (50 / clksize)) + ((RtcTime.minute * 10) / (12 * clksize)), WS_HOUR);
|
Ws2812UpdateHand(((RtcTime.hour % 12) * (5000 / clksize)) + ((RtcTime.minute * 1000) / (12 * clksize)), WS_HOUR);
|
||||||
|
|
||||||
Ws2812StripShow();
|
Ws2812StripShow();
|
||||||
}
|
}
|
||||||
|
@ -506,7 +506,8 @@ boolean HlwCommand(char *type, uint16_t index, char *dataBuf, uint16_t data_len,
|
|||||||
nvalue = Settings.hlw_imax;
|
nvalue = Settings.hlw_imax;
|
||||||
unit = UNIT_MILLIAMPERE;
|
unit = UNIT_MILLIAMPERE;
|
||||||
}
|
}
|
||||||
else if (CMND_ENERGYRESET == command_code) {
|
else if ((CMND_ENERGYRESET == command_code) && (index > 0) && (index <= 3)) {
|
||||||
|
/*
|
||||||
if ((payload >= 1) && (payload <= 3)) {
|
if ((payload >= 1) && (payload <= 3)) {
|
||||||
switch (payload) {
|
switch (payload) {
|
||||||
case 1:
|
case 1:
|
||||||
@ -523,6 +524,26 @@ boolean HlwCommand(char *type, uint16_t index, char *dataBuf, uint16_t data_len,
|
|||||||
break;
|
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 syesterday_energy[10];
|
||||||
char stoday_energy[10];
|
char stoday_energy[10];
|
||||||
char stotal_energy[10];
|
char stotal_energy[10];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user