Commit Graph

1205 Commits

Author SHA1 Message Date
Damien George
79a3158de6 stm32/pin: Change remaining uses of "af" to "alt".
The keyword "af" has been deprecated for some time and "alt" should be used
instead (but "af" still works).

Signed-off-by: Damien George <damien@micropython.org>
2022-01-27 16:44:13 +11:00
Damien George
c153bfd311 docs/differences: Update python_36 now that b2a_base64 accepts newline.
Signed-off-by: Damien George <damien@micropython.org>
2022-01-23 10:23:30 +11:00
Christian Decker
2e3a2785cd extmod/modubinascii: Add newline keyword to b2a_base64 function.
This allows encoding things (eg a Basic-Auth header for a request) without
slicing the \n from the string, which allocates additional memory.

Co-authored-by: David Lechner <david@lechnology.com>
2022-01-23 10:18:01 +11:00
Damien George
aafd8859e9 docs/differences: Update differences now that math.tau/inf/nan exist.
Signed-off-by: Damien George <damien@micropython.org>
2022-01-23 09:33:19 +11:00
Jonathan Hogg
3300d6d337 docs/esp32: Document expanded ADC API in quickref.
Document read_u16(), read_uv() and ADCBlock(). Mark old read(), atten() 
and width() methods as legacy.
2022-01-21 22:40:37 +11:00
Damien George
4d2f487ee1 docs/library: Specify additional ADC methods and new ADCBlock class.
The new ADC methods are: init(), read_uv() and block().

The new ADCBlock class has methods: init() and connect().

See related discussions in #3943, #4213.

Signed-off-by: Damien George <damien@micropython.org>
2022-01-21 22:35:23 +11:00
Damien George
7d71ae25ed extmod/machine_i2c: Increase default SoftI2C timeout to 50ms.
Some devices, eg BNO055, can stretch SCL for a long time, so make the
default large to accommodate them.  50ms matches the current default for
stm32 hardware I2C .

Signed-off-by: Damien George <damien@micropython.org>
2022-01-21 15:10:30 +11:00
Damien George
da4b38e756 all: Bump version to 1.18.
Signed-off-by: Damien George <damien@micropython.org>
2022-01-17 09:50:31 +11:00
Damien George
a3bbd5332b esp32/machine_bitstream: Reinstate bitstream bit-bang implementation.
The bit-bang implementation was replaced with the RMT implementation in
599b61c086.  This commit brings back that
bit-bang code, and allows it to be selected via the new static method:

    esp32.RMT.bitstream_channel(None)

The bit-bang implementation may be useful if the RMT needs to be used for
something else, or if bit-banging is more stable in certain applications.

Signed-off-by: Damien George <damien@micropython.org>
2022-01-14 16:40:01 +11:00
Damien George
8957386250 docs/esp32: Update RMT quickref example to match latest code.
The start keyword was removed in 18e48a71ee

Signed-off-by: Damien George <damien@micropython.org>
2022-01-13 22:39:58 +11:00
Damien George
8ac5613419 LICENSE,docs: Update copyright year range to include 2022.
Signed-off-by: Damien George <damien@micropython.org>
2022-01-06 15:50:14 +11:00
Maureen Helm
c6d26bc524 zephyr: Upgrade to Zephyr v2.7.0.
Updates the Zephyr port build instructions and CI to use the latest
Zephyr release tag.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-01-06 14:09:39 +11:00
NitiKaur
01953f2964 docs/differences: Document details of new PEPs/features in Python 3.5+.
And how they relate to MicroPython.  As these features are implemented (or
the decision is made to not implement them) the tables can be updated to
document the differences between MicroPython and standard Python.
2022-01-05 22:49:20 +11:00
IhorNehrutsa
09fe80d091 esp32/machine_pwm: Keep duty constant when changing frequency.
Save and restore the same duty cycle when the frequency (or frequency
resolution) is changed.  This allows a smooth frequency change.

Also update the esp32 PWM quickref to be clearer.
2021-12-22 00:05:58 +11:00
Damien George
de43b500bd py/runtime: Allow initialising sys.path/argv with defaults.
If MICROPY_PY_SYS_PATH_ARGV_DEFAULTS is enabled (which it is by default)
then sys.path and sys.argv will be initialised and populated with default
values.  This keeps all bare-metal ports aligned.

Signed-off-by: Damien George <damien@micropython.org>
2021-12-18 00:08:07 +11:00
Jim Mussared
86394f70fc docs/library/sys.rst: Add note about '.frozen' as an entry in sys.path.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-12-18 00:08:07 +11:00
Damien George
d9d67adef1 docs: Remove trailing spaces and convert tabs to spaces.
Signed-off-by: Damien George <damien@micropython.org>
2021-12-15 11:49:22 +11:00
IhorNehrutsa
b491967bbd esp32/machine_pwm: Implement duty_u16() and duty_ns() PWM methods.
The methods duty_u16() and duty_ns() are implemented to match the existing
docs.  The duty will remain the same when the frequency is changed.
Standard ESP32 as well as S2, S3 and C3 are supported.

Thanks to @kdschlosser for the fix for rounding in resolution calculation.

Documentation is updated and examples expanded for esp32, including the
quickref and tutorial.  Additional notes are added to the machine.PWM docs
regarding limitations of hardware PWM.
2021-12-03 23:58:52 +11:00
Jonathan Hogg
851ecb2da1 extmod/modbluetooth: Support gap_connect(None) to cancel a connection.
Allow cancellation of in-progress peripheral connections.
2021-12-01 11:56:37 +11:00
Scott Armitage
de7e3cd792 docs/library/machine.Pin.rst: Add Pin.ANALOG mode constant. 2021-11-30 22:33:18 +11:00
Michael Buesch
68d1245f42 docs/library/machine.Timer.rst: Document period and callback args.
Signed-off-by: Michael Buesch <m@bues.ch>
2021-11-30 22:29:03 +11:00
Michael Buesch
1e7c8f2b0b docs/library/machine.SPI.rst: Add example SPI usage.
Signed-off-by: Michael Buesch <m@bues.ch>
2021-11-30 22:28:19 +11:00
Michael Buesch
e7900351bf docs/library/machine.Timer.rst: Document 'id' as positional-only arg.
Signed-off-by: Michael Buesch <m@bues.ch>
2021-11-30 22:27:58 +11:00
Peter Hinch
d94ac4333f docs/library/uasyncio.rst: Detail exception behaviour in cancel/timeout. 2021-11-30 21:43:06 +11:00
gibbonsc
de8dc4bad2 docs/esp8266/tutorial: Fix comments of FrameBuffer examples.
The third and fourth parameters in display.rect() and display.fill_rect()
are not x,y coordinates, but are instead width,height values.  Update the
comment after the example to show the correct x,y coordinates of the bottom
right corner of each rectangle, respectively.
2021-11-25 23:34:19 +11:00
NitiKaur
b851950c26 docs/library/sys.rst: Add docs for sys.settrace. 2021-11-19 15:30:34 +11:00
NitiKaur
e538d8a5a6 docs/rp2/quickref.rst: Add section on PIO. 2021-11-19 15:30:14 +11:00
Damien George
01f1c3aac2 docs/reference/filesystem.rst: Add detail on how to use littlefs fuse.
Without the --block_count option the fuse will fail.

Signed-off-by: Damien George <damien@micropython.org>
2021-11-19 15:13:05 +11:00
oli
f72b49756d docs/library/rp2.rst: Update function asm_pio_encode to add sideset_opt. 2021-11-19 13:38:56 +11:00
Sebastian Wicki
8f3510799d docs/library/framebuf.rst: Adjust dimensions in example.
This commit swaps the dimensions of the `framebuffer.FrameBuffer` in the
docs example from 10x100 to 100x10 pixels to avoid clipping.

This is done to better fit the subsequent example code, which writes
text of size 96x8 followed by a 96x1 horizontal line.

The y coordinate of the horizontal line is also adjusted such that it is
drawn inside of the new canvas bounds.
2021-11-17 14:36:33 +11:00
Mike Teachman
b6dbbbe82f rp2/machine_i2s: Add I2S protocol support.
This commit adds I2S protocol support for the rp2 port:
- I2S API is consistent with STM32 and ESP32 ports
- I2S configurations supported:
  - master transmit and master receive
  - 16-bit and 32-bit sample sizes
  - mono and stereo formats
  - sampling frequency
  - 3 modes of operation:
    - blocking
    - non-blocking with callback
    - uasyncio
  - internal ring buffer size can be tuned
