Remove support for auto-brightness
This commit is contained in:
parent
c4db71d12e
commit
41bcd7b260
@ -104,8 +104,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_PA00,
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -84,8 +84,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_PB14, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -85,8 +85,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_PA23, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -84,7 +84,6 @@ void board_init(void) {
|
||||
NULL, // &pin_PA17, // brightness pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
0.0f, // brightness
|
||||
false, // auto_brightness
|
||||
false, // single_byte_bounds
|
||||
true, // data as commands
|
||||
true, // auto_refresh
|
||||
|
@ -137,8 +137,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
NULL, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
false, // auto_refresh
|
||||
|
@ -105,8 +105,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_PA01, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -107,8 +107,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_PA01, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -94,8 +94,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_PB31, // Backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -111,8 +111,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_PB31, // Backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -102,8 +102,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_PC05, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -105,7 +105,6 @@ void board_init(void) {
|
||||
NULL,
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness
|
||||
false, // auto_brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data as commands
|
||||
true, // auto_refresh
|
||||
|
@ -89,8 +89,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_GPIO38, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -95,7 +95,7 @@ void board_init(void) {
|
||||
display->base.type = &displayio_display_type;
|
||||
|
||||
// workaround as board_init() is called before reset_port() in main.c
|
||||
pwmout_reset();
|
||||
/// pwmout_reset();
|
||||
|
||||
common_hal_displayio_display_construct(
|
||||
display,
|
||||
@ -118,8 +118,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_GPIO45, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
false, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
@ -128,8 +127,6 @@ void board_init(void) {
|
||||
false, // SH1107_addressing
|
||||
50000 // backlight pwm frequency
|
||||
);
|
||||
|
||||
common_hal_never_reset_pin(&pin_GPIO45); // backlight pin
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
|
@ -94,8 +94,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_GPIO7, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -118,8 +118,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_GPIO45, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
false, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -97,8 +97,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_GPIO21, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -80,8 +80,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_GPIO45, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -81,8 +81,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_GPIO45, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -108,8 +108,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_GPIO9, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -100,8 +100,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_GPIO14, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -112,8 +112,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_GPIO45, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
false, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -117,8 +117,7 @@ static void display_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_GPIO38, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
false, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -117,8 +117,7 @@ static void display_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_GPIO33, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
false, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -198,8 +198,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
NULL, // There is no backlight pin, defined for now.
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -84,8 +84,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_P1_05, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -85,8 +85,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_P1_13, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -85,8 +85,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_P0_20, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -84,8 +84,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_P0_02, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -97,7 +97,6 @@ void board_init(void) {
|
||||
NULL,
|
||||
0x81,
|
||||
1.0f, // brightness
|
||||
false, // auto_brightness
|
||||
true, // single_byte_bounds
|
||||
true, // data as commands
|
||||
true, // auto_refresh
|
||||
|
@ -101,8 +101,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_GPIO12, // backlight pin
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
true, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -104,8 +104,7 @@ void board_init(void) {
|
||||
sizeof(display_init_sequence),
|
||||
&pin_PB03,
|
||||
NO_BRIGHTNESS_COMMAND,
|
||||
1.0f, // brightness (ignored)
|
||||
false, // auto_brightness
|
||||
1.0f, // brightness
|
||||
false, // single_byte_bounds
|
||||
false, // data_as_commands
|
||||
true, // auto_refresh
|
||||
|
@ -54,7 +54,7 @@
|
||||
//| Most people should not use this class directly. Use a specific display driver instead that will
|
||||
//| contain the initialization sequence at minimum."""
|
||||
//|
|
||||
//| def __init__(self, display_bus: _DisplayBus, init_sequence: ReadableBuffer, *, width: int, height: int, colstart: int = 0, rowstart: int = 0, rotation: int = 0, color_depth: int = 16, grayscale: bool = False, pixels_in_byte_share_row: bool = True, bytes_per_cell: int = 1, reverse_pixels_in_byte: bool = False, set_column_command: int = 0x2a, set_row_command: int = 0x2b, write_ram_command: int = 0x2c, backlight_pin: Optional[microcontroller.Pin] = None, brightness_command: Optional[int] = None, brightness: float = 1.0, auto_brightness: bool = False, single_byte_bounds: bool = False, data_as_commands: bool = False, auto_refresh: bool = True, native_frames_per_second: int = 60, backlight_on_high: bool = True, SH1107_addressing: bool = False) -> None:
|
||||
//| def __init__(self, display_bus: _DisplayBus, init_sequence: ReadableBuffer, *, width: int, height: int, colstart: int = 0, rowstart: int = 0, rotation: int = 0, color_depth: int = 16, grayscale: bool = False, pixels_in_byte_share_row: bool = True, bytes_per_cell: int = 1, reverse_pixels_in_byte: bool = False, set_column_command: int = 0x2a, set_row_command: int = 0x2b, write_ram_command: int = 0x2c, backlight_pin: Optional[microcontroller.Pin] = None, brightness_command: Optional[int] = None, brightness: float = 1.0, single_byte_bounds: bool = False, data_as_commands: bool = False, auto_refresh: bool = True, native_frames_per_second: int = 60, backlight_on_high: bool = True, SH1107_addressing: bool = False) -> None:
|
||||
//| r"""Create a Display object on the given display bus (`FourWire`, `ParallelBus` or `I2CDisplay`).
|
||||
//|
|
||||
//| The ``init_sequence`` is bitpacked to minimize the ram impact. Every command begins with a
|
||||
@ -102,8 +102,7 @@
|
||||
//| :param int write_ram_command: Command used to write pixels values into the update region. Ignored if data_as_commands is set.
|
||||
//| :param microcontroller.Pin backlight_pin: Pin connected to the display's backlight
|
||||
//| :param int brightness_command: Command to set display brightness. Usually available in OLED controllers.
|
||||
//| :param float brightness: Initial display brightness. This value is ignored if auto_brightness is True.
|
||||
//| :param bool auto_brightness: If True, brightness is controlled via an ambient light sensor or other mechanism.
|
||||
//| :param float brightness: Initial display brightness.
|
||||
//| :param bool single_byte_bounds: Display column and row commands use single bytes
|
||||
//| :param bool data_as_commands: Treat all init and boundary data as SPI commands. Certain displays require this.
|
||||
//| :param bool auto_refresh: Automatically refresh the screen
|
||||
@ -122,7 +121,7 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a
|
||||
ARG_bytes_per_cell, ARG_reverse_pixels_in_byte, ARG_reverse_bytes_in_word,
|
||||
ARG_set_column_command, ARG_set_row_command, ARG_write_ram_command,
|
||||
ARG_set_vertical_scroll, ARG_backlight_pin, ARG_brightness_command,
|
||||
ARG_brightness, ARG_auto_brightness, ARG_single_byte_bounds, ARG_data_as_commands,
|
||||
ARG_brightness, ARG_single_byte_bounds, ARG_data_as_commands,
|
||||
ARG_auto_refresh, ARG_native_frames_per_second, ARG_backlight_on_high,
|
||||
ARG_SH1107_addressing, ARG_backlight_pwm_frequency };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
@ -146,7 +145,6 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a
|
||||
{ MP_QSTR_backlight_pin, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} },
|
||||
{ MP_QSTR_brightness_command, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = NO_BRIGHTNESS_COMMAND} },
|
||||
{ MP_QSTR_brightness, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = MP_OBJ_NEW_SMALL_INT(1)} },
|
||||
{ MP_QSTR_auto_brightness, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
|
||||
{ MP_QSTR_single_byte_bounds, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
|
||||
{ MP_QSTR_data_as_commands, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
|
||||
{ MP_QSTR_auto_refresh, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = true} },
|
||||
@ -196,7 +194,6 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a
|
||||
MP_OBJ_TO_PTR(backlight_pin),
|
||||
args[ARG_brightness_command].u_int,
|
||||
brightness,
|
||||
args[ARG_auto_brightness].u_bool,
|
||||
args[ARG_single_byte_bounds].u_bool,
|
||||
args[ARG_data_as_commands].u_bool,
|
||||
args[ARG_auto_refresh].u_bool,
|
||||
@ -311,9 +308,7 @@ MP_PROPERTY_GETSET(displayio_display_auto_refresh_obj,
|
||||
(mp_obj_t)&displayio_display_set_auto_refresh_obj);
|
||||
|
||||
//| brightness: float
|
||||
//| """The brightness of the display as a float. 0.0 is off and 1.0 is full brightness. When
|
||||
//| `auto_brightness` is True, the value of `brightness` will change automatically.
|
||||
//| If `brightness` is set, `auto_brightness` will be disabled and will be set to False."""
|
||||
//| """The brightness of the display as a float. 0.0 is off and 1.0 is full brightness."""
|
||||
//|
|
||||
STATIC mp_obj_t displayio_display_obj_get_brightness(mp_obj_t self_in) {
|
||||
displayio_display_obj_t *self = native_display(self_in);
|
||||
@ -327,7 +322,6 @@ MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_brightness_obj, displayio_displa
|
||||
|
||||
STATIC mp_obj_t displayio_display_obj_set_brightness(mp_obj_t self_in, mp_obj_t brightness_obj) {
|
||||
displayio_display_obj_t *self = native_display(self_in);
|
||||
common_hal_displayio_display_set_auto_brightness(self, false);
|
||||
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"));
|
||||
@ -344,34 +338,6 @@ MP_PROPERTY_GETSET(displayio_display_brightness_obj,
|
||||
(mp_obj_t)&displayio_display_get_brightness_obj,
|
||||
(mp_obj_t)&displayio_display_set_brightness_obj);
|
||||
|
||||
//| auto_brightness: bool
|
||||
//| """True when the display brightness is adjusted automatically, based on an ambient
|
||||
//| light sensor or other method. Note that some displays may have this set to True by default,
|
||||
//| but not actually implement automatic brightness adjustment. `auto_brightness` is set to False
|
||||
//| if `brightness` is set manually."""
|
||||
//|
|
||||
STATIC mp_obj_t displayio_display_obj_get_auto_brightness(mp_obj_t self_in) {
|
||||
displayio_display_obj_t *self = native_display(self_in);
|
||||
return mp_obj_new_bool(common_hal_displayio_display_get_auto_brightness(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_auto_brightness_obj, displayio_display_obj_get_auto_brightness);
|
||||
|
||||
STATIC mp_obj_t displayio_display_obj_set_auto_brightness(mp_obj_t self_in, mp_obj_t auto_brightness) {
|
||||
displayio_display_obj_t *self = native_display(self_in);
|
||||
|
||||
common_hal_displayio_display_set_auto_brightness(self, mp_obj_is_true(auto_brightness));
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(displayio_display_set_auto_brightness_obj, displayio_display_obj_set_auto_brightness);
|
||||
|
||||
MP_PROPERTY_GETSET(displayio_display_auto_brightness_obj,
|
||||
(mp_obj_t)&displayio_display_get_auto_brightness_obj,
|
||||
(mp_obj_t)&displayio_display_set_auto_brightness_obj);
|
||||
|
||||
|
||||
|
||||
|
||||
//| width: int
|
||||
//| """Gets the width of the board"""
|
||||
//|
|
||||
@ -509,7 +475,6 @@ STATIC const mp_rom_map_elem_t displayio_display_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_auto_refresh), MP_ROM_PTR(&displayio_display_auto_refresh_obj) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_brightness), MP_ROM_PTR(&displayio_display_brightness_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_auto_brightness), MP_ROM_PTR(&displayio_display_auto_brightness_obj) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&displayio_display_width_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_display_height_obj) },
|
||||
|
@ -42,7 +42,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t *self,
|
||||
bool pixels_in_byte_share_row, uint8_t bytes_per_cell, bool reverse_pixels_in_byte, bool reverse_bytes_in_word,
|
||||
uint8_t set_column_command, uint8_t set_row_command, uint8_t write_ram_command,
|
||||
uint8_t *init_sequence, uint16_t init_sequence_len, const mcu_pin_obj_t *backlight_pin, uint16_t brightness_command,
|
||||
mp_float_t brightness, bool auto_brightness,
|
||||
mp_float_t brightness,
|
||||
bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second,
|
||||
bool backlight_on_high, bool SH1107_addressing, uint16_t backlight_pwm_frequency);
|
||||
|
||||
@ -59,9 +59,6 @@ uint16_t common_hal_displayio_display_get_height(displayio_display_obj_t *self);
|
||||
uint16_t common_hal_displayio_display_get_rotation(displayio_display_obj_t *self);
|
||||
void common_hal_displayio_display_set_rotation(displayio_display_obj_t *self, int rotation);
|
||||
|
||||
bool common_hal_displayio_display_get_auto_brightness(displayio_display_obj_t *self);
|
||||
void common_hal_displayio_display_set_auto_brightness(displayio_display_obj_t *self, bool auto_brightness);
|
||||
|
||||
bool common_hal_displayio_display_get_dither(displayio_display_obj_t *self);
|
||||
void common_hal_displayio_display_set_dither(displayio_display_obj_t *self, bool dither);
|
||||
|
||||
|
@ -48,7 +48,6 @@
|
||||
//| import time
|
||||
//| import pulseio
|
||||
//|
|
||||
//| board.DISPLAY.auto_brightness = False
|
||||
//| board.DISPLAY.brightness = 0
|
||||
//| splash = displayio.Group()
|
||||
//| board.DISPLAY.show(splash)
|
||||
|
@ -173,9 +173,7 @@ MP_PROPERTY_GETSET(framebufferio_framebufferdisplay_auto_refresh_obj,
|
||||
(mp_obj_t)&framebufferio_framebufferdisplay_set_auto_refresh_obj);
|
||||
|
||||
//| brightness: float
|
||||
//| """The brightness of the display as a float. 0.0 is off and 1.0 is full brightness. When
|
||||
//| `auto_brightness` is True, the value of `brightness` will change automatically.
|
||||
//| If `brightness` is set, `auto_brightness` will be disabled and will be set to False."""
|
||||
//| """The brightness of the display as a float. 0.0 is off and 1.0 is full brightness."""
|
||||
//|
|
||||
STATIC mp_obj_t framebufferio_framebufferdisplay_obj_get_brightness(mp_obj_t self_in) {
|
||||
framebufferio_framebufferdisplay_obj_t *self = native_display(self_in);
|
||||
@ -189,7 +187,6 @@ MP_DEFINE_CONST_FUN_OBJ_1(framebufferio_framebufferdisplay_get_brightness_obj, f
|
||||
|
||||
STATIC mp_obj_t framebufferio_framebufferdisplay_obj_set_brightness(mp_obj_t self_in, mp_obj_t brightness_obj) {
|
||||
framebufferio_framebufferdisplay_obj_t *self = native_display(self_in);
|
||||
common_hal_framebufferio_framebufferdisplay_set_auto_brightness(self, false);
|
||||
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"));
|
||||
@ -206,34 +203,6 @@ MP_PROPERTY_GETSET(framebufferio_framebufferdisplay_brightness_obj,
|
||||
(mp_obj_t)&framebufferio_framebufferdisplay_get_brightness_obj,
|
||||
(mp_obj_t)&framebufferio_framebufferdisplay_set_brightness_obj);
|
||||
|
||||
//| auto_brightness: bool
|
||||
//| """True when the display brightness is adjusted automatically, based on an ambient
|
||||
//| light sensor or other method. Note that some displays may have this set to True by default,
|
||||
//| but not actually implement automatic brightness adjustment. `auto_brightness` is set to False
|
||||
//| if `brightness` is set manually."""
|
||||
//|
|
||||
STATIC mp_obj_t framebufferio_framebufferdisplay_obj_get_auto_brightness(mp_obj_t self_in) {
|
||||
framebufferio_framebufferdisplay_obj_t *self = native_display(self_in);
|
||||
return mp_obj_new_bool(common_hal_framebufferio_framebufferdisplay_get_auto_brightness(self));
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(framebufferio_framebufferdisplay_get_auto_brightness_obj, framebufferio_framebufferdisplay_obj_get_auto_brightness);
|
||||
|
||||
STATIC mp_obj_t framebufferio_framebufferdisplay_obj_set_auto_brightness(mp_obj_t self_in, mp_obj_t auto_brightness) {
|
||||
framebufferio_framebufferdisplay_obj_t *self = native_display(self_in);
|
||||
|
||||
bool ok = common_hal_framebufferio_framebufferdisplay_set_auto_brightness(self, mp_obj_is_true(auto_brightness));
|
||||
if (!ok) {
|
||||
mp_raise_RuntimeError(translate("Brightness not adjustable"));
|
||||
}
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(framebufferio_framebufferdisplay_set_auto_brightness_obj, framebufferio_framebufferdisplay_obj_set_auto_brightness);
|
||||
|
||||
MP_PROPERTY_GETSET(framebufferio_framebufferdisplay_auto_brightness_obj,
|
||||
(mp_obj_t)&framebufferio_framebufferdisplay_get_auto_brightness_obj,
|
||||
(mp_obj_t)&framebufferio_framebufferdisplay_set_auto_brightness_obj);
|
||||
|
||||
//| width: int
|
||||
//| """Gets the width of the framebuffer"""
|
||||
//|
|
||||
@ -374,7 +343,6 @@ STATIC const mp_rom_map_elem_t framebufferio_framebufferdisplay_locals_dict_tabl
|
||||
{ MP_ROM_QSTR(MP_QSTR_auto_refresh), MP_ROM_PTR(&framebufferio_framebufferdisplay_auto_refresh_obj) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_brightness), MP_ROM_PTR(&framebufferio_framebufferdisplay_brightness_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_auto_brightness), MP_ROM_PTR(&framebufferio_framebufferdisplay_auto_brightness_obj) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&framebufferio_framebufferdisplay_width_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&framebufferio_framebufferdisplay_height_obj) },
|
||||
|
@ -55,9 +55,6 @@ uint16_t common_hal_framebufferio_framebufferdisplay_get_height(framebufferio_fr
|
||||
uint16_t common_hal_framebufferio_framebufferdisplay_get_rotation(framebufferio_framebufferdisplay_obj_t *self);
|
||||
void common_hal_framebufferio_framebufferdisplay_set_rotation(framebufferio_framebufferdisplay_obj_t *self, int rotation);
|
||||
|
||||
bool common_hal_framebufferio_framebufferdisplay_get_auto_brightness(framebufferio_framebufferdisplay_obj_t *self);
|
||||
bool common_hal_framebufferio_framebufferdisplay_set_auto_brightness(framebufferio_framebufferdisplay_obj_t *self, bool auto_brightness);
|
||||
|
||||
mp_float_t common_hal_framebufferio_framebufferdisplay_get_brightness(framebufferio_framebufferdisplay_obj_t *self);
|
||||
bool common_hal_framebufferio_framebufferdisplay_set_brightness(framebufferio_framebufferdisplay_obj_t *self, mp_float_t brightness);
|
||||
|
||||
|
@ -51,7 +51,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t *self,
|
||||
uint8_t bytes_per_cell, bool reverse_pixels_in_byte, bool reverse_bytes_in_word, uint8_t set_column_command,
|
||||
uint8_t set_row_command, uint8_t write_ram_command,
|
||||
uint8_t *init_sequence, uint16_t init_sequence_len, const mcu_pin_obj_t *backlight_pin,
|
||||
uint16_t brightness_command, mp_float_t brightness, bool auto_brightness,
|
||||
uint16_t brightness_command, mp_float_t brightness,
|
||||
bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second,
|
||||
bool backlight_on_high, bool SH1107_addressing, uint16_t backlight_pwm_frequency) {
|
||||
|
||||
@ -70,7 +70,6 @@ void common_hal_displayio_display_construct(displayio_display_obj_t *self,
|
||||
self->set_row_command = set_row_command;
|
||||
self->write_ram_command = write_ram_command;
|
||||
self->brightness_command = brightness_command;
|
||||
self->auto_brightness = auto_brightness;
|
||||
self->first_manual_refresh = !auto_refresh;
|
||||
self->data_as_commands = data_as_commands;
|
||||
self->backlight_on_high = backlight_on_high;
|
||||
@ -132,12 +131,8 @@ void common_hal_displayio_display_construct(displayio_display_obj_t *self,
|
||||
common_hal_never_reset_pin(backlight_pin);
|
||||
#endif
|
||||
}
|
||||
if (!self->auto_brightness && (self->backlight_inout.base.type != &mp_type_NoneType ||
|
||||
brightness_command != NO_BRIGHTNESS_COMMAND)) {
|
||||
common_hal_displayio_display_set_brightness(self, brightness);
|
||||
} else {
|
||||
self->current_brightness = -1.0;
|
||||
}
|
||||
|
||||
common_hal_displayio_display_set_brightness(self, brightness);
|
||||
|
||||
// Set the group after initialization otherwise we may send pixels while we delay in
|
||||
// initialization.
|
||||
@ -157,20 +152,11 @@ uint16_t common_hal_displayio_display_get_height(displayio_display_obj_t *self)
|
||||
return displayio_display_core_get_height(&self->core);
|
||||
}
|
||||
|
||||
bool common_hal_displayio_display_get_auto_brightness(displayio_display_obj_t *self) {
|
||||
return self->auto_brightness;
|
||||
}
|
||||
|
||||
void common_hal_displayio_display_set_auto_brightness(displayio_display_obj_t *self, bool auto_brightness) {
|
||||
self->auto_brightness = auto_brightness;
|
||||
}
|
||||
|
||||
mp_float_t common_hal_displayio_display_get_brightness(displayio_display_obj_t *self) {
|
||||
return self->current_brightness;
|
||||
}
|
||||
|
||||
bool common_hal_displayio_display_set_brightness(displayio_display_obj_t *self, mp_float_t brightness) {
|
||||
self->updating_backlight = true;
|
||||
if (!self->backlight_on_high) {
|
||||
brightness = 1.0 - brightness;
|
||||
}
|
||||
@ -209,7 +195,6 @@ bool common_hal_displayio_display_set_brightness(displayio_display_obj_t *self,
|
||||
}
|
||||
|
||||
}
|
||||
self->updating_backlight = false;
|
||||
if (ok) {
|
||||
self->current_brightness = brightness;
|
||||
}
|
||||
@ -413,23 +398,8 @@ void common_hal_displayio_display_set_auto_refresh(displayio_display_obj_t *self
|
||||
self->auto_refresh = auto_refresh;
|
||||
}
|
||||
|
||||
STATIC void _update_backlight(displayio_display_obj_t *self) {
|
||||
if (!self->auto_brightness || self->updating_backlight) {
|
||||
return;
|
||||
}
|
||||
if (supervisor_ticks_ms64() - self->last_backlight_refresh < 100) {
|
||||
return;
|
||||
}
|
||||
// TODO(tannewt): Fade the backlight based on its existing value and a target value. The target
|
||||
// should account for ambient light when possible.
|
||||
common_hal_displayio_display_set_brightness(self, 1.0);
|
||||
|
||||
self->last_backlight_refresh = supervisor_ticks_ms64();
|
||||
}
|
||||
|
||||
void displayio_display_background(displayio_display_obj_t *self) {
|
||||
_update_backlight(self);
|
||||
|
||||
common_hal_displayio_display_set_brightness(self, 1.0);
|
||||
if (self->auto_refresh && (supervisor_ticks_ms64() - self->core.last_refresh) > self->native_ms_per_frame) {
|
||||
_refresh_display(self);
|
||||
}
|
||||
@ -452,7 +422,6 @@ void release_display(displayio_display_obj_t *self) {
|
||||
|
||||
void reset_display(displayio_display_obj_t *self) {
|
||||
common_hal_displayio_display_set_auto_refresh(self, true);
|
||||
self->auto_brightness = true;
|
||||
common_hal_displayio_display_show(self, NULL);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,6 @@ typedef struct {
|
||||
pwmio_pwmout_obj_t backlight_pwm;
|
||||
#endif
|
||||
};
|
||||
uint64_t last_backlight_refresh;
|
||||
uint64_t last_refresh_call;
|
||||
mp_float_t current_brightness;
|
||||
uint16_t brightness_command;
|
||||
@ -57,8 +56,6 @@ typedef struct {
|
||||
bool auto_refresh;
|
||||
bool first_manual_refresh;
|
||||
bool data_as_commands;
|
||||
bool auto_brightness;
|
||||
bool updating_backlight;
|
||||
bool backlight_on_high;
|
||||
// new quirk for sh1107
|
||||
bool SH1107_addressing;
|
||||
|
@ -113,20 +113,6 @@ uint16_t common_hal_framebufferio_framebufferdisplay_get_height(framebufferio_fr
|
||||
return displayio_display_core_get_height(&self->core);
|
||||
}
|
||||
|
||||
bool common_hal_framebufferio_framebufferdisplay_get_auto_brightness(framebufferio_framebufferdisplay_obj_t *self) {
|
||||
if (self->framebuffer_protocol->get_auto_brightness) {
|
||||
return self->framebuffer_protocol->get_auto_brightness(self->framebuffer);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool common_hal_framebufferio_framebufferdisplay_set_auto_brightness(framebufferio_framebufferdisplay_obj_t *self, bool auto_brightness) {
|
||||
if (self->framebuffer_protocol->set_auto_brightness) {
|
||||
return self->framebuffer_protocol->set_auto_brightness(self->framebuffer, auto_brightness);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
mp_float_t common_hal_framebufferio_framebufferdisplay_get_brightness(framebufferio_framebufferdisplay_obj_t *self) {
|
||||
if (self->framebuffer_protocol->get_brightness) {
|
||||
return self->framebuffer_protocol->get_brightness(self->framebuffer);
|
||||
|
@ -43,7 +43,6 @@ typedef struct {
|
||||
mp_obj_t framebuffer;
|
||||
const struct _framebuffer_p_t *framebuffer_protocol;
|
||||
mp_buffer_info_t bufinfo;
|
||||
uint64_t last_backlight_refresh;
|
||||
uint64_t last_refresh_call;
|
||||
uint16_t native_frames_per_second;
|
||||
uint16_t native_ms_per_frame;
|
||||
@ -61,10 +60,8 @@ void framebufferio_framebufferdisplay_collect_ptrs(framebufferio_framebufferdisp
|
||||
|
||||
mp_obj_t common_hal_framebufferio_framebufferdisplay_get_framebuffer(framebufferio_framebufferdisplay_obj_t *self);
|
||||
|
||||
typedef bool (*framebuffer_get_auto_brightness_fun)(mp_obj_t);
|
||||
typedef bool (*framebuffer_get_reverse_pixels_in_byte_fun)(mp_obj_t);
|
||||
typedef bool (*framebuffer_get_reverse_pixels_in_word_fun)(mp_obj_t);
|
||||
typedef bool (*framebuffer_set_auto_brightness_fun)(mp_obj_t, bool);
|
||||
typedef bool (*framebuffer_set_brightness_fun)(mp_obj_t, mp_float_t);
|
||||
typedef int (*framebuffer_get_bytes_per_cell_fun)(mp_obj_t);
|
||||
typedef int (*framebuffer_get_color_depth_fun)(mp_obj_t);
|
||||
@ -105,9 +102,6 @@ typedef struct _framebuffer_p_t {
|
||||
framebuffer_get_brightness_fun get_brightness;
|
||||
framebuffer_set_brightness_fun set_brightness;
|
||||
|
||||
// Optional -- default is no automatic brightness control
|
||||
framebuffer_get_auto_brightness_fun get_auto_brightness;
|
||||
framebuffer_set_auto_brightness_fun set_auto_brightness;
|
||||
} framebuffer_p_t;
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_FRAMEBUFFERDISPLAY_H
|
||||
|
Loading…
Reference in New Issue
Block a user