Changed the Interrupt handling.
Now SIGTERM and SIGINT will be caught and the LEDs will be turned off.
This commit is contained in:
parent
b23bbc4d22
commit
1b39f92df8
@ -18,11 +18,17 @@ elif config.DEVICE == 'pi':
|
|||||||
strip.begin()
|
strip.begin()
|
||||||
elif config.DEVICE == 'blinkstick':
|
elif config.DEVICE == 'blinkstick':
|
||||||
from blinkstick import blinkstick
|
from blinkstick import blinkstick
|
||||||
import atexit
|
import signal
|
||||||
|
#Will turn all leds off when invoked.
|
||||||
|
def signal_handler(signal, frame):
|
||||||
|
all_off = [0]*(config.N_PIXELS*3)
|
||||||
|
stick.set_led_data(0, all_off)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
stick = blinkstick.find_first()
|
stick = blinkstick.find_first()
|
||||||
# Create a listener that turns the leds off when the program terminates
|
# Create a listener that turns the leds off when the program terminates
|
||||||
all_off = [0]*(config.N_PIXELS*3)
|
signal.signal(signal.SIGTERM, signal_handler)
|
||||||
atexit.register(lambda: stick.set_led_data(0, all_off))
|
signal.signal(signal.SIGINT, signal_handler)
|
||||||
|
|
||||||
_gamma = np.load(config.GAMMA_TABLE_PATH)
|
_gamma = np.load(config.GAMMA_TABLE_PATH)
|
||||||
"""Gamma lookup table used for nonlinear brightness correction"""
|
"""Gamma lookup table used for nonlinear brightness correction"""
|
||||||
|
Loading…
Reference in New Issue
Block a user