Skip to content

Commit 936f5bf

Browse files
authored
Merge pull request #6338 from jepler/fix-display-invalid-sh1107
Fix display invalid sh1107
2 parents 64ca3aa + 28b14e0 commit 936f5bf

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

locale/circuitpython.pot

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ msgstr ""
107107
msgid "%q must be %d-%d"
108108
msgstr ""
109109

110+
#: shared-bindings/displayio/Display.c
111+
msgid "%q must be 1 when %q is True"
112+
msgstr ""
113+
110114
#: py/argcheck.c shared-bindings/gifio/GifWriter.c
111115
msgid "%q must be <= %d"
112116
msgstr ""

ports/stm/boards/thunderpack_v12/mpconfigboard.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ EXTERNAL_FLASH_DEVICES = GD25Q16C
1414
CIRCUITPY_NVM = 1
1515
CIRCUITPY_BITMAPTOOLS = 0
1616
CIRCUITPY_BLEIO_HCI = 0
17+
CIRCUITPY_ONEWIREIO = 0
1718
CIRCUITPY_ZLIB = 0
1819

1920
MCU_SERIES = F4

shared-bindings/displayio/Display.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,20 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a
170170
mp_raise_ValueError(translate("Display rotation must be in 90 degree increments"));
171171
}
172172

173+
const bool sh1107_addressing = args[ARG_SH1107_addressing].u_bool;
174+
const mp_int_t color_depth = args[ARG_color_depth].u_int;
175+
if (sh1107_addressing && color_depth != 1) {
176+
mp_raise_ValueError_varg(translate("%q must be 1 when %q is True"), MP_QSTR_color_depth, MP_QSTR_SH1107_addressing);
177+
}
178+
173179
primary_display_t *disp = allocate_display_or_raise();
174180
displayio_display_obj_t *self = &disp->display;
175-
;
181+
176182
self->base.type = &displayio_display_type;
177183
common_hal_displayio_display_construct(
178184
self,
179185
display_bus, args[ARG_width].u_int, args[ARG_height].u_int, args[ARG_colstart].u_int, args[ARG_rowstart].u_int, rotation,
180-
args[ARG_color_depth].u_int, args[ARG_grayscale].u_bool,
186+
color_depth, args[ARG_grayscale].u_bool,
181187
args[ARG_pixels_in_byte_share_row].u_bool,
182188
args[ARG_bytes_per_cell].u_bool,
183189
args[ARG_reverse_pixels_in_byte].u_bool,
@@ -194,7 +200,7 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a
194200
args[ARG_auto_refresh].u_bool,
195201
args[ARG_native_frames_per_second].u_int,
196202
args[ARG_backlight_on_high].u_bool,
197-
args[ARG_SH1107_addressing].u_bool
203+
sh1107_addressing
198204
);
199205

200206
return self;

shared-module/displayio/Display.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t *self,
7474
self->first_manual_refresh = !auto_refresh;
7575
self->data_as_commands = data_as_commands;
7676
self->backlight_on_high = backlight_on_high;
77-
self->SH1107_addressing = SH1107_addressing;
77+
self->SH1107_addressing = SH1107_addressing && color_depth == 1;
7878

7979
self->native_frames_per_second = native_frames_per_second;
8080
self->native_ms_per_frame = 1000 / native_frames_per_second;

0 commit comments

Comments
 (0)