summaryrefslogtreecommitdiff
path: root/py
AgeCommit message (Collapse)Author
2020-11-19py.mk: allow translation to be overriden in GNUmakefileJeff Epler
I like to use local makefile overrides, in the file GNUmakefile (or, on case-sensitive systems, makefile) to set compilation choices. However, writing TRANSLATION := de_DE include Makefile did not work, because py.mk would override the TRANSLATION := specified in an earlier part of the makefiles (but not from the commandline). By using ?= instead of := the local makefile override works, but when TRANSLATION is not specified it continues to work as before.
2020-11-19Always use preprocessor for MICROPY_ERROR_REPORTINGJeff Epler
This ensures that only the translate("") alternative that will be used is seen after preprocessing. Improves the quality of the Huffman encoding and reduces binary size slightly. Also makes one "enhanced" error message only occur when ERROR_REPORTING_DETAILED: Instead of the word-for-word python3 error message "Type object has no attribute '%q'", the message will be "'type' object has no attribute '%q'". Also reduces binary size. (that's rolled into this commit as it was right next to a change to use the preprocessor for MICROPY_ERROR_REPORTING) Note that the odd semicolon after "value_error:" in parsenum.c is necessary due to a detail of the C grammar, in which a declaration cannot follow a label directly.
2020-11-19Introduce, use mp_raise_arg1Jeff Epler
This raises an exception with a given object value. Saves a bit of code size.
2020-11-19Use mp_raise instead of nlr_raise(new_exception) where possibleJeff Epler
This saves a bit of code space
2020-11-19Revert "samd21: Enable terse error reporting on resource constrained chip ↵Jeff Epler
family" This reverts commit 9a642fc0490c22b60460bcca8dec3b0b93344d81.
2020-11-19wipDan Halbert
2020-11-19merge from mainDan Halbert
2020-11-19WIP: redo API; not compiled yetDan Halbert
2020-11-18samd21: Enable terse error reporting on resource constrained chip familyJeff Epler
This reclaims over 1kB of flash space by simplifying certain exception messages. e.g., it will no longer display the requested/actual length when a fixed list/tuple of N items is needed: if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { mp_raise_ValueError(translate("tuple/list has wrong length")); } else { mp_raise_ValueError_varg(translate("requested length %d but object has length %d"), (int)len, (int)seq_len); Other chip families including samd51 keep their current error reporting capabilities.
2020-11-16Merge remote-tracking branch 'adafruit/main' into sleepDan Halbert
2020-11-16wip: initial code changes, starting from @tannewt's sleepio branchDan Halbert
2020-11-16Prevent exceptions from accumulating in REPLroot
2020-11-13Save flash spaceScott Shawcroft
* No weak link for modules. It only impacts _os and _time and is already disabled for non-full builds. * Turn off PA00 and PA01 because they are the crystal on the Metro M0 Express. * Change ejected default to false to move it to BSS. It is set on USB connection anyway. * Set sinc_filter to const. Doesn't help flash but keeps it out of RAM.
2020-11-03Renamed to adafruit_bus_devicegamblor21
2020-11-01add binascii to most buildsDan Halbert
2020-10-31Initial SPI commitgamblor21
2020-10-27Add check for invalid io, function to disable all alarmsmicroDev
2020-10-27Add alarm_touch modulemicroDev
2020-10-27Fix build errormicroDev
2020-10-27restructure alarm modulesmicroDev
2020-10-27Renamed alarm modulesmicroDev
2020-10-27Get io wake workingmicroDev
2020-10-27Initial Sleep SupportmicroDev
2020-10-24Initial commitgamblor21
2020-10-20Fix missing `nproc` on macOS.Christian Walther
396979a breaks building on macOS: `nproc` is a Linux thing, use a cross-platform alternative.
2020-10-15enable CIRCUITPY_BLEIO_HCI on non-nRF boards where it will fitDan Halbert
2020-10-14Merge pull request #3554 from gamblor21/move_ordereddictDan Halbert
Moved ORDEREDDICT define to central location
2020-10-14Remove ordered dict from SAMD21gamblor21
2020-10-14Removed MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT from unix coveragegamblor21
2020-10-13Moved ORDEREDDICT define to central locationgamblor21
2020-10-12Merge pull request #3538 from jepler/parallel-qstrlastScott Shawcroft
build: parallelize the qstr build steps
2020-10-12Merge pull request #3537 from jepler/update-protomatter-2Scott Shawcroft
rgbmatrix: update protomatter to 1.0.5 tag
2020-10-12Merge pull request #3539 from jepler/lto-type-mismatchScott Shawcroft
remove warning-disable flag that seems unneeded now
2020-10-11remove unnecessary board configuration and address feedbackKenny
2020-10-11build: Make genlast write the "split" filesJeff Epler
This gets a further speedup of about 2s (12s -> 9.5s elapsed build time) for stm32f405_feather For what are probably historical reasons, the qstr process involves preprocessing a large number of source files into a single "qstr.i.last" file, then reading this and splitting it into one "qstr" file for each original source ("*.c") file. By eliminating the step of writing qstr.i.last as well as making the regular-expression-matching part be parallelized, build speed is further improved. Because the step to build QSTR_DEFS_COLLECTED does not access qstr.i.last, the path is replaced with "-" in the Makefile.
2020-10-11build: parallelize the creation of qstr.i.lastJeff Epler
Rather than simply invoking gcc in preprocessor mode with a list of files, use a Python script with the (python3) ThreadPoolExecutor to invoke the preprocessor in parallel. The amount of concurrency is the number of system CPUs, not the makefile "-j" parallelism setting, because there is no simple and correct way for a Python program to correctly work together with make's idea of parallelism. This reduces the build time of stm32f405 feather (a non-LTO build) from 16s to 12s on my 16-thread Ryzen machine.
2020-10-11remove warning that seems unneeded nowJeff Epler
2020-10-10update async tests with less upython workaround and more cpython compatibilityKenny
2020-10-10i do not know if this is needed but this is not the vm i use anymoreKenny
2020-10-10async def syntax rigor and __await__ magic methodKenny
Some examples of improved compliance with CPython that currently have divergent behavior in CircuitPython are listed below: * yield from is not allowed in async methods ``` >>> async def f(): ... yield from 'abc' ... Traceback (most recent call last): File "<stdin>", line 2, in f SyntaxError: 'yield from' inside async function ``` * await only works on awaitable expressions ``` >>> async def f(): ... await 'not awaitable' ... >>> f().send(None) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 2, in f AttributeError: 'str' object has no attribute '__await__' ``` * only __await__()able expressions are awaitable Okay this one actually does not work in circuitpython at all today. This is how CPython works though and pretending __await__ does not exist will only bite users who write both. ``` >>> class c: ... pass ... >>> def f(self): ... yield ... yield ... return 'f to pay respects' ... >>> c.__await__ = f # could just as easily have put it on the class but this shows how it's wired >>> async def g(): ... awaitable_thing = c() ... partial = await awaitable_thing ... return 'press ' + partial ... >>> q = g() >>> q.send(None) >>> q.send(None) >>> q.send(None) Traceback (most recent call last): File "<stdin>", line 1, in <module> StopIteration: press f to pay respects ```
2020-10-10fix missing cflag defeating the board gatingwarriorofwire
2020-10-10Add async/await syntax to FULL_BUILDwarriorofwire
This adds the `async def` and `await` verbs to valid CircuitPython syntax using the Micropython implementation. Consider: ``` >>> class Awaitable: ... def __iter__(self): ... for i in range(3): ... print('awaiting', i) ... yield ... return 42 ... >>> async def wait_for_it(): ... a = Awaitable() ... result = await a ... return result ... >>> task = wait_for_it() >>> next(task) awaiting 0 >>> next(task) awaiting 1 >>> next(task) awaiting 2 >>> next(task) Traceback (most recent call last): File "<stdin>", line 1, in <module> StopIteration: 42 >>> ``` and more excitingly: ``` >>> async def it_awaits_a_subtask(): ... value = await wait_for_it() ... print('twice as good', value * 2) ... >>> task = it_awaits_a_subtask() >>> next(task) awaiting 0 >>> next(task) awaiting 1 >>> next(task) awaiting 2 >>> next(task) twice as good 84 Traceback (most recent call last): File "<stdin>", line 1, in <module> StopIteration: ``` Note that this is just syntax plumbing, not an all-encompassing implementation of an asynchronous task scheduler or asynchronous hardware apis. uasyncio might be a good module to bring in, or something else - but the standard Python syntax does not _strictly require_ deeper hardware support. Micropython implements the await verb via the __iter__ function rather than __await__. It's okay. The syntax being present will enable users to write clean and expressive multi-step state machines that are written serially and interleaved according to the rules provided by those users. Given that this does not include an all-encompassing C scheduler, this is expected to be an advanced functionality until the community settles on the future of deep hardware support for async/await in CircuitPython. Users will implement yield-based schedulers and tasks wrapping synchronous hardware APIs with polling to avoid blocking, while their application business logic gets simple `await` statements.
2020-10-10rgbmatrix: update protomatter to 1.0.5 tagJeff Epler
this is compile-tested on stm32f405 feather matrixportal nrf52840 feather but not actually tested-tested.
2020-09-28canio: RemoteTransmissionRequest: Split implementation, keep one structureJeff Epler
This already begins obscuring things, because now there are two sets of shared-module functions for manipulating the same structure, e.g., common_hal_canio_remote_transmission_request_get_id and common_hal_canio_message_get_id
2020-09-23Merge pull request #3456 from jepler/qstr-and-or-demagicScott Shawcroft
makeqstrdefs: don't make _and_, _or_ poisoned substrings for QSTRs
2020-09-22makeqstrdefs: don't make _and_, _or_ poisoned substrings for QSTRsJeff Epler
New contributor @mdroberts1243 encountered an interesting problem in which the argument they had named "column_underscore_and_page_addressing" simply couldn't be used; I discovered that internally this had been transformed into "column_underscore∧page_addressing", because QSTR makes _ENTITY_ stand for the same thing as &ENTITY; does in HTML. This might be nice for some things, but we don't want it here! I was unable to find a sensible way to "escape" and prevent this entity coding, so instead I ripped out support for the _and_ and _or_ escapes.
2020-09-21canio: rename from _canioJeff Epler
This reflects our belief that the API is stable enough to avoid incompatible changes during 6.x.
2020-09-21_canio: Minimal implementation for SAM E5x MCUsJeff Epler
Tested & working: * Send standard packets * Receive standard packets (1 FIFO, no filter) Interoperation between SAM E54 Xplained running this tree and MicroPython running on STM32F405 Feather with an external transceiver was also tested. Many other aspects of a full implementation are not yet present, such as error detection and recovery.
2020-09-21py: Add enum helper codeJeff Epler
This makes it much easier to implement enums, and the printing code is shared. We might want to convert other enums to this in the future.
2020-09-21makeqstrdata: Work around python3.6 compatibility problemJeff Epler
Discord user Folknology encountered a problem building with Python 3.6.9, `TypeError: ord() expected a character, but string of length 0 found`. I was able to reproduce the problem using Python3.5*, and discovered that the meaning of the regular expression `"|."` had changed in 3.7. Before, ``` >>> [m.group(0) for m in re.finditer("|.", "hello")] ['', '', '', '', '', ''] ``` After: ``` >>> [m.group(0) for m in re.finditer("|.", "hello")] ['', 'h', '', 'e', '', 'l', '', 'l', '', 'o', ''] ``` Check if `words` is empty and if so use `"."` as the regular expression instead. This gives the same result on both versions: ``` ['h', 'e', 'l', 'l', 'o'] ``` and fixes the generation of the huffman dictionary. Folknology verified that this fix worked for them. * I could easily install 3.5 but not 3.6. 3.5 reproduced the same problem