Commit Graph

780 Commits

Author SHA1 Message Date
Dan Halbert 9939c59caa wip 2021-03-02 15:16:55 -05:00
Scott Shawcroft e4f0e47d9f
Merge pull request #4233 from pewpew-game/displayio-group-list
displayio: make Group use a python list internally
2021-03-02 09:59:58 -08:00
Scott Shawcroft d0eab5c561
Merge pull request #4256 from kmatch98/bt_cleanup
Add `bitmaptools` module
2021-03-01 18:24:12 -08:00
Jeff Epler 238484ec26 Merge remote-tracking branch 'origin/main' into update-protomatter-rp2 2021-03-01 15:18:32 -06:00
Radomir Dopieralski 24473b7983 Separate out mp_obj_list_insert for use in display.Group
Note that for some reason this makes the binary 500 bytes larger!
2021-02-27 21:13:55 +01:00
Radomir Dopieralski 38fb7b511b Remove max_size from displayio.Group
Still accept it as an argument. Add deprecation note.
2021-02-27 20:52:38 +01:00
Radomir Dopieralski 9c41753e44 Remove unused typedef for group children 2021-02-27 20:52:38 +01:00
Radomir Dopieralski e505c59ed8 Separate mp_obj_list_pop so it can be used outside of objlist.c 2021-02-27 20:52:38 +01:00
Radomir Dopieralski 121c6bcc9b Replace displaio.Group.children with a python list
This is a first go at it, done by naive replacing of all array
operations with corresponding operations on the list. Note that
there is a lot of unnecessary type conversions, here. Also, list_pop
has been copied, because it's decalerd STATIC in py/objlist.h
2021-02-27 20:52:38 +01:00
Radomir Dopieralski 6e0ce23f3e displaio: don't store group children native object
Since we want to expose the list of group's children to the user,
we should only have the original objects in it, without any other
additional data, and compute the native object as needed.
2021-02-27 20:52:38 +01:00
Kevin Matocha 3afc269b18 fix two off by one errors 2021-02-26 17:22:11 -06:00
Jeff Epler 1d1ff5f308 Merge remote-tracking branch 'origin/main' into update-protomatter-rp2 2021-02-26 09:56:35 -06:00
Kevin Matocha 4097c949a3 Update for clean blitting into itself 2021-02-25 14:16:40 -06:00
Scott Shawcroft d4bf0d5e2d
Merge pull request #4258 from jepler/pixelbuf-brightness-performance
_pixelbuf: Increase performance of brightness-scaling
2021-02-25 10:51:32 -08:00
Jeff Epler dac4ac5d2a _pixelbuf: Respond to review comments
* Comment on the reason for scaling by 256
 * Divide by 256 instead of shifting
 * fix a cast; eliminate an unneeded roundf() to get a few bytes code back
2021-02-24 16:27:09 -06:00
Kamil Tomaszewski ef3a61432b Add the missing argument to the HID functions 2021-02-24 19:09:17 +01:00
Jeff Epler b7f5c277ad _pixelbuf: Increase performance of brightness-scaling
On the Pico, this increases the "fill rate" of
    pixels[:] = newvalues
considerably.  On a strip of 240 RGB LEDs, auto_write=False, the timings
are:

|| Brightness || Before || After || Improvement ||
|| 1.0        || 117 kpix/s || 307 kpix/s || 2.62x ||
|| 0.07       || 117 kpix/s || 273 kpix/s || 2.33x ||

It's worth noting that even the "before" rate is fast compared to the
time to transmit a single neopixel, but any time we can gain back
in the whole pipeline will let marginal animations work a little better.
To set all the pixels in this way and then show() gives a pleasant bump
to the framerate, from about 108Hz to 124Hz (1.15x)

The main source of speed-up is using integer math instead of floating
point math for the calculation of the post-scaled pixel values.  A slight
secondary gain is achieved by avoiding the scaling altogether when
the scale factor is 1.0.

Because the math is not exactly the same, some scaled pixel values may
change by +- 1 RGBW "step".  In practice, this is unlikely to matter.

The gains are bigger on the Pico and other M0 microcontrollers than M4
microcontrollers with floating point math in the hardware.

