Skip to content

display brightness pwm 500hz frequency #6416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ports/atmel-samd/boards/hallowing_m0_express/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false); // not SH1107
false, // not SH1107
50000); // backlight pwm frequency
}

bool board_requests_safe_mode(void) {
Expand Down
3 changes: 2 additions & 1 deletion ports/atmel-samd/boards/hallowing_m4_express/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false); // not SH1107
false, // not SH1107
50000); // backlight pwm frequency
}

bool board_requests_safe_mode(void) {
Expand Down
3 changes: 2 additions & 1 deletion ports/atmel-samd/boards/monster_m4sk/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false); // SH1107_addressing
false, // SH1107_addressing
50000); // backlight pwm frequency
}

bool board_requests_safe_mode(void) {
Expand Down
3 changes: 2 additions & 1 deletion ports/atmel-samd/boards/pewpew_lcd/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ void board_init(void) {
true, // auto_refresh
2, // native_frames_per_second
true, // backlight_on_high
true); // SH1107_addressing
true, // SH1107_addressing
50000); // backlight pwm frequency
}

bool board_requests_safe_mode(void) {
Expand Down
3 changes: 2 additions & 1 deletion ports/atmel-samd/boards/pewpew_m4/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ void board_init(void) {
false, // auto_refresh
20, // native_frames_per_second
true, // backlight_on_high
false); // SH1107_addressing
false, // SH1107_addressing
50000); // backlight pwm frequency
}

bool board_requests_safe_mode(void) {
Expand Down
3 changes: 2 additions & 1 deletion ports/atmel-samd/boards/pybadge/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false); // SH1107_addressing
false, // SH1107_addressing
50000); // backlight pwm frequency
}

bool board_requests_safe_mode(void) {
Expand Down
3 changes: 2 additions & 1 deletion ports/atmel-samd/boards/pygamer/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false); // SH1107_addressing
false, // SH1107_addressing
50000); // backlight pwm frequency
}

bool board_requests_safe_mode(void) {
Expand Down
3 changes: 2 additions & 1 deletion ports/atmel-samd/boards/pyportal/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false); // SH1107_addressing
false, // SH1107_addressing
50000); // backlight pwm frequency
}

bool board_requests_safe_mode(void) {
Expand Down
3 changes: 2 additions & 1 deletion ports/atmel-samd/boards/pyportal_titano/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion ports/atmel-samd/boards/seeeduino_wio_terminal/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false); // SH1107_addressing
false, // SH1107_addressing
50000); // backlight pwm frequency

// Enabling the Power of the 40-pin at the back
CTR_5V.base.type = &digitalio_digitalinout_type;
Expand Down
3 changes: 2 additions & 1 deletion ports/atmel-samd/boards/ugame10/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false); // SH1107_addressing
false, // SH1107_addressing
50000); // backlight pwm frequency
}

bool board_requests_safe_mode(void) {
Expand Down
3 changes: 2 additions & 1 deletion ports/espressif/boards/adafruit_esp32s2_camera/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false); // not SH1107
false, // not SH1107
50000); // backlight pwm frequency
}

bool board_requests_safe_mode(void) {
Expand Down
3 changes: 2 additions & 1 deletion ports/espressif/boards/adafruit_feather_esp32s2_tft/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false // SH1107_addressing
false, // SH1107_addressing
50000 // backlight pwm frequency
);

common_hal_never_reset_pin(&pin_GPIO45); // backlight pin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false); // not SH1107
false, // not SH1107
50000); // backlight pwm frequency
*/
}

Expand Down
3 changes: 2 additions & 1 deletion ports/espressif/boards/adafruit_feather_esp32s3_tft/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false // SH1107_addressing
false, // SH1107_addressing
50000 // backlight pwm frequency
);

common_hal_never_reset_pin(&pin_GPIO45); // backlight pin
Expand Down
3 changes: 2 additions & 1 deletion ports/espressif/boards/adafruit_funhouse/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false); // not SH1107
false, // not SH1107
50000); // backlight pwm frequency
}

