Commit Graph

289 Commits

Author SHA1 Message Date
Tsutomu IKEGAMI 72c4a5a523 Fix coordinate conversion algorithm of partial refresh area in displayio.TileGrid 2021-06-10 11:47:51 +09:00
lady ada 467a4e7664 fix comment 2021-06-07 19:51:57 -04:00
lady ada b39dd84560 move the col/row offsets to the top so oleds can take advantage of em 2021-06-07 19:43:49 -04:00
lady ada 2ff9e9766f handclang 2021-06-07 12:39:59 -04:00
lady ada 8f1c25c8ae fix SH110x mode, the SH1107 is actually column not row mode BUT the SD1107 module we use is vertical orientation (confusing!) so row/col are NOT swapped. we will have to fix the SH1107 driver to match. this fix required for SH1106 (which uses the same page mode commands but ISNT rotated) 2021-06-06 18:25:40 -04:00
Scott Shawcroft 6ee9acc900
Merge pull request #4755 from jepler/esp32s2-protomatter
Esp32s2 protomatter
2021-06-01 13:32:34 -07:00
Jeff Epler 9df8f235b1 OnDiskBitmap: INCOMPATIBLE CHANGE: Allow them to use palettes
Before, when an OnDiskBitmap was a paletted bitmap type, the palette
was internal to the OnDiskBitmap, and it internally performed the palette
conversion itself.  When using with a tilegrid, a ColorConverter() object
always had to be passed.

Now, an OnDiskBitmap has a "pixel_shader" property.  If the bitmap is
a paletted bitmap type, it is a (modifiable) Palette object.  Otherwise,
it is a ColorConverter() object as before. This allows palette effects
to be applied to paletted OnDiskBitmaps.

Code that used to say:
```python
face = displayio.TileGrid(odb, pixel_shader=displayio.ColorConverter())
```
must be updated to say:
```python
face = displayio.TileGrid(odb, pixel_shader=odb.pixel_shader)
```

Compatible code for 6.x and 7.x can say
```python
face = displayio.TileGrid(odb, pixel_shader=getattr(odb, 'pixel_shader', ColorConverter())
```
2021-05-28 10:53:21 -05:00
Jeff Epler 0d7f257eae displayio: Pause rgbmatrix during soft-reset
We can't handle rgbmatrix's interrupts from here until the display is
reinitialized, so set the display as paused.

With this change, I can survive multiple cycles with wifi+rgbmatrix
on an esp32s2.  Before, it usually failed.
2021-05-26 11:18:02 -05:00
Scott Shawcroft 1a0b4193b7
Simplify the status LED to save power
This also removes the need to pin share because we don't use the
status LED while user code is running.

The status flashes fallback to the HW_STATUS LED if no RGB LED is
present. Each status has a unique blink pattern as well.

One caveat is the REPL state. In order to not pin share, we set the
RGB color once. PWM and single color will be shutoff immediately but
DotStars and NeoPixels will hold the color until the user overrides
it.