Happily, flash size is also improved a bit on the Pico build I did,
going from
> 542552 bytes used, 506024 bytes free in flash firmware space out of 1048576 bytes (1024.0kB).

to
> 542376 bytes used, 506200 bytes free in flash firmware space out of 1048576 bytes (1024.0kB).
2021-02-24 09:51:27 -06:00
Kevin Matocha b720028642 Add bitmaptools module 2021-02-23 23:23:14 -06:00
Dan Halbert 93bf269c0d Avoid pulling in extra float-uint64 routines 2021-02-21 12:05:03 -05:00
Dan Halbert 67406488d1 merge from upstream; re-alphabetize 2021-02-19 14:22:50 -05:00
Dan Halbert 9d4442e298 handle reads/writes larger than buffers; add .write_timeout 2021-02-19 14:15:31 -05:00
Jeff Epler 5c758523c0 requested changes 2021-02-18 17:19:34 -06:00
Jeff Epler 7fd4567893 bitops: rename from _bit_transpose, describe the algorithm 2021-02-18 15:41:23 -06:00
Jeff Epler c284728621 bit_transpose: Support from 2 to 7 strands, not just 8 2021-02-18 11:33:13 -06:00
Jeff Epler 9cf7d73c6c core: add bit_transpose function
.. this version can only handle exactly 8 bits "across".  The restriction
may be relaxed in a future revision.
2021-02-18 11:32:47 -06:00
Dan Halbert ed49c02feb add timeout; finish up for PR 2021-02-17 23:24:11 -05:00
Dan Halbert c26de0136a works! no timeouts 2021-02-16 17:39:36 -05:00
Dan Halbert 0b8f1b9a90 wip: usb_cdc.serials 2021-02-15 20:06:18 -05:00
Dan Halbert 93d788543c Merge remote-tracking branch 'adafruit/main' into secondary-cdc 2021-02-15 20:03:53 -05:00
Dan Halbert d54b5861a3 wip 2021-02-12 19:01:14 -05:00
Jeff Epler ff1942cff6 Enable protomatter on RP2040 builds
Also found a race condition between timer_disable and redraw, which
would happen if I debugger-paused inside common_hal_rgbmatrix_timer_disable
or put a delay or print inside it.  That's what pausing inside reconstruct
fixes.

So that the "right timer" can be chosen, `timer_allocate` now gets the `self`
pointer.  It's guaranteed at this point that the pin information is accurate,
so you can e.g., find a PWM unit related to the pins themselves.
This required touching each port to add the parameter even though it's
unused everywhere but raspberrypi.
2021-02-12 08:25:15 -06:00
Dan Halbert d7305182f0 Remove adafruit_bus_device.SPIDevice.spi 2021-02-11 10:33:57 -05:00
Scott Shawcroft a861498404
Merge pull request #4114 from tannewt/spidevice_spi
Add .spi accessor to SPIDevice
2021-02-02 09:53:10 -08:00
Scott Shawcroft 8fd6bff727
Add .spi accessor to SPIDevice
Fixes #4108
2021-02-01 20:03:23 -08:00
gamblor21 0cf2df48c4 Fixed for boards without longint 2021-02-01 17:58:34 -06:00
Jeff Epler 20c9f25a65 rgbmatrix: Eliminate some duplicated height-calculating code
This was hard to write, so let's have it written in 2 places instead
of 4.
2021-01-26 14:35:26 -06:00
Jeff Epler 368977fb90 RGBMatrix: Additional tile tweaks
* Introduce explicit serpentine: bool argument instead of using negative
   numbers (thanks, ghost of @tannewt sitting on one shoulder)
 * Fix several calculations of height

Testing performed (matrixportal):
 * set up a serpentine 64x64 virtual display with 2 64x32 tiles
 * tried all 4 rotations
 * looked at output of REPL
