Skip to content

Commit b548717

Browse files
committed
examples: Update examples.
1 parent b79fdce commit b548717

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

examples/example.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def on_clight_changed(client, clight):
3131
logging.info(f"ColoredLight changed. Swi: {clight.swi} Bri: {clight.bri} Sat: {clight.sat} Hue: {clight.hue}")
3232

3333

34-
def user_task(client):
34+
def user_task(client, args):
3535
# NOTE: this function should not block.
3636
# This is a user-defined task that updates the colored light. Note any registered
3737
# cloud object can be accessed using the client object passed to this function.

examples/micropython_basic.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def on_clight_changed(client, clight):
3232
logging.info(f"ColoredLight changed. Swi: {clight.swi} Bri: {clight.bri} Sat: {clight.sat} Hue: {clight.hue}")
3333

3434

35-
def user_task(client):
35+
def user_task(client, args):
3636
# NOTE: this function should not block.
3737
# This is a user-defined task that updates the colored light. Note any registered
3838
# cloud object can be accessed using the client object passed to this function.
@@ -41,8 +41,7 @@ def user_task(client):
4141
client["clight"].bri = round(uniform(0, 100), 1)
4242

4343

44-
def wdt_task(client):
45-
global wdt
44+
def wdt_task(client, wdt):
4645
# Update the WDT to prevent it from resetting the system
4746
wdt.feed()
4847

@@ -130,7 +129,7 @@ def wifi_connect():
130129
from machine import WDT
131130
# Enable the WDT with a timeout of 5s (1s is the minimum)
132131
wdt = WDT(timeout=7500)
133-
client.register(Task("watchdog_task", on_run=wdt_task, interval=1.0))
132+
client.register(Task("watchdog_task", on_run=wdt_task, interval=1.0, args=wdt))
134133
except (ImportError, AttributeError):
135134
pass
136135

0 commit comments

Comments
 (0)