diff --git a/clock/api/hat/unicorn.py b/clock/api/hat/unicorn.py index f0c5850..f5f856a 100644 --- a/clock/api/hat/unicorn.py +++ b/clock/api/hat/unicorn.py @@ -29,13 +29,15 @@ class UnicornHat(object): self.brightness = 1 self.buffer = numpy.zeros((self.HEIGHT,self.WIDTH,3), dtype=int) - #self.reset_clock() + self.reset_clock() + def reset_clock(self): GPIO.output(self.PIN_CS, GPIO.LOW) - time.sleep(0.000001) + time.sleep(0.00001) GPIO.output(self.PIN_CS, GPIO.HIGH) + def spi_write(self, buf1, buf2): GPIO.output(self.PIN_CS, GPIO.LOW) @@ -44,10 +46,11 @@ class UnicornHat(object): for x in range(len(buf1)): b1, b2= buf1[x], buf2[x] self.spi_write_byte(b1, b2) - #time.sleep(0.0000001) + GPIO.output(self.PIN_CS, GPIO.HIGH) + def spi_write_byte(self, b1, b2): for x in range(8): GPIO.output(self.PINS_DAT[0], b1 & 0b10000000) @@ -90,6 +93,7 @@ class UnicornHat(object): def set_matrix(self, matrix): """Sets a height x width matrix directly""" + self.reset_clock() self.buffer = matrix self.show()