2021-01-26 14:33:48 -06:00
Jeff Epler 51f0544405 protmatter: Update to version that supports tiling 2021-01-26 09:19:44 -06:00
Scott Shawcroft 4241fd4b18
Merge pull request #4051 from jamesbowman/main
EVE: change fixed-point integer arguments to floating point
2021-01-25 14:44:48 -08:00
Scott Shawcroft a2ac2da7cc
Merge pull request #3936 from gamblor21/busdevice_fixes
Changing adafruit_bus_device to duck typing
2021-01-25 14:41:53 -08:00
James Bowman dff3423c23 Change from fixed-point integer arguments to floating point in EVE API functions
Changed calls: PointSize(), LineWidth(), VertexTranslateX() and VertexTranslateY()
Units for all the above are now pixels, not fixed-point integers. This matches OpenGL.
Docstrings updated accordingly
2021-01-22 15:52:46 -08:00
Scott Shawcroft 2b4ad1ed03
Fix warnings that come from -O3 (I think) 2021-01-20 19:16:56 -08:00
Scott Shawcroft 733094aead
Add initial RP2040 support
The RP2040 is new microcontroller from Raspberry Pi that features
two Cortex M0s and eight PIO state machines that are good for
crunching lots of data. It has 264k RAM and a built in UF2
bootloader too.

Datasheet: https://pico.raspberrypi.org/files/rp2040_datasheet.pdf
2021-01-20 19:16:56 -08:00
Bernhard Boser 41459d15d9 handle exttype & chunk long reads 2021-01-18 10:13:16 -08:00
gamblor21 d3995eaf97 Fixes from draft PR 2021-01-16 14:21:57 -06:00
gamblor21 ea0e2f80b7 Changing to duck-typing 2021-01-16 14:21:57 -06:00
Jeff Epler 1ca29ec47c Merge remote-tracking branch 'origin/main' into audioout-esp32 2021-01-12 09:23:07 -06:00
iot49 1a82555803
Merge branch 'main' into msgpack 2021-01-05 11:19:11 -08:00
Bernhard Boser 79e3c3d2fd Merge branch 'msgpack' of github.com:iot49/iotpython into msgpack 2021-01-05 11:02:00 -08:00
Jeff Epler a7542598a0 esp32s2: add I2SOut 2020-12-29 14:46:38 -06:00
microDev dc332baa87
update common_hal_reset_pin() 2020-12-28 20:04:00 +05:30
Scott Shawcroft df8cba1068
Merge pull request #3834 from jepler/pr3723
displayio: Fix several bugs (transparency and palettes of OnDiskBitmaps)
2020-12-21 17:46:30 -08:00
Bernhard Boser c875d7c22d speedup pack_bin, ext, str; catch short reads 2020-12-19 19:06:43 -08:00
Jeff Epler 6c4df5a8b4 adafruit_bus_device: Don't transmit STOP condition in write_then_readinto
Closes #3795
2020-12-18 11:13:54 -06:00
Jeff Epler f224ed1848 OnDiskBitmap: Correct handling of "0 color palette" images
Microsoft documentation says:

> If biCompression equals BI_RGB and the bitmap uses 8 bpp or less, the bitmap has a color table immediatelly following the BITMAPINFOHEADER structure. The color table consists of an array of RGBQUAD values. The size of the array is given by the biClrUsed member. If biClrUsed is zero, the array contains the maximum number of colors for the given bitdepth; that is, 2^biBitCount colors.

Formerly, we treated 0 colors as "no image palette" during construction,
but then during common_hal_displayio_ondiskbitmap_get_pixel indexed into
the palette anyway.  This could have unpredictable results.  On a pygamer,
it gave an image that was blue and black.  On magtag, it gave a crash.
2020-12-17 10:54:37 -06:00
Jeff Epler 28bd29eb42 displayio: ColorConverter: fix logic errors about transparent pixels
The transparent_color field was never initialized.  I _think_ this means
its value was always set to 0, or the blackest of blacks.  Instead,
initialize it to the sentinel value, newly given the name
NO_TRANSPARENT_COLOR.

This exposed a second problem: The test for whether there was an existing
transparent color was wrong (backwards).  I am guessing that this was not
found due to the first bug; since the converter had a transparent color,
the correct test would have led to always getting the error "Only one
color can be transparent at a time".

