Commit Graph

322 Commits

Author SHA1 Message Date
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
foamyguy 9adb77a2d0 set moved true when unhiding tilegrid 2020-11-08 19:28:46 -06:00
Scott Shawcroft 0d1649880f
Add grayscale EInk support 2020-10-26 16:59:59 -07: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
Jensen 74c07a4bdc displayio: Add in opaque pixel option for future 2020-10-16 19:50:41 -05:00
Jeff Epler 88d07ef35b displayio: further ensure just one start_terminal call
@cwalther determined that for boards with 2 displays (monster m4sk),
start_terminal would be called for each one, leaking supervisor heap
entries.

Determine, by comparing addresses, whether the display being acted on
is the first display (number zero) and do (or do not) call start_terminal.

stop_terminal can safely be called multiple times, so there's no need
to guard against calling it more than once.

Slight behavioral change: The terminal size would follow the displays[0]
size, not the displays[1] size
2020-10-15 15:24:19 -05:00
Jensen 3c5a08628a Merge branch 'color-converter-transparency' of github.com:jensechu/circuitpython into color-converter-transparency 2020-10-14 21:52:49 -05:00
Jensen 2517e4b486 displayio: ColorConverter handle if opaque color is black 2020-10-14 21:51:40 -05:00
Jensen Kuras de9ea47e8e
Merge branch 'main' into color-converter-transparency 2020-10-12 20:48:55 -05:00
Jensen 337019626a displayio: Add make_transparent to ColorConverter 2020-10-12 20:48:04 -05:00
Jensen b359e2945a displayio: Add make_transparent and make_opaque to ColorConvertor 2020-10-12 20:48:04 -05:00
Jensen 57b44928a3 displayio: Pass transparent_color to ColorConverter
Signed-off-by: Jensen <jensechu@gmail.com>
2020-10-12 20:48:04 -05:00
Jeff Epler 774f2e16ba displayio, framebufferio: Remove spurious call to supervisor_start_terminal
A call to supervisor_start_terminal remained in
common_hal_displayio_display_construct and was copied to other display
_construct functions, even though it was also being done in
displayio_display_core_construct when that was factored out.

Originally, this was harmless, except it created an extra allocation.
When investigating #3482, I found that this bug became harmful,
especially for displays that were created in Python code, because it
caused a supervisor allocation to leak.

I believe that it is safe to merge #3482 after this PR is merged.
2020-10-11 21:09:08 -05:00
Limor "Ladyada" Fried 9535edb8f4
Merge pull request #3507 from jepler/issue3506-matrixportal-crash
displayio: Fix matrixportal crash
2020-10-02 22:16:32 -04:00
Jeff Epler b1592564b2 displayio: Fix matrixportal crash
An RGBMatrix has no bus and no bus_free method.  It is always possible
to refresh the display.

