Browse Source

WiFi light sleep enabled, power saving delay in main loop

fastled
Xose Pérez 7 years ago
parent
commit
54341d4b54
3 changed files with 14 additions and 6 deletions
  1. +2
    -0
      code/espurna/config/general.h
  2. +8
    -6
      code/espurna/espurna.ino
  3. +4
    -0
      code/espurna/wifi.ino

+ 2
- 0
code/espurna/config/general.h View File

@ -9,6 +9,7 @@
#define ADMIN_PASS "fibonacci" // Default password (WEB, OTA, WIFI) #define ADMIN_PASS "fibonacci" // Default password (WEB, OTA, WIFI)
#define DEVICE_NAME MANUFACTURER "_" DEVICE // Concatenate both to get a unique device name #define DEVICE_NAME MANUFACTURER "_" DEVICE // Concatenate both to get a unique device name
#define LOOP_DELAY_TIME 10 // Delay for this millis in the main loop [0-250]
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// TELNET // TELNET
@ -266,6 +267,7 @@ PROGMEM const char* const custom_reset_string[] = {
#define WIFI_RECONNECT_INTERVAL 180000 // If could not connect to WIFI, retry after this time in ms #define WIFI_RECONNECT_INTERVAL 180000 // If could not connect to WIFI, retry after this time in ms
#define WIFI_MAX_NETWORKS 5 // Max number of WIFI connection configurations #define WIFI_MAX_NETWORKS 5 // Max number of WIFI connection configurations
#define WIFI_AP_MODE AP_MODE_ALONE #define WIFI_AP_MODE AP_MODE_ALONE
#define WIFI_SLEEP_ENABLED 1 // Enable WiFi light sleep
// Optional hardcoded configuration (up to 2 different networks) // Optional hardcoded configuration (up to 2 different networks)
//#define WIFI1_SSID "..." //#define WIFI1_SSID "..."


+ 8
- 6
code/espurna/espurna.ino View File

@ -241,6 +241,7 @@ void setup() {
if (!systemCheck()) return; if (!systemCheck()) return;
#endif #endif
// Init webserver required before any module that uses API
#if WEB_SUPPORT #if WEB_SUPPORT
webSetup(); webSetup();
#endif #endif
@ -256,7 +257,6 @@ void setup() {
#ifdef ITEAD_SONOFF_RFBRIDGE #ifdef ITEAD_SONOFF_RFBRIDGE
rfbSetup(); rfbSetup();
#endif #endif
#if POWER_PROVIDER != POWER_PROVIDER_NONE #if POWER_PROVIDER != POWER_PROVIDER_NONE
powerSetup(); powerSetup();
#endif #endif
@ -311,26 +311,23 @@ void loop() {
wifiLoop(); wifiLoop();
otaLoop(); otaLoop();
// Do not run the next services if system is flagged stable
#if SYSTEM_CHECK_ENABLED #if SYSTEM_CHECK_ENABLED
systemCheckLoop(); systemCheckLoop();
// Do not run the next services if system is flagged stable
if (!systemCheck()) return; if (!systemCheck()) return;
#endif #endif
#if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE #if LIGHT_PROVIDER != LIGHT_PROVIDER_NONE
lightLoop(); lightLoop();
#endif #endif
buttonLoop();
relayLoop(); relayLoop();
buttonLoop();
ledLoop(); ledLoop();
mqttLoop(); mqttLoop();
#ifdef ITEAD_SONOFF_RFBRIDGE #ifdef ITEAD_SONOFF_RFBRIDGE
rfbLoop(); rfbLoop();
#endif #endif
#if POWER_PROVIDER != POWER_PROVIDER_NONE #if POWER_PROVIDER != POWER_PROVIDER_NONE
powerLoop(); powerLoop();
#endif #endif
@ -362,4 +359,9 @@ void loop() {
irLoop(); irLoop();
#endif #endif
// Power saving delay
#if LOOP_DELAY_TIME
delay(LOOP_DELAY_TIME);
#endif
} }

+ 4
- 0
code/espurna/wifi.ino View File

@ -174,6 +174,10 @@ void wifiInject() {
void wifiSetup() { void wifiSetup() {
#if WIFI_SLEEP_ENABLED
wifi_set_sleep_type(LIGHT_SLEEP_T);
#endif
wifiInject(); wifiInject();
wifiConfigure(); wifiConfigure();


Loading…
Cancel
Save