Hi
New here from .au, modded the led.py code from the fanshim examples.
The following code runs well in Thonny (python IDE) on Raspbian RPi4b, when I type Ctrl/C the led if left showing blue.
But when I run it just from the command line, after Ctrl/C, the led stays off? Help! Thanks!
#!/usr/bin/env python3
from fanshim import FanShim
import time
import colorsys
import sys
fanshim = FanShim()
fanshim.set_fan(True) #fan on
fanshim.set_light(255, 255, 255) #set white
time.sleep(1)
try:
while True:
h = time.time() / 25.0
#print(h)
#print(colorsys.hsv_to_rgb(h, 1.0, 1.0))
r, g, b = [int(c * 255) for c in colorsys.hsv_to_rgb(h, 1.0, 1.0)]
fanshim.set_light(r, g, b)
#print(r, g, b)
time.sleep(1.0 / 60)
except KeyboardInterrupt:
pass
finally:
fanshim.set_light(0, 0, 255) #set blue
print('Led ended.')
sys.exit(0)