mirror of https://github.com/arendst/Tasmota.git
Use global struct
This commit is contained in:
parent
0cfe1ac3e1
commit
0d85f5c583
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue