The RGB python code is a bit slow at the time of this writing, but a few tweaks can dramatically speed it up.

First edit to use the hardware SPI, note the argument use_py_spi = True.

My was located at /home/pi/RPi-LPD8806/raspledstrip/
def __init__(self, leds, use_py_spi = True, dev="/dev/spidev0.0", driver="LPD8806"):
Now inside, we're going to change the SPI speed to 16MHz.
if self.use_py_spi:
	import spidev
	self.spi = spidev.SpiDev(),0)
	self.spi.max_speed_hz = 16000000
	print 'py-spidev MHz: %d' % (self.spi.max_speed_hz / 1000000.0 )
That print statement is there just to make sure everything gets set correctly.

One final change to the file is in the update() function. Every call to self.spi.xfer2() seems to have a 160ms delay at the end, so we're simply going to change the update function so that it calls the spi.xfer2() fewer times.
def update(self, buffer):
	temp_buffer = []
	if self.use_py_spi:
		for x in range(self.leds):
			temp_buffer = temp_buffer + [i for i in buffer[x]]
			#self.spi.xfer2([i for i in buffer[x]])
		self.spi.xfer2([0x00,0x00,0x00]) #zero fill the last to prevent stray colors at the end
		self.spi.xfer2([0x00]) #once more with feeling - this helps :) time2 = time.time()
If you re-run the python file, you should see a substantial increase in speed.

This guide was first published on Jan 13, 2014. It was last updated on Jan 13, 2014.

This page (Speed up the RGB Strip Software) was last updated on Jan 12, 2014.

Text editor powered by tinymce.