summaryrefslogtreecommitdiff
path: root/shared-module/displayio/Display.c
diff options
context:
space:
mode:
authorDave Astels <dastels@daveastels.com>2019-07-31 18:46:41 -0400
committerDave Astels <dastels@daveastels.com>2019-07-31 18:46:41 -0400
commitcd092df9d875d444cf110fc0a1dbb427b261bf8a (patch)
treee0d2da5d55335a485d75cd2ada2e3d70e9fb2ccc /shared-module/displayio/Display.c
parent1f9cb44fa3a09996d042b7b9e01864bf2feac363 (diff)
parent366fdcce18e148a6828b7a7074e1e4198fca3595 (diff)
Merge remote-tracking branch 'adafruit/master' into displayio_fill_area
Diffstat (limited to 'shared-module/displayio/Display.c')
-rw-r--r--shared-module/displayio/Display.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c
index 74a96fac2..1d8014575 100644
--- a/shared-module/displayio/Display.c
+++ b/shared-module/displayio/Display.c
@@ -44,7 +44,7 @@
void common_hal_displayio_display_construct(displayio_display_obj_t* self,
mp_obj_t bus, uint16_t width, uint16_t height, int16_t colstart, int16_t rowstart, uint16_t rotation,
- uint16_t color_depth, bool grayscale, bool pixels_in_byte_share_row,
+ uint16_t color_depth, bool grayscale, bool pixels_in_byte_share_row, uint8_t bytes_per_cell, bool reverse_pixels_in_byte,
uint8_t set_column_command, uint8_t set_row_command,
uint8_t write_ram_command, uint8_t set_vertical_scroll, uint8_t* init_sequence, uint16_t init_sequence_len,
const mcu_pin_obj_t* backlight_pin, uint16_t brightness_command, mp_float_t brightness, bool auto_brightness,
@@ -52,6 +52,8 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
self->colorspace.depth = color_depth;
self->colorspace.grayscale = grayscale;
self->colorspace.pixels_in_byte_share_row = pixels_in_byte_share_row;
+ self->colorspace.bytes_per_cell = bytes_per_cell;
+ self->colorspace.reverse_pixels_in_byte = reverse_pixels_in_byte;
self->set_column_command = set_column_command;
self->set_row_command = set_row_command;
self->write_ram_command = write_ram_command;
@@ -195,17 +197,25 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
common_hal_displayio_display_show(self, &circuitpython_splash);
}
-void common_hal_displayio_display_show(displayio_display_obj_t* self, displayio_group_t* root_group) {
+bool common_hal_displayio_display_show(displayio_display_obj_t* self, displayio_group_t* root_group) {
if (root_group == NULL) {
root_group = &circuitpython_splash;
}
if (root_group == self->current_group) {
- return;
+ return true;
+ }
+ if (root_group->in_group) {
+ return false;
+ }
+ if (self->current_group != NULL) {
+ self->current_group->in_group = false;
}
displayio_group_update_transform(root_group, &self->transform);
+ root_group->in_group = true;
self->current_group = root_group;
self->full_refresh = true;
common_hal_displayio_display_refresh_soon(self);
+ return true;
}
void common_hal_displayio_display_refresh_soon(displayio_display_obj_t* self) {
@@ -303,11 +313,11 @@ void displayio_display_set_region_to_update(displayio_display_obj_t* self, displ
if (self->colorspace.depth < 8) {
uint8_t pixels_per_byte = 8 / self->colorspace.depth;
if (self->colorspace.pixels_in_byte_share_row) {
- x1 /= pixels_per_byte;
- x2 /= pixels_per_byte;
+ x1 /= pixels_per_byte * self->colorspace.bytes_per_cell;
+ x2 /= pixels_per_byte * self->colorspace.bytes_per_cell;
} else {
- y1 /= pixels_per_byte;
- y2 /= pixels_per_byte;
+ y1 /= pixels_per_byte * self->colorspace.bytes_per_cell;
+ y2 /= pixels_per_byte * self->colorspace.bytes_per_cell;
}
}
@@ -322,7 +332,6 @@ void displayio_display_set_region_to_update(displayio_display_obj_t* self, displ
if (self->single_byte_bounds) {
data[data_length++] = x1 + self->colstart;
data[data_length++] = x2 - 1 + self->colstart;
- data_length += 2;
} else {
x1 += self->colstart;
x2 += self->colstart - 1;
@@ -417,7 +426,7 @@ bool displayio_display_clip_area(displayio_display_obj_t *self, const displayio_
// Expand the area if we have multiple pixels per byte and we need to byte
// align the bounds.
if (self->colorspace.depth < 8) {
- uint8_t pixels_per_byte = 8 / self->colorspace.depth;
+ uint8_t pixels_per_byte = 8 / self->colorspace.depth * self->colorspace.bytes_per_cell;
if (self->colorspace.pixels_in_byte_share_row) {
if (clipped->x1 % pixels_per_byte != 0) {
clipped->x1 -= clipped->x1 % pixels_per_byte;