@@ -277,7 +277,8 @@ def vline( self, aStart, aLen, aColor ) :
277277 if (stop [1 ] < start [1 ]):
278278 start , stop = stop , start
279279 self ._setwindowloc (start , stop )
280- self ._draw (aLen , aColor )
280+ self ._setColor (aColor )
281+ self ._draw (aLen )
281282
282283# @micropython.native
283284 def hline ( self , aStart , aLen , aColor ) :
@@ -288,7 +289,8 @@ def hline( self, aStart, aLen, aColor ) :
288289 if (stop [0 ] < start [0 ]):
289290 start , stop = stop , start
290291 self ._setwindowloc (start , stop )
291- self ._draw (aLen , aColor )
292+ self ._setColor (aColor )
293+ self ._draw (aLen )
292294
293295# @micropython.native
294296 def rect ( self , aStart , aSize , aColor ) :
@@ -317,7 +319,8 @@ def fillrect( self, aStart, aSize, aColor ) :
317319
318320 self ._setwindowloc (start , end )
319321 numPixels = (end [0 ] - start [0 ] + 1 ) * (end [1 ] - start [1 ] + 1 )
320- self ._draw (numPixels , aColor )
322+ self ._setColor (aColor )
323+ self ._draw (numPixels )
321324
322325# @micropython.native
323326 def circle ( self , aPos , aRadius , aColor ) :
@@ -373,15 +376,23 @@ def fill( self, aColor = BLACK ) :
373376 self .fillrect ((0 , 0 ), self ._size , aColor )
374377
375378# @micropython.native
376- def _draw ( self , aPixels , aColor ) :
377- '''Send given color to the device aPixels times.'''
379+ def _setColor ( self , aColor ) :
378380 self .colorData [0 ] = aColor >> 8
379381 self .colorData [1 ] = aColor
382+ self .buf = bytes (self .colorData ) * 32
383+
384+ # @micropython.native
385+ def _draw ( self , aPixels ) :
386+ '''Send given color to the device aPixels times.'''
380387
381388 self .dc (1 )
382389 self .cs (0 )
383- for i in range (aPixels ):
384- self .spi .write (self .colorData )
390+ for i in range (aPixels // 32 ):
391+ self .spi .write (self .buf )
392+ rest = (int (aPixels ) % 32 )
393+ if rest > 0 :
394+ buf2 = bytes (self .colorData ) * rest
395+ self .spi .write (buf2 )
385396 self .cs (1 )
386397
387398# @micropython.native
0 commit comments