@@ -237,29 +237,32 @@ def hex(str):
237
237
toret = "%s %02x" % (toret ,ord (c ));
238
238
return toret ;
239
239
240
+ def main ():
241
+ watchaddr = None ;
242
+ if len (sys .argv )> 1 : watchaddr = sys .argv [1 ];
243
+ mw = MetaWatch (watchaddr );
240
244
241
- watchaddr = None ;
242
- if len (sys .argv )> 1 : watchaddr = sys .argv [1 ];
243
- mw = MetaWatch (watchaddr );
245
+ mode = 0 ;
246
+ # Put an image on the display.
247
+ # First, clear the draw buffer to a filled template.
248
+ mw .clearbuffer (mode = mode ,filled = True );
244
249
245
- mode = 0 ;
246
- # Put an image on the display.
247
- # First, clear the draw buffer to a filled template.
248
- mw .clearbuffer (mode = mode ,filled = True );
249
250
251
+ imgfile = "template.bmp" ;
252
+ if len (sys .argv )> 2 :
253
+ imgfile = sys .argv [2 ];
250
254
251
- imgfile = "template.bmp" ;
252
- if len (sys .argv )> 2 :
253
- imgfile = sys .argv [2 ];
255
+ #Push a bird into the buffer.
256
+ try :
257
+ mw .writeimage (mode = mode ,image = imgfile ,live = True );
258
+ except :
259
+ print "Error loading image. Probably not in the working directory." ;
254
260
255
- #Push a bird into the buffer.
256
- try :
257
- mw .writeimage (mode = mode ,image = imgfile ,live = True );
258
- except :
259
- print "Error loading image. Probably not in the working directory." ;
261
+ #Test the writing function by writing a checker pattern.
262
+ #mw.testwritebuffer(mode=mode);
260
263
261
- #Test the writing function by writing a checker pattern.
262
- #mw.testwritebuffer(mode=mode);
263
-
264
- mw . close ();
264
+ mw . close ();
265
+
266
+ if __name__ == '__main__' :
267
+ main ()
265
268
0 commit comments