From 66f5d5d180766c86862fa7abd883f0758c34123f Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 28 Oct 2020 11:48:57 +0100 Subject: [PATCH] Prep global struct --- tasmota/support.ino | 2 +- tasmota/support_button.ino | 2 +- tasmota/support_switch.ino | 2 +- tasmota/support_wifi.ino | 6 ++---- tasmota/tasmota.ino | 27 ++++++++++++++------------- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/tasmota/support.ino b/tasmota/support.ino index dd51c8004..d901a542c 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -1632,7 +1632,7 @@ bool TimeReached(uint32_t timer) return (passed >= 0); } -void SetNextTimeInterval(unsigned long& timer, const unsigned long step) +void SetNextTimeInterval(uint32_t& timer, const uint32_t step) { timer += step; const long passed = TimePassedSince(timer); diff --git a/tasmota/support_button.ino b/tasmota/support_button.ino index 4dc5aa097..aef3c31a3 100644 --- a/tasmota/support_button.ino +++ b/tasmota/support_button.ino @@ -33,7 +33,7 @@ const char kMultiPress[] PROGMEM = "|SINGLE|DOUBLE|TRIPLE|QUAD|PENTA|"; struct BUTTON { - unsigned long debounce = 0; // Button debounce timer + uint32_t debounce = 0; // Button debounce timer uint16_t hold_timer[MAX_KEYS] = { 0 }; // Timer for button hold uint16_t dual_code = 0; // Sonoff dual received code diff --git a/tasmota/support_switch.ino b/tasmota/support_switch.ino index 91a2d59c6..3323bbe01 100644 --- a/tasmota/support_switch.ino +++ b/tasmota/support_switch.ino @@ -40,7 +40,7 @@ const uint8_t AC_PERIOD = (20 + SWITCH_FAST_PROBE_INTERVAL - 1) / SWITCH_FAST_PR Ticker TickerSwitch; struct SWITCH { - unsigned long debounce = 0; // Switch debounce timer + uint32_t debounce = 0; // Switch debounce timer uint16_t no_pullup_mask = 0; // Switch pull-up bitmask flags uint8_t state[MAX_SWITCHES] = { 0 }; uint8_t last_state[MAX_SWITCHES]; // Last wall switch states diff --git a/tasmota/support_wifi.ino b/tasmota/support_wifi.ino index 8246539a7..69ca08987 100644 --- a/tasmota/support_wifi.ino +++ b/tasmota/support_wifi.ino @@ -666,8 +666,6 @@ extern "C" { #endif } -unsigned long wifiTimer = 0; - void stationKeepAliveNow(void) { AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_WIFI "Sending Gratuitous ARP")); for (netif* interface = netif_list; interface != nullptr; interface = interface->next) @@ -693,11 +691,11 @@ void wifiKeepAlive(void) { if ((WL_CONNECTED != Wifi.status) || (0 == wifiTimerSec)) { return; } // quick exit if wifi not connected or feature disabled - if (TimeReached(wifiTimer)) { + if (TimeReached(wifi_timer)) { stationKeepAliveNow(); if (wifiTimerSec > 100) { wifiTimerSec = (wifiTimerSec - 100) * 60; // convert >100 as minutes, ex: 105 = 5 minutes, 110 = 10 minutes } - SetNextTimeInterval(wifiTimer, wifiTimerSec * 1000); + SetNextTimeInterval(wifi_timer, wifiTimerSec * 1000); } } diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index 9447c9b08..f42678477 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -77,14 +77,20 @@ WiFiUDP PortUdp; // UDP Syslog and Alexa -unsigned long serial_polling_window = 0; // Serial polling window -unsigned long state_second = 0; // State second timer -unsigned long state_50msecond = 0; // State 50msecond timer -unsigned long state_100msecond = 0; // State 100msecond timer -unsigned long state_250msecond = 0; // State 250msecond timer -unsigned long pulse_timer[MAX_PULSETIMERS] = { 0 }; // Power off timer -unsigned long blink_timer = 0; // Power cycle timer -unsigned long backlog_delay = 0; // Command backlog delay +uint32_t serial_polling_window = 0; // Serial polling window +uint32_t state_second = 0; // State second timer +uint32_t state_50msecond = 0; // State 50msecond timer +uint32_t state_100msecond = 0; // State 100msecond timer +uint32_t state_250msecond = 0; // State 250msecond timer +uint32_t pulse_timer[MAX_PULSETIMERS] = { 0 }; // Power off timer +uint32_t wifi_timer = 0; // Wifi keepalive timer +uint32_t blink_timer = 0; // Power cycle timer +uint32_t backlog_delay = 0; // Command backlog delay +uint32_t uptime = 0; // Counting every second until 4294967295 = 130 year +uint32_t loop_load_avg = 0; // Indicative loop load average +uint32_t global_update = 0; // Timestamp of last global temperature and humidity update +uint32_t web_log_index = 1; // Index in Web log buffer (should never be 0) +uint32_t baudrate = APP_BAUDRATE; // Current Serial baudrate power_t power = 0; // Current copy of Settings.power power_t last_power = 0; // Last power set state power_t blink_power; // Blink power state @@ -98,11 +104,6 @@ int ota_result = 0; // OTA result int restart_flag = 0; // Tasmota restart flag int wifi_state_flag = WIFI_RESTART; // Wifi state flag int blinks = 201; // Number of LED blinks -uint32_t uptime = 0; // Counting every second until 4294967295 = 130 year -uint32_t loop_load_avg = 0; // Indicative loop load average -uint32_t global_update = 0; // Timestamp of last global temperature and humidity update -uint32_t web_log_index = 1; // Index in Web log buffer (should never be 0) -uint32_t baudrate = APP_BAUDRATE; // Current Serial baudrate float global_temperature_celsius = NAN; // Provide a global temperature to be used by some sensors float global_humidity = 0.0f; // Provide a global humidity to be used by some sensors float global_pressure_hpa = 0.0f; // Provide a global pressure to be used by some sensors