diff options
author | John R. Lenton <jlenton@gmail.com> | 2014-01-07 23:06:46 +0000 |
---|---|---|
committer | John R. Lenton <jlenton@gmail.com> | 2014-01-07 23:06:46 +0000 |
commit | 9c83ec0edac2394431a5d1aecba1d666ffdea0a3 (patch) | |
tree | ccf18860da373cf13194788b793a962335d69fef /examples/mandel.py | |
parent | 27d4ca7693c276d09a911c00c3442729c516dc23 (diff) | |
download | micropython-9c83ec0edac2394431a5d1aecba1d666ffdea0a3.tar.gz micropython-9c83ec0edac2394431a5d1aecba1d666ffdea0a3.zip |
Merge remote-tracking branch 'upstream/master' into dict_feats
Diffstat (limited to 'examples/mandel.py')
-rw-r--r-- | examples/mandel.py | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/examples/mandel.py b/examples/mandel.py index b13b7d87f8..996132a915 100644 --- a/examples/mandel.py +++ b/examples/mandel.py @@ -1,14 +1,22 @@ -@micropython.native -def in_set(c): - z = 0 - for i in range(40): - z = z*z + c - if abs(z) > 60: - return False - return True +def mandelbrot(): + # returns True if c, complex, is in the Mandelbrot set + @micropython.native + def in_set(c): + z = 0 + for i in range(40): + z = z*z + c + if abs(z) > 60: + return False + return True -for v in range(31): - line = [] + lcd.clear() for u in range(91): - line.append('*' if in_set((u / 30 - 2) + (v / 15 - 1) * 1j) else ' ') - print(''.join(line)) + for v in range(31): + if in_set((u / 30 - 2) + (v / 15 - 1) * 1j): + lcd.set(u, v) + lcd.show() + +# PC testing +import lcd +lcd = lcd.LCD(128, 32) +mandelbrot() |