Skip to content

Power on with duration; power on if brightness > 0 #68

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

p1r473
Copy link
Contributor

@p1r473 p1r473 commented Mar 19, 2025

Hi Linus,
On my Pi, I am able to successfully fade with a duration with rpi-backlight -b 0 -d 3. However, I cant power on/off with a duration rpi-backlight -p off -d 3. I can, however, toggle with a duration just fine rpi-backlight -p toggle -d 3
I believe we should be able to power on/off with a duration based on this line in the code, showing the intention that power setting may indeed be set with a duration.
parser.error("-p/--set-power may only be used with -d/--duration")

After checking the code, I found that powering on/off with a duration wasn't actually implemented yet
So, I added it as a feature:
-Power on/off is now supported with duration

Additionally, I found that if you set the brightness to 100 while the power is off, nothing happens. So, I added an extra 2 features:
-If setting brightness >0, turn the power on first. (This will better the user experience)
-If setting brightness to 0, turn the power off once brightness is 0. (Perhaps $ energy savings?)

I also added a quick check to the code.
-Do not try to power on if already on (This will prevent the brightness from setting to 100 if brightness is already turned up (i.e. 40) and you try to power on) which fixes #44

There is a difference between power and toggle however that needs to be reflected in the code I believe.
If its on, and you try to turn it on, nothing should happen.
If its on, and you try to toggle it, it should turn off.

Toggle does not have this problem, because if you toggle it while its already on, it will just turn off

This code prevents setting the brightness to 100 if lets say, brightness is currently 40 and you power on. Without this code, if you power on an and the screen is already, brightness will just go to 100, which is probably not what the user wanted.

@p1r473 p1r473 changed the title Update cli.py Fade with duration Mar 23, 2025
@p1r473 p1r473 changed the title Fade with duration Power on with duration; power on if brightness > 0 Mar 23, 2025
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

Successfully merging this pull request may close these issues.

Toggle CLI turns brightness up to 100%
1 participant