mirror of https://github.com/arendst/Tasmota.git
Merge branch 'development' into release
This commit is contained in:
commit
4e0897a5cf
|
@ -471,7 +471,6 @@ bool SettingsUpdateText(uint32_t index, const char* replace_me)
|
|||
char replace[replace_len +1];
|
||||
memcpy(replace, replace_me, sizeof(replace));
|
||||
|
||||
if (Settings.version < 0x08000000) {
|
||||
uint32_t idx = 0;
|
||||
switch (index) {
|
||||
case SET_OTAURL: strlcpy(Settings.ota_url, replace, sizeof(Settings.ota_url)); break;
|
||||
|
@ -526,43 +525,6 @@ bool SettingsUpdateText(uint32_t index, const char* replace_me)
|
|||
case SET_FRIENDLYNAME2: idx++;
|
||||
case SET_FRIENDLYNAME1: strlcpy(Settings.friendlyname[idx], replace, sizeof(Settings.friendlyname[idx])); break;
|
||||
}
|
||||
} else {
|
||||
uint32_t start_pos = 0;
|
||||
uint32_t end_pos = 0;
|
||||
char* position = Settings.ota_url;
|
||||
for (uint32_t size = 0; size < SET_MAX; size++) {
|
||||
while (*position++ != '\0') { }
|
||||
if (1 == index) {
|
||||
start_pos = position - Settings.ota_url;
|
||||
}
|
||||
else if (0 == index) {
|
||||
end_pos = position - Settings.ota_url -1;
|
||||
}
|
||||
index--;
|
||||
}
|
||||
uint32_t char_len = position - Settings.ota_url;
|
||||
|
||||
uint32_t current_len = end_pos - start_pos;
|
||||
int diff = replace_len - current_len;
|
||||
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TST: start %d, end %d, len %d, current %d, replace %d, diff %d"),
|
||||
// start_pos, end_pos, char_len, current_len, replace_len, diff);
|
||||
|
||||
int too_long = (char_len + diff) - settings_text_size;
|
||||
if (too_long > 0) {
|
||||
// AddLog_P2(LOG_LEVEL_INFO, PSTR("CFG: Text too long by %d char(s)"), too_long);
|
||||
return false; // Replace text too long
|
||||
}
|
||||
|
||||
if (diff != 0) {
|
||||
// Shift Settings.text up or down
|
||||
memmove_P(Settings.ota_url + start_pos + replace_len, Settings.ota_url + end_pos, char_len - end_pos);
|
||||
}
|
||||
// Replace text
|
||||
memmove_P(Settings.ota_url + start_pos, replace, replace_len);
|
||||
// Fill for future use
|
||||
memset(Settings.ota_url + char_len + diff, 0x00, settings_text_size - char_len - diff);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1128,6 +1090,10 @@ void SettingsDefaultSet2(void)
|
|||
|
||||
memset(&Settings.monitors, 0xFF, 20); // Enable all possible monitors, displays and sensors
|
||||
SettingsEnableAllI2cDrivers();
|
||||
|
||||
if (VERSION < 0x08000000) {
|
||||
SettingsBackwardCompat();
|
||||
}
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
|
@ -1167,6 +1133,17 @@ void SettingsEnableAllI2cDrivers(void)
|
|||
Settings.i2c_drivers[2] = 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
void SettingsBackwardCompat(void)
|
||||
{
|
||||
Settings.ex_seriallog_level = Settings.seriallog_level; // 09E <- 452
|
||||
Settings.ex_sta_config = Settings.sta_config; // 09F <- EC7
|
||||
Settings.ex_sta_active = Settings.sta_active; // 0A0 <- EC8
|
||||
memcpy((char*)&Settings.ex_rule_stop, (char*)&Settings.rule_stop, 47); // 1A7 <- EC9
|
||||
Settings.ex_flag4 = Settings.flag4; // 1E0 <- EF8
|
||||
Settings.ex_mqtt_port = Settings.mqtt_port; // 20A <- EFC
|
||||
memcpy((char*)&Settings.ex_serial_config, (char*)&Settings.serial_config, 5); // 1E4 <- EFE
|
||||
}
|
||||
|
||||
/********************************************************************************************/
|
||||
|
||||
void SettingsDelta(void)
|
||||
|
@ -1387,6 +1364,27 @@ void SettingsDelta(void)
|
|||
}
|
||||
|
||||
if ((VERSION < 0x08000000) && (Settings.version >= 0x08000000)) {
|
||||
SettingsUpdateText(SET_WEBPWD, SettingsText(SET_WEBPWD));
|
||||
SettingsUpdateText(SET_CORS, SettingsText(SET_CORS));
|
||||
SettingsUpdateText(SET_MQTT_FULLTOPIC, SettingsText(SET_MQTT_FULLTOPIC));
|
||||
SettingsUpdateText(SET_MQTT_SWITCH_TOPIC, SettingsText(SET_MQTT_SWITCH_TOPIC));
|
||||
SettingsUpdateText(SET_STATE_TXT1, SettingsText(SET_STATE_TXT1));
|
||||
SettingsUpdateText(SET_STATE_TXT2, SettingsText(SET_STATE_TXT2));
|
||||
SettingsUpdateText(SET_STATE_TXT3, SettingsText(SET_STATE_TXT3));
|
||||
SettingsUpdateText(SET_STATE_TXT4, SettingsText(SET_STATE_TXT4));
|
||||
SettingsUpdateText(SET_NTPSERVER1, SettingsText(SET_NTPSERVER1));
|
||||
SettingsUpdateText(SET_NTPSERVER2, SettingsText(SET_NTPSERVER2));
|
||||
SettingsUpdateText(SET_NTPSERVER3, SettingsText(SET_NTPSERVER3));
|
||||
SettingsUpdateText(SET_MEM1, SettingsText(SET_MEM1));
|
||||
SettingsUpdateText(SET_MEM2, SettingsText(SET_MEM2));
|
||||
SettingsUpdateText(SET_MEM3, SettingsText(SET_MEM3));
|
||||
SettingsUpdateText(SET_MEM4, SettingsText(SET_MEM4));
|
||||
SettingsUpdateText(SET_MEM5, SettingsText(SET_MEM5));
|
||||
SettingsUpdateText(SET_FRIENDLYNAME1, SettingsText(SET_FRIENDLYNAME1));
|
||||
SettingsUpdateText(SET_FRIENDLYNAME2, SettingsText(SET_FRIENDLYNAME2));
|
||||
SettingsUpdateText(SET_FRIENDLYNAME3, SettingsText(SET_FRIENDLYNAME3));
|
||||
SettingsUpdateText(SET_FRIENDLYNAME4, SettingsText(SET_FRIENDLYNAME4));
|
||||
|
||||
char temp[strlen(SettingsText(SET_OTAURL)) +1]; strncpy(temp, SettingsText(SET_OTAURL), sizeof(temp));
|
||||
char temp21[strlen(SettingsText(SET_MQTTPREFIX1)) +1]; strncpy(temp21, SettingsText(SET_MQTTPREFIX1), sizeof(temp21));
|
||||
char temp22[strlen(SettingsText(SET_MQTTPREFIX2)) +1]; strncpy(temp22, SettingsText(SET_MQTTPREFIX2), sizeof(temp22));
|
||||
|
@ -1405,8 +1403,6 @@ void SettingsDelta(void)
|
|||
char temp12[strlen(SettingsText(SET_MQTT_BUTTON_TOPIC)) +1]; strncpy(temp12, SettingsText(SET_MQTT_BUTTON_TOPIC), sizeof(temp12));
|
||||
char temp13[strlen(SettingsText(SET_MQTT_GRP_TOPIC)) +1]; strncpy(temp13, SettingsText(SET_MQTT_GRP_TOPIC), sizeof(temp13));
|
||||
|
||||
uint32_t version = Settings.version;
|
||||
Settings.version = VERSION;
|
||||
SettingsUpdateText(SET_OTAURL, temp);
|
||||
SettingsUpdateText(SET_MQTTPREFIX1, temp21);
|
||||
SettingsUpdateText(SET_MQTTPREFIX2, temp22);
|
||||
|
@ -1424,7 +1420,8 @@ void SettingsDelta(void)
|
|||
SettingsUpdateText(SET_MQTT_TOPIC, temp11);
|
||||
SettingsUpdateText(SET_MQTT_BUTTON_TOPIC, temp12);
|
||||
SettingsUpdateText(SET_MQTT_GRP_TOPIC, temp13);
|
||||
Settings.version = version;
|
||||
|
||||
SettingsBackwardCompat();
|
||||
}
|
||||
|
||||
Settings.version = VERSION;
|
||||
|
|
|
@ -995,6 +995,13 @@ int ResponseJsonEndEnd(void)
|
|||
* GPIO Module and Template management
|
||||
\*********************************************************************************************/
|
||||
|
||||
void DigitalWrite(uint32_t gpio_pin, uint32_t state)
|
||||
{
|
||||
if (pin[gpio_pin] < 99) {
|
||||
digitalWrite(pin[gpio_pin], state &1);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t ModuleNr(void)
|
||||
{
|
||||
// 0 = User module (255)
|
||||
|
|
|
@ -166,9 +166,7 @@ void SetLatchingRelay(power_t lpower, uint32_t state)
|
|||
|
||||
for (uint32_t i = 0; i < devices_present; i++) {
|
||||
uint32_t port = (i << 1) + ((latching_power >> i) &1);
|
||||
if (pin[GPIO_REL1 +port] < 99) {
|
||||
digitalWrite(pin[GPIO_REL1 +port], bitRead(rel_inverted, port) ? !state : state);
|
||||
}
|
||||
DigitalWrite(GPIO_REL1 +port, bitRead(rel_inverted, port) ? !state : state);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -226,8 +224,8 @@ void SetDevicePower(power_t rpower, uint32_t source)
|
|||
else {
|
||||
for (uint32_t i = 0; i < devices_present; i++) {
|
||||
power_t state = rpower &1;
|
||||
if ((i < MAX_RELAYS) && (pin[GPIO_REL1 +i] < 99)) {
|
||||
digitalWrite(pin[GPIO_REL1 +i], bitRead(rel_inverted, i) ? !state : state);
|
||||
if (i < MAX_RELAYS) {
|
||||
DigitalWrite(GPIO_REL1 +i, bitRead(rel_inverted, i) ? !state : state);
|
||||
}
|
||||
rpower >>= 1;
|
||||
}
|
||||
|
@ -293,7 +291,7 @@ void SetLedPowerIdx(uint32_t led, uint32_t state)
|
|||
} else {
|
||||
led_power &= (0xFF ^ mask);
|
||||
}
|
||||
digitalWrite(pin[GPIO_LED1 + led], bitRead(led_inverted, led) ? !state : state);
|
||||
DigitalWrite(GPIO_LED1 + led, bitRead(led_inverted, led) ? !state : state);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -340,10 +340,10 @@ void HAssAnnounceButtonSwitch(uint8_t device, char* topic, uint8_t present, uint
|
|||
if (strlen(prefix) > 0 ) TryResponseAppend_P(HASS_DISCOVER_TOPIC_PREFIX, prefix);
|
||||
if (toggle) {
|
||||
if (!key) {
|
||||
TryResponseAppend_P(HASS_DISCOVER_BUTTON_TOGGLE, PSTR(D_RSLT_STATE), SettingsText(SET_STATE_TXT1 + toggle?2:1));
|
||||
TryResponseAppend_P(HASS_DISCOVER_BUTTON_TOGGLE, PSTR(D_RSLT_STATE), SettingsText(SET_STATE_TXT3));
|
||||
} else {TryResponseAppend_P(HASS_DISCOVER_SWITCH_TOGGLE);}
|
||||
}
|
||||
else TryResponseAppend_P(HASS_DISCOVER_BUTTON_SWITCH_ONOFF, PSTR(D_RSLT_STATE), SettingsText(SET_STATE_TXT1 + toggle?2:1), SettingsText(SET_STATE_TXT1));
|
||||
else TryResponseAppend_P(HASS_DISCOVER_BUTTON_SWITCH_ONOFF, PSTR(D_RSLT_STATE), SettingsText(SET_STATE_TXT2), SettingsText(SET_STATE_TXT1));
|
||||
|
||||
TryResponseAppend_P(PSTR("}"));
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ struct BUZZER {
|
|||
|
||||
void BuzzerOff(void)
|
||||
{
|
||||
digitalWrite(pin[GPIO_BUZZER], Buzzer.inverted); // Buzzer Off
|
||||
DigitalWrite(GPIO_BUZZER, Buzzer.inverted); // Buzzer Off
|
||||
}
|
||||
|
||||
//void BuzzerBeep(uint32_t count = 1, uint32_t on = 1, uint32_t off = 1, uint32_t tune = 0);
|
||||
|
@ -124,7 +124,7 @@ void BuzzerEvery100mSec(void)
|
|||
Buzzer.duration = Buzzer.set[Buzzer.state];
|
||||
}
|
||||
}
|
||||
digitalWrite(pin[GPIO_BUZZER], (Buzzer.inverted) ? !Buzzer.state : Buzzer.state);
|
||||
DigitalWrite(GPIO_BUZZER, (Buzzer.inverted) ? !Buzzer.state : Buzzer.state);
|
||||
} else {
|
||||
Buzzer.enable = false;
|
||||
}
|
||||
|
|
|
@ -143,9 +143,7 @@ void HlwEvery200ms(void)
|
|||
if (Hlw.cf1_timer >= 8) {
|
||||
Hlw.cf1_timer = 0;
|
||||
Hlw.select_ui_flag = (Hlw.select_ui_flag) ? false : true;
|
||||
if (pin[GPIO_NRG_SEL] < 99) {
|
||||
digitalWrite(pin[GPIO_NRG_SEL], Hlw.select_ui_flag);
|
||||
}
|
||||
DigitalWrite(GPIO_NRG_SEL, Hlw.select_ui_flag);
|
||||
|
||||
if (Hlw.cf1_pulse_counter) {
|
||||
cf1_pulse_length = Hlw.cf1_summed_pulse_length / Hlw.cf1_pulse_counter;
|
||||
|
|
|
@ -570,9 +570,7 @@ void McpSnsInit(void)
|
|||
} else {
|
||||
mcp_buffer = (char*)(malloc(MCP_BUFFER_SIZE));
|
||||
}
|
||||
if (pin[GPIO_MCP39F5_RST] < 99) {
|
||||
digitalWrite(pin[GPIO_MCP39F5_RST], 1); // MCP enable
|
||||
}
|
||||
DigitalWrite(GPIO_MCP39F5_RST, 1); // MCP enable
|
||||
} else {
|
||||
energy_flg = ENERGY_NONE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue