Skip to content
This repository was archived by the owner on Oct 29, 2018. It is now read-only.

Commit 82d7dcf

Browse files
Daniel Spindelbauergitbook-bot
Daniel Spindelbauer
authored andcommitted
GitBook: [master] 44 pages modified
1 parent 31da1d3 commit 82d7dcf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+321
-303
lines changed

firmware-and-api-reference/micropython/_thread.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,31 @@ for i in range(2):
1919
_thread.start_new_thread(th_func, (i + 1, i))
2020
```
2121

22-
## Functions
22+
## Methods
2323

24-
### \_thread.start\_new\_thread\(function, args\[, kwargs\]\)
24+
#### \_thread.start\_new\_thread\(function, args\[, kwargs\]\)
2525

2626
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\).
2727

28-
### \_thread.exit\(\)
28+
#### \_thread.exit\(\)
2929

3030
Raise the `SystemExit` exception. When not caught, this will cause the thread to exit silently.
3131

32-
### \_thread.allocate\_lock\(\)
32+
#### \_thread.allocate\_lock\(\)
3333

3434
Return a new lock object. Methods of locks are described below. The lock is initially unlocked.
3535

36-
### \_thread.get\_ident\(\)
36+
#### \_thread.get\_ident\(\)
3737

3838
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.
3939

40-
### \_thread.stack\_size\(\[size\]\)
40+
#### \_thread.stack\_size\(\[size\]\)
4141

4242
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.
4343

4444
## Objects
4545

46-
### \_thread.LockType
46+
#### \_thread.LockType
4747

4848
This is the type of lock objects.
4949

firmware-and-api-reference/micropython/array.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ Supported format codes: `b, B, h, H, i, I, l, L, q, Q, f, d` \(the latter 2 depe
66

77
## Classes
88

9-
### class array.array\(typecode\[, iterable\]\)
9+
#### class array.array\(typecode\[, iterable\]\)
1010

1111
Create array with elements of given type. Initial contents of the array are given by an iterable. If it is not provided, an empty array is created.
1212

13-
### array.append\(val\)
13+
## Methods
14+
15+
#### array.append\(val\)
1416

1517
Append new element to the end of array, growing it.
1618

17-
### array.extend\(iterable\)
19+
#### array.extend\(iterable\)
1820

1921
Append new elements as contained in an iterable to the end of array, growing it.
2022

firmware-and-api-reference/micropython/cmath.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,41 @@
22

33
The `cmath` module provides some basic mathematical functions for working with complex numbers. Floating point support required for this module.
44

5-
## Functions
5+
## Methods
66

7-
### cmath.cos\(z\)
7+
#### cmath.cos\(z\)
88

99
Return the cosine of `z`.
1010

11-
### cmath.exp\(z\)
11+
#### cmath.exp\(z\)
1212

1313
Return the exponential of `z`.
1414

15-
### cmath.log\(z\)
15+
#### cmath.log\(z\)
1616

1717
Return the natural logarithm of `z`. The branch cut is along the negative real axis.
1818

19-
### cmath.log10\(z\)
19+
#### cmath.log10\(z\)
2020

2121
Return the base-10 logarithm of `z`. The branch cut is along the negative real axis.
2222

23-
### cmath.phase\(z\)
23+
#### cmath.phase\(z\)
2424

2525
Returns the phase of the number `z`, in the range \(-pi, +pi\).
2626

27-
### cmath.polar\(z\)
27+
#### cmath.polar\(z\)
2828

2929
Returns, as a tuple, the polar form of `z`.
3030

31-
### cmath.rect\(r, phi\)
31+
#### cmath.rect\(r, phi\)
3232

3333
Returns the complex number with modulus `r` and phase `phi`.
3434

35-
### cmath.sin\(z\)
35+
#### cmath.sin\(z\)
3636

3737
Return the sine of `z`.
3838

39-
### cmath.sqrt\(z\)
39+
#### cmath.sqrt\(z\)
4040

4141
Return the square-root of `z`.
4242

Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
# gc
22

3-
## Functions
3+
## Methods
44

5-
### gc.enable\(\)
5+
#### gc.enable\(\)
66

77
Enable automatic garbage collection.
88

9-
### gc.disable\(\)
9+
#### gc.disable\(\)
1010

1111
Disable automatic garbage collection. Heap memory can still be allocated, and garbage collection can still be initiated manually using `gc.collect()`.
1212

13-
### gc.collect\(\)
13+
#### gc.collect\(\)
1414

1515
Run a garbage collection.
1616

17-
### gc.mem\_alloc\(\)
17+
#### gc.mem\_alloc\(\)
1818

1919
Return the number of bytes of heap RAM that are allocated.
2020

21-
### gc.mem\_free\(\)
21+
#### gc.mem\_free\(\)
2222

2323
Return the number of bytes of available heap RAM.
2424

firmware-and-api-reference/micropython/micropython.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# micropython
22

3-
## Functions
3+
## Methosd
44

5-
### micropython.alloc\_emergency\_exception\_buf\(size\)
5+
#### micropython.alloc\_emergency\_exception\_buf\(size\)
66

77
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.
88

99
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.
1010

11-
### micropython.const\(expr\)
11+
#### micropython.const\(expr\)
1212

1313
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:
1414

@@ -23,35 +23,35 @@ Constants declared this way are still accessible as global variables from outsid
2323

2424
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.
2525

26-
### micropython.opt\_level\(\[level\]\)
26+
#### micropython.opt\_level\(\[level\]\)
2727

2828
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.
2929

30-
### micropython.mem\_info\(\[verbose\]\)
30+
#### micropython.mem\_info\(\[verbose\]\)
3131

3232
Print information about currently used memory. If the `verbose` argument is given then extra information is printed.
3333

3434
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.
3535

36-
### micropython.qstr\_info\(\[verbose\]\)
36+
#### micropython.qstr\_info\(\[verbose\]\)
3737

3838
Print information about currently interned strings. If the `verbose` argument is given then extra information is printed.
3939

4040
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.
4141

42-
### micropython.stack\_use\(\)
42+
#### micropython.stack\_use\(\)
4343

4444
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.
4545

46-
### micropython.heap\_lock\(\)
46+
#### micropython.heap\_lock\(\)
4747

48-
### micropython.heap\_unlock\(\)
48+
#### micropython.heap\_unlock\(\)
4949

5050
Lock or unlock the heap. When locked no memory allocation can occur and a `MemoryError` will be raised if any heap allocation is attempted.
5151

5252
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.
5353

54-
### micropython.kbd\_intr\(chr\)
54+
#### micropython.kbd\_intr\(chr\)
5555

5656
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.
5757

firmware-and-api-reference/micropython/select.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ This module provides functions to wait for events on streams \(select streams wh
66

77
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`.
88

