[71] | 1 | #!/usr/bin/python |
---|
| 2 | from rgbkbd.core import Monochrome, KeyboardMode |
---|
| 3 | from rgbkbd.color import Color, Colors |
---|
| 4 | from rgbkbd.animation import RandomAnimation, ColorAnimation |
---|
| 5 | |
---|
| 6 | # Keyboard Modes |
---|
| 7 | def StaticMode(manager, keyboard, foreground=Colors.WHITE, |
---|
| 8 | background=Colors.BLACK): |
---|
| 9 | return KeyboardMode(manager, keyboard, |
---|
| 10 | static_lighting=Monochrome(keyboard, color=foreground), |
---|
| 11 | animations=[]) |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | def RandomMode(manager, keyboard, foreground=None, background=None): |
---|
| 15 | """Keyboard mode for RandomAnimation""" |
---|
| 16 | if foreground is None: |
---|
| 17 | foreground = Color.random8(exclude=background) |
---|
| 18 | if background is None: |
---|
| 19 | background = Color.random8(exclude=foreground) |
---|
| 20 | |
---|
| 21 | return KeyboardMode(manager, keyboard, |
---|
| 22 | static_lighting=Monochrome(keyboard, color=background), |
---|
| 23 | animations=[ |
---|
| 24 | RandomAnimation(foreground=foreground, background=background, keyboard=keyboard), |
---|
| 25 | ]) |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | def ColorMode(manager, keyboard, colors=(Colors.WHITE, Colors.BLACK), |
---|
| 29 | period=5, color_pattern_cls=None): |
---|
| 30 | """Keyboard mode to apply a stationary color pattern""" |
---|
| 31 | color_pattern = color_pattern_cls(colors=colors, period=period) |
---|
| 32 | animation = ColorAnimation(keyboard=keyboard, color_pattern=color_pattern) |
---|
| 33 | return KeyboardMode(manager, keyboard, |
---|
| 34 | static_lighting=Monochrome(keyboard, color=colors[-1]), |
---|
| 35 | animations=[animation]) |
---|