Commit Graph

5038 Commits

Author SHA1 Message Date
Dan Halbert 082b0d1aed
Merge pull request #7191 from jepler/fastpixelmap
Add a fast PixelMap-like class
2022-12-01 11:43:00 -05:00
Jeff Epler fb66a6bfe5
Don't use "offset" as an identifier 2022-11-30 14:39:54 -06:00
Jeff Epler e5b83821f8
fr should fit in 8 bits 2022-11-30 14:39:53 -06:00
Jeff Epler d16c9515b7
Compact the characters of certain translations, so they fit in uint8_t
This saves a few hundred bytes on the affected translations, such
as `el` which shrunk from 186152 to 185588 bytes (564 bytes saved).
2022-11-30 14:39:53 -06:00
Jeff Epler 6be0a425c7
Don't run maketranslationdata twice 2022-11-30 14:39:51 -06:00
Jeff Epler 9c11bb2ed9
Check that translations fit in expected character type 2022-11-30 14:39:50 -06:00
Jeff Epler c46e219795
Having an input-only pin is rare, save a string on other ports 2022-11-30 14:39:49 -06:00
Jeff Epler 4158ddfc17
compile out terse mismatch message when not used 2022-11-30 14:39:49 -06:00
Jeff Epler a94663b3c9
use a standard error message 2022-11-30 14:39:49 -06:00
Jeff Epler d39d146352
Merge some messages 2022-11-30 14:39:47 -06:00
Jeff Epler d61fde349d
re-use an error message 2022-11-30 14:39:34 -06:00
Jeff Epler 5fb191b51c
Use a standard validator 2022-11-30 14:39:33 -06:00
Jeff Epler 0e19fbb60f
Use a function to raise ZeroDivisionError, consistent string 2022-11-30 14:39:30 -06:00
Jeff Epler 7df21c9ecf
Combine a message 2022-11-30 12:06:17 -06:00
Jeff Epler f652a898e7
merge two messages 2022-11-30 12:06:17 -06:00
Jeff Epler 2315b62bff
Remove unused static qstrs
These are turned into TRANSLATE() messages now, so the qstr version
would not be used.
2022-11-30 12:06:15 -06:00
Jeff Epler 10d92873c3
Don't generate QSTRs for wrong identifiers
MP_REGISTER_MODULE would use identifiers like
"MODULE_DEF_MP_QSTR___FUTURE__" which would in turn cause
a QSTR to be generated for it. This wasn't desirable, because the
qstr would never be used.

This clears out quite a bit of flash storage on the proxlight trinkey.
2022-11-30 12:06:15 -06:00
Dan Halbert c8390a7918
Merge pull request #7069 from jepler/exception-chain
Implement chained exceptions
2022-11-30 11:13:57 -05:00
foamyguy 57d7f7f2ad move to _pixelmap 2022-11-24 09:07:08 -06:00
Dan Halbert 6d022733b3
Merge pull request #7162 from rhooper/boards-list
add boards list to make error message
2022-11-21 23:18:37 -05:00
MicroDev c3c1717813
refactor common port specific Makefile code 2022-11-18 23:00:28 +05:30
Jeff Epler dd443bacb8
Chain exceptions while unwinding 2022-11-13 19:53:23 -06:00
Jeff Epler b6f86e1e73
Recursively print chained exceptions 2022-11-13 19:53:21 -06:00
Jeff Epler f3169246ba
Implement chained exceptions
This adds the __cause__, __context__ and __suppress_context__
members to exception objects and makes e.g., `raise exc from cause`
set them in the same way as standard Python.
2022-11-13 19:52:50 -06:00
Jeff Epler b499275bb5
Don't crash when assigning attributes of the GeneratorExit const singleton 2022-11-13 19:52:49 -06:00
Jeff Epler f5c637dc10
Add adafruit_pixelmap.PixelMap
.. a fast helper for animations. It is similar to and inspired by the
PixelMap helper in Adafruit LED Animation library, but with an extremely
fast 'paste' method for setting a series of pixels. This is a common
operation for many animations, and can give a substantial speed improvement.

It's named `adafruit_pixelmap` so that we can package a compatible version
in pure Python for systems that can't fit it in C in flash, or for
Blinka.

