argument for backlight_pwm_frequency and use it in pyportal titano build
This commit is contained in:
parent
6b04b7efc8
commit
ffc451b338
|
@ -118,7 +118,8 @@ void board_init(void) {
|
|||
true, // auto_refresh
|
||||
60, // native_frames_per_second
|
||||
true, // backlight_on_high
|
||||
false); // SH1107_addressing
|
||||
false, // SH1107_addressing
|
||||
500); // backlight_pwm_frequency
|
||||
}
|
||||
|
||||
bool board_requests_safe_mode(void) {
|
||||
|
|
|
@ -111,6 +111,7 @@
|
|||
//| :param bool backlight_on_high: If True, pulling the backlight pin high turns the backlight on.
|
||||
//| :param bool SH1107_addressing: Special quirk for SH1107, use upper/lower column set and page set
|
||||
//| :param int set_vertical_scroll: This parameter is accepted but ignored for backwards compatibility. It will be removed in a future release.
|
||||
//| :param int backlight_pwm_frequency: The frequency to use to drive the PWM for backlight brightness control. Default is 50000.
|
||||
//| """
|
||||
//| ...
|
||||
//|
|
||||
|
@ -123,7 +124,7 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a
|
|||
ARG_set_vertical_scroll, ARG_backlight_pin, ARG_brightness_command,
|
||||
ARG_brightness, ARG_auto_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_SH1107_addressing, ARG_backlight_pwm_frequency };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_display_bus, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
{ MP_QSTR_init_sequence, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
|
@ -151,7 +152,8 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a
|
|||
{ MP_QSTR_auto_refresh, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = true} },
|
||||
{ MP_QSTR_native_frames_per_second, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 60} },
|
||||
{ MP_QSTR_backlight_on_high, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = true} },
|
||||
{ MP_QSTR_SH1107_addressing, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} }
|
||||
{ MP_QSTR_SH1107_addressing, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} },
|
||||
{ MP_QSTR_backlight_pwm_frequency, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 50000} }
|
||||
};
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
@ -200,7 +202,8 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a
|
|||
args[ARG_auto_refresh].u_bool,
|
||||
args[ARG_native_frames_per_second].u_int,
|
||||
args[ARG_backlight_on_high].u_bool,
|
||||
sh1107_addressing
|
||||
sh1107_addressing,
|
||||
args[ARG_backlight_pwm_frequency].u_int
|
||||
);
|
||||
|
||||
return self;
|
||||
|
|
|
@ -44,7 +44,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t *self,
|
|||
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,
|
||||
bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second,
|
||||
bool backlight_on_high, bool SH1107_addressing);
|
||||
bool backlight_on_high, bool SH1107_addressing, uint16_t backlight_pwm_frequency);
|
||||
|
||||
bool common_hal_displayio_display_show(displayio_display_obj_t *self,
|
||||
displayio_group_t *root_group);
|
||||
|
|
|
@ -53,7 +53,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t *self,
|
|||
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,
|
||||
bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second,
|
||||
bool backlight_on_high, bool SH1107_addressing) {
|
||||
bool backlight_on_high, bool SH1107_addressing, uint16_t backlight_pwm_frequency) {
|
||||
|
||||
// Turn off auto-refresh as we init.
|
||||
self->auto_refresh = false;
|
||||
|
@ -116,7 +116,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t *self,
|
|||
if (backlight_pin != NULL && common_hal_mcu_pin_is_free(backlight_pin)) {
|
||||
// Avoid PWM types and functions when the module isn't enabled
|
||||
#if (CIRCUITPY_PWMIO)
|
||||
pwmout_result_t result = common_hal_pwmio_pwmout_construct(&self->backlight_pwm, backlight_pin, 0, 500, false);
|
||||
pwmout_result_t result = common_hal_pwmio_pwmout_construct(&self->backlight_pwm, backlight_pin, 0, backlight_pwm_frequency, false);
|
||||
if (result != PWMOUT_OK) {
|
||||
self->backlight_inout.base.type = &digitalio_digitalinout_type;
|
||||
common_hal_digitalio_digitalinout_construct(&self->backlight_inout, backlight_pin);
|
||||
|
|
Loading…
Reference in New Issue