Fixes #4133
2021-05-13 14:41:20 -07:00
Scott Shawcroft e02a26453c
Merge MicroPython 1.14 into CircuitPython 2021-05-11 15:07:40 -07:00
Scott Shawcroft 3fda0c0a1b
Fix board builds and use MP_ERROR_TEXT in py and extmod 2021-05-05 17:51:52 -07:00
Scott Shawcroft 17fcd499b2
Merge pull request #4649 from tannewt/merge_1.11_2
Merge MicroPython v1.11 into CircuitPython
2021-04-27 11:02:02 -07:00
Scott Shawcroft 76033d5115
Merge MicroPython v1.11 into CircuitPython 2021-04-26 15:47:41 -07:00
Jeff Epler 76d68f21ac displayio: Add RGB555/565/_SWAPPED format support
This is helpful when displaying frames from an OV7670 camera, which
uses the RGB565_SWAPPED format internally.
2021-04-19 10:23:47 -05:00
Jeff Epler 78089107bc displayio.Bitmap: Allow modification though the buffer protocol
It is required to call .dirty() with appropriate arguments after modifications through the buffer protocol, or the display might not be updated correctly.
2021-04-03 10:41:20 -05:00
Kevin Matocha 9485805b6a move to displayio_area_union and away from _expand 2021-03-25 11:21:39 -05:00
Kevin Matocha 24831a79d3 update logic for transform_xy 2021-03-22 16:38:56 -05:00
Jeff Epler e084a92671
Merge pull request #4432 from jepler/bitmap-dirty-improvements
Bitmap dirty improvements
2021-03-20 13:09:59 -05:00
Kevin Matocha 40829d4cc8 switch to > in displayio_area_canon 2021-03-19 20:30:37 -05:00
Dan Halbert 1512ca520b Fix PWMOut non-error handling and never reset 2021-03-19 09:57:21 -04:00
Jeff Epler 623ece2c73
Merge pull request #4429 from jepler/displayio-bitmap-memoryview
displayio.Bitmap: Make memoryview()able
2021-03-18 18:38:25 -05:00
Jeff Epler f5fd42c393 displayio: Move bitmap read-only checking to displayio_bitmap_set_dirty_area
This is a modest code savings, but more importantly it reduces
boilerplate in bitmap-modifying routines.

Callers need only ensure they call displayio_bitmap_set_dirty_area in
advance of the bitmap modifications they perform.

(note that this assumes that no bitmap operation can enter background
tasks. If an operation COULD enter background tasks, it MUST re-dirty
the area it touches when it exits, simply by a fresh call to
set_dirty_area with the same area as before)
2021-03-18 09:20:56 -05:00
Jeff Epler 36d608aa67 displayio_bitmap_set_dirty_area: rewrite in terms of displayio_area
.. simplifying code in the process.  For instance, now fill_region
uses area routines to order and constrain its coordinates.

Happily, this change also frees a modest amount of code space.
2021-03-18 09:20:56 -05:00
Jeff Epler 3b506f0fa5 displayio: area: add displayio_area_canon
This routine will be used to simplify code that deals with ranges
of bitmap coordinates.
2021-03-18 09:06:00 -05:00
Jeff Epler f40c0c13ad displayio: area: add displayo_area_copy_coords, displayio_area_empty
.. and simplify the implmentation of displayio_area_union

This _slightly_ changes the behavior of displayio_area_union:

Formerly, if one of the areas was empty, its coordinates were still
used in the min/max calculations.

Now, if one of the areas is empty, the result gets the other area's coords

In particular, taking the union of the empty area with coords (0,0,0,0)
with the non-empty area (x1,y1,x2,y2) would give the area (0,0,x2,y2)
before, and (x1,y1,x2,y2) after the change.
2021-03-18 09:05:07 -05:00
Jeff Epler c157ada90c displayio.Bitmap: Make memoryview()able 2021-03-17 16:26:45 -05:00
Kevin Matocha 5c3cce6f5d add is_transparent getter to displayio.Palette 2021-03-16 20:43:23 -05:00
microDev a52eb88031
run code formatting script 2021-03-15 19:27:36 +05:30
Kevin Matocha 85f0f07d51 add fill_region and draw_line to bitmaptools 2021-03-10 11:37:27 -06:00
Kevin Matocha 0c012da080 refactor displayio set_pixel for use in bitmap_tools 2021-03-07 11:22:30 -06:00
Dan Halbert d1184e7e94 Be cognizant of null transform for .transpose_xy 2021-03-04 14:40:50 -05:00
Dan Halbert 29575ee439 use self->members in displayio_group_set() 2021-03-03 17:36:48 -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
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
Kevin Matocha 4097c949a3 Update for clean blitting into itself 2021-02-25 14:16:40 -06:00
microDev dc332baa87
update common_hal_reset_pin() 2020-12-28 20:04:00 +05:30
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 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
foamyguy 46c9b28dd8 use full_change instead of moved 2020-11-09 18:14:31 -06:00