led.py: add ‘on’ state
This commit is contained in:
parent
d28a767609
commit
2d84015e5e
2 changed files with 11 additions and 4 deletions
|
|
@ -184,9 +184,9 @@ class LEDControl:
|
|||
if self.debug:
|
||||
msg(f'led_loop({on_secs}, {off_secs})')
|
||||
|
||||
if not on_secs:
|
||||
if not off_secs: # 'on' or 'off'
|
||||
with open(self.board.control, 'w') as fp:
|
||||
fp.write('0\n')
|
||||
fp.write('255\n' if on_secs else '0\n')
|
||||
while True:
|
||||
if self.ev_sleep(3600):
|
||||
return
|
||||
|
|
@ -205,6 +205,7 @@ class LEDControl:
|
|||
def set(self, state): # pylint: disable=method-hidden
|
||||
lt = namedtuple('led_timings', ['on_secs', 'off_secs'])
|
||||
timings = {
|
||||
'on': lt(1, 0),
|
||||
'off': lt(0, 0),
|
||||
'standby': lt(2.2, 0.2),
|
||||
'busy': lt(0.06, 0.06),
|
||||
|
|
|
|||
|
|
@ -22,19 +22,25 @@ opts_data = {
|
|||
|
||||
cfg = Config(opts_data=opts_data)
|
||||
|
||||
led = LEDControl(enabled=True)
|
||||
|
||||
def confirm_or_exit(prompt):
|
||||
keypress_confirm(cfg, f'{prompt}. OK?', default_yes=True, do_exit=True)
|
||||
|
||||
confirm_or_exit('This script will interactively test LED functionality')
|
||||
|
||||
led = LEDControl(enabled=True)
|
||||
|
||||
color = led.board.color.capitalize()
|
||||
|
||||
atexit.register(led.stop)
|
||||
|
||||
led.set('off')
|
||||
|
||||
confirm_or_exit(f'{color} LED should now be turned off')
|
||||
|
||||
led.set('on')
|
||||
|
||||
confirm_or_exit(f'{color} LED should now be turned on')
|
||||
|
||||
led.set('busy')
|
||||
|
||||
confirm_or_exit(f'{color} LED should now be signaling busy (rapid flashing)')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue