Commit Graph

17333 Commits

Author SHA1 Message Date
Kevin Matocha 9edad9ea85 Delete trailing blank lines from Shape.c 2020-09-04 14:21:49 -05:00
Kevin Matocha f7714649ee Add dirty rectangle tracking to Shape display element 2020-09-04 14:15:15 -05:00
Wellington Terumi Uemura e13698f8f7 Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (785 of 785 strings)

Translation: CircuitPython/main
Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pt_BR/
2020-09-04 17:15:26 +02:00
Dan Halbert 42df254683
Merge pull request #3373 from dhalbert/trellis-m4-board-i2c
fix pins for trellis_m4 board.I2C()
2020-09-04 11:15:18 -04:00
Scott Shawcroft 96cf60fbbd
Merge remote-tracking branch 'adafruit/main' into native_wifi 2020-09-03 16:34:56 -07:00
Scott Shawcroft 0b94638aeb
Changes based on Dan's feedback 2020-09-03 16:32:12 -07:00
Dan Halbert 960888a3bd fix pins for trellis_m4 board.I2C() 2020-09-03 14:22:18 -04:00
Jeff Epler cbfd38d1ce Rename functions to encode_ngrams / decode_ngrams 2020-09-02 19:09:23 -05:00
Scott Shawcroft 5d17d6402d
Merge pull request #3366 from kmatch98/refresh_now
Update refresh to force immediate redraw with `display.refresh()`
2020-09-02 16:37:46 -07:00
Scott Shawcroft 786f4ed114
Merge pull request #3344 from jepler/issue-3184
Fix RGBMatrix, FrameBufferDisplay bugs
2020-09-02 15:32:30 -07:00
Jeff Epler c34cb82ecb makeqstrdata: correct range of low code points to 0x80..0x9f inclusive
The previous range was unintentionally big and overlaps some characters
we'd like to use (and also 0xa0, which we don't intentionally use)
2020-09-02 15:52:02 -05:00
Jeff Epler f1c7389b29 locales: Replace NBSP characters with true spaces
These characters, at code point 0xa0, are unintended.
2020-09-02 15:50:51 -05:00
Jeff Epler 17a5a85528 rgbmatrix: Move struct definition to shared-module, rename 'core' member 2020-09-02 13:34:16 -05:00
Kevin Matocha d224183a7e Delete trailing whitespace 2020-09-02 11:26:37 -05:00
Kevin Matocha 8256bf7ea6 Add backticks to function references in docs 2020-09-02 11:20:30 -05:00
Kevin Matocha 4b9306aa7c Cleanup for sphinx 2020-09-01 18:10:40 -05:00
Jeff Epler 07740d19f3 add bigram compression to makeqstrdata
Compress common unicode bigrams by making code points in the range
0x80 - 0xbf (inclusive) represent them.  Then, they can be greedily
encoded and the substituted code points handled by the existing Huffman
compression.  Normally code points in the range 0x80-0xbf are not used
in Unicode, so we stake our own claim.  Using the more arguably correct
"Private Use Area" (PUA) would mean that for scripts that only use
code points under 256 we would use more memory for the "values" table.

bigram means "two letters", and is also sometimes called a "digram".
It's nothing to do with "big RAM".  For our purposes, a bigram represents
two successive unicode code points, so for instance in our build on
trinket m0 for english the most frequent are:
['t ', 'e ', 'in', 'd ', ...].

The bigrams are selected based on frequency in the corpus, but the
selection is not necessarily optimal, for these reasons I can think of:
 * Suppose the corpus was just "tea" repeated 100 times.  The
   top bigrams would be "te", and "ea".  However,
   overlap, "te" could never be used.  Thus, some bigrams might actually
   waste space
    * I _assume_ this has to be why e.g., bigram 0x86 "s " is more
      frequent than bigram 0x85 " a" in English for Trinket M0, because
      sequences like "can't add" would get the "t " digram and then
      be unable to use the " a" digram.

 * And generally, if a bigram is frequent then so are its constituents.
   Say that "i" and "n" both encode to just 5 or 6 bits, then the huffman
   code for "in" had better compress to 10 or fewer bits or it's a net
   loss!
    * I checked though!  "i" is 5 bits, "n" is 6 bits (lucky guess)
      but the bigram 0x83 also just 6 bits, so this one is a win of
      5 bits for every "it" minus overhead.  Yay, this round goes to team
      compression.
    * On the other hand, the least frequent bigram 0x9d " n" is 10 bits
      long and its constituent code points are 4+6 bits so there's no
      savings, but there is the cost of the table entry.
    * and somehow 0x9f 'an' is never used at all!

With or without accounting for overlaps, there is some optimum number
of bigrams.  Adding one more bigram uses at least 2 bytes (for the
entry in the bigram table; 4 bytes if code points >255 are in the
source text) and also needs a slot in the Huffman dictionary, so
adding bigrams beyond the optimim number makes compression worse again.

If it's an improvement, the fact that it's not guaranteed optimal
doesn't seem to matter too much.  It just leaves a little more fruit
for the next sweep to pick up.  Perhaps try adding the most frequent
bigram not yet present, until it doesn't improve compression overall.

Right now, de_DE is again the "fullest" build on trinket_m0.  (It's
reclaimed that spot from the ja translation somehow)  This change saves
104 bytes there, increasing free space about 6.8%.  In the larger
(but not critically full) pyportal build it saves 324 bytes.

The specific number of bigrams used (32) was chosen as it is the max
number that fit within the 0x80..0xbf range.  Larger tables would
require the use of 16 bit code points in the de_DE build, losing savings
overall.

(Side note: The most frequent letters in English have been said
to be: ETA OIN SHRDLU; but we have UAC EIL MOPRST in our corpus)
2020-09-01 17:12:22 -05:00
Jeff Epler f27b89632d
Merge pull request #3357 from weblate/weblate-circuitpython-main
Translations update from Weblate
2020-09-01 16:13:25 -05:00
Kevin Matocha 554cc356db Delete trailing whitespace 2020-09-01 15:43:18 -05:00
Kevin Matocha 7b6d805580 Add Optional[int] to docs string 2020-09-01 15:40:55 -05:00
Kevin Matocha 649a955a74 Modified docs to try to pass sphinx build 2020-09-01 15:02:37 -05:00
Kevin Matocha c6529daac5 Added some backticks to clarify the docs 2020-09-01 14:44:32 -05:00
Kevin Matocha f5015e4485 Add hanging tab to doc 2020-09-01 14:36:43 -05:00
Kevin Matocha e14de38528 Revise .refresh input default value for target_frames_per_second to None 2020-09-01 13:57:19 -05:00
Jeff Epler bb17882065
Translated using Weblate (Japanese)
Currently translated at 68.7% (536 of 780 strings)

Translation: CircuitPython/main
Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/ja/
2020-09-01 20:44:01 +02:00
Hosted Weblate 00eb0b5a1a
Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: CircuitPython/main
Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/
2020-09-01 20:28:15 +02:00
Taku Fukada 23fc7a573e Translated using Weblate (Japanese)
Currently translated at 68.7% (536 of 780 strings)

Translation: CircuitPython/main
Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/ja/
2020-09-01 20:28:14 +02:00
Wellington Terumi Uemura 51acfbbb01 Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (780 of 780 strings)

Translation: CircuitPython/main
Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/pt_BR/
2020-09-01 20:28:14 +02:00
Scott Shawcroft f0e60da51f
Merge pull request #3310 from dhalbert/ble_hci
_bleio HCI implementation
2020-09-01 11:28:05 -07:00
Dan Halbert 4e3cb55ce7 share more of _bleio dict; fix one doc error 2020-09-01 12:41:58 -04:00
Jeff Epler 3c083330f8 RGBMatrix: Remove unused, dead allocation
@tannewt noticed this in a pull request review.  The allocated
memory was never used, but the GC would have collected it eventually.
2020-09-01 11:00:22 -05:00
Jeff Epler 71c63c2812 FramebufferDisplay: Don't set rotation via core_construct
The expectations of displayio.Display and frambufferio.FramebufferDisplay
are different when it comes to rotation.

In displayio.Display, if you call core_construct with a WxH = 64x32
and rotation=90, you get something that is 32 pixels wide and 64 pixels
tall in the LCD's coordinate system.

This is fine, as the existing definitions were written to work like this.
With framebuffer displays, however, the underlying framebuffer (such as
RGBMatrix) says "I am WxH pixels wide in my coordinate system" and the
constructor is given a rotation; when the rotation indicates a transpose
that means "exchange rows and columns, so that to the Groups displayed
on it, there is an effectively HxW pixel region for use".

Happily, we already have a set_rotation method.  Thus (modulo the time
spent debugging things anyway:) the fix is simple: Always request no
rotation from core_construct, then immediately fix up the rotation
to match what was requested.

Testing performed: 32x16 RGBMatrix on Metro M4 Express (but using
the Airlift firmware, as this is the configuration the error was reported
on):
 * initially construct display at 0, 90, 180, 270 degrees
 * later change angle to 0, 90, 180, 270 degrees
 * no garbled display
 * no safe mode crashes
2020-09-01 11:00:22 -05:00
Jeff Epler ce603dfebf rgbmatrix: Disable timer while reconstructing the display 2020-09-01 11:00:22 -05:00
Jeff Epler dfa90cc11d allocator.h: add a missing license notice 2020-09-01 11:00:19 -05:00
Jeff Epler e01ade3848 rgbmatrix: Don't inline the allocator functions 2020-09-01 11:00:07 -05:00
Jeff Epler 2f120c70ee rgbmatrix: recover gracefully from allocation errors
e.g., allocating a 192x32x6bpp matrix would be enough to trigger this
reliably on a Metro M4 Express using the "memory hogging" layout.
Allocating 64x32x6bpp could trigger it, but somewhat unreliably.

There are several things going on here:
 * we make the failing call with interrupts off
 * we were throwing an exception with interrupts off
 * protomatter failed badly in _PM_free when it was partially-initialized

