Python从另一个函数调用一个函数会导致分段错误



我正试图用一些LED制作一个时钟,所以我需要根据时间点亮某些LED。我点亮LED块的功能是

我的主循环是

from rpi_ws281x import *
import time
import datetime
from time import sleep
def blockfill (strip, startpixel, endpixel, color):
for i in range (startpixel, endpixel):
strip.setPixelColor(i, color)
#Various Parameters for LED Tape here
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL, LED_STRIP)
strip.begin()
while True:
now = datetime.datetime.now()
hour = (now.hour % 12)
minute = (now.minute)
second = now.second
#Calling something here
strip.show()
sleep(0.2)

如果我放

blockfill(strip, 96, 100, Color(255,0,0))

在#CallSomething下面在这里,那就好了。但是,如果我定义

def hour2():
blockfill(strip, 96, 100, Color(255,0,0))

然后从我的主文件中调用hour2();分段故障";

我错过了什么?

感谢您的建议。我试图将文件拆分为多个不同的文件,但我在错误的地方启动了剥离

Adam

最新更新