Skip to content
This repository was archived by the owner on May 7, 2025. It is now read-only.

Commit c969bc4

Browse files
committed
Universal .on decorator
1 parent 463a606 commit c969bc4

10 files changed

+14
-14
lines changed

examples/event_VIRTUAL_READ.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
blynk = BlynkLib.Blynk(BLYNK_AUTH)
3232

3333
# Register virtual pin handler
34-
@blynk.VIRTUAL_READ(2)
34+
@blynk.on("readV2")
3535
def v2_read_handler():
3636
# This widget will show some time in seconds..
3737
blynk.virtual_write(2, time.ticks_ms() // 1000)

examples/event_VIRTUAL_WRITE.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
blynk = BlynkLib.Blynk(BLYNK_AUTH)
3131

3232
# Register virtual pin handler
33-
@blynk.VIRTUAL_WRITE(3)
33+
@blynk.on("V3")
3434
def v3_write_handler(value):
3535
print('Current slider value: {}'.format(value[0]))
3636

examples/hardware/ESP32_Cellular_PPPoS.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
print("Connecting to Blynk...")
4848
blynk = BlynkLib.Blynk(BLYNK_AUTH)
4949

50-
@blynk.ON("connected")
50+
@blynk.on("connected")
5151
def blynk_connected(ping):
5252
print('Blynk ready. Ping:', ping, 'ms')
5353

examples/hardware/ESP8266_ESP32.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
print("Connecting to Blynk...")
3838
blynk = BlynkLib.Blynk(BLYNK_AUTH)
3939

40-
@blynk.ON("connected")
40+
@blynk.on("connected")
4141
def blynk_connected(ping):
4242
print('Blynk ready. Ping:', ping, 'ms')
4343

examples/hardware/PyCom_BLE.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def run(self):
7070

7171
blynk = BlynkBLE(BLYNK_AUTH)
7272

73-
@blynk.ON("connected")
73+
@blynk.on("connected")
7474
def blynk_connected(ping):
7575
print('Blynk ready. Ping:', ping, 'ms')
7676

examples/hardware/PyCom_WiPy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
print("Connecting to Blynk...")
3737
blynk = BlynkLib.Blynk(BLYNK_AUTH)
3838

39-
@blynk.ON("connected")
39+
@blynk.on("connected")
4040
def blynk_connected(ping):
4141
print('Blynk ready. Ping:', ping, 'ms')
4242

examples/other_functions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@
3131
log=print # use print function for debug logging
3232
)
3333

34-
@blynk.ON("connected")
34+
@blynk.on("connected")
3535
def blynk_connected(ping):
3636
print('Blynk ready. Ping:', ping, 'ms')
3737

38-
@blynk.ON("disconnected")
38+
@blynk.on("disconnected")
3939
def blynk_disconnected():
4040
print('Blynk disconnected')
4141

42-
@blynk.ON("V*")
42+
@blynk.on("V*")
4343
def blynk_handle_vpins(pin, value):
4444
print("V{} value: {}".format(pin, value))
4545

46-
@blynk.ON("readV*")
46+
@blynk.on("readV*")
4747
def blynk_handle_vpins_read(pin):
4848
print("Server asks a value for V{}".format(pin))
4949
blynk.virtual_write(pin, 0)

examples/sync_virtual.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
# initialize Blynk
1919
blynk = BlynkLib.Blynk(BLYNK_AUTH)
2020

21-
@blynk.ON("V*")
21+
@blynk.on("V*")
2222
def blynk_handle_vpins(pin, value):
2323
print("V{} value: {}".format(pin, value))
2424

25-
@blynk.ON("connected")
25+
@blynk.on("connected")
2626
def blynk_connected():
2727
# You can also use blynk.sync_virtual(pin)
2828
# to sync a specific virtual pin

examples/tweet_notify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# initialize Blynk
2828
blynk = BlynkLib.Blynk(BLYNK_AUTH)
2929

30-
@blynk.VIRTUAL_WRITE(4)
30+
@blynk.on("V4")
3131
def v4_write_handler(value):
3232
if value[0]: # is the the button is pressed?
3333
blynk.notify('You pressed the button and I know it ;)')

examples/widget_terminal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# initialize Blynk
2525
blynk = BlynkLib.Blynk(BLYNK_AUTH)
2626

27-
@blynk.VIRTUAL_WRITE(3)
27+
@blynk.on("V3")
2828
def v3_write_handler(value):
2929
# execute the command echo it back
3030
blynk.virtual_write(3, 'Command: ' + value + '\n')

0 commit comments

Comments
 (0)