Cejfi
November 5, 2020, 8:39pm
1
Hello everybody,
I searched very long for the solution but couldn’t find anything on the internet. I simply want to update the interval (example: from 5sec to 10sec) of an already created and running timer inside my Python script (Raspberry Pi)
This example can be used:
"""
[BLYNK TIMER EXAMPLE] ============================================================================================
Environment prepare:
In your Blynk App project:
- add "SuperChart" widget
- add two data streams for it ( stream #1 - Virtual Pin 8, stream #2 - Virtual Pin 9)
- set different colors for data stream (ex. red and orange)
- Run the App (green triangle in the upper right corner).
- define your auth token for current example and run it
This started program will register two timers that will update Virtual Pins data after defined intervals.
In app you can see on graph both pins data change. Additionally timers will print new pin values info to stdout.
Schema:
=================================================================================================================
+-----------+ +--------------+ +--------------+
| | | | | |
| blynk lib | | blynk server | | blynk app |
This file has been truncated. show original
If it is not possible to update, how could I recycle the timer as I already know how to register a timer programmatically.
This is the blinktimer library just in case someone can find something useful there for this issue:
# Copyright (c) 2019-2020 Anton Morozenko
"""
Polling timers for functions.
Registers timers and performs run once or periodical function execution after defined time intervals.
"""
# select.select call used as polling waiter where it is possible
# cause time.sleep sometimes may load CPU up to 100% with small polling wait interval
try:
# cpython
import time
import select
polling_wait = lambda x: select.select([], [], [], x)
polling_wait(0.01)
except OSError:
# windows case where select.select call fails
polling_wait = lambda x: time.sleep(x)
except ImportError:
# micropython
This file has been truncated. show original
Thank you in advance