squeeze some error msgs

This commit is contained in:
Dan Halbert 2023-12-20 12:40:52 -05:00
parent b272b88cd1
commit 6002f22041
2 changed files with 7 additions and 17 deletions

View file

@ -206,6 +206,10 @@ msgstr ""
msgid "%q must be array of type 'h'"
msgstr ""
#: shared-bindings/audiobusio/PDMIn.c
msgid "%q must be multiple of 8."
msgstr ""
#: ports/raspberrypi/bindings/cyw43/__init__.c py/argcheck.c py/objexcept.c
#: shared-bindings/canio/CAN.c shared-bindings/digitalio/Pull.c
#: shared-module/synthio/Synthesizer.c
@ -595,10 +599,6 @@ msgstr ""
msgid "Bit clock and word select must share a clock unit"
msgstr ""
#: shared-bindings/audiobusio/PDMIn.c
msgid "Bit depth must be multiple of 8."
msgstr ""
#: shared-bindings/bitmaptools/__init__.c
msgid "Bitmap size and bits per value must match"
msgstr ""
@ -1339,10 +1339,6 @@ msgstr ""
msgid "Mapping must be a tuple"
msgstr ""
#: shared-bindings/audiobusio/PDMIn.c
msgid "Microphone startup delay must be in range 0.0 to 1.0"
msgstr ""
#: ports/raspberrypi/bindings/rp2pio/StateMachine.c
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
msgid "Mismatched data size"
@ -1705,10 +1701,6 @@ msgstr ""
msgid "Out-buffer elements must be <= 4 bytes long"
msgstr ""
#: shared-bindings/audiobusio/PDMIn.c
msgid "Oversample must be multiple of 8."
msgstr ""
#: shared-bindings/pwmio/PWMOut.c
msgid ""
"PWM frequency not writable when variable_frequency is False on construction."

View file

@ -122,20 +122,18 @@ STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_ar
uint32_t sample_rate = args[ARG_sample_rate].u_int;
uint8_t bit_depth = args[ARG_bit_depth].u_int;
if (bit_depth % 8 != 0) {
mp_raise_ValueError(translate("Bit depth must be multiple of 8."));
mp_raise_ValueError_varg(translate("%q must be multiple of 8."), MP_QSTR_bit_depth);
}
uint8_t oversample = args[ARG_oversample].u_int;
if (oversample % 8 != 0) {
mp_raise_ValueError(translate("Oversample must be multiple of 8."));
mp_raise_ValueError_varg(translate("%q must be multiple of 8."), MP_QSTR_oversample);
}
bool mono = args[ARG_mono].u_bool;
mp_float_t startup_delay = (args[ARG_startup_delay].u_obj == MP_OBJ_NULL)
? (mp_float_t)STARTUP_DELAY_DEFAULT
: mp_obj_get_float(args[ARG_startup_delay].u_obj);
if (startup_delay < 0.0 || startup_delay > 1.0) {
mp_raise_ValueError(translate("Microphone startup delay must be in range 0.0 to 1.0"));
}
mp_arg_validate_float_range(startup_delay, 0.0f, 1.0f, MP_QSTR_startup_delay);
common_hal_audiobusio_pdmin_construct(self, clock_pin, data_pin, sample_rate,
bit_depth, mono, oversample);