summaryrefslogtreecommitdiffstatshomepage
path: root/examples/lcd.py
diff options
context:
space:
mode:
authorJohn R. Lenton <jlenton@gmail.com>2014-01-07 18:01:08 +0000
committerJohn R. Lenton <jlenton@gmail.com>2014-01-07 18:01:08 +0000
commit270112f7312f724e46ae34649dfce3ec43b697e0 (patch)
treed7438ae877350aede062d8ac7e62e52ab35cb018 /examples/lcd.py
parentc06763a0207dde7f2060f7b1670a0b99298a01f8 (diff)
parentfd04bb3bacf5dbc4d79c04a49520e3e81abb7352 (diff)
downloadmicropython-270112f7312f724e46ae34649dfce3ec43b697e0.tar.gz
micropython-270112f7312f724e46ae34649dfce3ec43b697e0.zip
Merge remote-tracking branch 'upstream/master' into listsort. Lots of conflict fun.
Conflicts: py/obj.h py/objbool.c py/objboundmeth.c py/objcell.c py/objclass.c py/objclosure.c py/objcomplex.c py/objdict.c py/objexcept.c py/objfun.c py/objgenerator.c py/objinstance.c py/objmodule.c py/objrange.c py/objset.c py/objslice.c
Diffstat (limited to 'examples/lcd.py')
-rw-r--r--examples/lcd.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/examples/lcd.py b/examples/lcd.py
new file mode 100644
index 0000000000..3303337bfb
--- /dev/null
+++ b/examples/lcd.py
@@ -0,0 +1,36 @@
+# LCD testing object for PC
+# uses double buffering
+class LCD:
+ def __init__(self, width, height):
+ self.width = width
+ self.height = height
+ self.buf1 = [[0 for x in range(self.width)] for y in range(self.height)]
+ self.buf2 = [[0 for x in range(self.width)] for y in range(self.height)]
+
+ def clear(self):
+ for y in range(self.height):
+ for x in range(self.width):
+ self.buf1[y][x] = self.buf2[y][x] = 0
+
+ def show(self):
+ print('') # blank line to separate frames
+ for y in range(self.height):
+ for x in range(self.width):
+ self.buf1[y][x] = self.buf2[y][x]
+ for y in range(self.height):
+ row = ''.join(['*' if self.buf1[y][x] else ' ' for x in range(self.width)])
+ print(row)
+
+ def get(self, x, y):
+ if 0 <= x < self.width and 0 <= y < self.height:
+ return self.buf1[y][x]
+ else:
+ return 0
+
+ def reset(self, x, y):
+ if 0 <= x < self.width and 0 <= y < self.height:
+ self.buf2[y][x] = 0
+
+ def set(self, x, y):
+ if 0 <= x < self.width and 0 <= y < self.height:
+ self.buf2[y][x] = 1