Commit Graph

4748 Commits

Author SHA1 Message Date
Scott Shawcroft 49dcdef512
Fix copy pasta 2021-08-13 11:32:26 -07:00
Scott Shawcroft de796e2304
Move OneWire to `onewireio` from `busio`
This will allow finer grained inclusion in 8.0.0

Fixes #5135
2021-08-12 10:47:14 -07:00
Scott Shawcroft fb6b438580
Make `getpass` and `traceback` full build only
This leaves much more space on SAMD21 builds that aren't "full builds".
These are new APIs that we don't need to add to old boards.

Also, tweak two Arduino boards to save space on them.
2021-08-11 14:47:35 -07:00
Scott Shawcroft 0c1d6cef75
Merge remote-tracking branch 'adafruit/main' into fix_cp_irremote 2021-08-11 13:43:59 -07:00
Scott Shawcroft 083960ce90
Fix SAMD51 builds and Prox Trinkey
Adds CIRCUITPY_BUSIO_UART to disable UART by raising ValueError
that no pins work.
2021-08-11 11:53:26 -07:00
microDev 93c9d59960
Merge branch 'main' into getpass 2021-08-10 01:00:10 +05:30
Jeff Epler c1ffab7476 Reduce code duplication in traceback module 2021-08-09 08:27:28 -05:00
Jeff Epler bfea6947e5 Improve mp_printf with support for compressed strings
* The new nonstandard '%S' format takes a pointer to compressed_string_t
   and prints it

 * The new mp_cprintf and mp_vcprintf take a format string that is a
   compressed_string_t
2021-08-09 08:27:28 -05:00
microDev 51f8603783
add getpass module 2021-08-09 17:50:28 +05:30
Jeff Epler d59a28db97 Compress word offset table
By storing "count of words by length", the long `wends` table can be
replaced with a short `wlencount` table.  This saves flash storage space.

Extend the range of string lengths that can be in the dictionary.
Originally it was to 2 to 9; at one point it was changed to 3 to 9.
Putting the lower bound back at 2 has a positive impact on the French
translation (a bunch of them, such as "ch", "\r\n", "%q", are used).
Increasing the maximum length gets 'mpossible', ' doit être ',
and 'CircuitPyth' at the long end.  This adds a bit of processing time
to makeqstrdata. The specific 2/11 values are again empirical based on
the French translation on the adafruit_proxlight_trinkey_m0.
2021-08-07 09:23:35 -05:00
microDev 063e3946d6
Merge pull request #5094 from jepler/quirc
Add qrio: Decode QR codes with quirc lib
2021-08-07 09:30:20 +05:30
Jeff Epler 67551c1ac0 qrio: Split QRInfo & PixelPolicy to their own .c/.h files 2021-08-06 09:53:17 -05:00
Jeff Epler bd903f2f03 Add qrio: Decode QR codes with quirc lib 2021-08-04 09:16:00 -05:00
microDev 193a8d2e67
add traceback object 2021-08-04 12:10:57 +05:30
microDev 4938851122
remove legacy sys.atexit() implementation 2021-07-30 10:00:00 +05:30
microDev a3998d0626
add atexit module 2021-07-30 09:32:28 +05:30
microDev f371c0a609
add traceback module 2021-07-28 18:06:23 +05:30
Dan Halbert b0fb709d83 more gamepad removal 2021-07-26 23:34:25 -04:00
Dan Halbert 901a6c27c0 remove gamepad; deprecate gamepadshift 2021-07-26 22:15:09 -04:00
microDev 79aaa3cc3a
make pre-commit happy
fix formatting
2021-07-23 09:27:54 +05:30
Scott Shawcroft f84cb94819
Remove OSError(0) and old network modules
The newer modules are `socketpool` and `ssl`.

Fixes #3924, related to #2021, closes #1880, closes #2273, closes #2274
2021-07-21 17:33:40 -07:00
Jeff Epler 9a373c4fb9
Merge pull request #4961 from dhalbert/restore-1970-epoch
Restore default epoch to 1970
2021-07-19 14:51:08 -05:00
Kattni Rembor dc2907ac1b Rename _pixelbuf to adafruit_pixelbuf, alias. 2021-07-16 13:31:40 -04:00
Scott Shawcroft 0fadf028ef
Create first BLE-only board, Micro:Bit v2
This fixes build issues with USB off, tweaks the README to allow
for BLE-only boards and adds the Micro:Bit v2 definition.

Fixes #4546
2021-07-14 09:55:51 -07:00
Scott Shawcroft 9fdecacec7
Merge pull request #4903 from jepler/split-type-objects
Split type objects
2021-07-12 16:37:55 -07:00
Kattni Rembor 4579bf9b12 Rename rainbow to rainbowio 2021-07-12 14:40:01 -04:00
Jeff Epler 93c6d16d3c Rename mp_type_attr -> mp_type_get_attr_slot 2021-07-12 07:30:29 -05:00
Jeff Epler 88434c53c7 Rename mp_type_parent -> mp_type_get_parent_slot 2021-07-12 07:30:16 -05:00
Jeff Epler 75e995f372 Rename mp_type_protocol -> mp_type_get_protocol_slot 2021-07-12 07:04:04 -05:00
Jeff Epler 1b2da0cda3 Rename mp_type_getbuffer -> mp_type_get_getbuffer_slot 2021-07-12 07:04:02 -05:00
Jeff Epler cdd879a3cc Rename mp_type_iternext -> mp_type_get_iternext_slot 2021-07-12 07:03:59 -05:00
Jeff Epler 9f6132b2ba Rename mp_type_getiter -> mp_type_get_getiter_slot 2021-07-12 07:03:57 -05:00
Jeff Epler 0efdf4a549 Rename mp_type_subscr -> mp_type_get_subscr_slot 2021-07-12 07:03:55 -05:00
Jeff Epler 6b8190b408 Rename mp_type_binary_op -> mp_type_get_binary_op_slot 2021-07-12 07:03:52 -05:00
Jeff Epler 46b5ed33ed Rename mp_type_unary_op -> mp_type_get_unary_op_slot 2021-07-12 07:03:50 -05:00
Jeff Epler ec53a674cf Rename mp_type_call -> mp_type_get_call_slot 2021-07-12 07:03:25 -05:00
Jeff Epler 9c1434014c remove redundant docs of struct _mp_obj_full_type_t 2021-07-12 07:01:14 -05:00
Jeff Epler 52540a9830 Rename EXTENDED_FIELDS -> MP_TYPE_EXTENDED_FIELDS 2021-07-12 06:57:59 -05:00
Jeff Epler 0b8b16f6ac increase comment on accuracy of the net savings estimate function
Thanks to tyomitch for suggesting the comment could be more accurate.
2021-07-11 08:57:27 -05:00
Jeff Epler 7302bc09a7 rename the type flag to EXTENDED for consistency 2021-07-09 14:59:37 -05:00
Jeff Epler 52e75c645d makeqstrdata: Don't include strings that are a net loss! 2021-07-09 14:26:43 -05:00
Jeff Epler 8836198ff1 TextSplitter: don't mutate 'words'
I was puzzled by why the dictionary words were sorted by length.
It was because TextSplitter sorted its parameter, instead of a copy.

This doesn't affect encoding size, but does affect the encoding NUMBER
of the found words.  We'll deliberately restore sorting by length next,
for other reasons, but not by spooky action.
2021-07-09 14:02:31 -05:00
Jeff Epler 99abd03b7a makeqstrdata: use an extremely accurate dictionary heuristic
Try to accurately measure the costs of including a word in the dictionary
vs the gains from using it in messages.

This saves about 160 bytes on trinket_m0 ja, the fullest translation
for that board.  Other translations on the same board all have savings,
ranging from 24 to 228 bytes.

```
Translation     Before  After   Savings
ja              1164    1324    160
de_DE           1260    1396    136
fr              1424    1652    228
zh_Latn_pinyin  1448    1520    72
pt_BR           1584    1736    152
pl              1592    1640    48
es              1724    1816    92
ko              1724    1816    92
fil             1764    1800    36
it_IT           1896    2040    144
nl              1956    2136    180
ID              2072    2180    108
cs              2124    2148    24
sv              2340    2448    108
en_x_pirate     2644    2740    96
en_GB           2652    2752    100
el              2656    2768    112
en_US           2656    2768    112
hi              2656    2768    112
```
2021-07-09 12:45:49 -05:00
Kattni Rembor 289575a811 Adding rainbow module. 2021-07-08 15:55:13 -04:00
Jeff Epler 26ae1c7705 Move & comment the field access macros 2021-07-07 08:32:59 -05:00
Jeff Epler 44a3da55e6 Fix EXTENDED_FIELDS macro to work with clang
This appears to work with clang versions at least since 3.0.
2021-07-07 08:32:33 -05:00
Jeff Epler 2997113e73 obj.h: Make mp_obj_is_type work between full & non-full types
By comparing the address of the initial 'name' field instead of the
addresses of the objects themselves, a small amount of type safety is
added back, vs just casting to void.

In the event that some other kind of object is passed in as 't',
which happens to have a 'name' field of the right type, the construct
would be (undesirably) accepted but it would almost certainly evaluate
to false at runtime.
2021-07-07 08:31:54 -05:00
Jeff Epler 0d756066e8 milestone: coverage make test_full passes 2021-07-06 10:37:32 -05:00
Jeff Epler df56ba207f WIP 2021-07-06 09:25:56 -05:00
Jeff Epler cd119ca3ec Introduce, use getters for fields which will be optional in types 2021-07-06 09:15:01 -05:00
Dan Halbert 0d9c4cb746 Merge remote-tracking branch 'adafruit/main' into restore-1970-epoch 2021-07-02 09:27:16 -04:00
Dan Halbert af13f9579c Restore default epoch to 1970 2021-07-02 09:04:42 -04:00
Dan Halbert c7ffc2c10b
Merge pull request #4957 from tannewt/ble_serial
Add serial over BLE
2021-07-01 23:05:18 -04:00
Dan Halbert 7f39779f45
Merge pull request #4931 from jepler/struct-time-construct
Allow construction of struct_time from another struct_time
2021-06-30 22:59:46 -04:00
microDev e0c626af16
fix bytes() and bytearray() input validation 2021-06-29 19:59:44 +05:30
Jeff Epler 33482e0831 mp_obj_get_array: Work with namedtuple, attrtuple.
Signed-off-by: Jeff Epler <jepler@gmail.com>
2021-06-26 20:25:24 -05:00
Jeff Epler f380a91e7c objtuple: Move mp_obj_is_tuple_compatible to obj.h.
Signed-off-by: Jeff Epler <jepler@gmail.com>
2021-06-26 20:25:23 -05:00
Scott Shawcroft 3177973843
Add BLE serial service 2021-06-25 15:00:10 -07:00
Scott Shawcroft b81573d439
Merge pull request #4891 from dhalbert/keypad-scanning-events
keypad: support for vector and matrix key scanning
2021-06-24 10:25:21 -07:00
Dan Halbert 8c74b4a5f2 fix some typos 2021-06-21 17:47:12 -04:00
Dan Halbert 51c547a5b9 add generic arg validation routines; add interval args to keypad 2021-06-21 12:13:39 -04:00
Jeff Epler a5876f4dea fix compile error on boards with inline asm 2021-06-18 16:59:48 -05:00
Jeff Epler fa29be5aea restore a redundant NULL-comparison, it silences compiler diagnostics 2021-06-18 11:24:39 -05:00
Jeff Epler 87d3740c64 Merge tag 'v1.16' 2021-06-18 10:54:19 -05: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
Damien George bc89cdeb45 py/gc: Only use no_sanitize_address attribute for GCC 4.8 and above.
It's not supported on older GCC versions.

Signed-off-by: Damien George <damien@micropython.org>
2021-06-18 14:15:37 +10:00
Dan Halbert af66931f71 Added keypad.ShiftRegisterKeys 2021-06-17 20:51:45 -04:00
Dan Halbert 04b69cde9b turn off gamepad on most builds;turn off keypad where appropriate 2021-06-17 13:46:45 -04:00
Dan Halbert cd31136c30 factor out keypad.EventQueue 2021-06-16 15:55:54 -04:00
Dan Halbert 3d18c5c327 Use a single list of keypad scanners 2021-06-16 13:29:38 -04:00
Dan Halbert 32eec85230 compiles 2021-06-14 20:54:43 -04:00
Dan Halbert 627c426259 wip 2021-06-14 16:00:15 -04:00
Dan Halbert 7d23206018 Inital keypad work: Keys working: one pin per key
keypad.Buttons and keypad.State

