I'm trying to make a clock with some LEDs, so I need to light certain LEDs based on the time. My function for lighting a block of LEDs is
My main loop is
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)
And if I put
blockfill(strip, 96, 100, Color(255,0,0))
under #CallSomethingHere then it's fine. However if I define
def hour2():
blockfill(strip, 96, 100, Color(255,0,0))
Then call hour2()
from my main file, I got "segmentation fault"
What am I missing?