aboutsummaryrefslogtreecommitdiff
path: root/turtetris_master/led_output.py
diff options
context:
space:
mode:
authorKarel Kočí <karel.koci@nic.cz>2017-07-19 11:06:04 +0200
committerKarel Kočí <karel.koci@nic.cz>2017-07-19 14:31:18 +0200
commitb934596cfd5415ce83b5a7b42120e0f0e229937a (patch)
treeeba32535681447d1eedad0e8f1f40f299f86f027 /turtetris_master/led_output.py
parentdd8bcc2da80d15280b9aa94cec648fbdac576cc3 (diff)
downloadturris-tetris-b934596cfd5415ce83b5a7b42120e0f0e229937a.tar.gz
turris-tetris-b934596cfd5415ce83b5a7b42120e0f0e229937a.tar.bz2
turris-tetris-b934596cfd5415ce83b5a7b42120e0f0e229937a.zip
Add screen checker
Diffstat (limited to 'turtetris_master/led_output.py')
-rw-r--r--turtetris_master/led_output.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/turtetris_master/led_output.py b/turtetris_master/led_output.py
index 7af7a35..443c44f 100644
--- a/turtetris_master/led_output.py
+++ b/turtetris_master/led_output.py
@@ -7,10 +7,13 @@ class Matrix:
def __init__(self):
"Establish connection to matrix"
- self.__mat__ = [[{
- 'color': '000000',
- 'intens': 0
- }]*12]*10
+ self.width = 12
+ self.height = 10
+ self.__mat__ = [None]*10
+ for x in range(10):
+ self.__mat__[x] = [None]*12
+ for y in range(12):
+ self.__mat__[x][y] = '000000'
self.context = zmq.Context()
self.socket = self.context.socket(zmq.PUB)
self.socket.bind('tcp://*:4444')
@@ -21,11 +24,8 @@ class Matrix:
self.socket.send_string('line' + str(i) + ' ' +
json.dumps(self.__mat__[i]))
- def pixel(self, x, y, color=None, bright=None):
+ def pixel(self, x, y, color):
"Set pixel in matrix"
if x < 0 or x > 11 or y < 0 or y > 9:
- return # just ignore any pixel outside of the matrix
- if color is not None:
- self.__mat__[y][x]['color'] = color
- if bright is not None:
- self.__mat__[y][x]['bright'] = bright
+ raise Exception('Pixel out of matrix')
+ self.__mat__[y][x] = color