Buttons -> Keys; further work

wip

wip

wip: compiles

about to try

keypad.Keys working
2021-06-08 20:27:31 -04:00
Damien George 5e1d3c8b5d py/stackctrl: Prevent unused-var warning when stack checking disabled.
Signed-off-by: Damien George <damien@micropython.org>
2021-06-05 11:03:09 +10:00
Damien George a70a4e6688 py/emitglue: Always flush caches when assigning native ARM code.
Prior to this commit, cache flushing for ARM native code was done only in
the assembler code asm_thumb_end_pass()/asm_arm_end_pass(), at the last
pass of the assembler.  But this misses flushing the cache when loading
native code from an .mpy file, ie in persistentcode.c.

The change here makes sure the cache is always flushed/cleaned/invalidated
when assigning native code on ARM architectures.

This problem was found running tests/micropython/import_mpy_native_gc.py on
the mimxrt port.

Signed-off-by: Damien George <damien@micropython.org>
2021-06-05 11:03:04 +10:00
George Waters c5066efacb
Enable slice indices 2021-06-03 22:55:32 -04:00
Tsutomu IKEGAMI 9490010d7d Fix format (expand tab) 2021-06-02 12:10:41 +09:00
Tsutomu IKEGAMI 6278c2bb9f Fix bit_length() method to work with zero-valued mpz integer. 2021-06-02 11:57:55 +09:00
Jonathan Giles 064e6881ed Fix mpy-cross build on Apple M1 machines 2021-05-31 14:14:20 -04:00
Damien George 53519e322a py/builtinimport: Change relative import's ValueError to ImportError.
Following CPython change, see https://bugs.python.org/issue37444.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-30 19:35:03 +10:00
Jeff Epler d67f4115b4 py/repl: Don't read past the end of import_str.
asan considers that memcmp(p, q, N) is permitted to access N bytes at each
of p and q, even for values of p and q that have a difference earlier.
Accessing additional values is frequently done in practice, reading 4 or
more bytes from each input at a time for efficiency, so when completing
"non_exist<TAB>" in the repl, this causes a diagnostic:

    ==16938==ERROR: AddressSanitizer: global-buffer-overflow on
    address 0x555555cd8dc8 at pc 0x7ffff726457b bp 0x7fffffffda20 sp 0x7fff
    READ of size 9 at 0x555555cd8dc8 thread T0
        #0 0x7ffff726457a  (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xb857a)
        #1 0x555555b0e82a in mp_repl_autocomplete ../../py/repl.c:301
        #2 0x555555c89585 in readline_process_char ../../lib/mp-readline/re
        #3 0x555555c8ac6e in readline ../../lib/mp-readline/readline.c:513
        #4 0x555555b8dcbd in do_repl /home/jepler/src/micropython/ports/uni
        #5 0x555555b90859 in main_ /home/jepler/src/micropython/ports/unix/
        #6 0x555555b90a3a in main /home/jepler/src/micropython/ports/unix/m
        #7 0x7ffff619a09a in __libc_start_main ../csu/libc-start.c:308
        #8 0x55555595fd69 in _start (/home/jepler/src/micropython/ports/uni

    0x555555cd8dc8 is located 0 bytes to the right of global variable
    'import_str' defined in '../../py/repl.c:285:23' (0x555555cd8dc0) of
    size 8
      'import_str' is ascii string 'import '

Signed-off-by: Jeff Epler <jepler@gmail.com>
2021-05-30 11:50:51 +10:00
Jeff Epler 9a74546f8d py/gc: Access the list of root pointers in an asan-compatible way.
Signed-off-by: Jeff Epler <jepler@gmail.com>
2021-05-30 11:50:51 +10:00
Jeff Epler f2dbc91022 py/compile: Raise an error on async with/for outside an async function.
A simple reproducer is:

   async for x in (): x

