From cf3d2ad0e562ebb84793e2847833648a64a86986 Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Sat, 8 Dec 2018 19:05:07 +0100 Subject: [PATCH] =?UTF-8?q?Super=20bien=20avanc=C3=A9=20sur=20les=20tests?= =?UTF-8?q?=20dsleep,=20je=20reste=20maintenant=20allum=C3=A9=20quand=20il?= =?UTF-8?q?=20y=20a=20une=20connexion=20au=20wifi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DeepSleep/ESP-M3/dsleep.lua | 45 +++++++++---------- .../ESP-M3/{ => goodies}/wifi_get_ip.lua | 0 DeepSleep/ESP-M3/web_ide2.lua | 4 +- 3 files changed, 22 insertions(+), 27 deletions(-) rename DeepSleep/ESP-M3/{ => goodies}/wifi_get_ip.lua (100%) diff --git a/DeepSleep/ESP-M3/dsleep.lua b/DeepSleep/ESP-M3/dsleep.lua index 86b46f4..af73f7b 100644 --- a/DeepSleep/ESP-M3/dsleep.lua +++ b/DeepSleep/ESP-M3/dsleep.lua @@ -1,35 +1,43 @@ -- Teste le deep sleep ! --- s'endore pendant 3 secondes après 8 secondes --- à mettre à la place du init.lua ! +-- s'endore pendant xx secondes après xx secondes --- ATTENTION: il faut connecter la pin 0 à la pin RESET ! +-- ATTENTION: il faut connecter la pin 0 à la pin RESET avec une résistance de 1k ! -print("\n dsleep.lua zf181208.1755 \n") +print("\n dsleep.lua zf181208.1858 \n") + +f= "flash_led_xfois.lua" if file.exists(f) then dofile(f) end function dsleep_on() - print("Je dors...") - node.dsleep(10*1000*1000) + print("timer dsleep on...") + ztmr_SLEEP = tmr.create() + tmr.alarm(ztmr_SLEEP, 10*1000, tmr.ALARM_SINGLE, function () + print("Je dors...") + node.dsleep(10*1000*1000) + end) end function dsleep_off() - tmr.unregister(train3timer1) + print("timer dsleep off...") + tmr.unregister(ztmr_SLEEP) end function watch_wifi_on() + dsleep_on() ztmr_watch_wifi_on=tmr.create() tmr.alarm(ztmr_watch_wifi_on, 1000, tmr.ALARM_AUTO , function() if wifi.sta.getip() == nil then - print("Unconnected... (on)") +-- print("Unconnected... (on)") else tmr.stop(ztmr_watch_wifi_on) print("Connected... (on)") - f= "wifi_info.lua" if file.exists(f) then dofile(f) end +-- f= "wifi_info.lua" if file.exists(f) then dofile(f) end watch_wifi_off() end end) end function watch_wifi_off() + dsleep_off() tmr.unregister(ztmr_watch_wifi_on) ztmr_watch_wifi_off=tmr.create() tmr.alarm(ztmr_watch_wifi_off, 1000, tmr.ALARM_AUTO , function() @@ -39,31 +47,18 @@ function watch_wifi_off() watch_wifi_on() tmr.unregister(ztmr_watch_wifi_off) else - print("Connected... (off)") +-- print("Connected... (off)") + xfois =2 + blink_LED () end end) end - - - _, reset_reason = node.bootreason() print("reset_reason: ",reset_reason) if reset_reason == 4 then print("Coucou, soft reset...") end if reset_reason == 5 then print("Coucou, je suis réveillé...") end if reset_reason == 6 then print("Coucou, hard reset...") end - watch_wifi_on() - - - - ---[[ -ztmr_SLEEP = tmr.create() -tmr.alarm(ztmr_SLEEP, 10*1000, tmr.ALARM_SINGLE, function () - print("Je dors...") - node.dsleep(10*1000*1000) -end) -]] \ No newline at end of file diff --git a/DeepSleep/ESP-M3/wifi_get_ip.lua b/DeepSleep/ESP-M3/goodies/wifi_get_ip.lua similarity index 100% rename from DeepSleep/ESP-M3/wifi_get_ip.lua rename to DeepSleep/ESP-M3/goodies/wifi_get_ip.lua diff --git a/DeepSleep/ESP-M3/web_ide2.lua b/DeepSleep/ESP-M3/web_ide2.lua index 6b58a0e..fd2037b 100644 --- a/DeepSleep/ESP-M3/web_ide2.lua +++ b/DeepSleep/ESP-M3/web_ide2.lua @@ -1,7 +1,7 @@ -- Petit WEB IDE tout simple autonome -- ATTENTION: tourne sur le port 88 ! -print("\n _web_ide2.lua zf181205.2112 \n") +print("\n _web_ide2.lua zf181208.1902 \n") --[[ XChip's NodeMCU IDE @@ -113,7 +113,7 @@ srv:listen(88,function(conn) if vars=="edit" then conn:send("") - conn:send("Back to file list


") + conn:send("Back to file list


") conn:send("run") end