This is a proof of concept and can make a very fast comet animation:
```python
import time
import adafruit_pixelbuf
import adafruti_pixelmap
import board
import neopixel
from supervisor import ticks_ms
from adafruit_led_animation.animation.solid import Solid
from adafruit_led_animation import color

pixel_pin = board.GP0
pixel_num = 96

pixels = neopixel.NeoPixel(pixel_pin, pixel_num, brightness=1, auto_write=False, pixel_order="RGB")

evens = adafruit_pixelmap.PixelMap(pixels, tuple(range(0, pixel_num, 2)))
odd_indices = tuple((i, i+2) for i in range(1, pixel_num, 4))
print(odd_indices)
odds = adafruit_pixelbuf.PixelMap(pixels, odd_indices)
assert len(odds) == len(odd_indices)


comet_length = 16

comet1 = [color.calculate_intensity(color.GREEN, ((1+i) / comet_length) ** 2.4)
        for i in range(comet_length)]
comet2 = [color.calculate_intensity(color.PURPLE, ((1+i) / comet_length) ** 2.4)
        for i in range(comet_length)]

pos1 = 0
pos2 = 96//4

while True:
    evens.paste(comet1, pos1, wrap=True, reverse=False, others=0)
    pos1 = (pos1 + 1) % len(evens)

    odds.paste(comet2, pos2, wrap=True, reverse=True, others=0)
    pos2 = (pos2 - 1) % len(odds)
    pixels.show()

    m = ticks_ms()
    if m % 2000 > 1000:
        time.sleep(.02)
```
2022-11-11 07:54:33 -06:00
Jeff Epler 9cdfba2e47
Simplify argument checking to reduce translated strings
Build size on proxlight trinkey m0 en_US:
Before:  2412 (en_US)  820 (ru)
After:   2544 (en_US)  984 (ru)
Savings: +132 (en_US) +164 (ru) bytes available flash
2022-11-07 12:37:11 -06:00
Jeff Epler 05252c87f4
Don't crash when assigning attributes of the GeneratorExit const singleton 2022-10-22 11:37:34 -05:00
microDev b33a2b45dc
add coproc alarm 2022-10-20 18:38:20 +05:30
microDev 5232e3f6c3
add coproc module 2022-10-20 09:09:44 +05:30
Jeff Epler 068b7c4af8
Use micropython #defines for stream polling operations
We adopted the file "py/ioctl.h" and the ioctl names beginning
with MP_IOCTL_POLL while micropython went with "py/stream.h" and
MP_STREAM_POLL.

Align with upstream.

Closes #6711
2022-10-14 12:15:30 -05:00
Dan Halbert 8825e7f241
Merge pull request #6397 from jepler/extra-memset
Some flash size optimizations related to string0.c (implementation of str/mem functions)
2022-10-13 12:34:59 -04:00
Dan Halbert 7e4b2a09eb
Merge pull request #7000 from MicroDev1/storage-extend
Add Storage Extension Support
2022-10-13 10:05:55 -04:00
Dan Halbert 86a0f9a861 save about 112 bytes 2022-10-09 19:22:39 -04:00
Jeff Epler dcb650c513 pico w: add ssl module
Note: at this time, the ssl module on pico_w never verifies the server
certificate. This means it does not actually provide a higher security
level than regular socket / http protocols.
2022-10-05 13:12:43 -04:00
Dan Halbert ed87579a65 add missing native modules to support matrix 2022-10-04 19:22:18 -04:00
microDev 9fe7308b88
conditionally add storage extension 2022-10-04 17:26:28 +05:30
Dan Halbert db065a299f
Merge pull request #6933 from jepler/🥧🐮
Implement a useful subset of `wifi` and `socketpool` modules on 🥧🐮
2022-09-28 18:09:24 -04:00
Jeff Epler 6c3cdceb45
Implement scan, connect, ping
My pings go out, and then they come back

```py
import os
import wifi
import ipaddress

wifi.radio.connect(os.getenv('WIFI_SSID'), os.getenv('WIFI_PASSWORD'))
ipv4 = ipaddress.ip_address("8.8.4.4")
print("Ping google.com: %f ms" % (wifi.radio.ping(ipv4)*1000))
```
2022-09-28 10:06:33 -05:00
Jeff Epler 346fff2e7c
cyw43 basic gpio support, hwaddr in boot_out 2022-09-28 10:06:33 -05:00
Dan Halbert a7b10d41b4
Merge pull request #6522 from jepler/must-be-int
Improve argument checking & reduce strings to translate
2022-09-25 17:55:56 -04:00
Dan Halbert de80db681f
Merge pull request #6915 from dhalbert/ringbuf-cleanup
ringbuf cleanup
2022-09-25 17:50:21 -04:00
Jeff Epler 18cb25e95c
Re-use another message 2022-09-22 08:39:34 -05:00
Dan Halbert ea15a9118a ringbuf cleanup 2022-09-21 10:03:05 -04:00
Dan Halbert c567b43441 add CIRCUITPY_USB_IDENTIFICATION to turn off on smallest builds 2022-09-20 14:32:38 -04:00
Jeff Epler f11ef4cc4e
makeversionhdr should be unforgiving
Recently(?) github started making it the default to only copy a single
branch (e.g., main) and NO TAGS into new forks.

This makes the step of the build process that determines the CircuitPython
version not work, because tags are expected to be present. When tags are
not present, the version number is only a git hash. The version number
ends up being 0.0.0.

This causes problems with libraries that check for CircuitPython version
to determine compatibility, among other things.

We'll do other things to improve the situation, such as document it.
But it'd also be good if the build stopped when this detectable condition
occurs.
2022-09-16 10:28:53 -05:00
Dan Halbert 6bb47038d5 Merge remote-tracking branch 'adafruit/main' into adcdma 2022-09-15 20:42:51 -04:00
Jeff Epler 56112e00a1 Give fontio its own enable
.. the default is intended to be the equivalent of the original,
implementing `DISPLAYIO && TERMINALIO`.

This is a possible alternative to #6889, if I understand the intent.
2022-09-11 08:09:14 -05:00
Lee Atkinson f279a2dbb2
Merge branch 'adafruit:main' into adcdma 2022-09-08 11:46:01 -04:00
latkinso42 a1856ea3e9 Renaming module from adcbuffer to analogbufio 2022-09-05 12:11:49 -04:00