Skip to content

Commit dec070b

Browse files
committed
new examples, update products, specify built-in wifi
1 parent 057f5fd commit dec070b

File tree

4 files changed

+162
-3
lines changed

4 files changed

+162
-3
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ or individual libraries can be installed using
3838

3939

4040

41-
Works with any CircuitPython device that supports WIFI or Ethernet networking.
41+
Works with any CircuitPython device has built-in WIFI.
4242

4343
`Purchase one from the Adafruit shop <http://www.adafruit.com/products/>`_
4444

adafruit_wiz.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@
1515
1616
**Hardware:**
1717
18-
Any CircuitPython device that supports WIFI or Ethernet networking.
18+
CircuitPython devices with built-in WIFI
19+
20+
* `Adafruit Feather ESP32-S2 <https://www.adafruit.com/product/5000>`_
21+
* `Adafruit Feather ESP32-S3 <https://www.adafruit.com/product/5477>`_
22+
* `Adafruit Feather ESP32-C6 <https://www.adafruit.com/product/5933>`_
23+
* `Raspberry Pi Pico W <https://www.adafruit.com/product/5526>`_
24+
* `Raspberry Pi Pico 2W <https://www.adafruit.com/product/6087>`_
25+
* `Adafruit Feather ESP32-S2 TFT <https://www.adafruit.com/product/5300>`_
26+
* `Adafruit Feather ESP32-S3 TFT <https://www.adafruit.com/product/5483>`_
1927
2028
**Software and Dependencies:**
2129
@@ -126,7 +134,6 @@ class WizConnectedLight:
126134
:param str ip: IP address of the Wiz connected light. Can be found in the smartphone app.
127135
:param int port: UDP port the Wiz connected light listens on. Default is 38899
128136
:param radio: WIFI radio object. It will attempt to use ``wifi.radio`` if not passed.
129-
Pass Radio objects for ESP32SPI or Wiznet ethernet networking to use them.
130137
:param bool debug: Enable additional debugging output.
131138
"""
132139

examples/wiz_buttons_controller.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2024 Tim Cocks for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
"""
5+
Basic demonstration of Wiz light control using 4 push buttons each
6+
wired to their own pin.
7+
"""
8+
import time
9+
10+
import board
11+
import wifi
12+
from digitalio import DigitalInOut, Direction, Pull
13+
14+
from adafruit_wiz import SCENE_IDS, WizConnectedLight
15+
16+
udp_host = "192.168.1.143" # IP of UDP Wiz connected light
17+
udp_port = 38899 # Default port is 38899, change if your light is configured differently
18+
19+
my_lamp = WizConnectedLight(udp_host, udp_port, wifi.radio, debug=True)
20+
21+
# Basic push buttons initialization
22+
btn_1 = DigitalInOut(board.D11)
23+
btn_1.direction = Direction.INPUT
24+
btn_1.pull = Pull.UP
25+
26+
btn_2 = DigitalInOut(board.D12)
27+
btn_2.direction = Direction.INPUT
28+
btn_2.pull = Pull.UP
29+
30+
btn_3 = DigitalInOut(board.A1)
31+
btn_3.direction = Direction.INPUT
32+
btn_3.pull = Pull.UP
33+
34+
btn_4 = DigitalInOut(board.A0)
35+
btn_4.direction = Direction.INPUT
36+
btn_4.pull = Pull.UP
37+
38+
# list of colors to cycle through
39+
colors = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 0), (0, 255, 255), (255, 0, 255)]
40+
# current index in the color cycle
41+
cur_rgb_index = 0
42+
43+
# list of temperatures to cycle through
44+
temperatures = [2200, 2800, 3600, 4800, 6200]
45+
# current index in the temperature cycle
46+
cur_temp_index = 0
47+
48+
while True:
49+
# if btn 1 pressed
50+
if not btn_1.value:
51+
print("Button 1")
52+
# toggle the on/off state
53+
my_lamp.state = not my_lamp.state
54+
time.sleep(0.5)
55+
56+
# if btn 2 pressed
57+
if not btn_2.value:
58+
print("Button 2")
59+
# set the current RGB color
60+
my_lamp.rgb_color = colors[cur_rgb_index]
61+
# increment the index for next time and wrap around to zero as needed
62+
cur_rgb_index = (cur_rgb_index + 1) % len(colors)
63+
time.sleep(0.5)
64+
65+
# if btn 3 pressed
66+
if not btn_3.value:
67+
print("Button 3")
68+
# set the current light color temperature
69+
my_lamp.temperature = temperatures[cur_temp_index]
70+
# increment the index for next time and wrap around to zero as needed
71+
cur_temp_index = (cur_temp_index + 1) % len(temperatures)
72+
time.sleep(0.5)
73+
74+
# if btn 4 pressed
75+
if not btn_4.value:
76+
print("Button 4")
77+
# uncomment to see the available scenes
78+
# print(SCENE_IDS.keys())
79+
80+
# set the scene
81+
my_lamp.scene = "Party"
82+
time.sleep(0.5)

examples/wiz_neokey1x4_controller.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2024 Tim Cocks for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
"""
5+
Demonstration of Wiz light control using a Neokey 1x4 QT I2C
6+
https://www.adafruit.com/product/4980
7+
"""
8+
import json
9+
import time
10+
11+
import board
12+
import wifi
13+
from adafruit_neokey.neokey1x4 import NeoKey1x4
14+
15+
from adafruit_wiz import SCENE_IDS, WizConnectedLight
16+
17+
udp_host = "192.168.1.143" # IP of UDP Wiz connected light
18+
udp_port = 38899 # Default port is 38899, change if your light is configured differently
19+
20+
my_lamp = WizConnectedLight(udp_host, udp_port, wifi.radio, debug=True)
21+
22+
# use default I2C bus
23+
i2c_bus = board.STEMMA_I2C()
24+
25+
# Create a NeoKey object
26+
neokey = NeoKey1x4(i2c_bus, addr=0x30)
27+
28+
# list of colors to cycle through
29+
colors = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 0), (0, 255, 255), (255, 0, 255)]
30+
# current index in the color cycle
31+
cur_rgb_index = 0
32+
33+
# list of temperatures to cycle through
34+
temperatures = [2200, 2800, 3600, 4800, 6200]
35+
# current index in the temperature cycle
36+
cur_temp_index = 0
37+
38+
while True:
39+
# if btn A pressed
40+
if neokey[0]:
41+
print("Button A")
42+
# toggle the on/off state
43+
my_lamp.state = not my_lamp.state
44+
time.sleep(0.5)
45+
46+
# if btn B pressed
47+
if neokey[1]:
48+
print("Button B")
49+
# set the current RGB color
50+
my_lamp.rgb_color = colors[cur_rgb_index]
51+
# increment the index for next time and wrap around to zero as needed
52+
cur_rgb_index = (cur_rgb_index + 1) % len(colors)
53+
time.sleep(0.5)
54+
55+
# if btn C pressed
56+
if neokey[2]:
57+
print("Button C")
58+
# set the current light color temperature
59+
my_lamp.temperature = temperatures[cur_temp_index]
60+
# increment the index for next time and wrap around to zero as needed
61+
cur_temp_index = (cur_temp_index + 1) % len(temperatures)
62+
time.sleep(0.5)
63+
# if btn D pressed
64+
if neokey[3]:
65+
print("Button D")
66+
# uncomment to see the available scenes
67+
# print(SCENE_IDS.keys())
68+
69+
# set the scene
70+
my_lamp.scene = "Party"

0 commit comments

Comments
 (0)