Commit Graph

9948 Commits

Author SHA1 Message Date
Damien George 81a06d2c9c lib/libm: Remove implementation of log2f, use MP_NEED_LOG2 instead. 2017-10-10 16:01:13 +11:00
Damien George d8d4e4dfbe py/modmath: Convert log2 macro into a function.
So that a pointer to it can be passed as a pointer to math_generic_1.  This
patch also makes the function work for single and double precision floating
point.
2017-10-10 16:01:04 +11:00
Damien George 25e140652b py/modmath: Add full checks for math domain errors.
This patch changes how most of the plain math functions are implemented:
there are now two generic math wrapper functions that take a pointer to a
math function (like sin, cos) and perform the necessary conversion to and
from MicroPython types.  This helps to reduce code size.  The generic
functions can also check for math domain errors in a generic way, by
testing if the result is NaN or infinity combined with finite inputs.

The result is that, with this patch, all math functions now have full
domain error checking (even gamma and lgamma) and code size has decreased
for most ports.  Code size changes in bytes for those with the math module
are:

   unix x64:  -432
unix nanbox:  -792
      stm32:   -88
    esp8266:   +12

Tests are also added to check domain errors are handled correctly.
2017-10-10 15:57:45 +11:00
Mike Causer f599a38059 docs/esp8266/quickref: Add quickref info for RTC class. 2017-10-10 15:22:23 +11:00
Mike Causer dc92f1c4ee docs/pyboard/tutorial: Update now that yellow LED also supports PWM. 2017-10-10 15:22:11 +11:00
Mike Causer d236d0c415 docs/pyboard/quickref: Add info for Switch, RTC, CAN, Accel classes. 2017-10-10 15:22:11 +11:00
Damien George 933eab46fc py/bc: Update opcode_format_table to match the bytecode. 2017-10-10 10:37:38 +11:00
Damien George add933feaf docs/library/network: Clarify usage of "bssid" arg in connect() method. 2017-10-09 23:11:25 +11:00
Damien George 6db132e130 esp8266/modnetwork: Add "bssid" keyword arg to WLAN.connect() method. 2017-10-09 23:09:06 +11:00
Ayke van Laethem d18bf876e3 ports/nrf: Add WT51822-S4AT board. 2017-10-08 23:23:11 +02:00
Paul Sokolovsky 53966fd9a8 examples: hwconfig_console: Add .on()/.off() methods.
Add these methods to this "GPIO output emulated with console prints"
config.
2017-10-09 00:22:30 +03:00
Dan Halbert ef65ee78c5 Freeze libraries needed by adafruit_circuitplayground library into firmware.
This saves a lot of RAM. Fixes #287.
Also fixed compilation of frozen_mpy.c to use supplied make rule rather than
builtin rule (supplied rule suppresses printing out the gcc command line).
2017-10-08 10:54:46 -06:00
Alex Vasylenko 9a9584aee0 Update pwm.rst
replace reference to non-existent `time.sleep_ms()`
2017-10-08 10:53:25 -06:00
Paul Sokolovsky c15be989ee tools/pyboard: Update docstring for additional device support. 2017-10-08 00:04:57 +03:00
Paul Sokolovsky 4514f073c1 zephyr: Switch to interrupt-driven pull-style console.
While this console API improves handling on real hardware boards
(e.g. clipboard paste is much more reliable, as well as programmatic
communication), it vice-versa poses problems under QEMU, apparently
because it doesn't emulate UART interrupt handling faithfully. That
leads to inability to run the testsuite on QEMU at all. To work that
around, we have to suuport both old and new console routines, and use
the old ones under QEMU.
2017-10-07 17:36:16 +03:00
Paul Sokolovsky 71c1a05d88 tests/run-tests: Close device under test using "finally".
We want to close communication object even if there were exceptions
somewhere in the code. This is important for --device exec:/execpty:
which may otherwise leave processing running in the background.
2017-10-07 15:49:58 +03:00
Paul Sokolovsky 58ea239510 zephyr: Use CONFIG_NET_APP_SETTINGS to setup initial network addresses.
Ideally, these should be configurable from Python (using network module),
but as that doesn't exist, we better off using Zephyr's native bootstrap
configuration facility.
2017-10-07 14:08:50 +03:00
Damien George 6f1a615427 stm32/boards: Fix typos in stm32f767_af.csv table. 2017-10-06 14:32:42 +11:00
Damien George ca2427c313 drivers/display/ssd1306: Make poweron() work the same with SSD1306_SPI.
The poweroff() and poweron() methods are used to do soft power control of
the display, and this patch makes these methods work the same for both I2C
and SPI interfaces.
2017-10-06 12:48:44 +11:00
Tiago Queiroz 7df4083ac6 drivers/display/ssd1306: Implement SSD1306_I2C poweron method.
After a poweroff(), the poweron() method does a soft power-on and any
previous state of the display persists.
2017-10-06 12:47:22 +11:00
Paul Sokolovsky ea6692a83e tools/pyboard: Use repr() when quoting data in error messages.
As it may contain newlines, etc.
2017-10-05 23:40:19 +03:00
Damien George 98dd126e98 tests/extmod: Add test for '-' in character class in regex. 2017-10-05 11:33:49 +11:00
Li Weiwei 8c7db42ee3 stm32/modnwwiznet5k: Get the IP address of an established socket.
When wiznet5k_socket_accept is called, if a socket is established, get the
IP address of the socket.
2017-10-05 11:09:07 +11:00
Damien George ff93fd4f50 py/persistentcode: Bump .mpy version number to version 3.
The binary and unary ops have changed bytecode encoding.
2017-10-05 10:49:44 +11:00
Damien George 36f7952f76 py/objtype: Clean up unary- and binary-op enum-to-qstr mapping tables. 2017-10-05 10:49:44 +11:00
Damien George 0864a6957f py: Clean up unary and binary enum list to keep groups together.
2 non-bytecode binary ops (NOT_IN and IN_NOT) are moved out of the
bytecode group, so this change will change the bytecode format.
2017-10-05 10:49:44 +11:00
Glenn Ruben Bakke a414199793 ports/nrf: Update Makefile and README.md after moving port to new directory 2017-10-04 21:54:01 +02:00
Glenn Ruben Bakke 831759faaa ports/nrf: Align help.c builtin help text to use correct type after upmerge with upstream master. 2017-10-04 21:52:08 +02:00
Glenn Ruben Bakke 44e2cb415f ports/nrf: Moving nrf51/52 port to new ports directory 2017-10-04 21:46:48 +02:00
Glenn Ruben Bakke bcab2ba0a8 ports/nrf: Upmerging port with upstream master 2017-10-04 21:45:04 +02:00
Glenn Ruben Bakke 4468731e3d nrf: Aligning with upstream the use of nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, ...) 2017-10-04 20:49:49 +02:00
glennrub 795116b432 nrf/modules/random: Backport of microbit random number generator module
Backport of micro:bit random module.
Plugged into the port as a general random module for all nrf51/nrf52 targets. Works both with and without Bluetooth LE stack enabled.

