Esempio n. 1
0
    def __init__(self,
                 add_delay=1.0,
                 speed=14.0,
                 color=Color(rgb=(1, 1, 1)),
                 width=6.0,
                 reverse=False):
        """
    Args:
      color the color of the center (maximally intense part) of a pulse
      width the maximum number of LEDs affected by a pulse (diameter)
      add_delay the number of seconds between new pulses
      speed the number of LEDs down the strip a pulse travels / second
      reverse If True, pulses travel in the opposite direction; by
          default, the start from index 0.
    """
        Pattern.__init__(self)
        if add_delay <= 0:
            raise ValueError('add_delay value %s is not > 0.' % add_delay)
        if speed == 0:
            raise ValueError('speed value %s is 0.')
        if width <= 0:
            raise ValueError('width value %s is not > 0.' % width)
        self.__add_delay = float(add_delay)
        self.__speed = float(speed)
        self.__interval = self.__speed * self.__add_delay
        self.__radius = width / 2.0
        self.__reverse = reverse
        self.__color = color

        self.__t0 = None
Esempio n. 2
0
 def apply(self, colorBuffer):
     Pattern.apply(self, colorBuffer)
     self.__updateColorsAndOffset()
     colors = colorBuffer.getColors()
     f = self.__offset
     for i in xrange(min(len(colors), len(self._colors) - 1)):
         colors[i].add(self._colors[i].scaled(f))
         colors[i].add(self._colors[i + 1].scaled(1.0 - f))
Esempio n. 3
0
 def __init__(self, colorSequence, speed=1.0):
     if speed <= 0.0:
         raise ValueError("Illegal speed %s must be > 0." % speed)
     Pattern.__init__(self)
     Buffer.__init__(self, size=STRIP_LENGTH + 2)
     self.__seq = iter(colorSequence)
     self.__speed = speed
     self.__offset = 1.0
     self.__t = None
Esempio n. 4
0
 def Apply(self, color_buffer):
     Pattern.Apply(self, color_buffer)
     self.__UpdateColorsAndOffset()
     colors = color_buffer.GetColors()
     f = self.__offset
     for i in xrange(min(len(colors), len(self._colors) - 1)):
         colors[i].Add(self._colors[i].Scaled(f))
         colors[i].Add(self._colors[i + 1].Scaled(1.0 - f))
Esempio n. 5
0
 def __init__(self, color_sequence, speed=1.0):
     """
 Args:
   color_sequence an iterable of Color objects, to be scrolled. When
       the color_sequence runs out, the marquee will stop animating.
    speed the number of positions (LEDs) to advance in one second.
       For example, with a speed of 5, the first color from
       color_sequence will move (smoothly) from the start of the LED
       strip to the 5th LED.
 """
     if speed <= 0.0:
         raise ValueError('Illegal speed %s must be > 0.' % speed)
     Pattern.__init__(self)
     Buffer.__init__(self, size=STRIP_LENGTH + 2)
     self.__seq = iter(color_sequence)
     self.__speed = speed
     self.__offset = 1.0
     self.__t = None
Esempio n. 6
0
	def apply(self, colorBuffer):
		"""
		Recalculate pulse positions for the current time and add pulses.
		"""
		Pattern.apply(self, colorBuffer)
		colors = colorBuffer.getColors()
		n = len(colors)
		for rawCenter in self.__generatePositions(n-1):
			center = rawCenter
			if self.__reverse:
				center = (n - 1) - center
			minIndex = int(1 + center - self.__radius)
			maxIndex = int(center + self.__radius)
			for i in xrange(minIndex, maxIndex+1):
				if i < 0 or i >= n:
					continue
				dx = abs(center - i)
				f = min(1.0, dx / self.__radius)
				colors[i] = colors[i].scaled(f)
				colors[i].add(self.__color.scaled(1.0 - f))
Esempio n. 7
0
	def __init__(self, addDelay=1.0, speed=14.0,
			color=Color(rgb=(1,1,1)), width=6.0,
			reverse=False):
		Pattern.__init__(self)
		if addDelay <= 0:
			raise ValueError('addDelay value %s is not > 0.'
				% addDelay)
		if speed == 0:
			raise ValueError('speed value %s is 0.')
		if width <= 0:
			raise ValueError('width value %s is not > 0.'
				% width)
		self.__addDelay = float(addDelay)
		self.__speed = float(speed)
		self.__interval = self.__speed * self.__addDelay
		self.__radius = width/2.0
		self.__reverse = reverse
		self.__color = color

		self.__t0 = None
Esempio n. 8
0
 def Apply(self, color_buffer):
     """Recalculates pulse positions for the current time and add pulses."""
     Pattern.Apply(self, color_buffer)
     colors = color_buffer.GetColors()
     n = len(colors)
     for raw_center in self.__GeneratePositions(n - 1):
         center = raw_center
         if self.__reverse:
             center = (n - 1) - center
         min_index = int(1 + center - self.__radius)
         max_index = int(center + self.__radius)
         for i in xrange(min_index, max_index + 1):
             if i < 0 or i >= n:
                 continue
             dx = abs(center - i)
             f = min(1.0, dx / self.__radius)
             colors[i] = colors[i].Scaled(f)
             colors[i].Add(self.__color.Scaled(1.0 - f))
 def __init__(self, color, opacity=0.0):
     Pattern.__init__(self)
     self.__color = color
     self.SetOpacity(opacity)
 def Apply(self, color_buffer):
     Pattern.Apply(self, color_buffer)
     for c in color_buffer.GetColors():
         c.set(Color.Lerp(self.__opacity, c, self.__color))
Esempio n. 11
0
	def __init__(self, color, opacity=0.0):
		Pattern.__init__(self)
		self.__color = color
		self.setOpacity(opacity)
Esempio n. 12
0
	def apply(self, colorBuffer):
		Pattern.apply(self, colorBuffer)
		for c in colorBuffer.getColors():
			c.set(Color.Lerp(self.__opacity, c, self.__color))
Esempio n. 13
0
	def __init__(self):
		Pattern.__init__(self)
		self.__patterns = []
Esempio n. 14
0
 def __init__(self):
     Pattern.__init__(self)
     self.__patterns = []