From 2d84015e5e8af44d258da38653f330b48fd41d79 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Wed, 9 Sep 2026 18:33:59 +0000 Subject: [PATCH] =?UTF-8?q?led.py:=20add=20=E2=80=98on=E2=80=99=20state?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mmgen/led.py | 5 +++-- test/misc/led.py | 10 ++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/mmgen/led.py b/mmgen/led.py index 9b9ccf12..64e8faaf 100755 --- a/mmgen/led.py +++ b/mmgen/led.py @@ -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), diff --git a/test/misc/led.py b/test/misc/led.py index e7052b26..c5a88301 100755 --- a/test/misc/led.py +++ b/test/misc/led.py @@ -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)')