You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
examples/usercmodule: Add example of a native C class.
This shows how ports can add their own custom types/classes.
It is part of the unix coverage build, so we can use it for tests too.
Signed-off-by: Laurens Valk <[email protected]>
Copy file name to clipboardExpand all lines: docs/develop/cmodules.rst
+16-3Lines changed: 16 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,9 +95,12 @@ A MicroPython user C module is a directory with the following files:
95
95
Basic example
96
96
-------------
97
97
98
-
This simple module named ``cexample`` provides a single function
99
-
``cexample.add_ints(a, b)`` which adds the two integer args together and returns
100
-
the result. It can be found in the MicroPython source tree
98
+
The ``cexample`` module provides examples for a function and a class. The
99
+
``cexample.add_ints(a, b)`` function adds two integer args together and returns
100
+
the result. The ``cexample.Timer()`` type creates timers that can be used to
101
+
measure the elapsed time since the object is instantiated.
102
+
103
+
The module can be found in the MicroPython source tree
101
104
`in the examples directory <https://github.com/micropython/micropython/tree/master/examples/usercmodule/cexample>`_
102
105
and has a source file and a Makefile fragment with content as described above::
103
106
@@ -272,3 +275,13 @@ can now be accessed in Python just like any other builtin module, e.g.
0 commit comments