Closes #3723
2020-12-16 13:48:27 -06:00
Scott Shawcroft 344d3c59cb
Merge branch 'main' into msgpack 2020-12-11 11:10:30 -08:00
Bernhard Boser b5b6b6d0f2 add ExtType, update doc, add a test 2020-12-07 15:40:02 -08:00
Scott Shawcroft 1130b80e2a
Merge pull request #3612 from gamblor21/bus_device
Moving Adafruit_CircuitPython_BusDevice to core
2020-12-02 13:23:02 -08:00
Scott Shawcroft 608c98501b
Merge remote-tracking branch 'adafruit/main' into msgpack 2020-12-02 13:10:39 -08:00
Scott Shawcroft d7ba641ff6
Merge pull request #3767 from dhalbert/sleep
Initial alarm and sleep PR: time alarms with light and deep sleep; PinAlarms not yet implemented
2020-12-02 12:51:43 -08:00
Bernhard Boser 582a47d71a
rename read, write to read_bytes, write_bytes 2020-12-01 18:41:11 -08:00
Bernhard Boser 59c3e25168
disable on boards tight on memory. add stddef.h to imports (not actually needed). 2020-12-01 18:39:24 -08:00
Bernhard Boser a310cde8c1
fixed res may not be initialized in read_size 2020-12-01 18:38:47 -08:00
Bernhard Boser b805bf8a62
cleanup 2020-12-01 18:38:47 -08:00
Bernhard Boser 44bc75af37
output little endian; update example 2020-12-01 18:38:47 -08:00
Bernhard Boser 912691e0d2
removed blanks line at end of file 2020-12-01 18:38:14 -08:00
Bernhard Boser 513253bc3f
moved logic to shared-module and added documentation 2020-12-01 18:38:14 -08:00
Mark 237385798c
Merge branch 'main' into bus_device 2020-12-01 15:47:16 -06:00
Christian Walther 7ca36d45a4 Fix align32_size().
It not only caused crashes with requests larger than 64K (can happen with RGBMatrix), but also generated a lot longer code than necessary.
2020-11-28 17:54:34 +01:00
Christian Walther a4b84cf0e1 Use movable allocation system for RGBMatrix allocations.
Hybrid allocation is now part of the infrastructure. Moving memory contents would not be necessary because displayio can recreate them, but does not hurt.
2020-11-28 17:54:34 +01:00
Christian Walther ac91220361 Use movable allocation system for Sharp display framebuffer.
Hybrid allocation is now part of the infrastructure. Moving memory contents would not be necessary because displayio can recreate them, but does not hurt.
2020-11-28 17:54:34 +01:00
Christian Walther c7404a3ff8 Add movable allocation system.
This allows calls to `allocate_memory()` while the VM is running, it will then allocate from the GC heap (unless there is a suitable hole among the supervisor allocations), and when the VM exits and the GC heap is freed, the allocation will be moved to the bottom of the former GC heap and transformed into a proper supervisor allocation. Existing movable allocations will also be moved to defragment the supervisor heap and ensure that the next VM run gets as much memory as possible for the GC heap.

By itself this breaks terminalio because it violates the assumption that supervisor_display_move_memory() still has access to an undisturbed heap to copy the tilegrid from. It will work in many cases, but if you're unlucky you will get garbled terminal contents after exiting from the vm run that created the display. This will be fixed in the following commit, which is separate to simplify review.
2020-11-28 17:50:23 +01:00
Dan Halbert 596e0e4bd2 merge from upstream 2020-11-27 16:06:57 -05:00
Dan Halbert ef0830bfe2 merge from upstream + wip 2020-11-25 17:52:06 -05:00
James Bowman fc344bc818 Fix opcode typo in VertexFormat() 2020-11-24 17:26:39 -08:00
Scott Shawcroft 491e314799
Merge pull request #3718 from jepler/epd-rotation
EPaperDisplay: add rotation property
2020-11-23 15:04:26 -08:00
Scott Shawcroft 2463a6d6ac
Fix Palette grayscale for EInk.
It needs to do the bitmasking that was only added to ColorConverter
in #3611
2020-11-18 16:32:07 -08:00
Jeff Epler f61f8f999b EPaperDisplay: add rotation property
untested, because I don't want to mess my magtag demo up :) but it builds
2020-11-18 18:06:31 -06:00
Scott Shawcroft 78ccac930f
Add .busy property to EPaperDisplay 2020-11-13 18:57:52 -08:00
Scott Shawcroft 8d4296f964
Add board.DISPLAY to MagTag. Fix luma computation
* Initialize the EPaper display on the MagTag at start.
* Tweak the display send to take a const buffer.
* Correct Luma math
  * Multiply the blue component, not add.
  * Add all of the components together before dividing. This
    reduces the impact of truncated division.
