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

Power on with duration, power on if brightness > 0 #40

Closed
wants to merge 22 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions rpi_backlight/cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
from argparse import ArgumentParser

from . import Backlight, BoardType, __version__, utils
Expand Down Expand Up @@ -100,8 +101,13 @@ def main():
"-b/--set-brightness must be used without other options except for -d/--duration"
)
# backlight.fade context manager can be used always as args.fade defaults to zero
if (backlight.power == False) and (args.set_brightness > 0):
p1r473 marked this conversation as resolved.
Show resolved Hide resolved
backlight.power = True
with backlight.fade(duration=args.duration):
backlight.brightness = args.set_brightness
if (backlight.power == True) and (args.set_brightness == 0):
time.sleep(args.duration)
p1r473 marked this conversation as resolved.
Show resolved Hide resolved
backlight.power = False
return

if args.set_power:
Expand All @@ -120,6 +126,18 @@ def main():
backlight.power = True
with backlight.fade(duration=args.duration):
backlight.brightness = 100
elif args.set_power == "on":
if backlight.power:
return
p1r473 marked this conversation as resolved.
Show resolved Hide resolved
with backlight.fade(duration=args.duration):
backlight.brightness = 100
p1r473 marked this conversation as resolved.
Show resolved Hide resolved
time.sleep(args.duration)
p1r473 marked this conversation as resolved.
Show resolved Hide resolved
backlight.power = True if args.set_power == "on" else False
p1r473 marked this conversation as resolved.
Show resolved Hide resolved
elif args.set_power == "off":
with backlight.fade(duration=args.duration):
backlight.brightness = 0
time.sleep(args.duration)
backlight.power = False if args.set_power == "off" else True
else:
backlight.power = True if args.set_power == "on" else False
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch is now dead code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ive moved the new path stuff to
https://github.com/j-coopz/rpi-backlight
So this branch can still be about the previous issues

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea what that means, but please update if you want to get this PR merged

Copy link
Contributor Author

@p1r473 p1r473 Aug 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Linus, could you please elaborate what you want updated in this code?
This new code does the following:
-Power on/off is now supported with duration
-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?)

return
Expand Down