This repository was archived by the owner on May 7, 2025. It is now read-only.
File tree 2 files changed +53
-2
lines changed
2 files changed +53
-2
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ class BlynkTimer:
14
14
'''Executes functions after a defined period of time'''
15
15
_MAX_TIMERS = 16
16
16
17
- def __init__ (self , ** kwargs ):
17
+ def __init__ (self ):
18
18
self .timers = []
19
19
self .ids = self ._get_unique_id ()
20
20
@@ -83,7 +83,7 @@ def disable(self, timerId):
83
83
return timerId
84
84
85
85
def run (self ):
86
- '''Starts Timers '''
86
+ '''Polls timers '''
87
87
[t .run () for t in self .timers ]
88
88
89
89
Original file line number Diff line number Diff line change
1
+ """
2
+ Blynk is a platform with iOS and Android apps to control
3
+ Arduino, Raspberry Pi and the likes over the Internet.
4
+ You can easily build graphic interfaces for all your
5
+ projects by simply dragging and dropping widgets.
6
+
7
+ Downloads, docs, tutorials: http://www.blynk.cc
8
+ Sketch generator: http://examples.blynk.cc
9
+ Blynk community: http://community.blynk.cc
10
+ Social networks: http://www.fb.com/blynkapp
11
+ http://twitter.com/blynk_app
12
+
13
+ This example shows how to run functions after certain intervals
14
+
15
+ It will automagically call hello_word once after 2 seconds, and print_me
16
+ every 5 seconds
17
+
18
+ You should only need one BlynkTimer instance for a project,
19
+ as you can add multiple functions to it
20
+ """
21
+
22
+ import BlynkLib
23
+ from BlynkTimer import BlynkTimer
24
+
25
+ BLYNK_AUTH = 'YourAuthToken'
26
+
27
+ # Initialize Blynk
28
+ blynk = BlynkLib .Blynk (BLYNK_AUTH )
29
+
30
+ # Create BlynkTimer Instance
31
+ timer = BlynkTimer ()
32
+
33
+
34
+ # Will only run once after 2 seconds
35
+ def hello_world ():
36
+ print ("Hello World!" )
37
+
38
+
39
+ # Will Print Every 5 Seconds
40
+ def print_me ():
41
+ print ("Thanks!" )
42
+
43
+
44
+ # Add Timers
45
+ timer .set_timeout (2 , hello_world )
46
+ timer .set_interval (5 , print_me )
47
+
48
+
49
+ while True :
50
+ blynk .run ()
51
+ timer .run ()
You can’t perform that action at this time.
0 commit comments