@@ -33,8 +33,8 @@ def setPixel(self, x, y, color=1):
33
33
if (x >= 8 ):
34
34
return
35
35
if (y >= 8 ):
36
- return
37
- x += 7
36
+ return
37
+ x += 7 # ATTN: This might be a bug? On the color matrix, this causes x=0 to draw on the last line instead of the first.
38
38
x %= 8
39
39
# Set the appropriate pixel
40
40
buffer = self .disp .getBuffer ()
@@ -47,3 +47,29 @@ def clear(self):
47
47
"Clears the entire display"
48
48
self .disp .clear ()
49
49
50
+ class ColorEightByEight (EightByEight ):
51
+ def setPixel (self , x , y , color = 1 ):
52
+ "Sets a single pixel"
53
+ if (x >= 8 ):
54
+ return
55
+ if (y >= 8 ):
56
+ return
57
+
58
+ x %= 8
59
+
60
+ # Set the appropriate pixel
61
+ buffer = self .disp .getBuffer ()
62
+
63
+ # TODO : Named color constants?
64
+ # ATNN : This code was mostly taken from the arduino code, but with the addition of clearing the other bit when setting red or green.
65
+ # The arduino code does not do that, and might have the bug where if you draw red or green, then the other color, it actually draws yellow.
66
+ # The bug doesn't show up in the examples because it's always clearing.
67
+
68
+ if (color == 1 ):
69
+ self .disp .setBufferRow (y , (buffer [y ] | (1 << x )) & ~ (1 << (x + 8 )) )
70
+ elif (color == 2 ):
71
+ self .disp .setBufferRow (y , (buffer [y ] | 1 << (x + 8 )) & ~ (1 << x ) )
72
+ elif (color == 3 ):
73
+ self .disp .setBufferRow (y , buffer [y ] | (1 << (x + 8 )) | (1 << x ) )
74
+ else :
75
+ self .disp .setBufferRow (y , buffer [y ] & ~ (1 << x ) & ~ (1 << (x + 8 )) )
0 commit comments