- DMA IRQs are managed on an I2S object basis, allowing other
  RP2 entities to use DMA IRQs when I2S is not being used
- MicroPython documentation
- tested on Raspberry Pi Pico development board
- build metric changes for this commit: text(+4552), data(0), bss(+8)

Signed-off-by: Mike Teachman <mike.teachman@gmail.com>
2021-11-13 12:27:42 +11:00
Andrew Scheller
0adea40716 docs/rp2/general.rst: Fix typo with missing spaces. 2021-11-01 15:41:50 +11:00
Jim Mussared
43467b9c71 extmod/modbluetooth: Add connection interval to gap_connect.
This forwards through directly to the NimBLE and BTStack connect functions.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-10-26 00:16:53 +11:00
NitiKaur
4c9e17e0a1 docs/esp32/tutorial: Add an example of peripheral control via regs. 2021-10-14 23:31:45 +11:00
NitiKaur
763042a287 docs/library/stm.rst: Document the stm module. 2021-10-14 23:19:08 +11:00
NitiKaur
e87b2e8bfa docs/reference/manifest.rst: Add docs for manifest.py files. 2021-10-14 14:03:03 +11:00
NitiKaur
135339ce3a docs/reference/mpremote.rst: Add docs for mpremote. 2021-10-14 13:09:51 +11:00
NitiKaur
c42c1c8718 docs/library/random.rst: Document the random module. 2021-10-13 16:56:37 +11:00
NitiKaur
baa5a76fc0 docs/rp2: Add reference for PIO assembly instructions, and PIO tutorial. 2021-10-13 15:54:49 +11:00
IhorNehrutsa
71111cffba docs/esp32: Explain ESP32 PWM modes, timers, and channels. 2021-09-21 23:28:16 +10:00
Jim Mussared
b326edf68c all: Remove MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE.
This commit removes all parts of code associated with the existing
MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE optimisation option, including the
-mcache-lookup-bc option to mpy-cross.

This feature originally provided a significant performance boost for Unix,
but wasn't able to be enabled for MCU targets (due to frozen bytecode), and
added significant extra complexity to generating and distributing .mpy
files.

The equivalent performance gain is now provided by the combination of
MICROPY_OPT_LOAD_ATTR_FAST_PATH and MICROPY_OPT_MAP_LOOKUP_CACHE (which has
been enabled on the unix port in the previous commit).

It's hard to provide precise performance numbers, but tests have been run
on a wide variety of architectures (x86-64, ARM Cortex, Aarch64, RISC-V,
xtensa) and they all generally agree on the qualitative improvements seen
by the combination of MICROPY_OPT_LOAD_ATTR_FAST_PATH and
MICROPY_OPT_MAP_LOOKUP_CACHE.

For example, on a "quiet" Linux x64 environment (i3-5010U @ 2.10GHz) the
change from CACHE_MAP_LOOKUP_IN_BYTECODE, to LOAD_ATTR_FAST_PATH combined
with MAP_LOOKUP_CACHE is:

diff of scores (higher is better)
N=2000 M=2000       bccache -> attrmapcache      diff      diff% (error%)
bm_chaos.py        13742.56 ->   13905.67 :   +163.11 =  +1.187% (+/-3.75%)
bm_fannkuch.py        60.13 ->      61.34 :     +1.21 =  +2.012% (+/-2.11%)
bm_fft.py         113083.20 ->  114793.68 :  +1710.48 =  +1.513% (+/-1.57%)
bm_float.py       256552.80 ->  243908.29 : -12644.51 =  -4.929% (+/-1.90%)
bm_hexiom.py         521.93 ->     625.41 :   +103.48 = +19.826% (+/-0.40%)
bm_nqueens.py     197544.25 ->  217713.12 : +20168.87 = +10.210% (+/-3.01%)
bm_pidigits.py      8072.98 ->    8198.75 :   +125.77 =  +1.558% (+/-3.22%)
misc_aes.py        17283.45 ->   16480.52 :   -802.93 =  -4.646% (+/-0.82%)
misc_mandel.py     99083.99 ->  128939.84 : +29855.85 = +30.132% (+/-5.88%)
misc_pystone.py    83860.10 ->   82592.56 :  -1267.54 =  -1.511% (+/-2.27%)
misc_raytrace.py   21490.40 ->   22227.23 :   +736.83 =  +3.429% (+/-1.88%)

This shows that the new optimisations are at least as good as the existing
inline-bytecode-caching, and are sometimes much better (because the new
ones apply caching to a wider variety of map lookups).

The new optimisations can also benefit code generated by the native
emitter, because they apply to the runtime rather than the generated code.
The improvement for the native emitter when LOAD_ATTR_FAST_PATH and
MAP_LOOKUP_CACHE are enabled is (same Linux environment as above):

diff of scores (higher is better)
N=2000 M=2000        native -> nat-attrmapcache  diff      diff% (error%)
bm_chaos.py        14130.62 ->   15464.68 :  +1334.06 =  +9.441% (+/-7.11%)
bm_fannkuch.py        74.96 ->      76.16 :     +1.20 =  +1.601% (+/-1.80%)
bm_fft.py         166682.99 ->  168221.86 :  +1538.87 =  +0.923% (+/-4.20%)
bm_float.py       233415.23 ->  265524.90 : +32109.67 = +13.756% (+/-2.57%)
bm_hexiom.py         628.59 ->     734.17 :   +105.58 = +16.796% (+/-1.39%)
bm_nqueens.py     225418.44 ->  232926.45 :  +7508.01 =  +3.331% (+/-3.10%)
bm_pidigits.py      6322.00 ->    6379.52 :    +57.52 =  +0.910% (+/-5.62%)
misc_aes.py        20670.10 ->   27223.18 :  +6553.08 = +31.703% (+/-1.56%)
misc_mandel.py    138221.11 ->  152014.01 : +13792.90 =  +9.979% (+/-2.46%)
misc_pystone.py    85032.14 ->  105681.44 : +20649.30 = +24.284% (+/-2.25%)
misc_raytrace.py   19800.01 ->   23350.73 :  +3550.72 = +17.933% (+/-2.79%)

In summary, compared to MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE, the new
MICROPY_OPT_LOAD_ATTR_FAST_PATH and MICROPY_OPT_MAP_LOOKUP_CACHE options:
- are simpler;
- take less code size;
- are faster (generally);
- work with code generated by the native emitter;
- can be used on embedded targets with a small and constant RAM overhead;
- allow the same .mpy bytecode to run on all targets.

See #7680 for further discussion.  And see also #7653 for a discussion
about simplifying mpy-cross options.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-09-16 16:04:03 +10:00
Jim Mussared
e3eebc329f stm32: Suggest putting code in main.py not boot.py.
Don't want users to accidentally use boot.py (because recovering requires
knowing how to activate safe mode).

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-09-16 12:40:05 +10:00
Peter Hinch
4552f1816b docs/library/machine.I2S.rst: Specify that I2S.shift args are kw-only. 2021-09-13 18:21:46 +10:00
Ihor Nehrutsa
c7842f4798 docs/make.bat: Change Windows output dir from '_build' to 'build'.
To match the output file used by Makefile.
2021-09-13 18:15:38 +10:00
Matt Trentini
60d3a3c3a0 docs/library/bluetooth.rst: Update incorrect link to gatts_write. 2021-09-10 15:24:02 +10:00
Peter Hinch
cc0884bb4f docs/library/os.rst: Clarify littlefs requirements for block erase. 2021-09-10 15:21:12 +10:00
Damien George
7c54b64280 all: Bump version to 1.17.
Signed-off-by: Damien George <damien@micropython.org>
2021-09-02 00:07:13 +10:00
Peter Hinch
3720a570f2 docs/reference: Mention that slicing a memoryview causes allocation. 2021-08-30 23:55:29 +10:00
Fernando
4954290e86 docs/esp8266: Use monospace for software tools.
Signed-off-by: Fernando <fepegar@gmail.com>
2021-08-30 23:51:27 +10:00
Fernando
577a3c4192 docs/library: Fix usage of :term: for frozen module reference.
Signed-off-by: Fernando <fepegar@gmail.com>
2021-08-30 23:51:18 +10:00
Peter Hinch
2296df0a32 extmod/modframebuf: Enable blit between different formats via a palette.
This achieves a substantial performance improvement when rendering glyphs
to color displays, the benefit increasing proportional to the number of
pixels in the glyph.
2021-08-25 15:31:23 +10:00
Jim Mussared
53145c4c5f docs: Add docs for machine.bitstream and neopixel module.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-08-19 22:50:32 +10:00
Jim Mussared
44818d1a35 docs/library/network.rst: Simplify socket import.
Replace `import socket as socket` with `import socket`.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-08-17 11:26:24 +10:00
Jim Mussared
af162257d3 docs/library/builtins.rst: Add module title.
This fixes the rendering on library/index.rst.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-08-17 11:26:24 +10:00
Jim Mussared
1d9e489af3 extmod/modbluetooth: Add send_update arg to gatts_write.
This allows the write to trigger a notification or indication, but only to
subscribed clients. This is different to gatts_notify/gatts_indicate,
which will unconditionally notify/indicate.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-08-14 22:21:55 +10:00
Jim Mussared
d7fbc755dc docs/library/index.rst: Clarify module naming and purpose.
Adds section about extending built-in modules from Python.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-08-13 23:14:08 +10:00
Jim Mussared
c737cde947 docs: Replace ufoo with foo in all docs.
Anywhere a module is mentioned, use its "non-u" name for consistency.

