From 0d85f5c583f6c8f89665eaceec558a3ccad599c3 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 29 Oct 2020 12:58:22 +0100 Subject: [PATCH] Use global struct --- tasmota/support_command.ino | 4 ++-- tasmota/support_tasmota.ino | 14 +++++++------- tasmota/tasmota.ino | 2 +- tasmota/xdrv_23_zigbee_9_serial.ino | 2 +- tasmota/xdrv_23_zigbee_9a_upload.ino | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index 026c4933a..49a4ed3d1 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -879,7 +879,7 @@ void CmndSetoption(void) #ifdef USE_LIGHT if (P_RGB_REMAP == pindex) { LightUpdateColorMapping(); - TasmotaGlobal.restart_flag = 2; // SetOption37 needs a reboot in most cases + TasmotaGlobal.restart_flag = 2; // SetOption37 needs a reboot in most cases } #endif #if (defined(USE_IR_REMOTE) && defined(USE_IR_RECEIVE)) || defined(USE_IR_REMOTE_FULL) @@ -926,7 +926,7 @@ void CmndSetoption(void) switch (pindex) { case 5: // SetOption55 if (0 == XdrvMailbox.payload) { - TasmotaGlobal.restart_flag = 2; // Disable mDNS needs restart + TasmotaGlobal.restart_flag = 2; // Disable mDNS needs restart } break; case 10: // SetOption60 enable or disable traditional sleep diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index f19ac60c6..02dbf8a29 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -276,7 +276,7 @@ void SetAllPower(uint32_t state, uint32_t source) TasmotaGlobal.power = all_on; break; case POWER_TOGGLE: - TasmotaGlobal.power ^= all_on; // Complement current state + TasmotaGlobal.power ^= all_on; // Complement current state } SetDevicePower(TasmotaGlobal.power, source); } @@ -471,7 +471,7 @@ bool SendKey(uint32_t key, uint32_t device, uint32_t state) !strcmp(mqtt_topic, key_topic) || !strcmp(SettingsText(SET_MQTT_GRP_TOPIC), key_topic)) && (POWER_TOGGLE == state)) { - state = ~(TasmotaGlobal.power >> (device -1)) &1; // POWER_OFF or POWER_ON + state = ~(TasmotaGlobal.power >> (device -1)) &1; // POWER_OFF or POWER_ON } snprintf_P(mqtt_data, sizeof(mqtt_data), GetStateText(state)); } @@ -520,7 +520,7 @@ void ExecuteCommandPower(uint32_t device, uint32_t state, uint32_t source) #ifdef USE_SONOFF_IFAN if (IsModuleIfan()) { - TasmotaGlobal.blink_mask &= 1; // No blinking on the fan relays + TasmotaGlobal.blink_mask &= 1; // No blinking on the fan relays Settings.flag.interlock = 0; // No interlock mode as it is already done by the microcontroller - CMND_INTERLOCK - Enable/disable interlock Settings.pulse_timer[1] = 0; // No pulsetimers on the fan relays Settings.pulse_timer[2] = 0; @@ -937,11 +937,11 @@ void Every250mSeconds(void) if (global_state.data &0x03) { // Network or MQTT problem if (global_state.mqtt_down) { blinkinterval = 7; } // MQTT problem so blink every 2 seconds (slowest) if (global_state.network_down) { blinkinterval = 3; } // Network problem so blink every second (slow) - TasmotaGlobal.blinks = 201; // Allow only a single blink in case the problem is solved + TasmotaGlobal.blinks = 201; // Allow only a single blink in case the problem is solved } } if (TasmotaGlobal.blinks || TasmotaGlobal.restart_flag || TasmotaGlobal.ota_state_flag) { - if (TasmotaGlobal.restart_flag || TasmotaGlobal.ota_state_flag) { // Overrule blinks and keep led lit + if (TasmotaGlobal.restart_flag || TasmotaGlobal.ota_state_flag) { // Overrule blinks and keep led lit blinkstate = true; // Stay lit } else { blinkspeed--; @@ -955,14 +955,14 @@ void Every250mSeconds(void) } if (!blinkstate) { TasmotaGlobal.blinks--; - if (200 == TasmotaGlobal.blinks) TasmotaGlobal.blinks = 0; // Disable blink + if (200 == TasmotaGlobal.blinks) { TasmotaGlobal.blinks = 0; } // Disable blink } } if (Settings.ledstate &1 && (PinUsed(GPIO_LEDLNK) || !(TasmotaGlobal.blinks || TasmotaGlobal.restart_flag || TasmotaGlobal.ota_state_flag)) ) { bool tstate = TasmotaGlobal.power & Settings.ledmask; #ifdef ESP8266 if ((SONOFF_TOUCH == my_module_type) || (SONOFF_T11 == my_module_type) || (SONOFF_T12 == my_module_type) || (SONOFF_T13 == my_module_type)) { - tstate = (!TasmotaGlobal.power) ? 1 : 0; // As requested invert signal for Touch devices to find them in the dark + tstate = (!TasmotaGlobal.power) ? 1 : 0; // As requested invert signal for Touch devices to find them in the dark } #endif // ESP8266 SetLedPower(tstate); diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index 4858f64d5..efaaf7af7 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -95,7 +95,6 @@ struct { power_t blink_mask; // Blink relay active mask int serial_in_byte_counter; // Index in receive buffer - int ota_state_flag; // OTA state flag float temperature_celsius; // Provide a global temperature to be used by some sensors float humidity; // Provide a global humidity to be used by some sensors @@ -103,6 +102,7 @@ struct { uint8_t blinks; // Number of LED blinks uint8_t restart_flag; // Tasmota restart flag + uint8_t ota_state_flag; // OTA state flag uint8_t wifi_state_flag; // Wifi state flag } TasmotaGlobal; diff --git a/tasmota/xdrv_23_zigbee_9_serial.ino b/tasmota/xdrv_23_zigbee_9_serial.ino index 47fd92a0f..279380913 100644 --- a/tasmota/xdrv_23_zigbee_9_serial.ino +++ b/tasmota/xdrv_23_zigbee_9_serial.ino @@ -672,7 +672,7 @@ int32_t ZigbeeProcessInputRaw(class SBuffer &buf) { // ERROR EZ_ERROR(buf.get8(2)); zigbee.active = false; // stop all zigbee activities - TasmotaGlobal.restart_flag = 2; // there is nothing more we can do except restart + TasmotaGlobal.restart_flag = 2; // there is nothing more we can do except restart } else { // Unknown diff --git a/tasmota/xdrv_23_zigbee_9a_upload.ino b/tasmota/xdrv_23_zigbee_9a_upload.ino index ec7697566..990a8cc57 100644 --- a/tasmota/xdrv_23_zigbee_9a_upload.ino +++ b/tasmota/xdrv_23_zigbee_9a_upload.ino @@ -445,7 +445,7 @@ bool ZigbeeUploadXmodem(void) { if (1 == ssleep) { ssleep = Settings.sleep; // Restore loop sleep } -// TasmotaGlobal.restart_flag = 2; // Restart to disable bootloader and use new firmware +// TasmotaGlobal.restart_flag = 2; // Restart to disable bootloader and use new firmware ZbUpload.ota_step = ZBU_FINISH; // Never return to zero without a restart to get a sane Zigbee environment break; }