This was not a problem before, but the fix I suggested (#3449) added
a call to core_bus_free when a FramebufferDisplay was being refreshed.
This was not caught during testing.

This is a band-aid fix and it brings to light a second problem in which
a SharpDisplay + FrameBuffer will not have a 'bus' object, and yet does
operate using a shared SPI bus.  This kind of display will need a
"bus-free" like function to be added, or it can have problems like
#3309.
2020-10-02 15:07:36 -05:00
Scott Shawcroft be6e6eabd2
Merge pull request #3449 from FoamyGuy/sdcard_odb_fix
Sdcard odb fix
2020-10-01 10:13:13 -07:00
FoamyGuy 422a7d4013 remove remaining top level displayio background check 2020-09-30 17:25:58 -05:00
FoamyGuy d1bda47d94 removing top level displayio background check 2020-09-30 14:03:03 -05:00
Mark Roberts ef245ef54e
Removed redundant subrectangle sizing code 2020-09-30 11:06:13 -07:00
Mark Roberts 9f19a8a760
Ran pre-commit locally 2020-09-30 11:06:13 -07:00
mdroberts1243 b1e1237887
Merge branch 'main' into New_quirk_for_SH1107 2020-09-28 19:40:47 -04:00
Mark Roberts b921543571 Requested changes take 1 2020-09-25 21:27:29 -04:00
Mark Roberts 19dbff67f2 Fixed page set mask to be four bits! 2020-09-25 00:26:39 -04:00
Mark Roberts 06a3d15266 Mostly-working-version with comments 2020-09-24 22:07:33 -04:00
Mark Roberts 5a176c2c67 Removed redundant send of page setting 2020-09-22 13:41:25 -04:00
root dbf8a9ad69 Changed delay calls to avoid conflicts with qspi_disable 2020-09-22 10:25:31 -05:00
Mark Roberts 5536e574db Changes to compile cleanly 2020-09-21 22:08:16 -04:00
Mark Roberts 08189edf24 Quirk coded up for ...set_region_to_update 2020-09-21 21:07:42 -04:00
FoamyGuy ff1a90a9c3 Merge branch 'adafruit_main' into sdcard_odb_fix 2020-09-21 17:58:05 -05:00
Mark Roberts f21dc253e0 Initial commit bool column_and_page_addressing 2020-09-21 18:42:16 -04:00
Lucian Copeland e504438fd2 Remove unlicensed file, fix reset pin type check 2020-09-14 11:58:13 -04:00
Lucian Copeland ecc219fe50 Merge remote-tracking branch 'upstream/main' into esp32-displayio-fix 2020-09-14 10:44:31 -04:00
FoamyGuy e114b5ab54 fixes showing OnDiskBitmap with adafruit_sdcard 2020-09-11 21:37:00 -05:00
Kevin Matocha 37e85aebd2 Fix off-by-one error, simplify the logic, add comments 2020-09-10 21:34:03 -05:00
Lucian Copeland f95ad7b27c Fix reset pin null reference, construct error null reference 2020-09-10 15:37:43 -04:00
Kevin Matocha d600759bc8 Utilize MIN and MAX functions from py/misc.h 2020-09-08 20:02:34 -05:00
Kevin Matocha 297b7195b0 Delete unnecessary comment 2020-09-04 22:03:57 -05:00
Kevin Matocha 95db456a7e Add final newline 2020-09-04 14:23:53 -05:00
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
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
Scott Shawcroft 1527a3ce92
Merge remote-tracking branch 'adafruit/main' into add_pwmio 2020-08-24 18:25:18 -07:00
Kevin Matocha a9f6d147c4 Merge adafruit/main latest 2020-08-21 14:37:32 -05:00
Kevin Matocha 7e529ed4c5 Merge with latest adafruit/main 2020-08-21 14:28:24 -05:00
Kevin Matocha 3753ea3cd8 Merge remote-tracking branch 'source/main' into main 2020-08-21 14:19:58 -05:00
Kevin Matocha 24ca133396 Updating main to adafruit/main 2020-08-21 14:19:28 -05:00
Scott Shawcroft 5771be9510
Merge pull request #3292 from jepler/allocate_display_bus_bug
allocate_display_bus: fix bug where in-use bus would be returned
2020-08-21 11:19:50 -07:00
Scott Shawcroft 6857f98426
Split pulseio.PWMOut into pwmio
This gives us better granularity when implementing new ports because
PWMOut is commonly implemented before PulseIn and PulseOut.

Fixes #3211
2020-08-18 13:08:33 -07:00
Jeff Epler f2f18da189 Fix build error for !SHARPDISPLAY 2020-08-18 10:59:55 -05:00
Jeff Epler 0bec39118f displayio: Don't need to specialcase reset of sharpdisplay framebuffer
.. for the case where the bus was not in use
2020-08-18 09:32:28 -05:00
Jeff Epler 6d2d36db3d Finish implementing scott's suggestion 2020-08-17 21:09:21 -05:00
Jeff Epler 6425a411ca
Update shared-module/displayio/__init__.c
Co-authored-by: Scott Shawcroft <scott@tannewt.org>
2020-08-17 21:07:24 -05:00
Jeff Epler 1ccd2e234f allocate_display_bus: fix bug where in-use bus would be returned 2020-08-17 10:48:23 -05:00
Kevin Matocha fc1347ac2a deleted whitespace 2020-08-14 13:37:06 -05:00
Kevin Matocha ba5dedc1df deleted whitespace 2020-08-14 13:37:06 -05:00
Kevin Matocha b1fce9e933 Deleted trailing whitespace 2020-08-14 13:36:59 -05:00
Kevin Matocha a66ef32da2 Added inclusive indexing for x2,y2, fixed default value handling for x1,y1, added bitmap palette comparison 2020-08-14 13:15:01 -05:00
Margaret Matocha 824f47d6e9 Added bitmap.blit function for bitmap slice copy 2020-08-14 12:59:57 -05:00
Margaret Matocha 4ba9ff892c Added bitmap.blit function for copying slices of bitmaps 2020-08-14 12:59:48 -05:00
Jeff Epler 759ded9c38 Fix build errors when SHARPDISPLAY && !RGBMATRIX 2020-08-12 07:39:12 -05:00
Jeff Epler c1400bae9b sharpmemory: Implement support for Sharp Memory Displays in framebufferio 2020-08-12 07:32:18 -05:00
Margaret Matocha b6008d0032 Adding bitmap.insert to copy a slice of a source bitmap into another bitmap 2020-08-07 15:59:42 -05:00
Margaret Matocha 64c9baa6aa Added bitmap.insert function for slice copy into a bitmap from another bitmap 2020-08-07 15:46:00 -05:00
Jeff Epler c243c13f02 framebufferio: Handle auto refresh flag at reset
if we don't set the flag via accessor fn the tick enable might become wrong
2020-07-20 08:52:35 -05:00
Jeff Epler af520729fe displayio, framebufferio: Enable supervisor tick when a display is auto-refresh
This is a step towards restoring the efficiency of the background
tasks
2020-07-15 09:26:47 -05:00
Jeff Epler fcddfd0f39
Merge pull request #3083 from tannewt/esp32s2_busio
Add busio support for the ESP32-S2
2020-07-01 21:02:08 -05:00
Scott Shawcroft ed6e81d688
Switch SPI to polling DMA and enable displayio 2020-06-24 13:10:08 -07:00