Scott Shawcroft
12fa5b3a66
Switch exception throwing to mp_raise helpers. It saves a little code space each time to share the call.
2017-02-24 15:13:07 +01:00
Scott Shawcroft
ccbb5e84f9
This introduces an alternative hardware API called nativeio structured around different functions that are typically accelerated by native hardware. Its not meant to reflect the structure of the hardware.
...
Docs are here: http://tannewt-micropython.readthedocs.io/en/microcontroller/
It differs from upstream's machine in the following ways:
* Python API is identical across ports due to code structure. (Lives in shared-bindings)
* Focuses on abstracting common functionality (AnalogIn) and not representing structure (ADC).
* Documentation lives with code making it easy to ensure they match.
* Pin is split into references (board.D13 and microcontroller.pin.PA17) and functionality (DigitalInOut).
* All nativeio classes claim underlying hardware resources when inited on construction, support Context Managers (aka with statements) and have deinit methods which release the claimed hardware.
* All constructors take pin references rather than peripheral ids. Its up to the implementation to find hardware or throw and exception.
2016-11-21 14:11:52 -08:00
Damien George
561844f3ba
py: Add MICROPY_FLOAT_CONST macro for defining float constants.
...
All float constants in the core should use this macro to prevent
unnecessary creation of double-precision floats, which makes code less
efficient.
2016-11-03 12:33:01 +11:00
Damien George
93c4a6a3f7
all: Remove 'name' member from mp_obj_module_t struct.
...
One can instead lookup __name__ in the modules dict to get the value.
2016-09-22 00:23:16 +10:00
Colin Hogben
a896951a9a
py/objfloat, py/modmath: Ensure M_PI and M_E defined.
...
In some compliation enviroments (e.g. mbed online compiler) with
strict standards compliance, <math.h> does not define constants such
as M_PI. Provide fallback definitions of M_E and M_PI where needed.
2016-05-12 13:28:45 +01:00
Damien George
4b72b3a133
py: Change type signature of builtin funs that take variable or kw args.
...
With this patch the n_args parameter is changed type from mp_uint_t to
size_t.
2016-01-11 00:49:27 +00:00
Michael Buesch
17298af61e
py/modmath: Add domain error checking to sqrt, log, log2, log10.
...
These functions will raise 'ValueError: math domain error' on invalid
input.
2015-12-12 15:12:54 +00:00
Damien George
cbf7674025
py: Add MP_ROM_* macros and mp_rom_* types and use them.
2015-11-29 14:25:04 +00:00
Damien George
a24eafacc9
py/modmath: Make log2, log10 and hyperbolic funcs be SPECIAL_FUNCTIONS.
...
Will be included only when MICROPY_PY_MATH_SPECIAL_FUNCTIONS is enabled.
Also covers cmath module (but only log10 is there at the moment).
2015-11-17 14:10:13 +00:00
Paul Sokolovsky
863d4cd862
py/modmath: Don't create symbol entry for expm1() if not needed.
2015-11-14 00:55:54 +02:00
Paul Sokolovsky
0d6116d86b
py/modmath: Make expm1() be in MICROPY_PY_MATH_SPECIAL_FUNCTIONS.
2015-11-14 00:46:52 +02:00
Paul Sokolovsky
6d1eabfeaa
unix/mpconfigport: Move log2() definition to modmath.c.
...
It's safer to define it where it's used, defining it for all source files
may lead to hard to diagnose conflicts in corner cases.
2015-11-13 15:24:48 +02:00
Damien George
7e359c648b
py: Move float e/pi consts to objfloat and make mp_obj_float_t private.
2015-10-20 12:35:17 +01:00
Paul Sokolovsky
1b586f3a73
py: Rename MP_BOOL() to mp_obj_new_bool() for consistency in naming.
2015-10-11 15:18:15 +03:00
Damien George
6f49520042
py: Implement second arg for math.log (optional value for base).
2015-06-13 22:35:25 +01:00
Damien George
5cbeacebdb
py: Make math special functions configurable and disabled by default.
...
The implementation of these functions is very large (order 4k) and they
are rarely used, so we don't enable them by default.
They are however enabled in stmhal and unix, since we have the room.
2015-02-22 14:48:18 +00:00
Damien George
51dfcb4bb7
py: Move to guarded includes, everywhere in py/ core.
...
Addresses issue #1022 .
2015-01-01 20:32:09 +00:00
Damien George
969a6b37bf
py: Make functions static where appropriate.
2014-12-10 22:08:14 +00:00
Damien George
3b603f29ec
Use MP_DEFINE_CONST_DICT macro to define module dicts.
...
This is just a clean-up of the code. Generated code is exactly the
same.
2014-11-29 14:39:27 +00:00
Damien George
30dd23aa7f
doc: Document gc, sys, math, cmath.
2014-08-10 17:50:28 +01:00
Damien George
40f3c02682
Rename machine_(u)int_t to mp_(u)int_t.
...
See discussion in issue #50 .
2014-07-03 13:25:24 +01:00
Paul Sokolovsky
59c675a64c
py: Include mpconfig.h before all other includes.
...
It defines types used by all other headers.
Fixes #691 .
2014-06-21 22:43:22 +03:00
Emmanuel Blot
f6932d6506
Prefix ARRAY_SIZE with micropython prefix MP_
2014-06-19 18:54:34 +02:00
Damien George
fb510b3bf9
Rename bultins config variables to MICROPY_PY_BUILTINS_*.
...
This renames:
MICROPY_PY_FROZENSET -> MICROPY_PY_BUILTINS_FROZENSET
MICROPY_PY_PROPERTY -> MICROPY_PY_BUILTINS_PROPERTY
MICROPY_PY_SLICE -> MICROPY_PY_BUILTINS_SLICE
MICROPY_ENABLE_FLOAT -> MICROPY_PY_BUILTINS_FLOAT
See issue #35 for discussion.
2014-06-01 13:32:54 +01:00
Damien George
ee3fd46f13
Rename configuration variables controling Python features.
...
Now of the form MICROPY_PY_*. See issue #35 .
2014-05-24 23:03:12 +01:00
Antonin ENFRUN
da1fffaa09
Fix some unused variables, and silence a clang warning about initialization override in vmentrytable.h
2014-05-12 09:06:18 +02:00
Damien George
04b9147e15
Add license header to (almost) all files.
...
Blanket wide to all .c and .h files. Some files originating from ST are
difficult to deal with (license wise) so it was left out of those.
Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
2014-05-03 23:27:38 +01:00
Damien George
6d3c5e4301
Add ARRAY_SIZE macro, and use it where possible.
2014-04-26 10:47:29 +01:00
Damien George
dbdfee15a1
py: Add cmath module, for complex math. Disabled by default.
...
Not all functions implemented. Not enabled on pyboard.
2014-04-17 17:11:03 +01:00
Damien George
8b0535e23f
py: Change module globals from mp_map_t* to mp_obj_dict_t*.
...
Towards addressing issue #424 .
Had a small increase to ROM usage (order 60 bytes).
2014-04-05 21:53:54 +01:00
Damien George
084ef373fb
py: Fix math.{ceil,floor,trunc} to return int.
2014-04-01 21:21:50 +01:00
Damien George
df6567e634
Merge map.h into obj.h.
...
Pretty much everyone needs to include map.h, since it's such an integral
part of the Micro Python object implementation. Thus, the definitions
are now in obj.h instead. map.h is removed.
2014-03-30 13:54:02 +01:00
Damien George
caac542b23
Proper support for registering builtin modules in ROM.
...
Comes with some refactoring of code and renaming of files. All modules
are now named mod*.[ch].
2014-03-25 14:18:18 +00:00