Incorporate the fix from protomatter, switch to a non-throwing malloc
variant, and ensure that interrupts get turned back on.

This decreases the quality of the MemoryError (it cannot report the size
of the failed allocation) but allows CircuitPython to survive, rather
than faulting.
2020-09-01 10:55:45 -05:00
Jeff Epler 9bd2a61d8b supervisor: Always allocate at least a 1x1 terminal
Otherwise, out of range writes would occur in tilegrid_set_tile, causing a safe mode reset.
```
Hardware watchpoint 6: -location *stack_alloc->ptr

Old value = 24652061
New value = 24641565
0x000444f2 in common_hal_displayio_tilegrid_set_tile (self=0x200002c8 <supervisor_terminal_text_grid>, x=1, y=1, tile_index=0 '\000')
    at ../../shared-module/displayio/TileGrid.c:236
236	    if (!self->partial_change) {
(gdb)
```
2020-09-01 10:55:45 -05:00
Jeff Epler 952d9bbb4a samd: Ignore a maybe-uninitialized diagnostic in asf4
I encountered this when changing optimization flags for debugging
purposes.  The diagnostic appears spurious and unrelated to what
I'm debugging.
2020-09-01 10:55:45 -05:00
Jeff Epler ad4bf75367 samd: only set NDEBUG for non-debug builds 2020-09-01 10:55:45 -05:00
Kevin Matocha 8be862e644 Remove trailing whitespace 2020-09-01 10:26:48 -05:00
Kevin Matocha c4b1db006f delete unnecessary comment 2020-09-01 09:38:57 -05:00
Kevin Matocha fc513956be Update refresh to force immediate redraw with display.refresh() or display.refresh(target_frames_per_second=None), even with auto_refresh=False 2020-09-01 09:36:29 -05:00
Dan Halbert ee1b142f5d
Merge pull request #3363 from dhalbert/matrix-portal
matrix portal board
2020-09-01 10:25:00 -04:00
Jeff Epler e8a29ece23
Merge pull request #3358 from jepler/esp-idf-submodules
actions: Clone the esp-idf submodules ourselves
2020-09-01 07:07:05 -05:00
Dan Halbert 4ac7650f22 matrix portal board 2020-08-31 23:56:38 -04:00
Scott Shawcroft 877a4f47cc
Merge pull request #3355 from jepler/import-builtin-submodule-crash-unix
builtinimport: Fix a crash with 'import ulab.linalg' on unix port only
2020-08-31 14:44:18 -07:00
Jeff Epler 8b2ae355ef
Merge pull request #3359 from adafruit/endpoint-counting-debug-remove
Remove debugging print-out for endpoint checking.
2020-08-31 06:44:26 -05:00
Dan Halbert 07e2fc721a
Remove debugging print-out for endpoint checking. 2020-08-30 23:14:50 -04:00
Jeff Epler ef8cde94a4 actions: Clone the esp-idf submodules ourselves
Builds of the esp32s2 targets frequently fail:
```
-- Found Git: /usr/bin/git (found version "2.28.0")
-- Initialising new submodule components/asio/asio...
warning: could not look up configuration 'remote.origin.url'. Assuming this repository is its own authoritative upstream.
Submodule 'components/asio/asio' (/home/runner/work/circuitpython/circuitpython/ports/espressif/asio.git) registered for path 'components/asio/asio'
fatal: repository '/home/runner/work/circuitpython/circuitpython/ports/espressif/asio.git' does not exist
fatal: clone of '/home/runner/work/circuitpython/circuitpython/ports/espressif/asio.git' into submodule path '/home/runner/work/circuitpython/circuitpython/ports/esp32s2/esp-idf/components/asio/asio' failed
Failed to clone 'components/asio/asio'. Retry scheduled
fatal: repository '/home/runner/work/circuitpython/circuitpython/ports/espressif/asio.git' does not exist
fatal: clone of '/home/runner/work/circuitpython/circuitpython/ports/espressif/asio.git' into submodule path '/home/runner/work/circuitpython/circuitpython/ports/esp32s2/esp-idf/components/asio/asio' failed
Failed to clone 'components/asio/asio' a second time, aborting
CMake Error at esp-idf/tools/cmake/git_submodules.cmake:48 (message):
  Git submodule init failed for components/asio/asio
Call Stack (most recent call first):
  esp-idf/tools/cmake/build.cmake:78 (git_submodule_check)
  esp-idf/tools/cmake/build.cmake:160 (__build_get_idf_git_revision)
  esp-idf/tools/cmake/idf.cmake:49 (__build_init)
  esp-idf/tools/cmake/project.cmake:7 (include)
  CMakeLists.txt:8 (include)
```

It's not clear how/why this happens--is it something to do with our
multithreaded build?.  Attempt to clear it up by manually checking out these
submodules ourselves.
2020-08-30 20:51:04 -05:00
Jeff Epler 5084d2b56b
Merge pull request #3356 from weblate/weblate-circuitpython-main
Translations update from Weblate
2020-08-30 19:37:17 -05:00