Power on with duration, power on if brightness > 0 #58
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi Linus,
On my Pi4, I am able to successfully fade with a duration with
rpi-backlight -b 0 -d 3
. However, I cant power on/off with a durationrpi-backlight -p off -d 3
. I can, however, toggle with a duration just finerpi-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
To your comment
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.