@@ -139,6 +139,16 @@ def writeimage(self,mode=0,image="template.bmp", live=False):
139
139
self .updatedisplay (mode = mode );
140
140
time .sleep (0.1 );
141
141
self .updatedisplay (mode = mode );
142
+
143
+
144
+ def writeText (self ,mode = 0 ,text = '' ):
145
+ import Image ,ImageDraw
146
+ image = Image .new ("1" ,(96 ,96 ))
147
+ draw = ImageDraw .Draw (image )
148
+ draw .text ((1 ,1 ),text ,fill = 'white' )
149
+ image .save ('tmp.bmp' ,'BMP' )
150
+ self .writeimage (mode ,"tmp.bmp" ,live = True )
151
+
142
152
def updatedisplay (self ,mode = 0 ,activate = 1 ):
143
153
"""Update the display to a particular mode."""
144
154
if activate : mode = mode | 0x10 ;
@@ -347,14 +357,15 @@ def main():
347
357
if len (sys .argv )> 2 :
348
358
imgfile = sys .argv [2 ];
349
359
350
-
351
- #Push a bird into the buffer.
352
- try :
353
- mw .writeimage (mode = mode ,image = imgfile ,live = True );
354
- except ImportError :
355
- print "Error, Python Imaging Library (PIL) needs to be installed"
356
- except :
357
- print "Error loading image. Probably not in the working directory." ;
360
+
361
+ mw .writeText (mode ,"Hello World" )
362
+ # #Push a bird into the buffer.
363
+ # try:
364
+ # mw.writeimage(mode=mode,image=imgfile,live=True);
365
+ # except ImportError:
366
+ # print "Error, Python Imaging Library (PIL) needs to be installed"
367
+ # except:
368
+ # print "Error loading image. Probably not in the working directory.";
358
369
359
370
#Test the writing function by writing a checker pattern.
360
371
#mw.testwritebuffer(mode=mode);
0 commit comments