The "import module" vs "import umodule" is something of a FAQ, and this
commit intends to help clear that up.  As a first approximation MicroPython
is Python, and so imports should work the same as Python and use the same
name, to a first approximation.  The u-version of a module is a detail that
can be learned later on, when the user wants to understand more and have
finer control over importing.

Existing Python code should just work, as much as it is possible to do that
within the constraints of embedded systems, and the MicroPython
documentation should match the idiomatic way to write Python code.

With universal weak links for modules (via MICROPY_MODULE_WEAK_LINKS) users
can consistently use "import foo" across all ports (with the exception of
the minimal ports).  And the ability to override/extend via "foo.py"
continues to work well.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-08-13 22:53:29 +10:00
Jim Mussared
218606351c docs: Rename ufoo.rst to foo.rst.
This is a simple rename of the files, no content changes
(other than updating index.rst to use the new paths)

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-08-13 20:31:32 +10:00
Damien George
671f012306 docs/templates: Add unix and zephyr quickref links to top-index.
Signed-off-by: Damien George <damien@micropython.org>
2021-08-13 20:21:21 +10:00
Julia Hathaway
6ed6990625 docs/library/zephyr: Add libraries specific to the Zephyr port.
Includes documentation for Zephyr specific modules (zephyr and zsensor),
classes (DiskAccess and FlashArea), and functions.

Signed-off-by: Julia Hathaway <julia.hathaway@nxp.com>
2021-08-13 20:21:14 +10:00
Julia Hathaway
333e16521b docs/zephyr: Add quick reference for the Zephyr port.
Includes an introduction to using the Zephyr port on MicroPython.  The
quickref details examples of how to use each module the port currently
supports.  The tutorial provides additional details for Zephyr specific
modules.

Signed-off-by: Julia Hathaway <julia.hathaway@nxp.com>
2021-08-13 20:20:57 +10:00
Damien George
45f9a38451 docs/library/machine.I2S.rst: Fix use of sd pin in examples.
Signed-off-by: Damien George <damien@micropython.org>
2021-08-07 20:40:54 +10:00
Peter Züger
ffc854f17f extmod/modujson: Add support for dump/dumps separators keyword-argument.
Optionally enabled via MICROPY_PY_UJSON_SEPARATORS.  Enabled by default.

For dump, make sure mp_get_stream_raise is called after
mod_ujson_separators since CPython does it in this order (if both
separators and stream are invalid, separators will raise an exception
first).

Add separators argument in the docs as well.

Signed-off-by: Peter Züger <zueger.peter@icloud.com>
Signed-off-by: Damien George <damien@micropython.org>
2021-08-07 13:52:16 +10:00
Damien George
8616129f2e esp8266,esp32: Include hidden networks in WLAN.scan results.
Addresses issues #2697 and #5329.

Signed-off-by: Damien George <damien@micropython.org>
2021-08-07 13:28:34 +10:00
Will Sowerbutts
a3675294ae esp32/machine_uart: Add flow kw-arg to enable hardware flow control.
This enables optional support for the hardware UART to use the RTS and/or
CTS pins for flow control.

The new "flow" constructor keyword specifies a bitmask of RTS and/or CTS.
This matches the interface used by machine.UART on stm32 and rp2.

Previously on ESP32 it was possible to specify which pins to use for the
RTS and CTS signals, but hardware flow control was never functional: CTS
was not checked before transmitting bytes, and RTS was always driven high
(signalling no buffer space available).  With this patch, CTS and RTS both
operate as expected.

This also includes an update to the machine.UART documentation.

Signed-off-by: Will Sowerbutts <will@sowerbutts.com>
2021-08-04 13:52:15 +10:00
Damien George
7f69246895 docs/library/uasyncio.rst: Document stream readexactly() method.
Signed-off-by: Damien George <damien@micropython.org>
2021-07-22 22:39:04 +10:00
Damien George
a5221c47eb docs/library/utime.rst: Clarify behaviour and precision of sleep ms/us.
This description is based on the existing bare-metal ports implementations.

Signed-off-by: Damien George <damien@micropython.org>
2021-07-22 00:07:37 +10:00
NitiKaur
6a9133a8b5 docs/rp2: Update general section to give a brief technical overview. 2021-07-20 00:26:37 +10:00
NitiKaur
da74ef6615 docs/rp2: Enhance quickref and change image to Pico pinout. 2021-07-20 00:21:06 +10:00
David P
fdd5b18133 docs: Replace master/slave with controller/peripheral in I2C and SPI.
See https://www.oshwa.org/a-resolution-to-redefine-spi-signal-names
2021-07-18 11:19:44 +10:00
Damien George
136369d72f all: Update to point to files in new shared/ directory.
Signed-off-by: Damien George <damien@micropython.org>
2021-07-12 17:08:10 +10:00
finefoot
e10a044d7c docs/esp8266/tutorial: Change flash mode from dio to dout.
For some boards, even -fm dio is too fast and they require -fm dout.  This
commit links to the esptool wiki about available flash modes and changes
dio to dout.
2021-07-07 21:15:58 +10:00
Tom McDermott
c1f74b3005 docs/library: Warn that ustruct doesn't handle spaces in format strings.
And also add a test to capture the CPython difference.
2021-07-06 14:59:50 +10:00
Mike Teachman
8a5bfe44a5 esp32,stm32: Add new machine.I2S class for I2S protocol support.
This commit adds I2S protocol support for the esp32 and stm32 ports, via
a new machine.I2S class.  It builds on the stm32 work of blmorris, #1361.

Features include:
- a consistent I2S API across the esp32 and stm32 ports
- I2S configurations supported:
  - master transmit and master receive
  - 16-bit and 32-bit sample sizes
  - mono and stereo formats
  - sampling frequency
  - 3 modes of operation:
    - blocking
    - non-blocking with callback
    - uasyncio
  - internal ring buffer size can be tuned
- documentation for Pyboards and esp32-based boards
- tested on the following development boards:
  - Pyboard D SF2W
  - Pyboard V1.1
  - ESP32 with SPIRAM
  - ESP32

Signed-off-by: Mike Teachman <mike.teachman@gmail.com>
2021-07-05 23:42:25 +10:00
Jonathan Hogg
0b3332c8e1 docs/library: Document new esp32.RMT features and fix wait_done.
Add new API for specifying the idle level and TX carrier output level, and
new write_pulses modes of operation.  Also fix wait_done documentation
which was inverted and wrong about timing.
2021-07-01 14:44:41 +10:00
Krzysztof Adamski
35b1359a3a rp2: Use 0=Monday datetime convention in RTC.
The RTC in rp2 can store any, even wrong, number as a weekday in RTC.  It
was, however, discussed in #7394 that we would like to unify all ports and
use 0 as Monday, not Sunday in the machine.RTC implementation.

This patch makes sure that the default date set in RTC is adheres to this
convention.  It also fixes the example in quickref to use proper weekday to
avoid confusion.

Signed-off-by: Krzysztof Adamski <k@japko.eu>
2021-06-25 10:29:12 +10:00
Damien George
63b8b79610 stm32/usb: Make irq's default trigger enable all events.
Following how other .irq() methods work on other objects.

