Skip to content

Commit 5d6cb43

Browse files
committed
Merge remote-tracking branch 'upstream/master' into esp32
2 parents 8f04b74 + 10b76a9 commit 5d6cb43

File tree

308 files changed

+5881
-5389
lines changed

Some content is hidden

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

308 files changed

+5881
-5389
lines changed

.gitattributes

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ tests/basics/string_cr_conversion.py -text
1717
tests/basics/string_crlf_conversion.py -text
1818
ports/stm32/pybcdc.inf_template -text
1919
ports/stm32/usbd_* -text
20-
ports/stm32/boards/*/stm32f4xx_hal_conf.h -text
2120
ports/stm32/usbdev/** -text
2221
ports/stm32/usbhost/** -text
2322
ports/cc3200/hal/aes.c -text

.travis.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ before_script:
1919
- sudo apt-get install -y --force-yes gcc-arm-none-eabi
2020
# For teensy build
2121
- sudo apt-get install realpath
22-
# For coverage testing
23-
# cpp-coveralls 0.4 conflicts with urllib3 preinstalled in Travis VM
24-
- sudo pip install cpp-coveralls==0.3.12
22+
# For coverage testing (upgrade is used to get latest urllib3 version)
23+
- sudo pip install --upgrade cpp-coveralls
2524
- gcc --version
2625
- arm-none-eabi-gcc --version
2726
- python3 --version
@@ -40,7 +39,7 @@ script:
4039
- make -C ports/bare-arm
4140
- make -C ports/qemu-arm test
4241
- make -C ports/stm32
43-
- make -C ports/stm32 BOARD=PYBV11 MICROPY_PY_WIZNET5K=1 MICROPY_PY_CC3K=1
42+
- make -C ports/stm32 BOARD=PYBV11 MICROPY_PY_WIZNET5K=5200 MICROPY_PY_CC3K=1
4443
- make -C ports/stm32 BOARD=STM32F769DISC
4544
- make -C ports/stm32 BOARD=STM32L476DISC
4645
- make -C ports/teensy

README.md

+30-14
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Additional components:
8484
The subdirectories above may include READMEs with additional info.
8585

8686
"make" is used to build the components, or "gmake" on BSD-based systems.
87-
You will also need bash and Python (at least 2.7 or 3.3).
87+
You will also need bash, gcc, and Python (at least 2.7 or 3.3).
8888

8989
The Unix version
9090
----------------
@@ -97,6 +97,7 @@ Alternatively, fallback implementation based on setjmp/longjmp can be used.
9797

9898
To build (see section below for required dependencies):
9999

100+
$ git submodule update --init
100101
$ cd ports/unix
101102
$ make axtls
102103
$ make
@@ -129,43 +130,48 @@ Standard library modules come from
129130
External dependencies
130131
---------------------
131132

132-
Building Unix version requires some dependencies installed. For
133+
Building MicroPython ports may require some dependencies installed.
134+
135+
For Unix port, `libffi` library and `pkg-config` tool are required. On
133136
Debian/Ubuntu/Mint derivative Linux distros, install `build-essential`
134137
(includes toolchain and make), `libffi-dev`, and `pkg-config` packages.
135138

136-
Other dependencies can be built together with MicroPython. Oftentimes,
137-
you need to do this to enable extra features or capabilities. To build
139+
Other dependencies can be built together with MicroPython. This may
140+
be required to enable extra features or capabilities, and in recent
141+
versions of MicroPython, these may be enabled by default. To build
138142
these additional dependencies, first fetch git submodules for them:
139143

140144
$ git submodule update --init
141145

142-
Use this same command to get the latest versions of dependencies, as
143-
they are updated from time to time. After that, in `ports/unix/` dir, execute:
146+
Use the same command to get the latest versions of dependencies, as
147+
they are updated from time to time. After that, in the port directory
148+
(e.g. `ports/unix/`), execute:
144149

145150
$ make deplibs
146151

147152
This will build all available dependencies (regardless whether they
148153
are used or not). If you intend to build MicroPython with additional
149154
options (like cross-compiling), the same set of options should be passed
150-
to `make deplibs`. To actually enabled use of dependencies, edit
155+
to `make deplibs`. To actually enable/disable use of dependencies, edit
151156
`ports/unix/mpconfigport.mk` file, which has inline descriptions of the options.
152-
For example, to build SSL module (required for `upip` tool described above),
153-
set `MICROPY_PY_USSL` to 1.
157+
For example, to build SSL module (required for `upip` tool described above,
158+
and so enabled by dfeault), `MICROPY_PY_USSL` should be set to 1.
154159

155-
In `ports/unix/mpconfigport.mk`, you can also disable some dependencies enabled
156-
by default, like FFI support, which requires libffi development files to
157-
be installed.
160+
For some ports, building required dependences is transparent, and happens
161+
automatically. They still need to be fetched with the git submodule command
162+
above.
158163

159164
The STM32 version
160165
-----------------
161166

162167
The "stm32" port requires an ARM compiler, arm-none-eabi-gcc, and associated
163-
bin-utils. For those using Arch Linux, you need arm-none-eabi-binutils and
164-
arm-none-eabi-gcc packages. Otherwise, try here:
168+
bin-utils. For those using Arch Linux, you need arm-none-eabi-binutils,
169+
arm-none-eabi-gcc and arm-none-eabi-newlib packages. Otherwise, try here:
165170
https://launchpad.net/gcc-arm-embedded
166171

167172
To build:
168173

174+
$ git submodule update --init
169175
$ cd ports/stm32
170176
$ make
171177

@@ -181,3 +187,13 @@ This will use the included `tools/pydfu.py` script. If flashing the firmware
181187
does not work it may be because you don't have the correct permissions, and
182188
need to use `sudo make deploy`.
183189
See the README.md file in the ports/stm32/ directory for further details.
190+
191+
Contributing
192+
------------
193+
194+
MicroPython is an open-source project and welcomes contributions. To be
195+
productive, please be sure to follow the
196+
[Contributors' Guidelines](https://github.com/micropython/micropython/wiki/ContributorGuidelines)
197+
and the [Code Conventions](https://github.com/micropython/micropython/blob/master/CODECONVENTIONS.md).
198+
Note that MicroPython is licenced under the MIT license, and all contributions
199+
should follow this license.

docs/esp8266/quickref.rst

+11
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,17 @@ and is accessed via the :ref:`machine.I2C <machine.I2C>` class::
223223
buf = bytearray(10) # create a buffer with 10 bytes
224224
i2c.writeto(0x3a, buf) # write the given buffer to the slave
225225

226+
Real time clock (RTC)
227+
---------------------
228+
229+
See :ref:`machine.RTC <machine.RTC>` ::
230+
231+
from machine import RTC
232+
233+
rtc = RTC()
234+
rtc.datetime((2017, 8, 23, 1, 12, 48, 0, 0)) # set a specific date and time
235+
rtc.datetime() # get date and time
236+
226237
Deep-sleep mode
227238
---------------
228239

docs/esp8266/tutorial/neopixel.rst

+14
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@ To set the colour of pixels use::
2020
>>> np[1] = (0, 128, 0) # set to green, half brightness
2121
>>> np[2] = (0, 0, 64) # set to blue, quarter brightness
2222

23+
For LEDs with more than 3 colours, such as RGBW pixels or RGBY pixels, the
24+
NeoPixel class takes a ``bpp`` parameter. To setup a NeoPixel object for an
25+
RGBW Pixel, do the following::
26+
27+
>>> import machine, neopixel
28+
>>> np = neopixel.NeoPixel(machine.Pin(4), 8, bpp=4)
29+
30+
In a 4-bpp mode, remember to use 4-tuples instead of 3-tuples to set the colour.
31+
For example to set the first three pixels use::
32+
33+
>>> np[0] = (255, 0, 0, 128) # Orange in an RGBY Setup
34+
>>> np[1] = (0, 255, 0, 128) # Yellow-green in an RGBY Setup
35+
>>> np[2] = (0, 0, 255, 128) # Green-blue in an RGBY Setup
36+
2337
Then use the ``write()`` method to output the colours to the LEDs::
2438

2539
>>> np.write()

docs/library/btree.rst

+11-7
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,24 @@ Example::
7676
Functions
7777
---------
7878

79-
.. function:: open(stream, \*, flags=0, cachesize=0, pagesize=0, minkeypage=0)
79+
.. function:: open(stream, \*, flags=0, pagesize=0, cachesize=0, minkeypage=0)
8080

8181
Open a database from a random-access `stream` (like an open file). All
8282
other parameters are optional and keyword-only, and allow to tweak advanced
8383
parameters of the database operation (most users will not need them):
8484

8585
* *flags* - Currently unused.
86-
* *cachesize* - Suggested maximum memory cache size in bytes. For a
87-
board with enough memory using larger values may improve performance.
88-
The value is only a recommendation, the module may use more memory if
89-
values set too low.
9086
* *pagesize* - Page size used for the nodes in BTree. Acceptable range
91-
is 512-65536. If 0, underlying I/O block size will be used (the best
92-
compromise between memory usage and performance).
87+
is 512-65536. If 0, a port-specific default will be used, optimized for
88+
port's memory usage and/or performance.
89+
* *cachesize* - Suggested memory cache size in bytes. For a
90+
board with enough memory using larger values may improve performance.
91+
Cache policy is as follows: entire cache is not allocated at once;
92+
instead, accessing a new page in database will allocate a memory buffer
93+
for it, until value specified by *cachesize* is reached. Then, these
94+
buffers will be managed using LRU (least recently used) policy. More
95+
buffers may still be allocated if needed (e.g., if a database contains
96+
big keys and/or values). Allocated cache buffers aren't reclaimed.
9397
* *minkeypage* - Minimum number of keys to store per page. Default value
9498
of 0 equivalent to 2.
9599

docs/library/framebuf.rst

+6-5
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ Constructors
3838
- *width* is the width of the FrameBuffer in pixels
3939
- *height* is the height of the FrameBuffer in pixels
4040
- *format* specifies the type of pixel used in the FrameBuffer;
41-
valid values are ``framebuf.MVLSB``, ``framebuf.RGB565``
42-
and ``framebuf.GS4_HMSB``. MVLSB is monochrome 1-bit color,
43-
RGB565 is RGB 16-bit color, and GS4_HMSB is grayscale 4-bit color.
41+
permissible values are listed under Constants below. These set the
42+
number of bits used to encode a color value and the layout of these
43+
bits in *buffer*.
4444
Where a color value c is passed to a method, c is a small integer
4545
with an encoding that is dependent on the format of the FrameBuffer.
4646
- *stride* is the number of pixels between each horizontal line
@@ -110,8 +110,9 @@ Other methods
110110
corresponding color will be considered transparent: all pixels with that
111111
color value will not be drawn.
112112

113-
This method works between FrameBuffer's utilising different formats, but the
114-
resulting colors may be unexpected due to the mismatch in color formats.
113+
This method works between FrameBuffer instances utilising different formats,
114+
but the resulting colors may be unexpected due to the mismatch in color
115+
formats.
115116

116117
Constants
117118
---------

docs/library/network.rst

+24-14
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ parameter should be `id`.
7272
connection parameters. For various medium types, there are different
7373
sets of predefined/recommended parameters, among them:
7474

75-
* WiFi: *bssid* keyword to connect by BSSID (MAC address) instead
76-
of access point name
75+
* WiFi: *bssid* keyword to connect to a specific BSSID (MAC address)
7776

7877
.. method:: disconnect()
7978

@@ -225,7 +224,9 @@ parameter should be `id`.
225224
==============
226225

227226
This class allows you to control WIZnet5x00 Ethernet adaptors based on
228-
the W5200 and W5500 chipsets (only W5200 tested).
227+
the W5200 and W5500 chipsets. The particular chipset that is supported
228+
by the firmware is selected at compile-time via the MICROPY_PY_WIZNET5K
229+
option.
229230

230231
Example usage::
231232
@@ -269,6 +270,11 @@ parameter should be `id`.
269270
Methods
270271
-------
271272

273+
.. method:: wiznet5k.isconnected()
274+
275+
Returns ``True`` if the physical Ethernet link is connected and up.
276+
Returns ``False`` otherwise.
277+
272278
.. method:: wiznet5k.ifconfig([(ip, subnet, gateway, dns)])
273279

274280
Get/set IP address, subnet mask, gateway and DNS.
@@ -333,9 +339,12 @@ parameter should be `id`.
333339
argument is passed. Otherwise, query current state if no argument is
334340
provided. Most other methods require active interface.
335341

336-
.. method:: wlan.connect(ssid, password)
342+
.. method:: wlan.connect(ssid=None, password=None, \*, bssid=None)
337343

338344
Connect to the specified wireless network, using the specified password.
345+
If *bssid* is given then the connection will be restricted to the
346+
access-point with that MAC address (the *ssid* must also be specified
347+
in this case).
339348

340349
.. method:: wlan.disconnect()
341350

@@ -413,16 +422,17 @@ parameter should be `id`.
413422
Following are commonly supported parameters (availability of a specific parameter
414423
depends on network technology type, driver, and `MicroPython port`).
415424

416-
========= ===========
417-
Parameter Description
418-
========= ===========
419-
mac MAC address (bytes)
420-
essid WiFi access point name (string)
421-
channel WiFi channel (integer)
422-
hidden Whether ESSID is hidden (boolean)
423-
authmode Authentication mode supported (enumeration, see module constants)
424-
password Access password (string)
425-
========= ===========
425+
============= ===========
426+
Parameter Description
427+
============= ===========
428+
mac MAC address (bytes)
429+
essid WiFi access point name (string)
430+
channel WiFi channel (integer)
431+
hidden Whether ESSID is hidden (boolean)
432+
authmode Authentication mode supported (enumeration, see module constants)
433+
password Access password (string)
434+
dhcp_hostname The DHCP hostname to use
435+
============= ===========
426436

427437

428438

docs/library/pyb.Accel.rst

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.. currentmodule:: pyb
2+
.. _pyb.Accel:
23

34
class Accel -- accelerometer control
45
====================================

docs/library/pyb.CAN.rst

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.. currentmodule:: pyb
2+
.. _pyb.CAN:
23

34
class CAN -- controller area network communication bus
45
======================================================

docs/library/pyb.LCD.rst

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.. currentmodule:: pyb
2+
.. _pyb.LCD:
23

34
class LCD -- LCD control for the LCD touch-sensor pyskin
45
========================================================

docs/library/pyb.Switch.rst

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.. currentmodule:: pyb
2+
.. _pyb.Switch:
23

34
class Switch -- switch object
45
=============================

docs/library/pyb.USB_HID.rst

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.. currentmodule:: pyb
2+
.. _pyb.USB_HID:
23

34
class USB_HID -- USB Human Interface Device (HID)
45
=================================================

docs/library/pyb.USB_VCP.rst

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.. currentmodule:: pyb
2+
.. _pyb.USB_VCP:
23

34
class USB_VCP -- USB virtual comm port
45
======================================

docs/library/uselect.rst

+8-2
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,18 @@ Methods
6666

6767
Tuples returned may contain more than 2 elements as described above.
6868

69-
.. method:: poll.ipoll([timeout])
69+
.. method:: poll.ipoll(timeout=-1, flags=0)
7070

7171
Like :meth:`poll.poll`, but instead returns an iterator which yields
72-
callee-owned tuples. This function provides efficient, allocation-free
72+
`callee-owned tuples`. This function provides efficient, allocation-free
7373
way to poll on streams.
7474

75+
If *flags* is 1, one-shot behavior for events is employed: streams for
76+
which events happened, event mask will be automatically reset (equivalent
77+
to ``poll.modify(obj, 0)``), so new events for such a stream won't be
78+
processed until new mask is set with `poll.modify()`. This behavior is
79+
useful for asynchronous I/O schedulers.
80+
7581
.. admonition:: Difference to CPython
7682
:class: attention
7783

0 commit comments

Comments
 (0)