pimoroni / EnviroPlus-FeatherWing

CircuitPython library for the Enviro+ FeatherWing
https://shop.pimoroni.com/products/enviro-plus-featherwing
MIT License
10 stars 11 forks source link

Screen does not support brightness property for display and backlight_control has unusual use in the code #18

Open kevinjwalters opened 3 years ago

kevinjwalters commented 3 years ago

The constructor for the screen includes a backlight_control=True described as

determines whether this class should handle the screen's backlight (default True) (this is useful to set to False if you want to control the brightness with pwm in your own code)

but the code uses this value to determine whether to set a reset parameter:

https://github.com/pimoroni/EnviroPlus-FeatherWing/blob/91b32ed6de01d87f3fd63c5dfde481019308a517/library/pimoroni_envirowing/screen/__init__.py#L26-L29

According to https://circuitpython.readthedocs.io/en/6.0.x/shared-bindings/displayio/#displayio.FourWire that reset is what it sounds like:

Reset pin. When None only software reset can be used

Is that code errorneous or is there more to this that meets the eye?

I can see example code in the plotters doing manual pwm. Was there a reason not to support the brightness property on the display?

Adafruit CircuitPython 6.0.0 on 2020-11-16; Adafruit Feather nRF52840 Express with nRF52840
>>>
>>> from pimoroni_envirowing import screen
>>> display = screen.Screen()
>>> display.brightness
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: Brightness not adjustable
dglaude commented 3 years ago

Well spotted, I don't know how to control the backlight, especially since my code use plotter, but the backlight_control is not exposed. Actually, I want to power it down to see if it affect the temperature reported by bme280.

kevinjwalters commented 3 years ago

Have a look at https://github.com/pimoroni/EnviroPlus-FeatherWing/blob/master/examples/plotter_light_and_sound.py - the pwm is setup for the backlight control and duty_cycle is then set from the program rather than any library code (0-65535 value).

dglaude commented 3 years ago

Right now I have it powered down:

pwm = pulseio.PWMOut(pimoroni_physical_feather_pins.pin21())
pwm.duty_cycle = 0

=> The bme280 temp continue to grow