From 2aefde06b74e9b6f213b5a4e171e5f4dde60de30 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 16 Jan 2014 19:07:08 +0200 Subject: CPython pyb.py placeholder: Implement delay(). --- examples/pyb.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'examples') diff --git a/examples/pyb.py b/examples/pyb.py index 5e24f40e4..f7b52a2a1 100644 --- a/examples/pyb.py +++ b/examples/pyb.py @@ -1,7 +1,9 @@ -# pyboard testing functions for PC +# pyboard testing functions for CPython +import time + def delay(n): - pass + time.sleep(float(n) / 1000) rand_seed = 1 def rand(): -- cgit v1.2.3 From d0db3d3e451089ef431321833b30bb2127cdcb7b Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 16 Jan 2014 19:10:32 +0200 Subject: conwaylife.py: Give people chance to enjoy the show. Delay between frames; run more generations. --- examples/conwaylife.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/conwaylife.py b/examples/conwaylife.py index fb62ce69e..7c6ac4d54 100644 --- a/examples/conwaylife.py +++ b/examples/conwaylife.py @@ -34,10 +34,11 @@ def conway_go(num_frames): for i in range(num_frames): conway_step() # do 1 iteration lcd.show() # update the LCD + pyb.delay(300) # PC testing import lcd import pyb lcd = lcd.LCD(128, 32) conway_rand() -conway_go(100) +conway_go(1000) -- cgit v1.2.3 From c8742a06ca84528a45a2f5bad7d169694757f096 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 16 Jan 2014 19:13:30 +0200 Subject: Add dummy micropython module to enable mandel.py run with CPython. --- examples/mandel.py | 6 ++++++ examples/micropython.py | 8 ++++++++ 2 files changed, 14 insertions(+) create mode 100644 examples/micropython.py (limited to 'examples') diff --git a/examples/mandel.py b/examples/mandel.py index 996132a91..d2b34fff8 100644 --- a/examples/mandel.py +++ b/examples/mandel.py @@ -1,3 +1,9 @@ +try: + import micropython +except: + pass + + def mandelbrot(): # returns True if c, complex, is in the Mandelbrot set @micropython.native diff --git a/examples/micropython.py b/examples/micropython.py new file mode 100644 index 000000000..091c92deb --- /dev/null +++ b/examples/micropython.py @@ -0,0 +1,8 @@ +# micropython module placeholder for CPython + +# Dummy function decorators + +def nodecor(x): + return x + +byte_code = native = viper = nodecor -- cgit v1.2.3