Signed-off-by: Damien George <damien@micropython.org>
2021-06-23 16:11:37 +10:00
Jim Mussared
2fa975c264 LICENSE: Reference third-party licenses.
This is to provide a summary of the licenses used by MicroPython.

- Add SPDX identifier for every directory that includes
  non-MIT-licensed content.
- Add brief summary.
- Update docs license to be more explicit.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-06-22 15:50:47 +10:00
Damien George
7c51cb2307 all: Bump version to 1.16.
Signed-off-by: Damien George <damien@micropython.org>
2021-06-18 16:38:06 +10:00
Thomas Wenrich
364670ecf1 docs/esp32: Document WLAN "reconnects" config option. 2021-06-17 18:48:17 +10:00
Mike Teachman
b0b8ebc4f6 extmod/uasyncio: Add readinto() method to Stream class.
With docs and a multi-test using TCP server/client.

This method is a MicroPython extension, although there is discussion of
adding it to CPython: https://bugs.python.org/issue41305

Signed-off-by: Mike Teachman <mike.teachman@gmail.com>
2021-06-15 13:13:35 +10:00
Peter Hinch
c0499bc2b9 docs/library/machine.RTC.rst: Document datetime method and fix ex code.
This is the minimum change to fix the example code so it actually runs on
the majority of ports.
2021-06-12 22:53:49 +10:00
Damien George
71e3538a32 stm32/usb: Add USB_VCP.irq method, to set a callback on USB data RX.
Usage:

    usb = pyb.USB_VCP()
    usb.irq(lambda u:print(u, u.read()), usb.IRQ_RX)

Signed-off-by: Damien George <damien@micropython.org>
2021-06-10 15:26:21 +10:00
Matt Trentini
a6a8941d84 docs/rp2: Add skeleton docs for the rp2 port. 2021-05-30 22:31:34 +10:00
Mike Causer
47b778332a all: Replace busses with buses.
"buses" is the widely accepted plural form of "bus".
2021-05-20 23:22:03 +10:00
Andrew Leech
9d58d46e0a docs/library/pyb.Pin.rst: Update the arguments for Pin.init().
Add details for Pin.init() value and alt arguments.
2021-05-20 23:08:43 +10:00
Brett Cannon
452fa3f8d4 docs/library: Add a blank line to fix formatting for ussl docs. 2021-05-18 12:27:57 +10:00
Brett Cannon
07528d1f85 docs/library: Clarify what type of algorithm is implemented in heapq. 2021-05-18 12:24:21 +10:00
Mike Causer
97fee47716 docs/esp8266: Add SSD1306 to quickref and tutorial. 2021-05-14 12:04:21 +10:00
Mike Causer
d43ed087ae docs/esp8266: Mention Signal in GPIO section of quickref. 2021-05-14 12:02:01 +10:00
Mike Causer
85c51a548f docs/esp32: Mention Signal in GPIO section of quickref. 2021-05-14 11:43:47 +10:00
Mike Causer
30cbcf881d docs/esp32: Add APA106 to quickref. 2021-05-14 11:41:42 +10:00
Damien George
87e38b3cc8 docs/library/rp2.rst: Fix typo overriden->overridden.
Signed-off-by: Damien George <damien@micropython.org>
2021-05-12 00:05:55 +10:00
Tim Radvan
fd24e649fd docs/library: Add initial API reference for rp2 module and its classes.
All the method signatures from rp2_pio.c and friends have been taken and
converted to RST format, then explanatory notes added for each signature.

Signed-off-by: Tim Radvan <tim@tjvr.org>
2021-05-08 18:02:04 +10:00
Mike Causer
64aebed70e docs/esp8266: Add WDT to quickref. 2021-05-06 15:50:42 +10:00
Mike Causer
a111889705 docs/esp32: Add SDCard to quickref. 2021-05-06 15:48:09 +10:00
Mike Causer
a65942a41d docs/esp32: Add WDT to quickref. 2021-05-06 15:46:28 +10:00
Mike Causer
b98197f950 docs/esp32: Add UART to quickref. 2021-05-06 15:44:53 +10:00
Gabriel M Schuyler
0054fff840 docs/pyboard: Fix typo in pyb.Switch tutorial. 2021-05-04 23:05:35 +10:00
Mike Causer
31ac410a4f docs: Fix some spelling mistakes. 2021-05-04 22:58:00 +10:00
Mordy Ovits
d70ab87b2b docs/esp8266: Clarify limitations of SSL in esp8266 and fix typos. 2021-05-04 15:15:34 +10:00
Damien George
2bf1beef5c docs/esp8266: Add instructions on entering programming mode manually.
This adds to the ESP8266 tutorial instructions explaining which pins to
pull low to enter programming mode.

Commit made originally by @ARF1 in #2910.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-04 14:24:40 +10:00
Chris Liechti
4154ffbcba docs/esp8266: Add note about simultaneous use of STA_IF and AP_IF.
See also https://github.com/esp8266/Arduino/issues/1624
2021-05-04 13:48:53 +10:00
Damien George
dd5c831a0b docs/library/machine: Add machine.bootloader docs.
This is provide by a few ports now, and is very useful.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 16:55:55 +10:00
Damien George
9e1b25a99e docs/library/machine: Specify initial machine.PWM class.
This adds an initial specification of the machine.PWM class, to provide a
way to generate PWM output that is portable across the different ports.
Such functionality may already be available in one way or another (eg
through a Timer object), but because configuring PWM via a Timer is very
port-specific, and because it's a common thing to do, it's beneficial to
have a top-level construct for it.

The specification in this commit aims to provide core functionality in a
minimal way.  It also somewhat matches most existing ad-hoc implementations
of machine.PWM.

See discussion in #2283 and #4237.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-30 16:42:51 +10:00
Damien George
3c4bfd1dec py/objexcept: Support errno attribute on OSError exceptions.
This commit adds the errno attribute to exceptions, so code can retrieve
errno codes from an OSError using exc.errno.

The implementation here simply lets `errno` (and the existing `value`)
attributes work on any exception instance (they both alias args[0]).  This
is for efficiency and to keep code size down.  The pros and cons of this
are:

Pros:
- more compatible with CPython, less difference to document and learn
- OSError().errno will correctly return None, whereas the current way of
  doing it via OSError().args[0] will raise an IndexError
- it reduces code size on most bare-metal ports (because they already have
  the errno qstr)
- for Python code that uses exc.errno the generated bytecode is 2 bytes
  smaller and more efficient to execute (compared with exc.args[0]); so
  bytecode loaded to RAM saves 2 bytes RAM for each use of this attribute,
  and bytecode that is frozen saves 2 bytes flash/ROM for each use
- it's easier/shorter to type, and saves 2 bytes of space in .py files that
  use it (for each use)

Cons:
- increases code size by 4-8 bytes on minimal ports that don't already have
  the `errno` qstr
- all exceptions now have .errno and .value attributes (a cpydiff test is
  added to address this)

See also #2407.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-23 22:03:46 +10:00
Damien George
321d1897c3 all: Bump version to 1.15.
Signed-off-by: Damien George <damien@micropython.org>
2021-04-19 00:11:51 +10:00
Damien George
f541b3673d docs/develop: Improve user C modules to properly describe how to build.
Make and CMake builds are slightly different and these changes help make it
clear what to do in each case.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-02 17:07:20 +11:00
Damien George
d87f42b0e5 examples/usercmodules: Simplify user C module enabling.
It's a bit of a pitfall with user C modules that including them in the
build does not automatically enable them.  This commit changes the docs and
examples for user C modules to encourage writers of user C modules to
enable them unconditionally.  This makes things simpler and covers most use
cases.

See discussion in issue #6960, and also #7086.

Signed-off-by: Damien George <damien@micropython.org>
2021-04-01 16:27:38 +11:00
Phil Howard
8e5756e2b6 docs/develop/cmodules.rst: Document C-modules and micropython.cmake.
Documents the micropython.cmake file required to make user C modules
compatible with the CMake build system.

Signed-off-by: Phil Howard <phil@pimoroni.com>
2021-03-31 00:28:21 +11:00
stijn
914380cb89 all: Add .git-blame-ignore-revs for fixing up git blame output.
Add most formatting-only commits to this file so that when used with
git blame, these commits are excluded and the output shows only the
interesting bits.
2021-03-15 11:07:29 +01:00
Damien George
6129b8e401 tests: Rename run-tests to run-tests.py for consistency.
Signed-off-by: Damien George <damien@micropython.org>
2021-03-12 19:56:09 +11:00
Damien George
b24fcd7aec esp32/machine_hw_spi: Use default pins when making SPI if none given.
The default pins can be optionally configured by a board.

