File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/python
2
+
3
+ import time
4
+ import datetime
5
+ from Adafruit_LEDBackpack import LEDBackpack
6
+
7
+ # ===========================================================================
8
+ # 16x8 Pixel Display
9
+ # ===========================================================================
10
+
11
+ class SixteenByEight :
12
+ disp = None
13
+
14
+ # Constructor
15
+ def __init__ (self , address = 0x70 , debug = False ):
16
+ if (debug ):
17
+ print "Initializing a new instance of LEDBackpack at 0x%02X" % address
18
+ self .disp = LEDBackpack (address = address , debug = debug )
19
+
20
+ def writeRowRaw (self , charNumber , value ):
21
+ "Sets a row of pixels using a raw 16-bit value"
22
+ if (charNumber > 7 ):
23
+ return
24
+ # Set the appropriate row
25
+ self .disp .setBufferRow (charNumber , value )
26
+
27
+ def clearPixel (self , x , y ):
28
+ "A wrapper function to clear pixels (purely cosmetic)"
29
+ self .setPixel (x , y , 0 )
30
+
31
+ def setPixel (self , x , y , color = 1 ):
32
+ "Sets a single pixel"
33
+ if (x >= 16 ):
34
+ return
35
+ if (y >= 8 ):
36
+ return
37
+ x += 16 # 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
+ x %= 16
39
+ # Set the appropriate pixel
40
+ buffer = self .disp .getBuffer ()
41
+ if (color ):
42
+ self .disp .setBufferRow (y , buffer [y ] | 1 << x )
43
+ else :
44
+ self .disp .setBufferRow (y , buffer [y ] & ~ (1 << x ))
45
+
46
+ def clear (self ):
47
+ "Clears the entire display"
48
+ self .disp .clear ()
You can’t perform that action at this time.
0 commit comments