Skip to content

Commit ae8347f

Browse files
committed
add error msg for SH1107 fix
1 parent b292a92 commit ae8347f

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

locale/circuitpython.pot

Lines changed: 5 additions & 1 deletion
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 ""
@@ -623,7 +627,7 @@ msgstr ""
623627
msgid "Buffer length must be a multiple of 512"
624628
msgstr ""
625629

626-
#: ports/stm/common-hal/sdioio/SDCard.c
630+
#: ports/stm/common-hal/sdioio/SDCard.c shared-bindings/floppyio/__init__.c
627631
msgid "Buffer must be a multiple of 512 bytes"
628632
msgstr ""
629633

shared-bindings/displayio/Display.c

Lines changed: 8 additions & 2 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;
175181

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;

0 commit comments

Comments
 (0)