Merge pull request #3450 from mdroberts1243/New_quirk_for_SH1107
New quirk for sh1107
This commit is contained in:
commit
5ac3c36d64
1
.gitignore
vendored
1
.gitignore
vendored
@ -80,6 +80,7 @@ TAGS
|
||||
*.mo
|
||||
|
||||
.vscode
|
||||
.idea
|
||||
|
||||
# Python Virtual Environments
|
||||
####################
|
||||
|
@ -110,7 +110,8 @@ void board_init(void) {
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
60, // native_frames_per_second
|
||||
true); // backlight_on_high
|
||||
true, // backlight_on_high
|
||||
false); // not SH1107
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
|
@ -91,7 +91,8 @@ void board_init(void) {
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
60, // native_frames_per_second
|
||||
true); // backlight_on_high
|
||||
true, // backlight_on_high
|
||||
false); // not SH1107
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
|
@ -92,7 +92,8 @@ void board_init(void) {
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
60, // native_frames_per_second
|
||||
true); // backlight_on_high
|
||||
true, // backlight_on_high
|
||||
false); // SH1107_addressing
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
|
@ -143,7 +143,8 @@ void board_init(void) {
|
||||
false, // data_as_commands
|
||||
false, // auto_refresh
|
||||
20, // native_frames_per_second
|
||||
true); // backlight_on_high
|
||||
true, // backlight_on_high
|
||||
false); // SH1107_addressing
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
|
@ -114,7 +114,8 @@ void board_init(void) {
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
60, // native_frames_per_second
|
||||
true); // backlight_on_high
|
||||
true, // backlight_on_high
|
||||
false); // SH1107_addressing
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
|
@ -92,7 +92,8 @@ void board_init(void) {
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
60, // native_frames_per_second
|
||||
true); // backlight_on_high
|
||||
true, // backlight_on_high
|
||||
false); // SH1107_addressing
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
|
@ -114,7 +114,8 @@ void board_init(void) {
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
60, // native_frames_per_second
|
||||
true); // backlight_on_high
|
||||
true, // backlight_on_high
|
||||
false); // SH1107_addressing
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
|
@ -92,7 +92,8 @@ void board_init(void) {
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
60, // native_frames_per_second
|
||||
true); // backlight_on_high
|
||||
true, // backlight_on_high
|
||||
false); // SH1107_addressing
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
|
@ -100,7 +100,8 @@ void board_init(void) {
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
60, // native_frames_per_second
|
||||
true); // backlight_on_high
|
||||
true, // backlight_on_high
|
||||
false); // SH1107_addressing
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
|
@ -117,7 +117,8 @@ void board_init(void) {
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
60, // native_frames_per_second
|
||||
true); // backlight_on_high
|
||||
true, // backlight_on_high
|
||||
false); // SH1107_addressing
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
|
@ -109,7 +109,8 @@ void board_init(void) {
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
60, // native_frames_per_second
|
||||
true); // backlight_on_high
|
||||
true, // backlight_on_high
|
||||
false); // SH1107_addressing
|
||||
|
||||
// Enabling the Power of the 40-pin at the back
|
||||
CTR_5V.base.type = &digitalio_digitalinout_type;
|
||||
|
@ -111,7 +111,8 @@ void board_init(void) {
|
||||
false, // data as commands
|
||||
true, // auto_refresh
|
||||
60, // native_frames_per_second
|
||||
true); // backlight_on_high
|
||||
true, // backlight_on_high
|
||||
false); // SH1107_addressing
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
|
@ -91,7 +91,8 @@ void board_init(void) {
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
60, // native_frames_per_second
|
||||
true); // backlight_on_high
|
||||
true, // backlight_on_high
|
||||
false); // not SH1107
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
|
@ -92,7 +92,8 @@ void board_init(void) {
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
60, // native_frames_per_second
|
||||
true); // backlight_on_high
|
||||
true, // backlight_on_high
|
||||
false); // SH1107_addressing
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
|
@ -92,7 +92,8 @@ void board_init(void) {
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
60, // native_frames_per_second
|
||||
true); // backlight_on_high
|
||||
true, // backlight_on_high
|
||||
false); // SH1107_addressing
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
|
@ -91,7 +91,8 @@ void board_init(void) {
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
60, // native_frames_per_second
|
||||
false); // backlight_on_high
|
||||
false, // backlight_on_high
|
||||
false); // SH1107_addressing
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
|
@ -111,7 +111,8 @@ void board_init(void) {
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
60, // native_frames_per_second
|
||||
true); // backlight_on_high
|
||||
true, // backlight_on_high
|
||||
false); // SH1107_addressing
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
|
@ -105,13 +105,22 @@
|
||||
//| :param bool auto_brightness: If True, brightness is controlled via an ambient light sensor or other mechanism.
|
||||
//| :param bool single_byte_bounds: Display column and row commands use single bytes
|
||||
//| :param bool data_as_commands: Treat all init and boundary data as SPI commands. Certain displays require this.
|
||||
//| :param bool SH1107_addressing: Special quirk for SH1107, use upper/lower column set and page set
|
||||
//| :param bool auto_refresh: Automatically refresh the screen
|
||||
//| :param int native_frames_per_second: Number of display refreshes per second that occur with the given init_sequence.
|
||||
//| :param bool backlight_on_high: If True, pulling the backlight pin high turns the backlight on."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_display_bus, ARG_init_sequence, ARG_width, ARG_height, ARG_colstart, ARG_rowstart, ARG_rotation, ARG_color_depth, ARG_grayscale, ARG_pixels_in_byte_share_row, ARG_bytes_per_cell, ARG_reverse_pixels_in_byte, ARG_reverse_bytes_in_word, ARG_set_column_command, ARG_set_row_command, ARG_write_ram_command, ARG_set_vertical_scroll, ARG_backlight_pin, ARG_brightness_command, ARG_brightness, ARG_auto_brightness, ARG_single_byte_bounds, ARG_data_as_commands, ARG_auto_refresh, ARG_native_frames_per_second, ARG_backlight_on_high };
|
||||
STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_args,
|
||||
const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_display_bus, ARG_init_sequence, ARG_width, ARG_height, ARG_colstart, ARG_rowstart,
|
||||
ARG_rotation, ARG_color_depth, ARG_grayscale, ARG_pixels_in_byte_share_row,
|
||||
ARG_bytes_per_cell, ARG_reverse_pixels_in_byte, ARG_reverse_bytes_in_word,
|
||||
ARG_set_column_command, ARG_set_row_command, ARG_write_ram_command,
|
||||
ARG_set_vertical_scroll, ARG_backlight_pin, ARG_brightness_command,
|
||||
ARG_brightness, ARG_auto_brightness, ARG_single_byte_bounds, ARG_data_as_commands,
|
||||
ARG_auto_refresh, ARG_native_frames_per_second, ARG_backlight_on_high,
|
||||
ARG_SH1107_addressing };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_display_bus, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
{ MP_QSTR_init_sequence, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
@ -139,6 +148,7 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a
|
||||
{ MP_QSTR_auto_refresh, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = true} },
|
||||
{ MP_QSTR_native_frames_per_second, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 60} },
|
||||
{ MP_QSTR_backlight_on_high, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = true} },
|
||||
{ MP_QSTR_SH1107_addressing, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} }
|
||||
};
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
@ -180,7 +190,8 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a
|
||||
args[ARG_data_as_commands].u_bool,
|
||||
args[ARG_auto_refresh].u_bool,
|
||||
args[ARG_native_frames_per_second].u_int,
|
||||
args[ARG_backlight_on_high].u_bool
|
||||
args[ARG_backlight_on_high].u_bool,
|
||||
args[ARG_SH1107_addressing].u_bool
|
||||
);
|
||||
|
||||
return self;
|
||||
|
@ -45,7 +45,8 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
|
||||
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,
|
||||
bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second, bool backlight_on_high);
|
||||
bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second,
|
||||
bool backlight_on_high, bool SH1107_addressing);
|
||||
|
||||
bool common_hal_displayio_display_show(displayio_display_obj_t* self,
|
||||
displayio_group_t* root_group);
|
||||
|
@ -45,7 +45,7 @@ void render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1,
|
||||
area.y2 = y1;
|
||||
displayio_display_core_set_region_to_update(
|
||||
&display->core, display->set_column_command, display->set_row_command,
|
||||
NO_COMMAND, NO_COMMAND, display->data_as_commands, false, &area);
|
||||
NO_COMMAND, NO_COMMAND, display->data_as_commands, false, &area, display->SH1107_addressing);
|
||||
|
||||
while (!displayio_display_core_begin_transaction(&display->core)) {
|
||||
RUN_BACKGROUND_TASKS;
|
||||
|
@ -48,7 +48,9 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
|
||||
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,
|
||||
bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second, bool backlight_on_high) {
|
||||
bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second,
|
||||
bool backlight_on_high, bool SH1107_addressing) {
|
||||
|
||||
// Turn off auto-refresh as we init.
|
||||
self->auto_refresh = false;
|
||||
uint16_t ram_width = 0x100;
|
||||
@ -68,6 +70,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
|
||||
self->first_manual_refresh = !auto_refresh;
|
||||
self->data_as_commands = data_as_commands;
|
||||
self->backlight_on_high = backlight_on_high;
|
||||
self->SH1107_addressing = SH1107_addressing;
|
||||
|
||||
self->native_frames_per_second = native_frames_per_second;
|
||||
self->native_ms_per_frame = 1000 / native_frames_per_second;
|
||||
@ -240,11 +243,17 @@ STATIC bool _refresh_area(displayio_display_obj_t* self, const displayio_area_t*
|
||||
if (!displayio_display_core_clip_area(&self->core, area, &clipped)) {
|
||||
return true;
|
||||
}
|
||||
uint16_t subrectangles = 1;
|
||||
uint16_t rows_per_buffer = displayio_area_height(&clipped);
|
||||
uint8_t pixels_per_word = (sizeof(uint32_t) * 8) / self->core.colorspace.depth;
|
||||
uint16_t pixels_per_buffer = displayio_area_size(&clipped);
|
||||
if (displayio_area_size(&clipped) > buffer_size * pixels_per_word) {
|
||||
|
||||
uint16_t subrectangles = 1;
|
||||
// for SH1107 and other boundary constrained controllers
|
||||
// write one single row at a time
|
||||
if (self->SH1107_addressing) {
|
||||
subrectangles = rows_per_buffer; // vertical (column mode) write each separately (height times)
|
||||
rows_per_buffer = 1;
|
||||
} else if (displayio_area_size(&clipped) > buffer_size * pixels_per_word) {
|
||||
rows_per_buffer = buffer_size * pixels_per_word / displayio_area_width(&clipped);
|
||||
if (rows_per_buffer == 0) {
|
||||
rows_per_buffer = 1;
|
||||
@ -286,7 +295,9 @@ STATIC bool _refresh_area(displayio_display_obj_t* self, const displayio_area_t*
|
||||
}
|
||||
remaining_rows -= rows_per_buffer;
|
||||
|
||||
displayio_display_core_set_region_to_update(&self->core, self->set_column_command, self->set_row_command, NO_COMMAND, NO_COMMAND, self->data_as_commands, false, &subrectangle);
|
||||
displayio_display_core_set_region_to_update(&self->core, self->set_column_command,
|
||||
self->set_row_command, NO_COMMAND, NO_COMMAND, self->data_as_commands, false,
|
||||
&subrectangle, self->SH1107_addressing);
|
||||
|
||||
uint16_t subrectangle_size_bytes;
|
||||
if (self->core.colorspace.depth >= 8) {
|
||||
|
@ -60,6 +60,8 @@ typedef struct {
|
||||
bool auto_brightness;
|
||||
bool updating_backlight;
|
||||
bool backlight_on_high;
|
||||
// new quirk for sh1107
|
||||
bool SH1107_addressing;
|
||||
} displayio_display_obj_t;
|
||||
|
||||
void displayio_display_background(displayio_display_obj_t* self);
|
||||
|
@ -238,8 +238,11 @@ bool displayio_epaperdisplay_refresh_area(displayio_epaperdisplay_obj_t* self, c
|
||||
for (uint8_t pass = 0; pass < passes; pass++) {
|
||||
uint16_t remaining_rows = displayio_area_height(&clipped);
|
||||
|
||||
// added false parameter at end for SH1107_addressing quirk
|
||||
if (self->set_row_window_command != NO_COMMAND) {
|
||||
displayio_display_core_set_region_to_update(&self->core, self->set_column_window_command, self->set_row_window_command, self->set_current_column_command, self->set_current_row_command, false, self->chip_select, &clipped);
|
||||
displayio_display_core_set_region_to_update(&self->core, self->set_column_window_command,
|
||||
self->set_row_window_command, self->set_current_column_command, self->set_current_row_command,
|
||||
false, self->chip_select, &clipped, false);
|
||||
}
|
||||
|
||||
uint8_t write_command = self->write_black_ram_command;
|
||||
|
@ -208,7 +208,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 +256,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 +295,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) {
|
||||
|
@ -74,7 +74,10 @@ bool displayio_display_core_bus_free(displayio_display_core_t *self);
|
||||
bool displayio_display_core_begin_transaction(displayio_display_core_t* self);
|
||||
void displayio_display_core_end_transaction(displayio_display_core_t* self);
|
||||
|
||||
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);
|
||||
|
||||
void release_display_core(displayio_display_core_t* self);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user