Behavioral change: seed() method has been removed, as the use of RNG peripheral generates true random sequences and not pseudo-random sequences.
2017-10-04 20:49:03 +02:00
glennrub f49b202e7d nrf/hal/rng: Adding HAL driver for accessing RNG peripheral
The driver also takes care of calling the Bluetooth LE stack for random values if the stack is enabled. The reason for this is that the Bluetooth LE stack take ownership of the NRF_RNG when enabled. Tolerate to enable/disable on the fly, and will choose to use direct access to the peripheral if Bluetooth LE stack is disabled or not compiled in at all.

Driver has been included in the top Makefile, and will not be compiled in unless nrf51_hal_conf.h/nrf52_hal_conf.h defines HAL_RNG_MODULE_ENABLED (1).
2017-10-04 20:45:40 +02:00
glennrub 8c0bbb983b nrf/boards: Adding Arduino Primo board support (#88)
* nrf: Adding Arduino Primo board support

* nrf: Adding arduino_primo to target boards table in readme.md

* nrf/boards: Activating pyb.LED module for arduino_primo board.

* nrf/boards: Removing define not needed for arduino_primo

Updating arduino_primo board mpconfigboard.h. Removing a define
that was wrongly named. Instead of renaming it, it was removed as
it was never used.
2017-10-04 20:44:11 +02:00
Glenn Ruben Bakke 863a5c1734 nrf: Add support for floating point on nrf52 targets.
Duplicating pattern for detecting location of libm, libc and libgcc
from teensy port. Activating MICROPY_FLOAT_IMPL (FLOAT) for nrf52 targets
and adding libs into the compile. For nrf51 targets it is still set to
NONE as code grows to much (about 30k).

Some numbers on flash use if MICROPY_FLOAT_IMPL is set to
MICROPY_FLOAT_IMPL_FLOAT and math libraries are enabled (lgcc, lc, lm).

nrf51:
======

without float support:
   text	   data	    bss	    dec	    hex	filename
 144088	    260	  30020	 174368	  2a920	build-pca10028/firmware.elf

with float support:
   text	   data	    bss	    dec	    hex	filename
 176228	   1336	  30020	 207584	  32ae0	build-pca10028/firmware.elf

nrf52:
======

without float support:
   text	   data	    bss	    dec	    hex	filename
 142040	    356	  36236	 178632	  2b9c8	build-pca10040/firmware.elf

with float support:
   text	   data	    bss	    dec	    hex	filename
 165068	   1436	  36236	 202740	  317f4	build-pca10040/firmware.elf
2017-10-04 20:42:27 +02:00
Damien George f869d6b2e3 lib/libm: Fix tanhf so that it correctly handles +/- infinity args. 2017-10-04 21:14:00 +11:00
Damien George 23faf88cab py/mpprint: Only check for null string printing when NDEBUG not defined.
Printing "(null)" when a NULL string pointer is passed to %s is a debugging
feature and not a feature that's relied upon by the code.  So it only needs
to be compiled in when debugging (such as assert) is enabled, and saves
roughy 30 bytes of code when disabled.

This patch also fixes this NULL check to not do the check if the precision
is specified as zero.
2017-10-04 18:07:32 +11:00
Damien George dfa563c71f py/objstr: Make empty bytes object have a null-terminating byte.
Because a lot of string processing functions assume there is a null
terminating byte, so they can work in an efficient way.

Fixes issue #3334.
2017-10-04 17:59:22 +11:00
Damien George a3dc1b1957 all: Remove inclusion of internal py header files.
Header files that are considered internal to the py core and should not
normally be included directly are:
    py/nlr.h - internal nlr configuration and declarations
    py/bc0.h - contains bytecode macro definitions
    py/runtime0.h - contains basic runtime enums

Instead, the top-level header files to include are one of:
    py/obj.h - includes runtime0.h and defines everything to use the
        mp_obj_t type
    py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h,
        and defines everything to use the general runtime support functions

Additional, specific headers (eg py/objlist.h) can be included if needed.
2017-10-04 12:37:50 +11:00
Damien George 6c82cfc089 py/objtype: Change type of enum-to-qstr table to uint16_t to save space.
Qstr values fit in 16-bits (and this fact is used elsewhere in the code) so
no need to use more than that for the large lookup tables.  The compiler
will anyway give a warning if the qstr values don't fit in 16 bits.  Saves
around 80 bytes of code space for Thumb2 archs.
2017-10-04 11:31:05 +11:00
Gabe 9e0cdb22f1 docs/esp8266/tutorial: Update neopixel with example of using 4 bbp. 2017-10-04 10:35:22 +11:00
Radomir Dopieralski f4981677b0 Add a `gamepad` module for handling buttons in the background. (#295)
The `GamePad` singleton monitors buttons in the background to make sure a button press is never missed and debouncing happens consistently.
2017-10-03 13:35:57 -07:00
Dan Halbert c478c10923 Do not allow a *io object to be used after deinit().
Fixes #278, #277, #276, #275.
2017-10-03 12:07:17 -07:00
Radomir Dopieralski c2bb9e2eb5 Add board file for the hacked Trinket M0 Haxpress (#303)
Add a hacked Tinket M0 Haxpress board definition

Based on https://daveastels.com/2017/09/01/trinket-m0-express-hack/
2017-10-03 11:24:48 -07:00
chrismas9 3289b9b7a7 py/{mkenv.mk,mkrules.mk}: Append .exe for Windows executable files.
Building mpy-cross: this patch adds .exe to the PROG name when building
executables for host (eg mpy-cross) on Windows.  make clean now removes
mpy-cross.exe under Windows.

Building MicroPython: this patch sets MPY_CROSS to mpy-cross.exe or
mpy-cross so they can coexist and use cygwin or WSL without rebuilding
mpy-cross.  The dependency in the mpy rule now uses mpy-cross.exe for
Windows and mpy-cross for Linux.
2017-10-04 00:21:05 +11:00
Damien George b00040c43c esp8266/esp_mphal: Send data in chunks to mp_uos_dupterm_tx_strn.
Sending byte-by-byte is inefficient and leads to errors in the WebSocket
protocol when sending utf-8 encoded characters.
2017-10-03 23:24:24 +11:00
Damien George 54acd0b0f0 drivers/nrf24l01: Make nRF24L01 test script more portable. 2017-10-03 20:00:31 +11:00
Damien George 1394258f37 py/objset: Include the failed key in a KeyError raised from set.remove. 2017-10-03 18:03:06 +11:00
Damien George 2ac1364688 py/objset: Check that RHS of a binary op is a set/frozenset.
CPython docs explicitly state that the RHS of a set/frozenset binary op
must be a set to prevent user errors.  It also preserves commutativity of
the ops, eg: "abc" & set() is a TypeError, and so should be set() & "abc".

This change actually decreases unix (x64) code by 160 bytes; it increases
stm32 by 4 bytes and esp8266 by 28 bytes (but previous patch already
introduced a much large saving).
2017-10-03 17:56:27 +11:00
Damien George 01978648fd py/objset: Simplify set and frozenset by separating their locals dicts.
A lot of set's methods (the mutable ones) are not allowed to operate on a
frozenset, and giving frozenset a separate locals dict with only the
methods that it supports allows to simplify the logic that verifies if
args are a set or a frozenset.  Even though the new frozenset locals dict
is relatively large (88 bytes on 32-bit archs) there is a much bigger
saving coming from the removal of a const string for an error message,
along with the removal of some checks for set or frozenset type.

Changes in code size due to this patch are (for ports that changed at all):

   unix x64:   -56
unix nanbox:  -304
      stm32:   -64
    esp8266:  -124
     cc3200:   -40

Apart from the reduced code, frozenset now has better tab-completion
because it only lists the valid methods.  And the error message for
accessing an invalid method is now more detailed (it includes the
method name that wasn't found).
2017-10-03 17:55:53 +11:00