Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Data packet size incorrect
#11
Adam,

I've given this a whirl but am running into an error on the run.

Traceback (most recent call last):

  File "testAnimationChooser.py", line 52, in <module>
    chooser.run(threaded=True)
  File "/home/pi/Desktop/xmas/AnimationChooser.py", line 47, in run
    super(AnimationQueue, self).run(amt=1, fps=None, sleep=None, max_steps=0, untilComplete=untilComplete,
TypeError: super(type, obj): obj must be an instance or subtype of type


My Code Below:
from AnimationChooser import AnimationChooser
import bibliopixel
from bibliopixel.drivers.serial_driver import *
import bibliopixel.colors as colors
#load the LEDStrip class
from bibliopixel.led import *


class PingPong(BaseStripAnim):

    def __init__(self, led, max_led=None, color=(255, 255, 255), total_pixels=1):
        super(PingPong, self).__init__(led, 0, -1)
        self._current = 0
        self._minLed = 0
        self._maxLed = max_led
        if self._maxLed == None or self._maxLed < self._minLed:
            self._maxLed = self._led.lastIndex
        self._additionalPixels = total_pixels - 1
        self._positive = True
        self._color = color

    def step(self, amt=1):
        self._led.fill((0, 0, 0), 0, self._maxLed)

        self._led.fill(
            self._color, self._current, self._current + self._additionalPixels)

        if self._positive:
            self._current += 1
        else:
            self._current -= 1

        if self._current + self._additionalPixels == self._maxLed:
            self._positive = False

        if self._current == self._minLed:
            self._positive = True



led0 = None
NUM_LED0 = 118
def initLed():
global led0
driver0 = DriverSerial(num = NUM_LED0, type = LEDTYPE.APA102, c_order = ChannelOrder.BGR)
led0 = LEDStrip(driver0)
led0.all_off()
led0.update()

def addAnimations():
# ADD ANIMATIONS WITH DIFFERENT FPS TO CHOOSER
global chooser
global led0
anim =PingPong(led0)

for fps in range(5,65,5):
animName = str("PingPong_"+str(fps))
chooser.addAnim(animName, anim, fps=fps)


##### MAIN #####

initLed()
chooser = AnimationChooser(led0)
addAnimations()

chooser.run(threaded=True)

chooser.choose_anim("PingPong_5")
#12
Whoops.... grab the gist again. I fixed it... I think. Told you it was untested Wink
I just forgot to rename some of the class definitions in the super() calls since I copied it for AnimationQueue
#13
(04-24-2016, 05:13 PM)Adam Wrote: Whoops.... grab the gist again. I fixed it... I think. Told you it was untested Wink
I just forgot to rename some of the class definitions in the super() calls since I copied it for AnimationQueue

Found two bugs in choose_anim.  
1.  curAnim is initialized to None and it gets called before an animation is actually run so I added a test to see if it is initialized.  
2.  There is a call to self.curAnim._stopEvent.set() when curAnim is a tuple.  So I unpacked the tuple before calling stopEvent.  Fixed code below for check-in.

ks

    def choose_anim(self, choice):

        if choice not in self.anims:
            raise ValueError('{} is not a valid animation'.format(choice))
        self.choose_lock.acquire()
        self.anim_choice = choice
        if self.curAnim != None:
                anim, run = self.curAnim
                anim._stopEvent.set()
        self.choose_lock.release()


Forum Jump:


Users browsing this thread: 1 Guest(s)