Fixes issue #6974.

Signed-off-by: Damien George <damien@micropython.org>
2021-03-12 10:56:25 +11:00
Thorsten von Eicken
c10d431819 esp32: Add basic support for Non-Volatile-Storage in esp32 module.
This commit implements basic NVS support for the esp32.  It follows the
pattern of the esp32.Partition class and exposes an NVS object per NVS
namespace.  The initial support provided is only for signed 32-bit integers
and binary blobs.  It's easy (albeit a bit tedious) to add support for
more types.

See discussions in: #4436, #4707, #6780
2021-02-19 15:05:19 +11:00
Thorsten von Eicken
2c1299b007 extmod/modussl: Fix ussl read/recv/send/write errors when non-blocking.
Also fix related problems with socket on esp32, improve docs for
wrap_socket, and add more tests.
2021-02-17 11:50:54 +11:00
Jim Mussared
cdf9c8648f docs/library/uasyncio.rst: Add docs for ThreadSafeFlag.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2021-02-16 16:35:37 +11:00
Jim Mussared
7ed99544e4 extmod/uasyncio: Add asyncio.current_task().
Matches CPython behavior.

Fixes #6686
2021-02-13 15:11:17 +11:00
Brianna Laugher
d128999938 tools: Add filesystem action examples to pyboard.py help.
Signed-off-by: Brianna Laugher <brianna.laugher@gmail.com>
2021-02-13 14:37:28 +11:00
Damien George
78b23c3a1f all: Bump version to 1.14.
Signed-off-by: Damien George <damien@micropython.org>
2021-02-03 00:59:07 +11:00
Damien George
0e44587076 docs/library/machine.Pin.rst: Make it clear which methods are not core.
Signed-off-by: Damien George <damien@micropython.org>
2021-02-03 00:54:18 +11:00
Damien George
ef9fde7339 LICENSE,docs: Update copyright year range to include 2021.
Signed-off-by: Damien George <damien@micropython.org>
2021-01-31 23:17:42 +11:00
Samuelson
407df82f81 docs/develop/natmod: Fix a small typo, con->can. 2021-01-30 15:20:44 +11:00
Christopher Tse
ddb53c9458 docs/esp8266/quickref: Add warning block about NeoPixel timing. 2021-01-30 14:36:30 +11:00
Andrew Scheller
499e199add docs,stm32: Fix minor typos in RTC docs, and->an. 2021-01-30 14:13:30 +11:00
nanjekyejoannah
4eaebc1988 docs/develop: Add MicroPython Internals chapter.
This commit adds many new sections to the existing "Developing and building
MicroPython" chapter to make it all about the internals of MicroPython.

This work was done as part of Google's Season of Docs 2020.
2021-01-27 16:59:58 +11:00
iabdalkader
20f8ce1982 stm32/pyb_can: Add ability to calculate CAN bit timing from baudrate.
Calculate the bit timing from baudrate if provided, allowing sample point
override.  This makes it a lot easier to make CAN work between different
MCUs with different clocks, prescalers etc.

Tested on F4, F7 and H7 Y/V variants.
2020-12-17 23:01:15 +11:00
Damien George
1719459c28 extmod/modubinascii: Update code, docs for hexlify now CPython has sep.
Since CPython 3.8 the optional "sep" argument to hexlify is officially
supported, so update comments in the code and the docs to reflect this.

Signed-off-by: Damien George <damien@micropython.org>
2020-12-14 14:35:29 +11:00
Jim Mussared
68136eb4ba docs/library/ubluetooth.rst: Add passkey docs.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02 14:44:36 +11:00
Jim Mussared
b799fe1421 docs/library/ubluetooth.rst: Add bonding docs.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02 14:42:46 +11:00
Jim Mussared
fff634e031 docs/library/ubluetooth.rst: Add gap_pair() docs.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02 14:41:36 +11:00
Jim Mussared
f822557cbb docs/library/ubluetooth.rst: Add pairing/bonding config docs.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02 14:41:21 +11:00
Andrew Leech
05fef8c6a4 extmod/modbluetooth: Add _IRQ_ENCRYPTION_UPDATE event.
This allows the application to be notified if any of encrypted,
authenticated and bonded state change, as well as the encryption key size.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02 14:40:15 +11:00
Jim Mussared
5e20f689ad docs/library/ubluetooth.rst: Update read request IRQ docs.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02 14:39:17 +11:00
Jim Mussared
89553997b8 docs/library/ubluetooth.rst: Update char/desc flags.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02 14:37:45 +11:00
Jim Mussared
7a9aa49595 docs/library/ubluetooth.rst: Add _IRQ_CONNECTION_UDPATE docs.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-12-02 14:36:41 +11:00
Damien George
a14ca31e85 docs/reference/repl.rst: Add information about new raw-paste mode.
Signed-off-by: Damien George <damien@micropython.org>
2020-12-01 22:35:13 +11:00
Jim Mussared
3795c71271 docs/library/ubluetooth.rst: Add docs for L2CAP channels.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2020-11-24 01:07:17 +11:00
Damien George
dbb13104ca docs/develop/cmodules.rst: Add link to source code for user C example.
Signed-off-by: Damien George <damien@micropython.org>
2020-10-29 23:10:43 +11:00
stijn
25c4563f26 examples: Add example code for user C modules, both C and C++.
Add working example code to provide a starting point for users with files
that they can just copy, and include the modules in the coverage test to
verify the complete user C module build functionality.  The cexample module
uses the code originally found in cmodules.rst, which has been updated to
reflect this and partially rewritten with more complete information.
2020-10-29 15:30:42 +11:00
stijn
0153148fd2 py/py.mk: Support C++ code for user C modules.
Support C++ code in .cpp files by providing CXX counterparts of the
_USERMOD_ flags we have for C already.  This merely enables the Makefile of
user C modules to use variables specific to C++ compilation, it is still up
to each port's main Makefile to also include these in the build.
2020-10-29 15:29:20 +11:00
stijn
78c8b55067 docs: Fix reference to QSTR_GEN_CFLAGS Makefile flag. 2020-10-29 15:28:18 +11:00
Kevin Thomas
6eebdbc495 docs/reference/glossary.rst: Fix minor grammar error, An -> A. 2020-10-22 15:40:11 +11:00
Howard Lovatt
4842060366 docs/library/machine.Timer.rst: Add mention of constructor arguments. 2020-10-20 17:23:54 +11:00
Howard Lovatt
cf6845b1cf docs/library/machine.Signal.rst: Correct typo: usecases to use cases. 2020-10-20 17:21:30 +11:00
Howard Lovatt
23f9439f44 docs/library/machine.rst: Correct minor typo: timout to timeout. 2020-10-20 17:19:47 +11:00
Howard Lovatt
3bc0ecbcd9 docs/library/btree.rst: Correct method typo: __detitem__ to __delitem__. 2020-10-20 17:13:02 +11:00
Damien George
d4b61b0017 extmod/utime_mphal: Add generic utime.time_ns() function.
It requires mp_hal_time_ns() to be provided by a port.  This function
allows very accurate absolute timestamps.

Enabled on unix, windows, stm32, esp8266 and esp32.

Signed-off-by: Damien George <damien@micropython.org>
2020-10-01 14:20:42 +10:00
Damien George
98182a97c5 docs: Update I2C and SPI docs to add reference to SoftI2C and SoftSPI.
Signed-off-by: Damien George <damien@micropython.org>
2020-10-01 12:57:10 +10:00
David Lechner
ee7568ca8d docs/reference/packages.rst: Fix typo, remove duplicate "port".
Fixes #6485.
2020-09-30 23:32:24 +10:00
Damien George
c8ade2bd7f docs/develop: Add notes on prerequisite tools for building native .mpy.
Signed-off-by: Damien George <damien@micropython.org>
2020-09-25 12:25:29 +10:00
Damien George
81f2162ca0 extmod/modbluetooth: Change module-owned bytes objects to memoryview.
A read-only memoryview object is a better representation of the data, which
is owned by the ubluetooth module and may change between calls to the
user's irq callback function.

Signed-off-by: Damien George <damien@micropython.org>
2020-09-25 12:23:11 +10:00
Damien George
bd7af6151d ports: Add utime.gmtime() function.
To portably get the Epoch.  This is simply aliased to localtime() on ports
that are not timezone aware.

