def main(): mote.set_clear_on_exit(False) # Very important for c in range(NUM_CHANNELS): mote.configure_channel(c + 1, NUM_PIXELS, True) current = start.copy() print(start) print(current) print(target) while current != target: mote.set_all(current[0], current[1], current[2]) mote.show() diff = abs(current[0] - target[0]) current[0] += (STEP if diff > STEP else diff) * (-1 if current[0] > target[0] else 1) diff = abs(current[1] - target[1]) current[1] += (STEP if diff > STEP else diff) * (-1 if current[1] > target[1] else 1) diff = abs(current[2] - target[2]) current[2] += (STEP if diff > STEP else diff) * (-1 if current[2] > target[2] else 1) time.sleep(INTERVAL)
def main(): mote.set_clear_on_exit(False) # Very important for c in range(NUM_CHANNELS): mote.configure_channel(c + 1, NUM_PIXELS, True) mote.set_all(r, g, b) mote.show()
def setMoteColor(r, g, b): # http://forums.pimoroni.com/t/mote-phat-not-all-leds-are-lighting-on-first-show/3740/3 # Workaround: multiple motephat.show() motephat.set_all(r, g, b, 1.0) motephat.show() motephat.show()
def mote_off(): motephat.set_all(0, 0, 0) motephat.show()
def mote_on(): motephat.set_all(255, 0, 0) motephat.show()
#!/usr/bin/env python3 import math import time import motephat as mote try: while True: br = (math.sin(time.time()) + 1) / 2 br *= 255.0 br = int(br) mote.set_all(br, br, br) mote.show() time.sleep(0.01) except KeyboardInterrupt: mote.clear() mote.show()
def set_all(self, r, g, b): r, g, b = self.apply_correction(r, g, b) mote.set_all(r, g, b) self.show()
def mote_update(r, g, b): mote.set_all(r, g, b) mote.show()