9-
## Functions
9+
## Methods
1010

11-
### select.poll\(\)
11+
#### select.poll\(\)
1212

1313
Create an instance of the `Poll` class.
1414

15-
### select.select\(rlist, wlist, xlist\[, timeout\]\)
15+
#### select.select\(rlist, wlist, xlist\[, timeout\]\)
1616

1717
Wait for activity on a set of objects.
1818

firmware-and-api-reference/micropython/sys.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# sys
22

3-
## Functions
3+
## Methods
44

5-
### sys.exit\(retval=0\)
5+
#### sys.exit\(retval=0\)
66

77
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`.
88

9-
### sys.print\_exception\(exc, file=sys.stdout\)
9+
#### sys.print\_exception\(exc, file=sys.stdout\)
1010

1111
Print exception with a traceback to a file-like object file \(or `sys.stdout` by default\).
1212

firmware-and-api-reference/micropython/ubinascii.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
This module implements conversions between binary data and various encodings of it in ASCII form \(in both directions\).
44

5-
## Functions
5+
## Methods
66

7-
### ubinascii.hexlify\(data\[, sep\]\)
7+
#### ubinascii.hexlify\(data\[, sep\]\)
88

99
Convert binary data to hexadecimal representation. Returns bytes string.
1010

@@ -14,15 +14,15 @@ Convert binary data to hexadecimal representation. Returns bytes string.
1414
If additional argument, `sep` is supplied, it is used as a separator between hexadecimal values.
1515
{% endhint %}
1616

17-
### ubinascii.unhexlify\(data\)
17+
#### ubinascii.unhexlify\(data\)
1818

1919
Convert hexadecimal data to binary representation. Returns bytes string. \(i.e. inverse of `hexlify`\)
2020

21-
### ubinascii.a2b\_base64\(data\)
21+
#### ubinascii.a2b\_base64\(data\)
2222

2323
Convert Base64-encoded data to binary representation. Returns bytes string.
2424

25-
### ubinascii.b2a\_base64\(data\)
25+
#### ubinascii.b2a\_base64\(data\)
2626

2727
Encode binary data in Base64 format. Returns string.
2828

firmware-and-api-reference/micropython/ucrypto.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This module provides native support for cryptographic algorithms. It’s loosely
88

99
## **Methods**
1010

11-
### crypto.getrandbits\(bits\)
11+
#### crypto.getrandbits\(bits\)
1212

1313
Returns a bytes object filled with random bits obtained from the hardware random number generator.
1414

firmware-and-api-reference/micropython/uctypes.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -77,35 +77,35 @@ Note that bitfield operations are independent of target byte endianness, in part
7777

7878
## Module Contents
7979

80-
### class uctypes.struct\(addr, descriptor, layout\_type=NATIVE\)
80+
#### class uctypes.struct\(addr, descriptor, layout\_type=NATIVE\)
8181

8282
Instantiate a "foreign data structure" object based on structure address in memory, descriptor \(encoded as a dictionary\), and layout type \(see below\).
8383

84-
### uctypes.LITTLE\_ENDIAN
84+
#### uctypes.LITTLE\_ENDIAN
8585

8686
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\).
8787

88-
### uctypes.BIG\_ENDIAN
88+
#### uctypes.BIG\_ENDIAN
8989

9090
Layout type for a big-endian packed structure.
9191

92-
### uctypes.NATIVE
92+
#### uctypes.NATIVE
9393

9494
Layout type for a native structure - with data endianness and alignment conforming to the ABI of the system on which MicroPython runs.
9595

96-
### uctypes.sizeof\(struct\)
96+
#### uctypes.sizeof\(struct\)
9797

9898
Return size of data structure in bytes. Argument can be either structure class or specific instantiated structure object \(or its aggregate field\).
9999

100-
### uctypes.addressof\(obj\)
100+
#### uctypes.addressof\(obj\)
101101

102102
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\).
103103

104-
### uctypes.bytes\_at\(addr, size\)
104+
#### uctypes.bytes\_at\(addr, size\)
105105

106106
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.
107107

108-
### uctypes.bytearray\_at\(addr, size\)
108+
#### uctypes.bytearray\_at\(addr, size\)
109109

110110
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.
111111

firmware-and-api-reference/micropython/uhashlib.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,41 @@ This module implements binary data hashing algorithms. MD5 and SHA are supported
44

55
## Constructors
66

7-
### class uhashlib.md5\(\[data\]\)
7+
#### class uhashlib.md5\(\[data\]\)
88

99
Create a MD5 hasher object and optionally feed data into it.
1010

11-
### class uhashlib.sha1\(\[data\]\)
11+
#### class uhashlib.sha1\(\[data\]\)
1212

1313
Create a SHA-1 hasher object and optionally feed data into it.
1414

15-
### class uhashlib.sha224\(\[data\]\)
15+
#### class uhashlib.sha224\(\[data\]\)
1616

1717
Create a SHA-224 hasher object and optionally feed data into it.
1818

19-
### class uhashlib.sha256\(\[data\]\)
19+
#### class uhashlib.sha256\(\[data\]\)
2020

2121
Create a SHA-256 hasher object and optionally feed data into it.
2222

23-
### class uhashlib.sha384\(\[data\]\)
23+
#### class uhashlib.sha384\(\[data\]\)
2424

2525
Create a SHA-384 hasher object and optionally feed data into it.
2626

27-
### class uhashlib.sha512\(\[data\]\)
27+
#### class uhashlib.sha512\(\[data\]\)
2828

2929
Create a SHA-512 hasher object and optionally feed data into it.
3030

3131
## Methods
3232

33-
### hash.update\(data\)
33+
#### hash.update\(data\)
3434

3535
Feed more binary data into hash.
3636

37-
### hash.digest\(\)
37+
#### hash.digest\(\)
3838

3939
Return hash for all data passed through hash, as a bytes object. After this method is called, more data cannot be fed into hash any longer.
4040

41-
### hash.hexdigest\(\)
41+
#### hash.hexdigest\(\)
4242

4343
This method is NOT implemented. Use `ubinascii.hexlify(hash.digest())` to achieve a similar effect.
4444

firmware-and-api-reference/micropython/ujson.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
This modules allows to convert between Python objects and the JSON data format.
44

5-
## Functions
5+
## Methods
66

7-
### ujson.dumps\(obj\)
7+
#### ujson.dumps\(obj\)
88

99
Return `obj` represented as a JSON string.
1010

11-
### ujson.loads\(str\)
11+
#### ujson.loads\(str\)
1212

1313
Parse the JSON `str` and return an object. Raises `ValueError` if the string is not correctly formed.
1414

15-
### ujson.load\(fp\)
15+
#### ujson.load\(fp\)
1616

1717
Parse contents of `fp` \(a `.read()`-supporting file-like object containing a JSON document\). Raises `ValueError` if the content is not correctly formed.
1818

0 commit comments

Comments
 (0)