def __init__(self, verbose, showUpdates): # initializations self.beVerbose = verbose self.dryRun = False self.colorCalculator = ColorCalculator() self.deviceConnected = False self.currentFrameCount = 0 self.targetTimePerFrame = 0.0 self.updateFrameTimestamp = datetime.datetime.now() self.asyncUpdateRateController = AsyncUpdateRateController( self, showUpdates) self.pixelMap = [ 42, 43, 44, 45, 46, 47, 48, 41, 20, 21, 22, 23, 24, 25, 40, 19, 18, 17, 16, 15, 26, 39, 10, 11, 12, 13, 14, 27, 38, 9, 8, 7, 6, 5, 28, 37, 0, 1, 2, 3, 4, 29, 36, 35, 34, 33, 32, 31, 30 ] # establish connection to device try: if not self.dryRun: self.serialConnection = serial.Serial(DEVICE_FILE, DEVICE_BAUDRATE) self.deviceConnected = True except serial.SerialException: print('can not connect to the Arduino; going on as dry run') self.dryRun = True # build header for buffer # unsigned char array, will transfered serially to the device self.buffer = array('B') # ASCII for 'A'; magic number self.buffer.append(65) # ASCII for 'd'; magic number self.buffer.append(100) # ASCII for 'a'; magic number self.buffer.append(97) # LED count high byte self.buffer.append((NUMBER_LEDS - 1) >> 8) # LED count low byte self.buffer.append((NUMBER_LEDS - 1) & 0xff) # checksum self.buffer.append((NUMBER_LEDS - 1) >> 8 ^ (NUMBER_LEDS - 1) & 0xff ^ 0x55) for _ in range(0, (NUMBER_LEDS * 3)): # fill up every channel of every LED with zeros self.buffer.append(255) # calculate max. useful frame rate which the serial bus can handle targetFPS = (DEVICE_BAUDRATE / 8) / sys.getsizeof(self.buffer) self.targetTimePerFrame = 1.0 / targetFPS # wait for initialization if not self.dryRun: if self.beVerbose: print('wait for Arduino to be initialized') sleep(5) # start frame rate controller self.asyncUpdateRateController.start()
def __init__(self, device): # initializations self.device = device self.colors = ColorController self.colorCalculator = ColorCalculator() self.hueAdditionPerFrame = 0.0 # animation settings self.currentHueAddition = 0.0 self.speed = 10
def __init__(self, device): # animation settings self.glowingPixelCount = 17 self.glowingPixelDegreeOfColorDivergence = 35 self.minimumSpeed = 50 # initializations self.colorCalculator = ColorCalculator() self.colors = ColorController self.device = device self.randomGlowingPixels = {} self.sinFactorForHueAddition = 0
def __init__(self, device): # animation settings self.centerPositionX = 1 self.centerPositionY = 5 self.degreeOfColorDivergence = 30 self.distanceToDarkness = 3 self.speed = 0.01 self.iterationStep = 0 # initializations self.colorCalculator = ColorCalculator() self.colors = ColorController self.device = device self.degreeFactor = 0 # construct array of precalculated values self.sinSummands = [[ 0.0 for x in range(self.device.getNumberOfLeds()) ] for x in range(self.device.getNumberOfLeds())]
def __init__(self): # initializations self.device = None self.colorCalculator = ColorCalculator() self.basisColor = ORANGE self.binaryClockColor = WHITE self.basisLightness = 0.50 self.binaryClockLightness = 1 # value predefinitions self.basisHue = 0 self.basisSaturation = 1 self.basisRedChannel = 0 self.basisGreenChannel = 0 self.basisBlueChannel = 0 self.binaryClockColorRedChannel = 0 self.binaryClockColorGreenChannel = 0 self.binaryClockColorBlueChannel = 0 # calculate variations of initial color self.calculateVariationsOfBasisValues()