-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhite_keyboard_blink.py
More file actions
34 lines (28 loc) · 915 Bytes
/
white_keyboard_blink.py
File metadata and controls
34 lines (28 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# SPDX-FileCopyrightText: Daniel Schaefer 2023 for Framework Computer
# SPDX-License-Identifier: MIT
#
# Blink keyboard backlight and capslock LED every second
# Keep lights off if SLEEP# low
import time
import board
import digitalio
import pwmio
capslock = digitalio.DigitalInOut(board.GP24)
capslock.direction = digitalio.Direction.OUTPUT
# SLEEP# pin. Low if the host is sleeping
sleep_pin = digitalio.DigitalInOut(board.GP0)
sleep_pin.direction = digitalio.Direction.INPUT
backlight = pwmio.PWMOut(board.GP25, frequency=5000, duty_cycle=0)
# Blink capslock LED and backlight
while True:
sleeping = not sleep_pin.value
if sleeping:
# If the host is asleep, stop blinking
time.sleep(0.1)
continue
capslock.value = True
backlight.duty_cycle = int(65535 / 2) # 50% brightness
time.sleep(1)
capslock.value = False
backlight.duty_cycle = 0
time.sleep(1)