Before this change, it would cause an assertion error in mpy-cross and
micropython-coverage.
2021-05-30 10:38:48 +10:00
Damien George 4ee8ec6931 py/asmarm: Use builtin func to flush I- and D-cache on ARM 7 archs.
The inline assembler code does not work for __ARM_ARCH == 7.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-26 16:24:00 +10:00
James Carr 61a7212b28
Update comment in persistentcode.c
Update comment in mp_raw_code_save so that it matches the code.
2021-05-23 08:57:41 +01:00
Damien George e61ac453dc py/mkrules.cmake: Add MPY_LIB_DIR and BOARD_DIR to makemanifest call.
So that the FROZEN_MANIFEST option in cmake works the same as make.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-23 00:00:39 +10:00
Scott Shawcroft 5643355e90
Merge remote-tracking branch 'adafruit/main' into simplify_status_led 2021-05-20 08:35:15 -07:00
Damien George 5176a2d732 py/emitnative: Fix x86-64 emitter to generate correct 8/16-bit stores.
Fixes issue #6643.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-20 23:43:25 +10:00
Damien George f49d47c167 py/asmx64: Support use of top 8 regs in src_r64 argument.
Signed-off-by: Damien George <damien@micropython.org>
2021-05-20 23:43:25 +10:00
Scott Shawcroft 499a4388cf
Handle inverted neopixel power 2021-05-19 17:29:02 -07:00
Bob Abeles 7ceccad4e2 py/nlrx64: Correct the detection of Darwin ABI.
__APPLE__ tests for an Apple OS and __MACH__ tests that it is based on CMU
Mach.  Using both tests ensures that just Darwin is recognized.
2021-05-18 11:52:00 +10:00
Bob Abeles 126b1c7271 py/nlraarch64: Add underscore prefix to function symbols for Darwin ABI.
The proper way to do this is to test for __APPLE__ and __MACH__, where
__APPLE__ tests for an Apple OS and __MACH__ tests that it is based on CMU
Mach.  Using both tests ensures that just Darwin (Apple's open source base
for MacOS, iOS, etc.) is recognized. __APPLE__ by itself will test for any
Apple OS, which can include older OS 7-9 and any future Apple OS. __MACH__
tests for any OS based on CMU Mach, including Darwin and GNU Hurd.

Fixes #7232.
2021-05-18 11:46:30 +10:00
Damien George 6d2680fa36 py/objarray: Fix constructing a memoryview from a memoryview.
Fixes issue #7261.

Signed-off-by: Damien George <damien@micropython.org>
2021-05-18 10:18:56 +10:00
Damien George 1446107b4d py/objarray: Use mp_obj_memoryview_init helper in mp_obj_new_memoryview.
Signed-off-by: Damien George <damien@micropython.org>
2021-05-18 00:22:53 +10:00
Limor "Ladyada" Fried 9752162508
Merge pull request #4765 from dhalbert/rotary-trinkey-rev-c-pins
Update various Trinkey pins and add _pixelbuf
2021-05-15 11:52:33 -04:00
Dan Halbert 1e2a945782 Make busio.SPI be NotImplementedError on proxlight to save space 2021-05-14 21:52:54 -04:00
Scott Shawcroft 689ec86225
Merge pull request #4754 from dhalbert/fix-endpoint-checking
Fix endpoint checking; Clean up safe mode printing
2021-05-14 11:25:01 -07:00
Dan Halbert fa6c06fb38 count in/out endpoints; allow more usb modules on low-endpoint boards 2021-05-13 21:59:02 -04:00
stijn 09be0c083c py/objarray: Implement more/less comparisons for array. 2021-05-13 22:16:14 +10:00
stijn 57365d8557 py/objarray: Prohibit comparison of mismatching types.
Array equality is defined as each element being equal but to keep
code size down MicroPython implements a binary comparison.  This
can only be used correctly for elements with the same binary layout
though so turn it into an NotImplementedError when comparing types
for which the binary comparison yielded incorrect results: types
with different sizes, and floating point numbers because nan != nan.
2021-05-13 22:16:14 +10:00