Skip to content

Commit 4fc0f8b

Browse files
committed
Turn off auto_brightness if brightness is set
1 parent 49c4c1e commit 4fc0f8b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

shared-bindings/displayio/Display.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,8 @@ MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_wait_for_frame_obj, displayio_displa
209209
//| .. attribute:: brightness
210210
//|
211211
//| The brightness of the display as a float. 0.0 is off and 1.0 is full brightness. When
212-
//| `auto_brightness` is True this value will change automatically and setting it will have no
213-
//| effect. To control the brightness, auto_brightness must be false.
212+
//| `auto_brightness` is True, the value of `brightness` will change automatically.
213+
//| If `brightness` is set, `auto_brightness` will be disabled and will be set to False.
214214
//|
215215
STATIC mp_obj_t displayio_display_obj_get_brightness(mp_obj_t self_in) {
216216
displayio_display_obj_t *self = native_display(self_in);
@@ -224,6 +224,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_brightness_obj, displayio_displa
224224

225225
STATIC mp_obj_t displayio_display_obj_set_brightness(mp_obj_t self_in, mp_obj_t brightness) {
226226
displayio_display_obj_t *self = native_display(self_in);
227+
common_hal_displayio_display_set_auto_brightness(self, false);
227228
bool ok = common_hal_displayio_display_set_brightness(self, mp_obj_get_float(brightness));
228229
if (!ok) {
229230
mp_raise_RuntimeError(translate("Brightness not adjustable"));
@@ -241,7 +242,10 @@ const mp_obj_property_t displayio_display_brightness_obj = {
241242

242243
//| .. attribute:: auto_brightness
243244
//|
244-
//| True when the display brightness is auto adjusted.
245+
//| True when the display brightness is adjusted automatically, based on an ambient
246+
//| light sensor or other method. Note that some displays may have this set to True by default,
247+
//| but not actually implement automatic brightness adjustment. `auto_brightness` is set to False
248+
//| if `brightness` is set manually.
245249
//|
246250
STATIC mp_obj_t displayio_display_obj_get_auto_brightness(mp_obj_t self_in) {
247251
displayio_display_obj_t *self = native_display(self_in);

0 commit comments

Comments
 (0)