Make PulseIO optional within DisplayIO
This commit is contained in:
parent
2d7cf4b792
commit
4f71bd295d
@ -22,7 +22,6 @@ ifeq ($(MCU_SERIES),H7)
|
||||
CIRCUITPY_ANALOGIO = 0
|
||||
CIRCUITPY_NEOPIXEL_WRITE = 0
|
||||
CIRCUITPY_PULSEIO = 0
|
||||
CIRCUITPY_OS = 1
|
||||
CIRCUITPY_NVM = 0
|
||||
CIRCUITPY_AUDIOBUSIO = 0
|
||||
CIRCUITPY_AUDIOIO = 0
|
||||
@ -30,18 +29,12 @@ ifeq ($(MCU_SERIES),H7)
|
||||
CIRCUITPY_RTC = 0
|
||||
CIRCUITPY_FREQUENCYIO = 0
|
||||
CIRCUITPY_I2CSLAVE = 0
|
||||
# shared-module modules that still need prerequisites filled
|
||||
CIRCUITPY_DISPLAYIO = 0 # Requires SPI, PulseIO, and common-hal module (stub ok)
|
||||
CIRCUITPY_RANDOM = 0 # Requires OS
|
||||
CIRCUITPY_STORAGE = 0 # Requires OS, filesystem
|
||||
endif
|
||||
|
||||
ifeq ($(MCU_SERIES),F7)
|
||||
# Not yet implemented common-hal modules:
|
||||
CIRCUITPY_ANALOGIO = 0
|
||||
CIRCUITPY_NEOPIXEL_WRITE = 0
|
||||
CIRCUITPY_PULSEIO = 1
|
||||
CIRCUITPY_OS = 1
|
||||
CIRCUITPY_NVM = 0
|
||||
CIRCUITPY_AUDIOBUSIO = 0
|
||||
CIRCUITPY_AUDIOIO = 0
|
||||
@ -50,7 +43,4 @@ ifeq ($(MCU_SERIES),F7)
|
||||
CIRCUITPY_FREQUENCYIO = 0
|
||||
CIRCUITPY_I2CSLAVE = 0
|
||||
# shared-module modules that still need prerequisites filled
|
||||
CIRCUITPY_DISPLAYIO = 0 # Requires SPI, PulseIO, and common-hal module (stub ok)
|
||||
CIRCUITPY_RANDOM = 0 # Requires OS
|
||||
CIRCUITPY_STORAGE = 0 # Requires OS, filesystem
|
||||
endif
|
||||
|
@ -111,6 +111,8 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
|
||||
// Always set the backlight type in case we're reusing memory.
|
||||
self->backlight_inout.base.type = &mp_type_NoneType;
|
||||
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_PULSIO)
|
||||
pwmout_result_t result = common_hal_pulseio_pwmout_construct(&self->backlight_pwm, backlight_pin, 0, 50000, false);
|
||||
if (result != PWMOUT_OK) {
|
||||
self->backlight_inout.base.type = &digitalio_digitalinout_type;
|
||||
@ -120,6 +122,12 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
|
||||
self->backlight_pwm.base.type = &pulseio_pwmout_type;
|
||||
common_hal_pulseio_pwmout_never_reset(&self->backlight_pwm);
|
||||
}
|
||||
#else
|
||||
// Otherwise default to digital
|
||||
self->backlight_inout.base.type = &digitalio_digitalinout_type;
|
||||
common_hal_digitalio_digitalinout_construct(&self->backlight_inout, backlight_pin);
|
||||
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)) {
|
||||
@ -164,9 +172,21 @@ bool common_hal_displayio_display_set_brightness(displayio_display_obj_t* self,
|
||||
brightness = 1.0-brightness;
|
||||
}
|
||||
bool ok = false;
|
||||
if (self->backlight_pwm.base.type == &pulseio_pwmout_type) {
|
||||
|
||||
// Avoid PWM types and functions when the module isn't enabled
|
||||
#if (CIRCUITPY_PULSIO)
|
||||
bool ispwm = (self->backlight_pwm.base.type == &pulseio_pwmout_type) ? true : false;
|
||||
#else
|
||||
bool ispwm = false;
|
||||
#endif
|
||||
|
||||
if (ispwm) {
|
||||
#if (CIRCUITPY_PULSIO)
|
||||
common_hal_pulseio_pwmout_set_duty_cycle(&self->backlight_pwm, (uint16_t) (0xffff * brightness));
|
||||
ok = true;
|
||||
#else
|
||||
ok = false;
|
||||
#endif
|
||||
} else if (self->backlight_inout.base.type == &digitalio_digitalinout_type) {
|
||||
common_hal_digitalio_digitalinout_set_value(&self->backlight_inout, brightness > 0.99);
|
||||
ok = true;
|
||||
@ -392,12 +412,16 @@ void displayio_display_background(displayio_display_obj_t* self) {
|
||||
|
||||
void release_display(displayio_display_obj_t* self) {
|
||||
release_display_core(&self->core);
|
||||
#if (CIRCUITPY_PULSIO)
|
||||
if (self->backlight_pwm.base.type == &pulseio_pwmout_type) {
|
||||
common_hal_pulseio_pwmout_reset_ok(&self->backlight_pwm);
|
||||
common_hal_pulseio_pwmout_deinit(&self->backlight_pwm);
|
||||
} else if (self->backlight_inout.base.type == &digitalio_digitalinout_type) {
|
||||
common_hal_digitalio_digitalinout_deinit(&self->backlight_inout);
|
||||
}
|
||||
#else
|
||||
common_hal_digitalio_digitalinout_deinit(&self->backlight_inout);
|
||||
#endif
|
||||
}
|
||||
|
||||
void reset_display(displayio_display_obj_t* self) {
|
||||
|
Loading…
Reference in New Issue
Block a user