Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
François Revol
firmware
Commits
0d8be9c3
Verified
Commit
0d8be9c3
authored
Aug 01, 2019
by
Rahix
Browse files
feat(pycardium): Add RTC_ALARM interrupt number
Signed-off-by:
Rahix
<
rahix@rahix.de
>
parent
b4246ffd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Documentation/pycardium/utime.rst
View file @
0d8be9c3
...
...
@@ -65,3 +65,22 @@ alarm.
utime.alarm(alarm, minute_timer)
minute_timer(None)
Alternatively, you can register a callback using the interrupt module and
then call :py:func:`utime.alarm` without a ``callback`` parameter:
.. code-block:: python
import interrupt, utime
def 5_second_timer(x):
current = utime.time()
print("Current: " + str(current))
alarm = (current // 10) * 10 + 5
utime.alarm(alarm)
# This time, we need to register and enable the callback manually
interrupt.set_callback(interrupt.RTC_ALARM, 5_second_timer)
interrupt.enable_callback(interrupt.RTC_ALARM)
5_second_timer(None)
pycardium/modules/interrupt.c
View file @
0d8be9c3
...
...
@@ -81,7 +81,12 @@ static const mp_rom_map_elem_t interrupt_module_globals_table[] = {
MP_ROM_PTR
(
&
interrupt_enable_callback_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_disable_callback
),
MP_ROM_PTR
(
&
interrupt_disable_callback_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_BHI160
),
MP_OBJ_NEW_SMALL_INT
(
2
)
},
/* Interrupt Numbers */
{
MP_ROM_QSTR
(
MP_QSTR_BHI160
),
MP_OBJ_NEW_SMALL_INT
(
EPIC_INT_BHI160_TEST
)
},
{
MP_ROM_QSTR
(
MP_QSTR_RTC_ALARM
),
MP_OBJ_NEW_SMALL_INT
(
EPIC_INT_RTC_ALARM
)
},
};
static
MP_DEFINE_CONST_DICT
(
interrupt_module_globals
,
interrupt_module_globals_table
...
...
pycardium/modules/qstrdefs.h
View file @
0d8be9c3
...
...
@@ -34,6 +34,7 @@ Q(set_callback)
Q
(
enable_callback
)
Q
(
disable_callback
)
Q
(
BHI160
)
Q
(
RTC_ALARM
)
/* display */
Q
(
sys_display
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment