Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Binary Epoch Strip Animation

From the YouTube video description:
"Using 15m of LPD8806 lights and the AllPixel to turn my tree into a giant Binary Epoch clock. Based on the idea behind our Binary Epoch Clock Kit, the Unix epoch time (number of seconds since 12:00am Jan 1 1970) is represented in binary notation. The strand of lights shows 32 places. Green represents a 'one', red, a 'zero'. The top of the tree is the Least Significant Bit, the bottom the Most Significant Bit. Practical clock? No. Festive? Very."

The 'BEClock' class (shown below) can be added to the BiblioPixel '' file.

class BEClock(BaseStripAnim):
   """Binary Epoch Clock"""

   def __init__(self, led, onColor, offColor, bitWidth, bitSpace, reverse):
        super(BEClock, self).__init__(led, 0, 0)
        self._onColor = onColor
        self._offColor = offColor
        self._bitWidth = bitWidth
        self._bitSpace = bitSpace
        self._reverse = reverse
   def step(self, amt = 1):
       z = calendar.timegm(time.gmtime(time.time()))

if self._reverse:
for i in range(32):
if (z & (1 << i)) > 0:
for i in range(32):
if (z & (1 << i)) > 0:
self._step = 0


from strip_animations import BEClock
anim = BEClock(led, onColor = colors.Green, offColor = colors.Red, bitWidth = 5, bitSpace = 12, reverse = True)

'led' is your 'LEDStrip' LED Display class (with appropriate LED driver supplied).
'onColor' is the color that will represent a binary '1'
'offColor' is the color that will represent a binary '0'
'bitWidth' is how many pixels wide each bit representation will be
'bitSpace' is the number of blank pixels between each bit representation
'reverse' allows the animation to be flipped on the strip (0 bit at the start or end of the strip).
I just noticed (rather, had it pointed out) an indentation error in the animation __init__. It has been corrected, and the part added to the '' file should work now. Hooray syntax errors.......

Forum Jump:

Users browsing this thread: 1 Guest(s)