diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2020-08-25 16:39:23 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2020-08-25 16:39:23 -0700 |
| commit | 8b71e26abdd5ae2dfcd82d9f2dcb8f7179882d3f (patch) | |
| tree | a9167d237c97818596b554a67a2d3b60a305b566 /shared-module/displayio | |
| parent | 380cbfba55e45f9f0d8ccae6c28c23b1ea93147f (diff) | |
| parent | 78c512e86b5c61d337e10cb5ec598cecd728c5f6 (diff) | |
Merge remote-tracking branch 'adafruit/main' into native_wifi
Diffstat (limited to 'shared-module/displayio')
| -rw-r--r-- | shared-module/displayio/Bitmap.c | 26 | ||||
| -rw-r--r-- | shared-module/displayio/Display.c | 16 | ||||
| -rw-r--r-- | shared-module/displayio/Display.h | 8 | ||||
| -rw-r--r-- | shared-module/displayio/__init__.c | 4 |
4 files changed, 40 insertions, 14 deletions
diff --git a/shared-module/displayio/Bitmap.c b/shared-module/displayio/Bitmap.c index 8bcda6086..d1942efc7 100644 --- a/shared-module/displayio/Bitmap.c +++ b/shared-module/displayio/Bitmap.c @@ -105,6 +105,32 @@ uint32_t common_hal_displayio_bitmap_get_pixel(displayio_bitmap_t *self, int16_t return 0; } +void common_hal_displayio_bitmap_blit(displayio_bitmap_t *self, int16_t x, int16_t y, displayio_bitmap_t *source, + int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint32_t skip_index, bool skip_index_none) { + // Copy complete "source" bitmap into "self" bitmap at location x,y in the "self" + // Add a boolean to determine if all values are copied, or only if non-zero + // If skip_value is encountered in the source bitmap, it will not be copied. + // If skip_value is `None`, then all pixels are copied. + + if (self->read_only) { + mp_raise_RuntimeError(translate("Read-only object")); + } + + // simplest version - use internal functions for get/set pixels + for (int16_t i=0; i < (x2-x1) ; i++) { + if ( (x+i >= 0) && (x+i < self->width) ) { + for (int16_t j=0; j < (y2-y1) ; j++){ + if ((y+j >= 0) && (y+j < self->height) ) { + uint32_t value = common_hal_displayio_bitmap_get_pixel(source, x1+i, y1+j); + if ( (skip_index_none) || (value != skip_index) ) { // write if skip_value_none is True + common_hal_displayio_bitmap_set_pixel(self, x+i, y+j, value); + } + } + } + } + } +} + void common_hal_displayio_bitmap_set_pixel(displayio_bitmap_t *self, int16_t x, int16_t y, uint32_t value) { if (self->read_only) { mp_raise_RuntimeError(translate("Read-only object")); diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index 46bb6fdb5..4f92f249f 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -111,14 +111,14 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, if (backlight_pin != NULL && common_hal_mcu_pin_is_free(backlight_pin)) { // Avoid PWM types and functions when the module isn't enabled #if (CIRCUITPY_PULSEIO) - pwmout_result_t result = common_hal_pulseio_pwmout_construct(&self->backlight_pwm, backlight_pin, 0, 50000, false); + pwmout_result_t result = common_hal_pwmio_pwmout_construct(&self->backlight_pwm, backlight_pin, 0, 50000, false); if (result != PWMOUT_OK) { self->backlight_inout.base.type = &digitalio_digitalinout_type; common_hal_digitalio_digitalinout_construct(&self->backlight_inout, backlight_pin); common_hal_never_reset_pin(backlight_pin); } else { - self->backlight_pwm.base.type = &pulseio_pwmout_type; - common_hal_pulseio_pwmout_never_reset(&self->backlight_pwm); + self->backlight_pwm.base.type = &pwmio_pwmout_type; + common_hal_pwmio_pwmout_never_reset(&self->backlight_pwm); } #else // Otherwise default to digital @@ -173,14 +173,14 @@ bool common_hal_displayio_display_set_brightness(displayio_display_obj_t* self, // Avoid PWM types and functions when the module isn't enabled #if (CIRCUITPY_PULSEIO) - bool ispwm = (self->backlight_pwm.base.type == &pulseio_pwmout_type) ? true : false; + bool ispwm = (self->backlight_pwm.base.type == &pwmio_pwmout_type) ? true : false; #else bool ispwm = false; #endif if (ispwm) { #if (CIRCUITPY_PULSEIO) - common_hal_pulseio_pwmout_set_duty_cycle(&self->backlight_pwm, (uint16_t) (0xffff * brightness)); + common_hal_pwmio_pwmout_set_duty_cycle(&self->backlight_pwm, (uint16_t) (0xffff * brightness)); ok = true; #else ok = false; @@ -419,9 +419,9 @@ void release_display(displayio_display_obj_t* self) { common_hal_displayio_display_set_auto_refresh(self, false); release_display_core(&self->core); #if (CIRCUITPY_PULSEIO) - if (self->backlight_pwm.base.type == &pulseio_pwmout_type) { - common_hal_pulseio_pwmout_reset_ok(&self->backlight_pwm); - common_hal_pulseio_pwmout_deinit(&self->backlight_pwm); + if (self->backlight_pwm.base.type == &pwmio_pwmout_type) { + common_hal_pwmio_pwmout_reset_ok(&self->backlight_pwm); + common_hal_pwmio_pwmout_deinit(&self->backlight_pwm); } else if (self->backlight_inout.base.type == &digitalio_digitalinout_type) { common_hal_digitalio_digitalinout_deinit(&self->backlight_inout); } diff --git a/shared-module/displayio/Display.h b/shared-module/displayio/Display.h index 861a38fd7..bdb861aa0 100644 --- a/shared-module/displayio/Display.h +++ b/shared-module/displayio/Display.h @@ -29,8 +29,8 @@ #include "shared-bindings/digitalio/DigitalInOut.h" #include "shared-bindings/displayio/Group.h" -#if CIRCUITPY_PULSEIO -#include "shared-bindings/pulseio/PWMOut.h" +#if CIRCUITPY_PWMIO +#include "shared-bindings/pwmio/PWMOut.h" #endif #include "shared-module/displayio/area.h" @@ -41,8 +41,8 @@ typedef struct { displayio_display_core_t core; union { digitalio_digitalinout_obj_t backlight_inout; - #if CIRCUITPY_PULSEIO - pulseio_pwmout_obj_t backlight_pwm; + #if CIRCUITPY_PWMIO + pwmio_pwmout_obj_t backlight_pwm; #endif }; uint64_t last_backlight_refresh; diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c index 4a6428ea0..101dac4b3 100644 --- a/shared-module/displayio/__init__.c +++ b/shared-module/displayio/__init__.c @@ -394,8 +394,8 @@ primary_display_t *allocate_display_or_raise(void) { } primary_display_t *allocate_display_bus(void) { for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { - mp_const_obj_t display_type = displays[i].display.base.type; - if (display_type == NULL || display_type == &mp_type_NoneType) { + mp_const_obj_t display_bus_type = displays[i].bus_base.type; + if (display_bus_type == NULL || display_bus_type == &mp_type_NoneType) { return &displays[i]; } } |
