1

Repost with minimal reproducible error: I'm building a basic daylight alarm clock out of a rp2040, RTC, and NeoPixel strip. I'm building the Class for Alarm (inherits from Clock, inherits from NeoPixel) objects that contain: Time to trigger(hour, minute, second), Function to trigger, and Args for the function being triggered. I have Alarm inherit from Clock to be able to use the Clock method calculate_absolute_time which translates hr/min/sec to seconds from midnight. I did not include this method as last time I posted it caused much confusion.

import neopixel
import board
class Clock(neopixel.NeoPixel):
    def __init__(
        self, pin, n, *, bpp=3, brightness=1.0, auto_write=True, pixel_order=None, debugging=False,):
        super().__init__(pin, n, bpp=bpp, brightness=brightness, auto_write=auto_write, pixel_order=pixel_order,)

class Alarm(Clock):
    def __init__(self, time, trigger, *args):
        pass
def light_bar_soft_fade(*args):
    pass

clock_pixels = Clock(board.D10, 12, brightness=1, auto_write=False,
                           pixel_order=(1, 0, 2, 3))
wake_up_alarm = Alarm((7,0,0), light_bar_soft_fade, 1, clock_pixels)

Throws this error on line wake_up_alarm...:

Traceback (most recent call last):
  File "code.py", line 16, in <module>
TypeError: can't convert tuple to int

1 Answers1

0

Answer found from initial post, I learned something __new__:

class Alarm(Clock):
    def __new__(cls, self, time, trigger, *args):
        pass
    def __init__(self, time, trigger, *args):
        pass

Alarm was trying to call NeoPixels __new__ function and expected the first argument to be a pin designation