Skip to content

Commit 844de23

Browse files
authored
Merge pull request #2 from FoamyGuy/new_examples
new examples, update products, specify built-in wifi
2 parents 057f5fd + 04d4a0b commit 844de23

File tree

4 files changed

+164
-3
lines changed

4 files changed

+164
-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: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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+
9+
import time
10+
11+
import board
12+
import wifi
13+
from digitalio import DigitalInOut, Direction, Pull
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+
# Basic push buttons initialization
23+
btn_1 = DigitalInOut(board.D11)
24+
btn_1.direction = Direction.INPUT
25+
btn_1.pull = Pull.UP
26+
27+
btn_2 = DigitalInOut(board.D12)
28+
btn_2.direction = Direction.INPUT
29+
btn_2.pull = Pull.UP
30+
31+
btn_3 = DigitalInOut(board.A1)
32+
btn_3.direction = Direction.INPUT
33+
btn_3.pull = Pull.UP
34+
35+
btn_4 = DigitalInOut(board.A0)
36+
btn_4.direction = Direction.INPUT
37+
btn_4.pull = Pull.UP
38+
39+
# list of colors to cycle through
40+
colors = [(255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 0), (0, 255, 255), (255, 0, 255)]
41+
# current index in the color cycle
42+
cur_rgb_index = 0
43+
44+
# list of temperatures to cycle through
45+
temperatures = [2200, 2800, 3600, 4800, 6200]
46+
# current index in the temperature cycle
47+
cur_temp_index = 0
48+
49+
while True:
50+
# if btn 1 pressed
51+
if not btn_1.value:
52+
print("Button 1")
53+
# toggle the on/off state
54+
my_lamp.state = not my_lamp.state
55+
time.sleep(0.5)
56+
57+
# if btn 2 pressed
58+
if not btn_2.value:
59+
print("Button 2")
60+
# set the current RGB color
61+
my_lamp.rgb_color = colors[cur_rgb_index]
62+
# increment the index for next time and wrap around to zero as needed
63+
cur_rgb_index = (cur_rgb_index + 1) % len(colors)
64+
time.sleep(0.5)
65+
66+
# if btn 3 pressed
67+
if not btn_3.value:
68+
print("Button 3")
69+
# set the current light color temperature
70+
my_lamp.temperature = temperatures[cur_temp_index]
71+
# increment the index for next time and wrap around to zero as needed
72+
cur_temp_index = (cur_temp_index + 1) % len(temperatures)
73+
time.sleep(0.5)
74+
75+
# if btn 4 pressed
76+
if not btn_4.value:
77+
print("Button 4")
78+
# uncomment to see the available scenes
79+
# print(SCENE_IDS.keys())
80+
81+
# set the scene
82+
my_lamp.scene = "Party"
83+
time.sleep(0.5)

examples/wiz_neokey1x4_controller.py

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

0 commit comments

Comments
 (0)