Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
R. Nestler
firmware
Commits
b4246ffd
Verified
Commit
b4246ffd
authored
5 years ago
by
rahix
Browse files
Options
Downloads
Patches
Plain Diff
docs: Document utime module
Signed-off-by:
Rahix
<
rahix@rahix.de
>
parent
1b575b03
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Documentation/index.rst
+1
-0
1 addition, 0 deletions
Documentation/index.rst
Documentation/pycardium/utime.rst
+67
-0
67 additions, 0 deletions
Documentation/pycardium/utime.rst
with
68 additions
and
0 deletions
Documentation/index.rst
+
1
−
0
View file @
b4246ffd
...
...
@@ -25,6 +25,7 @@ Last but not least, if you want to start hacking the lower-level firmware, the
pycardium/display
pycardium/leds
pycardium/light-sensor
pycardium/utime
pycardium/vibra
.. toctree::
...
...
This diff is collapsed.
Click to expand it.
Documentation/pycardium/utime.rst
0 → 100644
+
67
−
0
View file @
b4246ffd
``utime`` - Time
================
The ``utime`` module loosely follows CPython's |time|_ module, but is heavily
stripped down. Instead, it has a few time related functions which are not in
CPython but wouldn't fit anywhere else in our implementation. Most
prominently, this is the :py:func:`utime.alarm` function for setting an RTC
alarm.
.. |time| replace:: ``time``
.. _time: https://docs.python.org/3/library/time.html
.. py:function:: utime.sleep(secs)
Sleep for ``secs`` seconds. Can take a floating-point value.
.. py:function:: utime.sleep_ms(msecs)
Sleep for ``msecs`` milliseconds. Only takes integer values.
.. py:function:: utime.sleep_us(usecs)
Sleep for ``usecs`` microseconds. Only takes integer values.
.. py:function:: utime.time()
Return the current timestamp in seconds since 2000-01-01
.. py:function:: utime.localtime([secs])
Return the current time as a timestruct tuple. If ``secs`` is given, return
its timestruct tuple instead. Timestruct tuple looks like:
.. code-block:: python
(year, month, mday, hour, min, sec, wday, yday)
# 0 1 2 3 4 5 6 7
.. py:function:: utime.mktime(t)
Convert timestruct tuple into a seconds time stamp. See
:py:func:`utime.localtime` for details about timestruct tuples.
:returns: Seconds since 2000-01-01
.. py:function:: utime.alarm(secs, [callback])
Register the next RTC alarm for the timestamp ``secs``. ``secs`` is seconds
since 2000-01-01.
If an optional ``callback`` is given, it will be registered for the RTC
alarm interrupt. This will overwrite any previous interrupt handler. If
``callback`` is given, :c:func:`utime.alarm` will also enable the RTC alarm
interrupt.
**Example**:
.. code-block:: python
import utime
def minute_timer(x):
current = utime.time()
print("Current: " + str(current))
alarm = (current // 60 + 1) * 60
utime.alarm(alarm, minute_timer)
minute_timer(None)
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