Skip to content

Commit e8c3f31

Browse files
agattidpgeorge
authored andcommitted
mimxrt/machine_rtc: Deprecate RTC.cancel in MicroPython v2.
The current documentation for the `machine.RTC` class contains information about the `RTC.cancel` method for cancelling pending alarms. However only two ports (cc3200 and mimxrt) implement this functionality but under a different name: `RTC.alarm_cancel`. The mimxrt port also implements `RTC.cancel` but it is aliased to `RTC.alarm_cancel` anyway. To maintain naming consistency, this commit updates the documentation to officially define `RTC.alarm_cancel` as the method to call to cancel pending alarms and deprecates mimxrt's `RTC.cancel` implementation. `RTC.cancel` in the mimxrt port is thus scheduled for removal in MicroPython v2. Signed-off-by: Alessandro Gatti <[email protected]>
1 parent 28b5244 commit e8c3f31

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

docs/library/machine.RTC.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,13 @@ Methods
6262

6363
Get the number of milliseconds left before the alarm expires.
6464

65-
.. method:: RTC.cancel(alarm_id=0)
65+
.. method:: RTC.alarm_cancel(alarm_id=0)
6666

6767
Cancel a running alarm.
6868

69+
The mimxrt port also exposes this function as ``RTC.cancel(alarm_id=0)``, but this is
70+
scheduled to be removed in MicroPython 2.0.
71+
6972
.. method:: RTC.irq(*, trigger, handler=None, wake=machine.IDLE)
7073

7174
Create an irq object triggered by a real time clock alarm.

ports/mimxrt/machine_rtc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,9 @@ static const mp_rom_map_elem_t machine_rtc_locals_dict_table[] = {
394394
{ MP_ROM_QSTR(MP_QSTR_alarm), MP_ROM_PTR(&machine_rtc_alarm_obj) },
395395
{ MP_ROM_QSTR(MP_QSTR_alarm_left), MP_ROM_PTR(&machine_rtc_alarm_left_obj) },
396396
{ MP_ROM_QSTR(MP_QSTR_alarm_cancel), MP_ROM_PTR(&machine_rtc_alarm_cancel_obj) },
397+
#if !MICROPY_PREVIEW_VERSION_2
397398
{ MP_ROM_QSTR(MP_QSTR_cancel), MP_ROM_PTR(&machine_rtc_alarm_cancel_obj) },
399+
#endif
398400
{ MP_ROM_QSTR(MP_QSTR_irq), MP_ROM_PTR(&machine_rtc_irq_obj) },
399401
{ MP_ROM_QSTR(MP_QSTR_ALARM0), MP_ROM_INT(0) },
400402
};

0 commit comments

Comments
 (0)