Added support for user animations with docs

This commit is contained in:
Kyle Brown
2019-03-16 14:26:19 -07:00
parent 9d8682c866
commit 3f8c6e7648
5 changed files with 96 additions and 13 deletions

View File

@@ -104,6 +104,33 @@ keyboard.pixels.disable_auto_write = True
keyboard.pixels.neopixel() # <-- This is the neopixel object
```
## User animations
User animations can be created as well. An example of a light show would look like this
```python
from kmk.keys import make_key
def start_light_show(*args, **kwargs):
# Setting mode to user will use the user animation
keyboard.pixels.animation_mode = 'user'
def light_show(self):
# This is the code that is run every cycle that can serve as an animation
# Refer to the kmk/rgb.py for actual examples of what has been done
self.hue = (self.hue + 35) % 360
keyboard.pixels.set_hsv_fill(self.hue, self.sat, self.val)
return self
# This is what "gives" your function to KMK so it knows what your animation code is
keyboard.rgb_config['user_animation'] = light_show
# Makes a key that would start your animation
LS = make_key(on_press=start_light_show())
keymap = [...LS,...]
```
## Troubleshooting
### Incorrect colors
If your colors are incorrect, check the pixel order of your specific LED's. Here are some common ones.