diff options
| author | siddacious <nospam187+github@gmail.com> | 2020-03-25 22:43:18 -0700 |
|---|---|---|
| committer | siddacious <nospam187+github@gmail.com> | 2020-03-25 22:51:20 -0700 |
| commit | 9e0c00dfd42504a53f000da374355829da7c7c77 (patch) | |
| tree | 0f7c88c5451ca00fab8d6b6b6d24a425626a9c93 /shared-module | |
| parent | 7bba79363aab2b53cb1883fe5cab51a214d23461 (diff) | |
adding a backlight polarity flag to Display
Diffstat (limited to 'shared-module')
| -rw-r--r-- | shared-module/displayio/Display.c | 5 | ||||
| -rw-r--r-- | shared-module/displayio/Display.h | 1 |
2 files changed, 5 insertions, 1 deletions
diff --git a/shared-module/displayio/Display.c b/shared-module/displayio/Display.c index 299c8ad35..820fbcce6 100644 --- a/shared-module/displayio/Display.c +++ b/shared-module/displayio/Display.c @@ -50,7 +50,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self, uint8_t set_row_command, uint8_t write_ram_command, uint8_t set_vertical_scroll, 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 single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second, bool backlight_on_high) { // Turn off auto-refresh as we init. self->auto_refresh = false; uint16_t ram_width = 0x100; @@ -159,6 +159,9 @@ mp_float_t common_hal_displayio_display_get_brightness(displayio_display_obj_t* 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; + } bool ok = false; if (self->backlight_pwm.base.type == &pulseio_pwmout_type) { common_hal_pulseio_pwmout_set_duty_cycle(&self->backlight_pwm, (uint16_t) (0xffff * brightness)); diff --git a/shared-module/displayio/Display.h b/shared-module/displayio/Display.h index e5fe0a708..8adaf597f 100644 --- a/shared-module/displayio/Display.h +++ b/shared-module/displayio/Display.h @@ -55,6 +55,7 @@ typedef struct { bool data_as_commands; bool auto_brightness; bool updating_backlight; + bool backlight_on_high; } displayio_display_obj_t; void displayio_display_background(displayio_display_obj_t* self); |
