Add timeout sample. Remove make axtls from buildnew script.

pull/7/head
Peter Hinch 2018-11-25 10:56:15 +00:00
rodzic ac350c1e28
commit 11d6db9d68
3 zmienionych plików z 17 dodań i 2 usunięć

Wyświetl plik

@ -44,7 +44,8 @@ Raise an exception if a firmware build is earlier than a given date.
# timed_function
Time a function's execution using a decorator.
Time a function's execution using a decorator. Also a way to implement timeouts
using a closure.
# ESP8266 (MQTT benchmark)

Wyświetl plik

@ -17,7 +17,6 @@ cd ../esp8266
make clean
cd ../unix
make clean
make -j 8 axtls
# If you're going to enable deplibs: see micropython/README
#make deplibs
make -j 8

Wyświetl plik

@ -0,0 +1,15 @@
# Implement a timeout using a closure
import utime
def to(t):
tstart = utime.ticks_ms()
def foo():
return utime.ticks_diff(utime.ticks_ms(), tstart) > t
return foo
# Usage
t = to(3000)
for _ in range(10):
print(t())
utime.sleep(0.5)