bool board_requests_safe_mode(void) {
Expand Down
3 changes: 2 additions & 1 deletion ports/espressif/boards/espressif_esp32s3_box/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false); // SH1107_addressing
false, // SH1107_addressing
50000); // backlight pwm frequency

// Debug UART
#ifdef DEBUG
Expand Down
3 changes: 2 additions & 1 deletion ports/espressif/boards/espressif_esp32s3_usb_otg_n8/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false); // SH1107_addressing
false, // SH1107_addressing
50000); // backlight pwm frequency
}

bool espressif_board_reset_pin_number(gpio_num_t pin_number) {
Expand Down
3 changes: 2 additions & 1 deletion ports/espressif/boards/hexky_s2/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false // SH1107_addressing
false, // SH1107_addressing
50000 // backlight pwm frequency
);

common_hal_never_reset_pin(&pin_GPIO45); // backlight pin
Expand Down
3 changes: 2 additions & 1 deletion ports/espressif/boards/hiibot_iots2/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ static void display_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false // SH1107_addressing
false, // SH1107_addressing
50000 // backlight pwm frequency
);

common_hal_never_reset_pin(&pin_GPIO38); // backlight pin
Expand Down
3 changes: 2 additions & 1 deletion ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ static void display_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false // SH1107_addressing
false, // SH1107_addressing
50000 // backlight pwm frequency
);

common_hal_never_reset_pin(&pin_GPIO33); // backlight pin
Expand Down
3 changes: 2 additions & 1 deletion ports/espressif/boards/morpheans_morphesp-240/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
false, // backlight_on_high
false // SH1107_addressing
false, // SH1107_addressing
50000 // backlight pwm frequency
);
}

Expand Down
3 changes: 2 additions & 1 deletion ports/nrf/boards/clue_nrf52840_express/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false); // not SH1107
false, // not SH1107
50000); // backlight pwm frequency
}

bool board_requests_safe_mode(void) {
Expand Down
3 changes: 2 additions & 1 deletion ports/nrf/boards/hiibot_bluefi/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false); // SH1107_addressing
false, // SH1107_addressing
50000); // backlight pwm frequency
}

bool board_requests_safe_mode(void) {
Expand Down
3 changes: 2 additions & 1 deletion ports/nrf/boards/makerdiary_nrf52840_m2_devkit/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false); // SH1107_addressing
false, // SH1107_addressing
50000); // backlight pwm frequency
}

bool board_requests_safe_mode(void) {
Expand Down
3 changes: 2 additions & 1 deletion ports/nrf/boards/ohs2020_badge/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
false, // backlight_on_high
false); // SH1107_addressing
false, // SH1107_addressing
50000); // backlight pwm frequency
}

bool board_requests_safe_mode(void) {
Expand Down
3 changes: 2 additions & 1 deletion ports/raspberrypi/boards/adafruit_macropad_rp2040/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
true); // SH1107_addressing
true, // SH1107_addressing
50000); // backlight pwm frequency
}

bool board_requests_safe_mode(void) {
Expand Down
3 changes: 2 additions & 1 deletion ports/raspberrypi/boards/pimoroni_picosystem/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false); // SH1107_addressing
false, // SH1107_addressing
50000); // backlight pwm frequency
}

void board_deinit(void) {
Expand Down
3 changes: 2 additions & 1 deletion ports/stm/boards/meowbit_v121/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ void board_init(void) {
true, // auto_refresh
60, // native_frames_per_second
true, // backlight_on_high
false); // SH1107_addressing
false, // SH1107_addressing
50000); // backlight pwm frequency

board_buzz_obj.base.type = &audiopwmio_pwmaudioout_type;
common_hal_audiopwmio_pwmaudioout_construct(&board_buzz_obj,
Expand Down
9 changes: 6 additions & 3 deletions shared-bindings/displayio/Display.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//| """
//| ...
//|
Expand All @@ -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 },
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion shared-bindings/displayio/Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions shared-module/displayio/Display.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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, 50000, 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);
Expand Down