Save space with consolidated errors
This commit is contained in:
parent
eab202aa53
commit
75046b3a58
|
@ -358,7 +358,7 @@ STATIC mp_obj_t displayio_display_obj_set_brightness(mp_obj_t self_in, mp_obj_t
|
|||
displayio_display_obj_t *self = native_display(self_in);
|
||||
mp_float_t brightness = mp_obj_get_float(brightness_obj);
|
||||
if (brightness < 0 || brightness > 1.0) {
|
||||
mp_raise_ValueError(translate("Brightness must be 0-1.0"));
|
||||
mp_raise_ValueError_varg(translate("%q must be %d-%d"), MP_QSTR_brightness, 0, 1);
|
||||
}
|
||||
bool ok = common_hal_displayio_display_set_brightness(self, brightness);
|
||||
if (!ok) {
|
||||
|
|
|
@ -194,7 +194,7 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_set_brightness(mp_obj_t sel
|
|||
framebufferio_framebufferdisplay_obj_t *self = native_display(self_in);
|
||||
mp_float_t brightness = mp_obj_get_float(brightness_obj);
|
||||
if (brightness < 0.0f || brightness > 1.0f) {
|
||||
mp_raise_ValueError(translate("Brightness must be 0-1.0"));
|
||||
mp_raise_ValueError_varg(translate("%q must be %d-%d"), MP_QSTR_brightness, 0, 1);
|
||||
}
|
||||
bool ok = common_hal_framebufferio_framebufferdisplay_set_brightness(self, brightness);
|
||||
if (!ok) {
|
||||
|
|
|
@ -162,7 +162,7 @@ STATIC mp_obj_t is31fl3741_FrameBuffer_set_brightness(mp_obj_t self_in, mp_obj_t
|
|||
check_for_deinit(self);
|
||||
mp_float_t brightness = mp_obj_get_float(value_in);
|
||||
if (brightness < 0.0f || brightness > 1.0f) {
|
||||
mp_raise_ValueError(translate("Brightness must be 0-1.0"));
|
||||
mp_raise_ValueError_varg(translate("%q must be %d-%d"), MP_QSTR_brightness, 0, 1);
|
||||
}
|
||||
|
||||
uint8_t current = (uint8_t)(brightness * 0xFF);
|
||||
|
|
|
@ -294,7 +294,7 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_set_brightness(mp_obj_t self_in, mp_obj_t va
|
|||
check_for_deinit(self);
|
||||
mp_float_t brightness = mp_obj_get_float(value_in);
|
||||
if (brightness < 0.0f || brightness > 1.0f) {
|
||||
mp_raise_ValueError(translate("Brightness must be 0-1.0"));
|
||||
mp_raise_ValueError_varg(translate("%q must be %d-%d"), MP_QSTR_brightness, 0, 1);
|
||||
}
|
||||
common_hal_rgbmatrix_rgbmatrix_set_paused(self, brightness <= 0);
|
||||
|
||||
|
|
|
@ -63,15 +63,17 @@ void common_hal_displayio_shape_construct(displayio_shape_t *self, uint32_t widt
|
|||
}
|
||||
|
||||
void common_hal_displayio_shape_set_boundary(displayio_shape_t *self, uint16_t y, uint16_t start_x, uint16_t end_x) {
|
||||
if (y < 0 || y >= self->height || (self->mirror_y && y >= self->half_height)) {
|
||||
mp_raise_ValueError(translate("y value out of bounds"));
|
||||
uint16_t max_y = self->height - 1;
|
||||
if (self->mirror_y) {
|
||||
max_y = self->half_height - 1;
|
||||
}
|
||||
if (start_x < 0 || start_x >= self->width || end_x < 0 || end_x >= self->width) {
|
||||
mp_raise_ValueError(translate("x value out of bounds"));
|
||||
}
|
||||
if (self->mirror_x && (start_x >= self->half_width || end_x >= self->half_width)) {
|
||||
mp_raise_ValueError_varg(translate("Maximum x value when mirrored is %d"), self->half_width);
|
||||
mp_arg_validate_int_range(y, 0, max_y, MP_QSTR_y);
|
||||
uint16_t max_x = self->width - 1;
|
||||
if (self->mirror_x) {
|
||||
max_x = self->half_width - 1;
|
||||
}
|
||||
mp_arg_validate_int_range(start_x, 0, max_x, MP_QSTR_start_x);
|
||||
mp_arg_validate_int_range(end_x, 0, max_x, MP_QSTR_end_x);
|
||||
|
||||
uint16_t lower_x, upper_x, lower_y, upper_y;
|
||||
|
||||
|
|
Loading…
Reference in New Issue