esp8266/modmachine: In lightsleep, only waiti if wifi is turned off.

Otherwise the STA interface can't do DTIM sleeping correctly and power
consumption goes up.
This commit is contained in:
Damien George 2019-01-31 00:05:00 +11:00
parent 4dfcc255d5
commit 3ff3e96865

View File

@ -105,11 +105,15 @@ STATIC mp_obj_t machine_lightsleep(size_t n_args, const mp_obj_t *args) {
} }
max_us = max_ms * 1000; max_us = max_ms * 1000;
} }
uint32_t wifi_mode = wifi_get_opmode();
uint32_t start = system_get_time(); uint32_t start = system_get_time();
while (system_get_time() - start <= max_us) { while (system_get_time() - start <= max_us) {
ets_event_poll(); ets_event_poll();
if (wifi_mode == NULL_MODE) {
// Can only idle if the wifi is off
asm("waiti 0"); asm("waiti 0");
} }
}
return mp_const_none; return mp_const_none;
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_lightsleep_obj, 0, 1, machine_lightsleep); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_lightsleep_obj, 0, 1, machine_lightsleep);