summaryrefslogtreecommitdiff
path: root/shared-module/displayio/display_core.c
diff options
context:
space:
mode:
authorfoamyguy <foamyguy@gmail.com>2020-11-08 18:32:15 -0600
committerGitHub <noreply@github.com>2020-11-08 18:32:15 -0600
commitcf21c4da601e00a614efd8ade774a0c8e5444c64 (patch)
tree118a157edbc1884f502de8e9e26f79d178ed8c9a /shared-module/displayio/display_core.c
parent7611e71a1bc49bcb426e0854519d5143eb262a17 (diff)
parenteec9821fdc19ca81c2d0811a6b6c5909a54b8c81 (diff)
Merge pull request #1 from adafruit/main
merge from adafruit
Diffstat (limited to 'shared-module/displayio/display_core.c')
-rw-r--r--shared-module/displayio/display_core.c43
1 files changed, 39 insertions, 4 deletions
diff --git a/shared-module/displayio/display_core.c b/shared-module/displayio/display_core.c
index 43f2d1937..57d33b565 100644
--- a/shared-module/displayio/display_core.c
+++ b/shared-module/displayio/display_core.c
@@ -48,6 +48,7 @@ void displayio_display_core_construct(displayio_display_core_t* self,
uint16_t color_depth, bool grayscale, bool pixels_in_byte_share_row, uint8_t bytes_per_cell, bool reverse_pixels_in_byte, bool reverse_bytes_in_word) {
self->colorspace.depth = color_depth;
self->colorspace.grayscale = grayscale;
+ self->colorspace.grayscale_bit = 8 - color_depth;
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;
@@ -85,7 +86,10 @@ void displayio_display_core_construct(displayio_display_core_t* self,
self->bus = bus;
- supervisor_start_terminal(width, height);
+ // (offsetof core is equal in all display types)
+ if (self == &displays[0].display.core) {
+ supervisor_start_terminal(width, height);
+ }
self->width = width;
self->height = height;
@@ -197,7 +201,7 @@ bool displayio_display_core_get_dither(displayio_display_core_t* self){
}
bool displayio_display_core_bus_free(displayio_display_core_t *self) {
- return self->bus_free(self->bus);
+ return !self->bus || self->bus_free(self->bus);
}
bool displayio_display_core_begin_transaction(displayio_display_core_t* self) {
@@ -208,7 +212,10 @@ void displayio_display_core_end_transaction(displayio_display_core_t* self) {
self->end_transaction(self->bus);
}
-void displayio_display_core_set_region_to_update(displayio_display_core_t* self, uint8_t column_command, uint8_t row_command, uint16_t set_current_column_command, uint16_t set_current_row_command, bool data_as_commands, bool always_toggle_chip_select, displayio_area_t* area) {
+void displayio_display_core_set_region_to_update(displayio_display_core_t* self, uint8_t column_command,
+ uint8_t row_command, uint16_t set_current_column_command, uint16_t set_current_row_command,
+ bool data_as_commands, bool always_toggle_chip_select,
+ displayio_area_t* area, bool SH1107_addressing) {
uint16_t x1 = area->x1;
uint16_t x2 = area->x2;
uint16_t y1 = area->y1;
@@ -253,8 +260,17 @@ void displayio_display_core_set_region_to_update(displayio_display_core_t* self,
data[data_length++] = x2 >> 8;
data[data_length++] = x2 & 0xff;
}
+ // Quirk for SH1107 "SH1107_addressing"
+ // Note... column is y! page is x!
+ // Page address command = 0xB0
+ if (SH1107_addressing) {
+ // set the page to our x value
+ data[0] = 0xB0 | (x1 & 0x0F);
+ data_length = 1;
+ }
self->send(self->bus, data_type, chip_select, data, data_length);
displayio_display_core_end_transaction(self);
+
if (set_current_column_command != NO_COMMAND) {
uint8_t command = set_current_column_command;
displayio_display_core_begin_transaction(self);
@@ -283,7 +299,16 @@ void displayio_display_core_set_region_to_update(displayio_display_core_t* self,
data[data_length++] = y2 >> 8;
data[data_length++] = y2 & 0xff;
}
+ // Quirk for SH1107 "SH1107_addressing"
+ // Note... column is y! page is x!
+ // Column lower command = 0x00, Column upper command = 0x10
+ if (SH1107_addressing) {
+ data[0] = y1 & 0x0F; // 0x00 to 0x0F
+ data[1] = (y1 >> 4 & 0x0F) | 0x10; // 0x10 to 0x17
+ data_length = 2;
+ }
self->send(self->bus, data_type, chip_select, data, data_length);
+
displayio_display_core_end_transaction(self);
if (set_current_row_command != NO_COMMAND) {
@@ -295,8 +320,17 @@ void displayio_display_core_set_region_to_update(displayio_display_core_t* self,
}
}
-void displayio_display_core_start_refresh(displayio_display_core_t* self) {
+bool displayio_display_core_start_refresh(displayio_display_core_t* self) {
+ if (!displayio_display_core_bus_free(self)) {
+ // Can't acquire display bus; skip updating this display. Try next display.
+ return false;
+ }
+ if (self->refresh_in_progress) {
+ return false;
+ }
+ self->refresh_in_progress = true;
self->last_refresh = supervisor_ticks_ms64();
+ return true;
}
void displayio_display_core_finish_refresh(displayio_display_core_t* self) {
@@ -305,6 +339,7 @@ void displayio_display_core_finish_refresh(displayio_display_core_t* self) {
displayio_group_finish_refresh(self->current_group);
}
self->full_refresh = false;
+ self->refresh_in_progress = false;
self->last_refresh = supervisor_ticks_ms64();
}