Skip to content

Commit b832220

Browse files
committed
Linting.
1 parent 496fd86 commit b832220

3 files changed

Lines changed: 34 additions & 31 deletions

File tree

Slider_Trinkey/Hue_Brightness_Python_Code/Hue_Brightness_Python_code.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
"""
2-
Slider Trinkey Hue Dimmer Python Example
3-
(Requires Hue Dimmer CircuitPython example to be running on the Slider Trinkey)
2+
Slider Trinkey Hue Brightness Python Example
3+
(Requires Hue and Monitor Brightness CircuitPython example to be running on the Slider Trinkey)
44
"""
5+
import sys
56
from phue import Bridge
67
import serial
78
from serial.tools import list_ports
89

910
# Update this to the room, zone or individual lamp you want to control.
10-
LAMP_OR_GROUP_NAME = "Office Desk Stand Lamp"
11+
LAMP_OR_GROUP_NAME = "Office"
1112

1213
# Update this to the IP address of your Hue Bridge.
13-
b = Bridge("10.19.69.50")
14+
b = Bridge("0.0.0.0")
1415

1516
slider_trinkey_port = None
1617
ports = list_ports.comports(include_links=False)
@@ -20,14 +21,11 @@
2021
if p.pid == 0x8102:
2122
slider_trinkey_port = p
2223
print("Found Slider Trinkey!")
24+
trinkey = serial.Serial(p.device)
2325
break
24-
else:
25-
print()
2626
else:
2727
print("Did not find Slider Trinkey port :(")
28-
exit(-1)
29-
30-
trinkey = serial.Serial(p.device)
28+
sys.exit()
3129

3230
# If the app is not registered and the button on the Hue Bridge is not pressed, press the button
3331
# and call connect() (this only needs to be run a single time)
Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
import time
2-
import board
3-
from analogio import AnalogIn
4-
import adafruit_simplemath
5-
6-
analog_in = AnalogIn(board.POTENTIOMETER)
7-
8-
def read_pot(samples, min_val, max_val):
9-
sum = 0
10-
for _ in range(samples):
11-
sum += analog_in.value
12-
sum /= samples # ok take the average
13-
14-
return adafruit_simplemath.map_range(sum, 100, 65535, min_val, max_val)
15-
16-
while True:
17-
print("Slider:", round(read_pot(10, 0, 100)))
18-
time.sleep(0.1)
1+
import time
2+
import board
3+
from analogio import AnalogIn
4+
import adafruit_simplemath
5+
6+
analog_in = AnalogIn(board.POTENTIOMETER)
7+
8+
9+
def read_pot(samples, min_val, max_val):
10+
sum_samples = 0
11+
for _ in range(samples):
12+
sum_samples += analog_in.value
13+
sum_samples /= samples # ok take the average
14+
15+
return adafruit_simplemath.map_range(sum_samples, 100, 65535, min_val, max_val)
16+
17+
18+
while True:
19+
print("Slider:", round(read_pot(10, 0, 100)))
20+
time.sleep(0.1)

Slider_Trinkey/Monitor_Brightness_Python_Code/Montor_Brightness_Python_code.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""
2+
Slider Trinkey Monitor Brightness Demo for Windows
3+
(Requires Hue and Monitor Brightness CircuitPython example to be running on the Slider Trinkey)
4+
"""
5+
import sys
16
import screen_brightness_control as sbc
27
import serial
38
from serial.tools import list_ports
@@ -10,14 +15,12 @@
1015
if p.pid == 0x8102:
1116
slider_trinkey_port = p
1217
print("Found Slider Trinkey!")
18+
trinkey = serial.Serial(p.device)
1319
break
14-
else:
15-
print()
1620
else:
1721
print("Did not find Slider Trinkey port :(")
18-
exit(-1)
22+
sys.exit()
1923

20-
trinkey = serial.Serial(p.device)
2124
curr_brightness = sbc.get_brightness()
2225

2326
while True:

0 commit comments

Comments
 (0)