以最小的可重现错误重新发布:我正在用 rp2040、RTC 和 NeoPixel 条构建一个基本的日光闹钟。我正在构建警报类(从时钟继承,从 NeoPixel 继承)对象,其中包含:触发时间(小时、分钟、秒)、触发函数和被触发函数的参数。我从 Clock 继承了 Alarm,以便能够使用 Clock 方法calculate_absolute_time
将 hr/min/sec 从午夜转换为秒。我没有包括这个方法,因为我上次发布它引起了很多混乱。
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)
在线抛出此错误wake_up_alarm...
:
Traceback (most recent call last):
File "code.py", line 16, in <module>
TypeError: can't convert tuple to int