Skip to content

Commit 6002f22

Browse files
committed
squeeze some error msgs
1 parent b272b88 commit 6002f22

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

locale/circuitpython.pot

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ msgstr ""
206206
msgid "%q must be array of type 'h'"
207207
msgstr ""
208208

209+
#: shared-bindings/audiobusio/PDMIn.c
210+
msgid "%q must be multiple of 8."
211+
msgstr ""
212+
209213
#: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c
210214
#: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c
211215
#: shared-module/synthio/Synthesizer.c
@@ -595,10 +599,6 @@ msgstr ""
595599
msgid "Bit clock and word select must share a clock unit"
596600
msgstr ""
597601

598-
#: shared-bindings/audiobusio/PDMIn.c
599-
msgid "Bit depth must be multiple of 8."
600-
msgstr ""
601-
602602
#: shared-bindings/bitmaptools/__init__.c
603603
msgid "Bitmap size and bits per value must match"
604604
msgstr ""
@@ -1339,10 +1339,6 @@ msgstr ""
13391339
msgid "Mapping must be a tuple"
13401340
msgstr ""
13411341

1342-
#: shared-bindings/audiobusio/PDMIn.c
1343-
msgid "Microphone startup delay must be in range 0.0 to 1.0"
1344-
msgstr ""
1345-
13461342
#: ports/raspberrypi/bindings/rp2pio/StateMachine.c
13471343
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
13481344
msgid "Mismatched data size"
@@ -1705,10 +1701,6 @@ msgstr ""
17051701
msgid "Out-buffer elements must be <= 4 bytes long"
17061702
msgstr ""
17071703

1708-
#: shared-bindings/audiobusio/PDMIn.c
1709-
msgid "Oversample must be multiple of 8."
1710-
msgstr ""
1711-
17121704
#: shared-bindings/pwmio/PWMOut.c
17131705
msgid ""
17141706
"PWM frequency not writable when variable_frequency is False on construction."

shared-bindings/audiobusio/PDMIn.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,18 @@ STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_ar
122122
uint32_t sample_rate = args[ARG_sample_rate].u_int;
123123
uint8_t bit_depth = args[ARG_bit_depth].u_int;
124124
if (bit_depth % 8 != 0) {
125-
mp_raise_ValueError(translate("Bit depth must be multiple of 8."));
125+
mp_raise_ValueError_varg(translate("%q must be multiple of 8."), MP_QSTR_bit_depth);
126126
}
127127
uint8_t oversample = args[ARG_oversample].u_int;
128128
if (oversample % 8 != 0) {
129-
mp_raise_ValueError(translate("Oversample must be multiple of 8."));
129+
mp_raise_ValueError_varg(translate("%q must be multiple of 8."), MP_QSTR_oversample);
130130
}
131131
bool mono = args[ARG_mono].u_bool;
132132

133133
mp_float_t startup_delay = (args[ARG_startup_delay].u_obj == MP_OBJ_NULL)
134134
? (mp_float_t)STARTUP_DELAY_DEFAULT
135135
: mp_obj_get_float(args[ARG_startup_delay].u_obj);
136-
if (startup_delay < 0.0 || startup_delay > 1.0) {
137-
mp_raise_ValueError(translate("Microphone startup delay must be in range 0.0 to 1.0"));
138-
}
136+
mp_arg_validate_float_range(startup_delay, 0.0f, 1.0f, MP_QSTR_startup_delay);
139137

140138
common_hal_audiobusio_pdmin_construct(self, clock_pin, data_pin, sample_rate,
141139
bit_depth, mono, oversample);

0 commit comments

Comments
 (0)