From 597b007333d8ec0d9cfd29e6941fcbe57379108a Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Mon, 22 May 2023 08:40:47 +0200 Subject: Initial commit --- src/macros/4-move_mouse.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/macros/4-move_mouse.py (limited to 'src/macros/4-move_mouse.py') diff --git a/src/macros/4-move_mouse.py b/src/macros/4-move_mouse.py new file mode 100644 index 0000000..ef6ede0 --- /dev/null +++ b/src/macros/4-move_mouse.py @@ -0,0 +1,54 @@ +import skeleton + +class Color(object): + """ Return a color which may change over time. + """ + def __init__(self, code): + self.code = code + + def __int__(self): + return self.code + +class NoIdle(object): + + def __init__(self): + self.x = 10 + self.color = Color(0x000500) + self.active = False + + def update(self, macropad): + if not self.active: + return + + self.x *= -1 + macropad.mouse.move( + self.x, + 0, + 0) + # Update the color in red or blue in order to show that the heartbeat + # is active. + self.color.code = 0x010000 if self.x > 0 else 0x000001 + macropad.pixels[4] = int(self.color) + macropad.pixels.show() + + def pause(self, macropad, key, pressed): + if pressed: + self.active = not self.active + if self.active: + self.update(macropad) + else: + # Restore the default color (green) + self.color.code = 0x000500 + macropad.pixels[4] = int(self.color) + macropad.pixels.show() + + +def build_application(): + configuration = skeleton.Configuration("NoIdle") + actor = NoIdle() + configuration.setTick(5000, actor.update) + configuration.registerKey(4, "switch", actor.pause, actor.color) + return configuration + +configuration = build_application() + -- cgit v1.2.3