Signed-off-by: Damien George <damien@micropython.org>
2020-09-18 16:25:36 +10:00
Jim Mussared
f271b96b5c docs/library/ubluetooth.rst: Add docs for MTU API. 2020-09-18 12:51:21 +10:00
Jim Mussared
c200759290 docs/library/ubluetooth.rst: Clarify peripheral/central vs server/client
Previously this documentation assumed peripheral=server and central=client,
but this is not accurate or true to the implementation.
2020-09-15 15:42:59 +10:00
Jim Mussared
19faf55090 docs/library/ubluetooth.rst: Clarify position/kw arguments.
Almost all ubluetooth functions are positional-only, but some have optional
args.  Make this clearer and show what the defaults are.
2020-09-15 15:28:59 +10:00
Jim Mussared
67d8139e2b docs/library/ubluetooth.rst: Document BLE address modes. 2020-09-08 12:53:24 +10:00
stijn
40ad8f1666 all: Rename "sys" module to "usys".
This is consistent with the other 'micro' modules and allows implementing
additional features in Python via e.g. micropython-lib's sys.

Note this is a breaking change (not backwards compatible) for ports which
do not enable weak links, as "import sys" must now be replaced with
"import usys".
2020-09-04 00:10:24 +10:00
Damien George
b0932fcf2e all: Bump version to 1.13.
Signed-off-by: Damien George <damien@micropython.org>
2020-09-02 12:01:26 +10:00
Damien George
338b12d3c8 LICENSE,docs: Update copyright year range to include 2020.
Signed-off-by: Damien George <damien@micropython.org>
2020-08-29 13:58:20 +10:00
Andrew Leech
a80a146858 extmod/bluetooth: Support active scanning in BLE.gap_scan().
This adds an additional optional parameter to gap_scan() to select active
scanning, where scan responses are returned as well as normal scan results.
This parameter is False by default which retains the existing behaviour.
2020-08-26 15:00:11 +10:00
Damien George
2acc087880 extmod/vfs_lfs: Add mtime support to littlefs files.
This commit adds support for modification time of files on littlefs v2
filesystems, using file attributes.  For some background see issue #6114.

Features/properties of this implementation:
- Only supported on littlefs2 (not littlefs1).
- Uses littlefs2's general file attributes to store the timestamp.
- The timestamp is 64-bits and stores nanoseconds since 1970/1/1 (if the
  range to the year 2554 is not enough then additional bits can be added to
  this timestamp by adding another file attribute).
- mtime is enabled by default but can be disabled in the constructor, eg:
  uos.mount(uos.VfsLfs2(bdev, mtime=False), '/flash')
- It's fully backwards compatible, existing littlefs2 filesystems will work
  without reformatting and timestamps will be added transparently to
  existing files (once they are opened for writing).
- Files without timestamps will open correctly, and stat will just return 0
  for their timestamp.
- mtime can be disabled or enabled each mount time and timestamps will only
  be updated if mtime is enabled (otherwise they will be untouched).

Signed-off-by: Damien George <damien@micropython.org>
2020-08-25 17:35:19 +10:00
Zenix27
e76c7466b6 docs: Change \* to * in argument lists.
Latest versions of Sphinx (at least 3.1.0) do not need the `*` escaped and
will render the `\` in the output if it is there, so remove it.

Fixes issue #6209.
2020-08-21 12:24:13 +10:00
Josh Lloyd
fe7d47971f docs/esp32: Fix machine.Timer quickref to specify HW timers.
Also remove trailing spaces on other lines.
2020-07-25 00:50:06 +10:00
Howard Lovatt
47289f4bc9 docs/library: Update pyb.UART to correct pyboard UART availability.
On original pyboard UART 5 isn't available; added pyboard D availability.
2020-07-25 00:46:29 +10:00
Howard Lovatt
4a7c2731c5 docs/library: Update pyb.Timer to add missing args and defaults to init. 2020-07-25 00:34:48 +10:00
Howard Lovatt
cf9be201d7 docs/library: Update pyb.SPI init method to add descr about "ti" arg. 2020-07-25 00:28:16 +10:00
Jonathan Hogg
5f0e9d1bac docs/library: Update documentation of esp32's RMT.
This explains how looping now works, and removes the warning about calling
wait_done().
2020-07-21 00:57:35 +10:00
Jim Mussared
c7f7c0214c docs/library: For ubluetooth, add docs for _IRQ_GATTS_INDICATE_DONE. 2020-07-20 23:28:31 +10:00
Jim Mussared
b7698841b2 docs/library: Add gatts_indicate() doc to ubluetooth.rst.
Also clarify behavior of `gatts_notify` and add some TODOs about adding an
event for indication acknowledgement.
2020-07-18 14:34:44 +10:00
spacemanspiff2007
b572aa5721 docs/esp32: Add info about PWM duty cycle range to esp32 quickref.
See related #4581.
2020-06-30 22:28:09 +10:00
victor
cb9aafbf8f docs/library: Clarify that the arg to esp.deepsleep is in microseconds. 2020-06-30 22:01:44 +10:00
Jon Rob
1678f41744 esp32/esp32_rmt: Extend RMT to support carrier feature.
The ESP32 RMT peripheral has hardware support for a carrier frequency, and
this commit exposes it to Python with the keyword arguments carrier_freq
and carrier_duty_percent in the constructor.  Example usage:

    r = esp32.RMT(0, pin=Pin(2), clock_div=80, carrier_freq=38000, carrier_duty_percent=50)
2020-06-17 00:03:33 +10:00
Nick Crabtree
2934e41df0 docs/esp8266: Add quickref documentation for UART on esp8266.
This patch adds quickref documentation for the change in commit
afd0701bf7.  This commit added the ability to
disable the REPL and hence use UART0 for serial communication on the
esp8266, but was not previously documented anywhere.

The text is largely taken from the commit message, with generic information
on using the UART duplicated from the Wipy quickref document.
2020-06-10 22:46:09 +10:00
Damien George
a4c96fb3b0 extmod/uasyncio: Add asyncio.wait_for_ms function.
Fixes issue #6107.
2020-06-10 22:29:44 +10:00
David Lechner
1e6d18c915 docs: Fix Sphinx 3.x warnings, and enable warnings-as-errors on build.
This enables warnings as errors and fixes all current errors, namely:

- reference to terms in the glossary must now be explicit (:term:)
- method overloads must not be declared as a separate method or must
  use :noindex:
- 2 cases where `` should have been used instead of `
2020-06-05 21:42:17 +10:00
Jim Mussared
1cad63c0bc extmod/modbluetooth: Ensure status=0 always on success.
This commit makes sure that all discovery complete and read/write status
events set the status to zero on success.

The status value will be implementation-dependent on non-success cases.
2020-06-05 14:11:04 +10:00
Jim Mussared
9708fe8788 docs/library: Update ubluetooth for new events and discover by uuid. 2020-06-05 14:10:13 +10:00
Andrew Leech
e54626f4c1 docs/reference: Add note about multiple exceptions when heap is locked. 2020-06-02 15:56:34 +10:00
cccc
1662a0b06f esp32/machine_sdcard: Add "freq" keyword arg to SDCard constructor.
To allow high speed access.
2020-05-28 12:19:04 +10:00
Damien George
cae77daf00 docs/develop: Fix module/source name in Makefile of native example. 2020-05-16 15:00:46 +10:00
Damien George
3b6c9119eb extmod/modbluetooth: Add support for changing the GAP device name.
This commit allows the user to set/get the GAP device name used by service
0x1800, characteristic 0x2a00.  The usage is:

    BLE.config(gap_name="myname")
    print(BLE.config("gap_name"))

As part of this change the compile-time setting
MICROPY_PY_BLUETOOTH_DEFAULT_NAME is renamed to
MICROPY_PY_BLUETOOTH_DEFAULT_GAP_NAME to emphasise its link to GAP and this
new "gap_name" config value.  And the default value of this for the NimBLE
bindings is changed from "PYBD" to "MPY NIMBLE" to be more generic.
2020-05-11 21:30:41 +10:00
Thorsten von Eicken
952ff8a8ea esp32: Improve support for OTA updates.
This commit adds several small items to improve the support for OTA
updates on an esp32:

- a partition table for 4MB flash modules that has two OTA partitions ready
  to go to do updates
