Skip to content
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

MiniTFTFeatherWing backlight value issue #43

Closed
iraytrace opened this issue Jun 2, 2019 · 4 comments
Closed

MiniTFTFeatherWing backlight value issue #43

iraytrace opened this issue Jun 2, 2019 · 4 comments

Comments

@iraytrace
Copy link

When using the backlight setting, the value returned is not the value set. For example, the following code:

 import time
 import board
 import math
 from adafruit_featherwing import minitft_featherwing

 minitft = minitft_featherwing.MiniTFTFeatherWing(cs=board.D11, dc=board.D12)
 old = minitft.buttons
 while True:
    buttons = minitft.buttons

    if buttons.right and not old.right:
        print("Button RIGHT!")
        minitft.backlight = 0.125
        print('backlight %g %g' % (.125, minitft.backlight))

    if buttons.left and not old.left:
        print("Button LEFT!")
        minitft.backlight = 0.875
        print('backlight now %g %g' % (.875, minitft.backlight))

`

produces

Button RIGHT!
backlight 0.125 0.87451
Button LEFT!
backlight now 0.875 0.121569

At a minimum these values should be consistent between set/get. The following should result in no change to the value:

 minitft.brightness = minitft.brightness 

Ideally, given the parameter name "brightness" the value 1.0 should be maximum brightness and the value 0.0 should be off for clarity.

Thus line 105:

  self._backlight.duty_cycle = int(255 * min(max(1 - brightness, 0.0), 1.0))

should become:

  self._backlight.duty_cycle = int(255 * min(max(brightness, 0.0), 1.0))
@makermelissa makermelissa self-assigned this Jun 2, 2019
@makermelissa
Copy link
Contributor

Thanks for reporting this. I had noticed it a little while back, but it fell through the cracks.

@makermelissa
Copy link
Contributor

Did you want to submit a PR? The set value should be correct, but return value wrong.

@makermelissa makermelissa removed their assignment Jun 2, 2019
@iraytrace
Copy link
Author

Just submitted a PR. Opted to invert the value so that 1.0 is bright and 0.0 is dark as suggested in this bug report

@makermelissa
Copy link
Contributor

Fixed by #44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants