On unhandled exceptions, blink the feather LED repeatedly
This commit is contained in:
parent
96368c4632
commit
ea18655a21
@ -1,4 +1,12 @@
|
||||
import sys
|
||||
|
||||
from kmk.circuitpython.util import feather_red_led_flash
|
||||
from kmk_keyboard_user import main
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
try:
|
||||
main()
|
||||
except Exception as e:
|
||||
sys.print_exception(e)
|
||||
feather_red_led_flash(duration=10, rate=0.5)
|
||||
sys.exit(1)
|
||||
|
@ -1,23 +1,17 @@
|
||||
import sys
|
||||
import time
|
||||
|
||||
import board
|
||||
import digitalio
|
||||
|
||||
|
||||
def feather_signal_error_with_led_flash(rate=0.5):
|
||||
def feather_red_led_flash(duration=10, rate=0.5):
|
||||
'''
|
||||
Flash the red LED for 10 seconds, alternating every $rate
|
||||
Could be useful as an uncaught exception handler later on,
|
||||
but is for now unused
|
||||
Flash the red LED for $duration seconds, alternating every $rate
|
||||
'''
|
||||
|
||||
rled = digitalio.DigitalInOut(board.LED1)
|
||||
rled.direction = digitalio.Direction.OUTPUT
|
||||
|
||||
# blink for 5 seconds and exit
|
||||
for cycle in range(10):
|
||||
for cycle in range(duration / rate):
|
||||
rled.value = cycle % 2
|
||||
time.sleep(rate)
|
||||
|
||||
sys.exit(1)
|
||||
|
Loading…
Reference in New Issue
Block a user