2016-06-07 22:46:27 +01:00
|
|
|
.. currentmodule:: machine
|
2015-10-14 11:32:01 +01:00
|
|
|
.. _machine.RTC:
|
|
|
|
|
|
|
|
class RTC -- real time clock
|
|
|
|
============================
|
|
|
|
|
|
|
|
The RTC is and independent clock that keeps track of the date
|
|
|
|
and time.
|
|
|
|
|
|
|
|
Example usage::
|
|
|
|
|
|
|
|
rtc = machine.RTC()
|
2015-10-22 19:23:28 +01:00
|
|
|
rtc.init((2014, 5, 1, 4, 13, 0, 0, 0))
|
|
|
|
print(rtc.now())
|
2015-10-14 11:32:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
Constructors
|
|
|
|
------------
|
|
|
|
|
|
|
|
.. class:: machine.RTC(id=0, ...)
|
|
|
|
|
|
|
|
Create an RTC object. See init for parameters of initialization.
|
|
|
|
|
|
|
|
Methods
|
|
|
|
-------
|
|
|
|
|
2015-10-22 19:23:28 +01:00
|
|
|
.. method:: rtc.init(datetime)
|
2015-10-14 11:32:01 +01:00
|
|
|
|
|
|
|
Initialise the RTC. Datetime is a tuple of the form:
|
|
|
|
|
|
|
|
``(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]])``
|
|
|
|
|
|
|
|
.. method:: rtc.now()
|
|
|
|
|
|
|
|
Get get the current datetime tuple.
|
|
|
|
|
|
|
|
.. method:: rtc.deinit()
|
|
|
|
|
|
|
|
Resets the RTC to the time of January 1, 2015 and starts running it again.
|
|
|
|
|
|
|
|
.. method:: rtc.alarm(id, time, /*, repeat=False)
|
|
|
|
|
|
|
|
Set the RTC alarm. Time might be either a milllisecond value to program the alarm to
|
|
|
|
current time + time_in_ms in the future, or a datetimetuple. If the time passed is in
|
|
|
|
milliseconds, repeat can be set to ``True`` to make the alarm periodic.
|
|
|
|
|
|
|
|
.. method:: rtc.alarm_left(alarm_id=0)
|
|
|
|
|
|
|
|
Get the number of milliseconds left before the alarm expires.
|
|
|
|
|
|
|
|
.. method:: rtc.cancel(alarm_id=0)
|
|
|
|
|
|
|
|
Cancel a running alarm.
|
|
|
|
|
|
|
|
.. method:: rtc.irq(\*, trigger, handler=None, wake=machine.IDLE)
|
|
|
|
|
|
|
|
Create an irq object triggered by a real time clock alarm.
|
|
|
|
|
|
|
|
- ``trigger`` must be ``RTC.ALARM0``
|
|
|
|
- ``handler`` is the function to be called when the callback is triggered.
|
|
|
|
- ``wake`` specifies the sleep mode from where this interrupt can wake
|
|
|
|
up the system.
|
|
|
|
|
|
|
|
Constants
|
|
|
|
---------
|
|
|
|
|
|
|
|
.. data:: RTC.ALARM0
|
|
|
|
|
|
|
|
irq trigger source
|