Commit Graph

890 Commits

Author SHA1 Message Date
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
Jim Mussared 4ddd46e6cf docs/develop/qstr.rst: Add documentation for string interning. 2019-10-04 17:13:13 +10:00
Damien George 78e0e76b4f docs/library/pyb.USB_VCP.rst: Add info about id and flow params. 2019-09-26 14:00:21 +10:00
Damien George cb84e22ac6 docs/library/pyb.rst: Update pyb.usb_mode() to mention VCP+MSC+HID. 2019-09-11 15:17:38 +10:00
Damien George 50636e5296 docs/library/pyb.rst: Update docs for pyb.usb_mode() function. 2019-09-10 13:22:35 +10:00
Damien George e509da22df docs/library: Specify new machine.ADC class.
This initial specification is only for the ADC constructor and read_u16()
method.
2019-09-04 15:35:09 +10:00
Damien George 8a237237a3 docs: Rename machine.ADC docs to machine.ADCWiPy.
To signify that this ADC documentation is specific to the WiPy, and to make
way for a standardised ADC documentation.
2019-09-04 15:05:03 +10:00
Jim Mussared 74fe841449 docs/library/pyb.DAC.rst: Correct frequency for triangle mode output.
Also correct comments in related code.
2019-09-03 23:25:45 +10:00
Paul m. p. P afc8596c15 docs/reference/speed_python: Add missing self to var caching example. 2019-08-28 12:55:41 +10:00
Damien George 05eb897d06 esp32: Add esp32.Partition class to expose partition and OTA funcs.
Partitions are exposed as a standard MicroPython block device.
2019-08-20 16:49:18 +10:00
Peter Hinch 3a679eaf00 docs/reference/speed_python: Update that read-only buffers are accepted.
As allowed by recent cd35dd9d9a
2019-08-19 16:39:30 +10:00
Vicki Lowe afd10a4531 docs/pyboard: Emphasize the instructions for making a USB mouse.
It wasn't clear why that element was `10` instead of `0`.  Also bumped the
`10` to `100` to make the mouse movement more obvious.
2019-08-15 18:21:10 +10:00
Tom McDermott d5a7741606 docs/library: Document that sys.version_info returns a 3-tuple only.
See issue #4970.
2019-08-15 18:12:22 +10:00
Vicki Lowe 6592a30f4b docs/pyboard: Clarify initial files on pyboard and fix up formatting. 2019-08-15 18:01:28 +10:00
Vicki Lowe 57476a3c37 docs/pyboard: Update name of mounted volume to match code. 2019-08-15 17:50:06 +10:00
Damien George ed9c0185d8 docs/library/sys: Add documentation for sys.atexit function. 2019-08-15 17:42:38 +10:00