spidev copies received data into tx buffer which corrupts led_values
Opened this issue · 0 comments
windy54 commented
def write_leds(self):
"""write_leds() writes all stored led_values to LEDs"""
self.flush_leds()
for value in self.led_values:
self.send = spi.xfer(value)
for x in range((self.numleds // 32) +2): #check this not overkill
self.flush_leds()
the latest version of spider copies the received data into the tx variable so the line
self.send = spi.xfer(value)
results in received data being copied into self.send and value. this means that self.led_values also gets modified by the received data, resulting in led_values been set to [0,0,0,0]. So in example03.py the data gets corrupted and only the first led addresses.
I have "fixed" it by adding
import copy at the top of the file
and changing the for loop to
for value in self.led_values:
txdata=copy.copy(value)
self.send = spi.xfer(txdata)
example03 now works. I am not sure if there is a more elegant fix which is why I have not posted me version of apa.py