2020-11-13 18:57:52 -08:00
gamblor21 03b110b44c Add abort check in I2C lock 2020-11-11 09:58:08 -06:00
foamyguy 46c9b28dd8 use full_change instead of moved 2020-11-09 18:14:31 -06:00
foamyguy 9adb77a2d0 set moved true when unhiding tilegrid 2020-11-08 19:28:46 -06:00
gamblor21 4c93db3595 Renamed to adafruit_bus_device 2020-11-03 18:35:20 -06:00
gamblor21 8bbbb2833a Fixes from testing SPI 2020-11-01 21:38:20 -06:00
gamblor21 78477a374a Initial SPI commit 2020-10-31 12:17:29 -05:00
Dan Halbert 144eb131ae
Merge pull request #3627 from adafruit/6.0.x
Merge 6.0.x bugfixes to main
2020-10-31 12:28:20 -04:00
gamblor21 e7da852db7 Fixing review comments 2020-10-29 16:13:03 -05:00
gamblor21 2374b0d013 Fixed whitespace issues 2020-10-27 09:13:14 -05:00
Scott Shawcroft 0d1649880f
Add grayscale EInk support 2020-10-26 16:59:59 -07:00
gamblor21 8a379830a8 Added doc and translations 2020-10-26 16:54:24 -05:00
Christian Walther 99a3750a2c Fix lost board.SPI and board.I2C after explicitly deiniting them.
After calling board.SPI().deinit(), calling board.SPI() again would return the unusable deinited object and there was no way of getting it back into an initialized state until the end of the session.
2020-10-26 22:44:38 +01:00
Christian Walther f4f80e07ca Fix lost board.SPI and board.I2C after being used by display.
Fixes #3581.

Pins were marked as never_reset by common_hal_displayio_fourwire_construct() and common_hal_sharpdisplay_framebuffer_construct(), but these marks were never removed, so at the end of a session after displayio.release_displays(), {spi|i2c}_singleton would be set to NULL but the pins would not be reset. In the next session, board.SPI() and board.I2C() were unable to reconstruct the object because the pins were still in use.

For symmetry with creation of the singleton, add deinitialization before setting it to NULL in reset_board_busses(). This makes the pins resettable, so that reset_port(), moved behind it, then resets them.
2020-10-26 22:44:38 +01:00
Christian Walther 1117edae63 Fix erroneous claim of board.I2C() by deinited display.
At the end of a session that called displayio.release_displays() (and did not initialize a new display), a board.I2C() bus that was previously used by a display would wrongly be considered still in use. While I can’t think of any unrecoverable problem this would cause in the next session, it violates the assumption that a soft reboot resets everything not needed by displays, potentially leading to confusion.

By itself, this change does not fix the problem yet - rather, it introduces the same issue as in #3581 for SPI. This needs to be solved in the same way for I2C and SPI.
2020-10-26 22:44:38 +01:00
gamblor21 12d770b427 Added __probe_for_device 2020-10-25 10:15:45 -05:00
gamblor21 b637d3911e Initial commit 2020-10-24 20:48:35 -05:00
Jeff Epler b520498c73 sharpdisplay: Re-use supervisor allocations if possible
This is enabled by #3482

I was unable to determine why previously I had added sizeof(void*)
to the GC heap allocation, so I removed that code as a mistake.
2020-10-22 12:36:12 -05:00
Jensen fc3f2a3f7f displayio: Remove trailing whitespace 2020-10-16 20:05:39 -05:00
Jensen Kuras 575b2e607b
Merge branch 'main' into color-converter-transparency 2020-10-16 19:55:24 -05:00