Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
aerobs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Gattringer
aerobs
Commits
c71d9672
Commit
c71d9672
authored
1 year ago
by
Andreas Gattringer
Browse files
Options
Downloads
Patches
Plain Diff
updated period task logic
parent
aa4b0a59
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
umnp/microcontroller/tasks/periodictask.py
+7
-2
7 additions, 2 deletions
umnp/microcontroller/tasks/periodictask.py
with
7 additions
and
2 deletions
umnp/microcontroller/tasks/periodictask.py
+
7
−
2
View file @
c71d9672
...
...
@@ -18,10 +18,13 @@ class PeriodicTask:
self
.
_call_back
=
async_call_back
async
def
run
(
self
):
start_time
=
time
.
ticks_ms
()
last
=
start_time
func
=
self
.
_function
args
=
self
.
_args
call_back
=
self
.
_call_back
delay_seconds
=
25
/
1000
while
True
:
last
=
time
.
time
()
print
(
"
A0
"
,
args
)
...
...
@@ -32,7 +35,9 @@ class PeriodicTask:
await
call_back
(
result
)
while
True
:
now
=
time
.
time
()
if
now
-
last
>
0
:
now
=
time
.
ticks_ms
()
diff
=
time
.
ticks_diff
(
last
,
now
)
if
diff
>
self
.
_every_ms
:
last
=
now
break
await
asyncio
.
sleep
(
delay_seconds
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment