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
{{ message }}
This repository was archived by the owner on Oct 29, 2018. It is now read-only.
Start a new thread and return its identifier. The thread executes the function with the argument list args \(which must be a tuple\). The optional `kwargs` argument specifies a dictionary of keyword arguments. When the function returns, the thread silently exits. When the function terminates with an unhandled exception, a stack trace is printed and then the thread exits \(but other threads continue to run\).
27
27
28
-
### \_thread.exit\(\)
28
+
####\_thread.exit\(\)
29
29
30
30
Raise the `SystemExit` exception. When not caught, this will cause the thread to exit silently.
31
31
32
-
### \_thread.allocate\_lock\(\)
32
+
####\_thread.allocate\_lock\(\)
33
33
34
34
Return a new lock object. Methods of locks are described below. The lock is initially unlocked.
35
35
36
-
### \_thread.get\_ident\(\)
36
+
####\_thread.get\_ident\(\)
37
37
38
38
Return the `thread identifier` of the current thread. This is a nonzero integer. Its value has no direct meaning; it is intended as a magic cookie to be used e.g. to index a dictionary of thread-specific data. Thread identifiers may be recycled when a thread exits and another thread is created.
39
39
40
-
### \_thread.stack\_size\(\[size\]\)
40
+
####\_thread.stack\_size\(\[size\]\)
41
41
42
42
Return the thread stack size \(in bytes\) used when creating new threads. The optional size argument specifies the stack size to be used for subsequently created threads, and must be `0`\(use platform or configured default\) or a positive integer value of at least `4096`\(4KiB\). 4KiB is currently the minimum supported stack size value to guarantee sufficient stack space for the interpreter itself.
Allocate size bytes of RAM for the emergency exception buffer \(a good size is around 100 bytes\). The buffer is used to create exceptions in cases when normal RAM allocation would fail \(eg within an interrupt handler\) and therefore give useful traceback information in these situations.
8
8
9
9
A good way to use this function is to place it at the start of a main script \(e.g. `boot.py` or `main.py`\) and then the emergency exception buffer will be active for all the code following it.
10
10
11
-
### micropython.const\(expr\)
11
+
####micropython.const\(expr\)
12
12
13
13
Used to declare that the expression is a constant so that the compile can optimise it. The use of this function should be as follows:
14
14
@@ -23,35 +23,35 @@ Constants declared this way are still accessible as global variables from outsid
23
23
24
24
This const function is recognised directly by the MicroPython parser and is provided as part of the `micropython` module mainly so that scripts can be written which run under both CPython and MicroPython, by following the above pattern.
25
25
26
-
### micropython.opt\_level\(\[level\]\)
26
+
####micropython.opt\_level\(\[level\]\)
27
27
28
28
If `level` is given then this function sets the optimisation level for subsequent compilation of scripts, and returns `None`. Otherwise it returns the current optimisation level.
29
29
30
-
### micropython.mem\_info\(\[verbose\]\)
30
+
####micropython.mem\_info\(\[verbose\]\)
31
31
32
32
Print information about currently used memory. If the `verbose` argument is given then extra information is printed.
33
33
34
34
The information that is printed is implementation dependent, but currently includes the amount of stack and heap used. In verbose mode it prints out the entire heap indicating which blocks are used and which are free.
35
35
36
-
### micropython.qstr\_info\(\[verbose\]\)
36
+
####micropython.qstr\_info\(\[verbose\]\)
37
37
38
38
Print information about currently interned strings. If the `verbose` argument is given then extra information is printed.
39
39
40
40
The information that is printed is implementation dependent, but currently includes the number of interned strings and the amount of RAM they use. In verbose mode it prints out the names of all RAM-interned strings.
41
41
42
-
### micropython.stack\_use\(\)
42
+
####micropython.stack\_use\(\)
43
43
44
44
Return an integer representing the current amount of stack that is being used. The absolute value of this is not particularly useful, rather it should be used to compute differences in stack usage at different points.
45
45
46
-
### micropython.heap\_lock\(\)
46
+
####micropython.heap\_lock\(\)
47
47
48
-
### micropython.heap\_unlock\(\)
48
+
####micropython.heap\_unlock\(\)
49
49
50
50
Lock or unlock the heap. When locked no memory allocation can occur and a `MemoryError` will be raised if any heap allocation is attempted.
51
51
52
52
These functions can be nested, i.e. `heap_lock()` can be called multiple times in a row and the lock-depth will increase, and then `heap_unlock()` must be called the same number of times to make the heap available again.
53
53
54
-
### micropython.kbd\_intr\(chr\)
54
+
####micropython.kbd\_intr\(chr\)
55
55
56
56
Set the character that will raise a `KeyboardInterrupt` exception. By default this is set to 3 during script execution, corresponding to `Ctrl-C`. Passing `-1` to this function will disable capture of `Ctrl-C`, and passing `3` will restore it.
Copy file name to clipboardExpand all lines: firmware-and-api-reference/micropython/select.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -6,13 +6,13 @@ This module provides functions to wait for events on streams \(select streams wh
6
6
7
7
Polling is an efficient way of waiting for read/write activity on multiple objects. Current objects that support polling are: `pyb.UART`, `pyb.USB_VCP`.
Copy file name to clipboardExpand all lines: firmware-and-api-reference/micropython/sys.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
1
# sys
2
2
3
-
## Functions
3
+
## Methods
4
4
5
-
### sys.exit\(retval=0\)
5
+
####sys.exit\(retval=0\)
6
6
7
7
Terminate current program with a given exit code. Underlyingly, this function raise as `SystemExit` exception. If an argument is given, its value given as an argument to `SystemExit`.
8
8
9
-
### sys.print\_exception\(exc, file=sys.stdout\)
9
+
####sys.print\_exception\(exc, file=sys.stdout\)
10
10
11
11
Print exception with a traceback to a file-like object file \(or `sys.stdout` by default\).
Instantiate a "foreign data structure" object based on structure address in memory, descriptor \(encoded as a dictionary\), and layout type \(see below\).
83
83
84
-
### uctypes.LITTLE\_ENDIAN
84
+
####uctypes.LITTLE\_ENDIAN
85
85
86
86
Layout type for a little-endian packed structure. \(Packed means that every field occupies exactly as many bytes as defined in the descriptor, i.e. the alignment is 1\).
87
87
88
-
### uctypes.BIG\_ENDIAN
88
+
####uctypes.BIG\_ENDIAN
89
89
90
90
Layout type for a big-endian packed structure.
91
91
92
-
### uctypes.NATIVE
92
+
####uctypes.NATIVE
93
93
94
94
Layout type for a native structure - with data endianness and alignment conforming to the ABI of the system on which MicroPython runs.
95
95
96
-
### uctypes.sizeof\(struct\)
96
+
####uctypes.sizeof\(struct\)
97
97
98
98
Return size of data structure in bytes. Argument can be either structure class or specific instantiated structure object \(or its aggregate field\).
99
99
100
-
### uctypes.addressof\(obj\)
100
+
####uctypes.addressof\(obj\)
101
101
102
102
Return address of an object. Argument should be bytes, `bytearray` or other object supporting buffer protocol \(and address of this buffer is what actually returned\).
103
103
104
-
### uctypes.bytes\_at\(addr, size\)
104
+
####uctypes.bytes\_at\(addr, size\)
105
105
106
106
Capture memory at the given address and size as bytes object. As bytes object is immutable, memory is actually duplicated and copied into bytes object, so if memory contents change later, created object retains original value.
107
107
108
-
### uctypes.bytearray\_at\(addr, size\)
108
+
####uctypes.bytearray\_at\(addr, size\)
109
109
110
110
Capture memory at the given address and size as `bytearray` object. Unlike `bytes_at()` function above, memory is captured by reference, so it can be both written too, and you will access current value at the given memory address.
Copy file name to clipboardExpand all lines: firmware-and-api-reference/micropython/ujson.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -2,17 +2,17 @@
2
2
3
3
This modules allows to convert between Python objects and the JSON data format.
4
4
5
-
## Functions
5
+
## Methods
6
6
7
-
### ujson.dumps\(obj\)
7
+
####ujson.dumps\(obj\)
8
8
9
9
Return `obj` represented as a JSON string.
10
10
11
-
### ujson.loads\(str\)
11
+
####ujson.loads\(str\)
12
12
13
13
Parse the JSON `str` and return an object. Raises `ValueError` if the string is not correctly formed.
14
14
15
-
### ujson.load\(fp\)
15
+
####ujson.load\(fp\)
16
16
17
17
Parse contents of `fp`\(a `.read()`-supporting file-like object containing a JSON document\). Raises `ValueError` if the content is not correctly formed.
0 commit comments