Ligne 148 : |
Ligne 148 : |
| np.fill( (0,0,0) ) | | np.fill( (0,0,0) ) |
| np.write() | | np.write() |
| + | </syntaxhighlight> |
| + | |
| + | == Effets Lumineux == |
| + | Le GitHub contient également un fichier nommé [https://github.com/mchobby/esp8266-upy/blob/master/neopixel/fxdemo.py fxdemo.py]. Ce dernier reprend différentes fonctions d'animation NéoPixel que vous pourriez utiliser dans vos propres projets. |
| + | |
| + | Il est possible de tester ces effets en faisant un {{fname|import fxdemo}} depuis une session REPL. |
| + | |
| + | A titre d'exemple, voici les différents appels de fonctions permettant de tester les effets lumineux. |
| + | |
| + | <syntaxhighlight lang="python"> |
| + | # theater_chase sample |
| + | theater_chase( np, (127,0,0) ) # red |
| + | theater_chase( np, (127,127,127) ) # white |
| + | theater_chase( np, (0,0,127) ) # blue |
| + | clear( np ) |
| + | sleep( 1 ) |
| + | |
| + | # Wipe in color |
| + | np.fill( (190, 0, 0) ) # fill in red |
| + | np.write() |
| + | wipe( np, (0,180,0), pause=0.150 ) # wipe in green |
| + | wipe( np, (0,0,255), pause=0.150 ) # wipe in blue |
| + | wipe( np, (0,0,0), pause=0.150 ) # wipe in black |
| + | sleep( 1 ) |
| + | |
| + | # Moving_rainbow |
| + | for i in range( 4 ): |
| + | moving_rainbow( np ) |
| + | clear( np ) |
| + | sleep( 1 ) |
| + | |
| + | # Fade In And Out |
| + | fade_inout( np, (255, 0, 0) ) # Red |
| + | fade_inout( np, (0 , 255, 0) ) # Green |
| + | fade_inout( np, (0 , 0, 255) ) # Blue |
| + | clear( np ) |
| + | sleep( 1 ) |
| + | |
| + | # moving_wheel |
| + | moving_wheel( np ) |
| + | clear( np ) |
| + | sleep( 1 ) |
| + | |
| + | # cycle_wheel |
| + | for i in range(2): |
| + | cycle_wheel( np ) |
| + | clear( np ) |
| + | sleep( 1 ) |
| + | |
| + | # Candle Effect |
| + | candle( np ) |
| + | clear( np ) |
| + | sleep( 1 ) |
| + | |
| + | # Larson Scanner (K2000) |
| + | # execute 3 iterations |
| + | posdir = None |
| + | for i in range( 3 ): |
| + | posdir = larson_scanner( np, posdir ) |
| + | clear( np ) |
| + | sleep( 1 ) |
| </syntaxhighlight> | | </syntaxhighlight> |
| | | |