Skip to content

Commit 71638ad

Browse files
committed
Refactor resolution checking
1 parent 98cc153 commit 71638ad

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

locale/circuitpython.pot

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,11 +1202,14 @@ msgstr ""
12021202
msgid "Invalid %q"
12031203
msgstr ""
12041204

1205-
#: ports/raspberrypi/common-hal/picodvi/Framebuffer_RP2350.c
12061205
#: shared-module/aurora_epaper/aurora_framebuffer.c
12071206
msgid "Invalid %q and %q"
12081207
msgstr ""
12091208

1209+
#: ports/raspberrypi/common-hal/picodvi/Framebuffer_RP2350.c
1210+
msgid "Invalid %q and %q for color depth %d"
1211+
msgstr ""
1212+
12101213
#: ports/atmel-samd/common-hal/microcontroller/Pin.c
12111214
#: ports/espressif/common-hal/dotclockframebuffer/DotClockFramebuffer.c
12121215
#: ports/mimxrt10xx/common-hal/microcontroller/Pin.c
@@ -1274,6 +1277,7 @@ msgid "Invalid socket for TLS"
12741277
msgstr ""
12751278

12761279
#: ports/espressif/common-hal/espidf/__init__.c
1280+
#: ports/nordic/common-hal/_bleio/__init__.c
12771281
msgid "Invalid state"
12781282
msgstr ""
12791283

@@ -1970,7 +1974,8 @@ msgstr ""
19701974
msgid "The length of rgb_pins must be 6, 12, 18, 24, or 30"
19711975
msgstr ""
19721976

1973-
#: shared-module/audiodelays/Echo.c shared-module/audiomixer/MixerVoice.c
1977+
#: shared-module/audiodelays/Echo.c shared-module/audiofilters/Filter.c
1978+
#: shared-module/audiomixer/MixerVoice.c
19741979
msgid "The sample's %q does not match"
19751980
msgstr ""
19761981

@@ -2504,7 +2509,8 @@ msgstr ""
25042509
msgid "bits must be 32 or less"
25052510
msgstr ""
25062511

2507-
#: shared-bindings/audiodelays/Echo.c shared-bindings/audiomixer/Mixer.c
2512+
#: shared-bindings/audiodelays/Echo.c shared-bindings/audiofilters/Filter.c
2513+
#: shared-bindings/audiomixer/Mixer.c
25082514
msgid "bits_per_sample must be 8 or 16"
25092515
msgstr ""
25102516

ports/raspberrypi/common-hal/picodvi/Framebuffer_RP2350.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ static void __not_in_flash_func(dma_irq_handler)(void) {
129129
ch->al3_read_addr_trig = (uintptr_t)active_picodvi->dma_commands;
130130
}
131131

132+
static void mode_ok(mp_uint_t width, mp_uint_t height, mp_uint_t color_depth) {
133+
if (width == 640 && height == 480 && (color_depth < 8)) {
134+
return true;
135+
}
136+
if (width == 320 && height == 240 )
137+
return true;
138+
}
139+
return false;
140+
}
141+
132142
void common_hal_picodvi_framebuffer_construct(picodvi_framebuffer_obj_t *self,
133143
mp_uint_t width, mp_uint_t height,
134144
const mcu_pin_obj_t *clk_dp, const mcu_pin_obj_t *clk_dn,
@@ -140,8 +150,8 @@ void common_hal_picodvi_framebuffer_construct(picodvi_framebuffer_obj_t *self,
140150
mp_raise_msg_varg(&mp_type_RuntimeError, MP_ERROR_TEXT("%q in use"), MP_QSTR_picodvi);
141151
}
142152

143-
if (!(width == 640 && height == 480) && !(width == 320 && height == 240 && (color_depth == 16 || color_depth == 8))) {
144-
mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q and %q"), MP_QSTR_width, MP_QSTR_height);
153+
if (!mode_ok(width, height, color_depth)) {
154+
mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q and %q for color depth %d"), MP_QSTR_width, MP_QSTR_height, color_depth);
145155
}
146156

147157
bool pixel_doubled = width == 320 && height == 240;

0 commit comments

Comments
 (0)