- a GENERIC_OTA board that uses that partition table and that enables
  automatic roll-back in the bootloader
- a new esp32.Partition.mark_app_valid_cancel_rollback() class-method to
  signal that the boot is successful and should not be rolled back at the
  next reset
- an automated test for doing an OTA update
- documentation updates
2020-05-03 15:00:45 +10:00
Thorsten von Eicken
7d97d241e8 docs/library: Fix docs for machine.WDT to specify millisecond timeout. 2020-05-02 22:55:48 +10:00
Damien George
391927c126 docs/library: Note that machine.Pin.irq's hard arg may not be supported. 2020-04-30 23:50:53 +10:00
Jim Mussared
7563d58210 unix: Add support for modbluetooth and BLE using btstack.
This commit adds full support to the unix port for Bluetooth using the
common extmod/modbluetooth Python bindings.  This uses the libusb HCI
transport, which supports many common USB BT adaptors.
2020-04-29 16:45:46 +10:00
Thorsten von Eicken
a177831c46 esp32/modesp32: Add idf_heap_info(capabilities) to esp32 module.
This commit adds an idf_heap_info(capabilities) method to the esp32 module
which returns info about the ESP-IDF heaps.  It's useful to get a bit of a
picture of what's going on when code fails because ESP-IDF can't allocate
memory anymore.  Includes documentation and a test.
2020-04-23 00:02:11 +10:00
Thomas Friebel
1b1ceb67b2 docs/library: Document that char_data/notify_data are also references. 2020-04-19 00:18:14 +10:00
Damien George
db137e70dc extmod/uasyncio: Add Loop.new_event_loop method.
This commit adds Loop.new_event_loop() which is used to reset the singleton
event loop.  This functionality is put here instead of in Loop.close() to
make it possible to write code that is compatible with CPython.
2020-04-13 22:16:52 +10:00
Peter Hinch
7409467361 docs/library: Note that uasyncio.wait_for() can raise exception. 2020-04-09 22:11:13 +10:00
Damien George
e0905e85a7 esp8266: Change from FAT to littlefs v2 as default filesystem.
This commit changes the esp8266 boards to use littlefs v2 as the
filesystem, rather than FAT.  Since the esp8266 doesn't expose the
filesystem to the PC over USB there's no strong reason to keep it as FAT.
Littlefs is smaller in code size, is more efficient in use of flash to
store data, is resilient over power failure, and using it saves about 4k of
heap RAM, which can now be used for other things.

This is a backwards incompatible change because all existing esp8266 boards
will need to update their filesystem after installing new firmware (eg
backup old files, install firmware, restore files to new filesystem).

As part of this commit the memory layout of the default board (GENERIC) has
changed.  It now allocates all 1M of memory-mapped flash to the firmware,
so the filesystem area starts at the 2M point.  This is done to allow more
frozen bytecode to be stored in the 1M of memory-mapped flash.  This
requires an esp8266 module with 2M or more of flash to work, so a new board
called GENERIC_1M is added which has the old memory-mapping (but still
changed to use littlefs for the filesystem).

In summary there are now 3 esp8266 board definitions:
- GENERIC_512K: for 512k modules, doesn't have a filesystem.
- GENERIC_1M: for 1M modules, 572k for firmware+frozen code, 396k for
  filesystem (littlefs).
- GENERIC: for 2M (or greater) modules, 968k for firmware+frozen code,
  1M+ for filesystem (littlefs), FAT driver also included in firmware for
  use on, eg, external SD cards.
2020-04-04 16:30:36 +11:00
Damien George
df156b18e5 docs,tests: Add docs and test for uasyncio custom exc handler methods. 2020-04-04 10:47:48 +11:00
Damien George
f97b5395ed extmod/uasyncio: Add StreamReader/StreamWriter as aliases of Stream cls.
To be compatible with CPython.  Fixes issue #5847.
2020-04-02 00:51:00 +11:00
Damien George
b389bc0afa extmod/uasyncio: Implement Loop.stop() to stop the event loop. 2020-04-02 00:14:18 +11:00
Lars Kellogg-Stedman
3a0f64fc7a tools/pyboard.py: Add -d as an alias for --device. 2020-03-30 11:37:32 +11:00
Lars Kellogg-Stedman
1cf994c48b tools/pyboard.py: Support setting device/baudrate from shell env vars.
Allow defaults for --device and --baudrate to be set in the environment
using PYBOARD_DEVICE and PYBOARD_BAUDRATE.
2020-03-30 11:37:32 +11:00
Damien George
c99322f8d8 docs/library: Add initial docs for uasyncio module. 2020-03-26 01:25:45 +11:00
Andrew Leech
86bfabec11 py/modmicropython: Add heap_locked function to test state of heap.
This commit adds micropython.heap_locked() which returns the current
lock-depth of the heap, and can be used by Python code to check if the heap
is locked or not.  This new function is configured via
MICROPY_PY_MICROPYTHON_HEAP_LOCKED and is disabled by default.

This commit also changes the return value of micropython.heap_unlock() so
it returns the current lock-depth as well.
2020-03-11 16:54:16 +11:00
Damien George
dd0bc26e65 extmod/modbluetooth: Change scan result's "connectable" to "adv_type".
This commit changes the BLE _IRQ_SCAN_RESULT data from:

    addr_type, addr, connectable, rssi, adv_data

to:

    addr_type, addr, adv_type, rssi, adv_data

This allows _IRQ_SCAN_RESULT to handle all scan result types (not just
connectable and non-connectable passive scans), and to distinguish between
them using adv_type which is an integer taking values 0x00-0x04 per the BT
specification.

This is a breaking change to the API, albeit a very minor one: the existing
connectable value was a boolean and True now becomes 0x00, False becomes
0x02.

Documentation is updated and a test added.

Fixes #5738.
2020-03-11 14:00:44 +11:00
Thomas Friebel
f4726735cf extmod/modbluetooth: Implement config getter for BLE rxbuf size.
Knowing the buffer size can be important, to ensure that valid data will be
received.
2020-02-18 13:37:50 +11:00
Thorsten von Eicken
be92aacba3 docs/develop: Detail how to add symbols to mp_fun_table for native mods. 2020-02-16 00:04:25 +11:00
stijn
5f91933e54 windows: Improve default search path.
The default value for MICROPYPATH used in unix/main.c is
"~/.micropython/lib:/usr/lib/micropython" which has 2 problems when used in
the Windows port:
- it has a ':' as path separator but the port uses ';' so the entire string
  is effectively discarded since it gets interpreted as a single path which
  doesn't exist
- /usr/lib/micropython is not a valid path in a standard Windows
  environment

Override the value with a suitable default.
2020-02-11 13:34:35 +11:00
Peter Hinch
88cbfd791a docs/library: Fix framebuf monochrome 1-bit modes, swapping HLSB/HMSB.
This fix can be demonstrated by the following:

    b = bytearray(32)
    f = framebuf.FrameBuffer(b, 32, 8, framebuf.MONO_HLSB)
    f.pixel(0, 0, 1)
    print('MONO_HLSB', hex(b[0]))

    b = bytearray(32)
    f = framebuf.FrameBuffer(b, 32, 8, framebuf.MONO_HMSB)
    f.pixel(0, 0, 1)
    print('MONO_HMSB', hex(b[0]))

Outcome:

    MONO_HLSB 0x80
    MONO_HMSB 0x1
