bool 'object' is not callable (what!?)

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Draculen
 
Posts: 72
Joined: Mon Jan 24, 2022 11:14 pm

bool 'object' is not callable (what!?)

Post by Draculen »

I'm adding an on_cycle_complete function to the sparkle.mpy adafruit_led_animation library. The final piece I have not really been able to understand is receiving the "bool object is not call-able" error. However all other animations that support on_cycle_complete are calling that function the same way I am.

Code: Select all

    on_cycle_complete_supported = True
    
    def on_cycle_complete(self):
        """
        Called by some animations when they complete an animation cycle.
        Animations that support cycle complete notifications will have X property set to False.
        Override as needed.
        """
        self.cycle_count += 1
        if self.cycle_count % self.notify_cycles == 0:
            for callback in self._also_notify:
                callback(self)
Example

Code: Select all

    def draw(self):
        self._pixels = [self._random_in_mask() for _ in range(self._num_sparkles)]
        for pixel in self._pixels:
            self.pixel_object[pixel] = self._sparkle_color
            
        if self.draw_count % len(self.pixel_object) == 0:
            print("what the hell")
            self.cycle_complete()
And here is a snippet of the theater chase animation code

Code: Select all

        if self.draw_count % len(self.pixel_object) == 0:
            self.cycle_complete = True
        self._offset = (self._offset + self._direction) % self._repeat_width
I dont see any other variables im excluding to pass self.cycle_complete, in other animations or even the base Animation class it all looks like it should work?

User avatar
danhalbert
 
Posts: 4654
Joined: Tue Aug 08, 2017 12:37 pm

Re: bool 'object' is not callable (what!?)

Post by danhalbert »

Code: Select all

       if self.draw_count % len(self.pixel_object) == 0:
            print("what the hell")
            self.cycle_complete()
I'm a little confused by what you're doing, but do you want the above to be `self.on_cycle_complete()` ??

Code: Select all

           self.cycle_complete = True
`self.cycle_complete` is just `True`, so you can't call it in first code snippet above.

User avatar
Draculen
 
Posts: 72
Joined: Mon Jan 24, 2022 11:14 pm

Re: bool 'object' is not callable (what!?)

Post by Draculen »

That makes perfect sense! Thank you for pointing that out.

I'm getting a pystack exausted runtime error but I think its unrelated or trying to call reset() to set the animation back to its original state over and over again.Time to tinker with it

I sincerely appreciate the reply!

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”