summaryrefslogtreecommitdiff
path: root/shared-module
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2019-04-05 16:07:17 -0400
committerGitHub <noreply@github.com>2019-04-05 16:07:17 -0400
commitdf058c971fe37b2f7f3214eea952b4a5c2b8d442 (patch)
tree60b98205e5d92d77ca1667d9c9727868854ebdc6 /shared-module
parentb9e37818ea9fb87847d84d0255180b799405ad4c (diff)
parent36b10104d62b6a2d195a8e0a32b936fd290f4dd5 (diff)
Merge pull request #1751 from makermelissa/ssd1331
Allow parameter data to be treated as commands for the ssd1331
Diffstat (limited to 'shared-module')
-rw-r--r--shared-module/displayio/Display.c25
-rw-r--r--shared-module/displayio/Display.h1
2 files changed, 19 insertions, 7 deletions
diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c
index eccb2d0ef..28df062f8 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, 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, bool single_byte_bounds) {
+ const mcu_pin_obj_t* backlight_pin, bool single_byte_bounds, bool data_as_commands) {
self->color_depth = color_depth;
self->set_column_command = set_column_command;
self->set_row_command = set_row_command;
@@ -54,6 +54,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
self->colstart = colstart;
self->rowstart = rowstart;
self->auto_brightness = false;
+ self->data_as_commands = data_as_commands;
self->single_byte_bounds = single_byte_bounds;
if (MP_OBJ_IS_TYPE(bus, &displayio_parallelbus_type)) {
@@ -82,7 +83,14 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
data_size &= ~DELAY;
uint8_t *data = cmd + 2;
self->send(self->bus, true, cmd, 1);
- self->send(self->bus, false, data, data_size);
+ if (self->data_as_commands) {
+ // Loop through each parameter to force a CS toggle
+ for (uint32_t j=0; j < data_size; j++) {
+ self->send(self->bus, true, data + j, 1);
+ }
+ } else {
+ self->send(self->bus, false, data, data_size);
+ }
uint16_t delay_length_ms = 10;
if (delay) {
data_size++;
@@ -214,30 +222,33 @@ void displayio_display_end_transaction(displayio_display_obj_t* self) {
void displayio_display_set_region_to_update(displayio_display_obj_t* self, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) {
self->send(self->bus, true, &self->set_column_command, 1);
+ bool isCommand = self->data_as_commands;
if (self->single_byte_bounds) {
uint8_t data[2];
data[0] = x0 + self->colstart;
data[1] = x1 - 1 + self->colstart;
- self->send(self->bus, false, (uint8_t*) data, 2);
+ self->send(self->bus, isCommand, (uint8_t*) data, 2);
} else {
uint16_t data[2];
data[0] = __builtin_bswap16(x0 + self->colstart);
data[1] = __builtin_bswap16(x1 - 1 + self->colstart);
- self->send(self->bus, false, (uint8_t*) data, 4);
+ self->send(self->bus, isCommand, (uint8_t*) data, 4);
}
self->send(self->bus, true, &self->set_row_command, 1);
if (self->single_byte_bounds) {
uint8_t data[2];
data[0] = y0 + self->rowstart;
data[1] = y1 - 1 + self->rowstart;
- self->send(self->bus, false, (uint8_t*) data, 2);
+ self->send(self->bus, isCommand, (uint8_t*) data, 2);
} else {
uint16_t data[2];
data[0] = __builtin_bswap16(y0 + self->rowstart);
data[1] = __builtin_bswap16(y1 - 1 + self->rowstart);
- self->send(self->bus, false, (uint8_t*) data, 4);
+ self->send(self->bus, isCommand, (uint8_t*) data, 4);
+ }
+ if (!self->data_as_commands) {
+ self->send(self->bus, true, &self->write_ram_command, 1);
}
- self->send(self->bus, true, &self->write_ram_command, 1);
}
bool displayio_display_frame_queued(displayio_display_obj_t* self) {
diff --git a/shared-module/displayio/Display.h b/shared-module/displayio/Display.h
index 4ccae37bf..52f98a252 100644
--- a/shared-module/displayio/Display.h
+++ b/shared-module/displayio/Display.h
@@ -50,6 +50,7 @@ typedef struct {
int16_t colstart;
int16_t rowstart;
bool single_byte_bounds;
+ bool data_as_commands;
display_bus_begin_transaction begin_transaction;
display_bus_send send;
display_bus_end_transaction end_transaction;