2020-02-10 23:04:15 +11:00
David Lechner
83439e38fc unix/main: Add command-line -h option for printing help text.
This adds a -h option to print the usage help text and adds a new, shorter
error message that is printed when invalid arguments are given.  This
behaviour follows CPython (and other tools) more closely.
2020-02-04 17:54:31 +11:00
David Lechner
c8d2f7838f docs/unix: Add a new new quickref page for the UNIX port.
This adds a new quickstart page for the UNIX port that documents the
command line options and environment variables.
2020-02-04 17:53:06 +11:00
Jesse Andrews
c4ea4c1810 docs/esp8266: In TCP tutorial, add HTTP response code and content-type.
Show how to send an HTTP response code and content-type.  Without the
response code Safari/iOS will fail.  Without the content-type Lynx/Links
will fail.
2020-02-03 23:50:09 +11:00
adzierzanowski
a55c17dc69 esp32/modnetwork: Add max_clients kw-arg to WLAN.config for AP setting.
This allows the user to configure the maximum number of clients that are
connected to the access point.  Resolves #5125.
2020-01-22 16:43:25 +11:00
Peter Hinch
59746ac14a docs/library/uos.rst: Improve block devices section, and ioctl ret vals. 2020-01-22 16:37:31 +11:00
Jason Neal
7ef2f65114 docs/library: Add / to indicate positional-only args in library docs.
Removes the confusion of positional-only arguments which have defaults that
look like keyword arguments.
2020-01-12 13:44:59 +11:00
Thorsten von Eicken
1caede927a docs/library/machine: Document machine.soft_reset() function. 2020-01-12 13:38:27 +11:00
Thorsten von Eicken
bc5c993adf docs/README: Add short paragraph about using readthedocs.
This adds a short paragraph on how to hook readthedocs.org up.  The main
goal is to make people aware of the option, to help with contributing to
the documentation.
2020-01-12 11:45:55 +11:00
Jason Neal
5ef3b6b2d9 docs/library/machine.UART.rst: Detail timeout behaviour of read methods.
Also document existence of "invert" argument to constructor.
2020-01-06 22:50:58 +11:00
Jason Neal
99ed431d28 docs/library/machine.I2C.rst: Use positional-only arguments syntax.
Addresses issue #5196.
2020-01-06 22:25:35 +11:00
Jason Neal
aec88ddf03 docs: More consistent capitalization and use of articles in headings.
See issue #3188.
2020-01-06 22:17:29 +11:00
Damien George
1f37194730 all: Bump version to 1.12. 2019-12-20 16:58:17 +11:00
Matt Trentini
7f235cbee9 docs/esp32: Add quickref and full docs for esp32.RMT class. 2019-12-20 12:25:38 +11:00
Damien George
8449e41818 docs/develop: Add documentation on how to build native .mpy modules. 2019-12-19 17:07:53 +11:00
Damien George
e58c7ce3d6 docs/reference: Add documentation describing use of .mpy files.
Including information about .mpy versioning and how to debug failed imports
of .mpy files.
2019-12-19 17:06:27 +11:00
ketograph
04e7aa0563 docs/esp8266/quickref: Add note that machine.RTC is not fully supported.
See issues #3220 and #3710.
2019-12-17 12:19:27 +11:00
Jim Mussared
f3f7eb48da docs/library/uos.rst: Clarify why the extended interface exists. 2019-12-16 12:45:15 +11:00
Damien George
b310930dba docs/library/uos: Add notes and links about littlefs failures. 2019-12-10 16:58:53 +11:00
Damien George
159388f850 docs/library/ubluetooth: Add note about API being under development. 2019-12-10 16:58:27 +11:00
Damien George
381be9a745 docs/reference/filesystem: Add note and example about using filesystem. 2019-12-09 14:21:22 +11:00
Daniel Mizyrycki
50dc5f10a6 docs/reference/filesystem: Fix typo in block device code example. 2019-12-09 14:13:09 +11:00
Damien George
84958a8fe1 extmod/modbluetooth: Allow setting ringbuf size via BLE.config(rxbuf=).
The size of the event ringbuf was previously fixed to compile-time config
value, but it's necessary to sometimes increase this for applications that
have large characteristic buffers to read, or many events at once.

With this commit the size can be set via BLE.config(rxbuf=512), for
example.  This also resizes the internal event data buffer which sets the
maximum size of incoming data passed to the event handler.
2019-12-05 11:30:35 +11:00
Damien George
7aeafe2ae9 extmod/modbluetooth: Add optional 4th arg to gattc_write for write mode.
This allows the user to explicitly select the behaviour of the write to the
remote peripheral.  This is needed for peripherals that have
characteristics with WRITE_NO_RESPONSE set (instead of normal WRITE).  The
function's signature is now:

    BLE.gattc_write(conn_handle, value_handle, data, mode=0)

mode=0 means write without response, while mode=1 means write with
response.  The latter was the original behaviour so this commit is a change
in behaviour of this method, and one should specify 1 as the 4th argument
to get back the old behaviour.

In the future there could be more modes supported, such as long writes.
2019-12-04 23:23:07 +11:00
Jim Mussared
9a849cc7ca docs: Add littlefs docs and a filesystem tutorial. 2019-12-04 23:18:23 +11:00
Jim Mussared
f2650be844 docs/library: Add docs for pyb.Flash class. 2019-12-04 23:18:17 +11:00
Jim Mussared
d7dbd267e7 docs/reference: Add docs describing use of pyboard.py. 2019-12-04 23:18:03 +11:00
Damien George
90c524c114 docs: Remove spaces on lines that are empty. 2019-12-04 15:02:54 +11:00
Jim Mussared
e873d352ad extmod/modbluetooth: Simplify management of pre-allocated event data.
The address, adv payload and uuid fields of the event are pre-allocated by
modbluetooth, and reused in the IRQ handler.  Simplify this and move all
storage into the `mp_obj_bluetooth_ble_t` instance.

This now allows users to hold on to a reference to these instances without
crashes, although they may be overwritten by future events.  If they want
to hold onto the values longer term they need to copy them.
2019-11-25 17:32:10 +11:00
Damien George
d667bc642f docs/library/ubluetooth: Fix name and link to FLAG_xxx constants. 2019-11-12 15:15:12 +11:00
Jim Mussared
d30b75e8f2 docs/library/machine.SDCard.rst: Fix various typos. 2019-11-07 14:47:11 +11:00
Jim Mussared
59850c0b83 docs/templates/topindex.html: Replace usage of deprecated defindex.html.
defindex.html (used by topindex.html) is deprecated, but topindex.html was
already identical other than setting the title, so just inherit directly
from layout.html.
2019-11-07 14:45:55 +11:00
Jim Mussared
1295146a6f docs/conf.py: Fix path to favicon.ico. 2019-11-07 14:45:34 +11:00
Jim Mussared
ca3d4c84e4 docs/library/ubluetooth: Add docs for gatts_set_buffer. 2019-10-29 23:11:11 +11:00
Damien George
7a24b7f091 docs/library: Add documentation for extended block device protocol. 2019-10-29 14:17:29 +11:00
Mike Wadsten
f69ef97f24 docs: Move ubluetooth under "MicroPython-specific libraries".
CPython does not have a bluetooth module,
so it is not appropriate to call ubluetooth
a Python standard library or micro-library.
2019-10-23 11:43:01 -05:00
Jim Mussared
19e87742c4 docs/library/bluetooth: Rename to "ubluetooth". 2019-10-22 21:58:05 +11:00
Damien George
a2eea57b1d docs/library: Rename "array" module to "uarray". 2019-10-22 16:40:58 +11:00
Volodymyr Shymanskyy
615d6b3c66 docs/wipy/tutorial: Link Blynk examples to the official library. 2019-10-16 14:20:31 +11:00
Mike Causer
a2c4cb484d docs: Fix spelling in various parts of the docs. 2019-10-16 14:08:28 +11:00
Mike Causer
5a8f392f09 docs/esp8266: Add ntptime usage to esp8266 quickref. 2019-10-16 14:08:13 +11:00
Peter Hinch
c0b3419261 docs/library: Clarify relation between machine and port-specific mods. 2019-10-16 14:03:44 +11:00
Thiago Paes
5463ab6df6 docs/esp8266/tutorial: Make http_get sample function self contained. 2019-10-16 13:52:04 +11:00
Damien George
d1ed73ca8f docs/library/bluetooth.rst: Fix typo in HR/UART services example. 2019-10-16 11:23:54 +11:00
Jim Mussared
36502bdfdc extmod/modbluetooth: Make gap_disconnect not raise when disconnected.
Previously it raised OSError(MP_ENOTCONN) if the conn_handle was already
disconnected.  Now it returns True/False.
2019-10-15 17:22:53 +11:00
Jim Mussared
ea315d7d58 docs/library/bluetooth.rst: Explain how to increase char buffer size. 2019-10-15 17:22:45 +11:00
Jim Mussared
62e3a966fb docs/library/bluetooth.rst: Clarify gap_advertise adv_data behavior.
Make it clear that the previous adv_data will be reused if it's not set.
And some minor other improvements.
2019-10-15 17:21:32 +11:00
Jim Mussared
a93495b66d docs/reference/glossary.rst: Add new terms and reduce complexity of old. 2019-10-15 16:36:02 +11:00
Jim Mussared
dc82bee298 docs/library/bluetooth: Add initial BLE documentation. 2019-10-11 14:03:01 +11:00