adafruit / adafruit/Adafruit_CircuitPython_LED_Animation

what is the easiest way to do a `fadeOn` animation?

Open
#128 0 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
Python
Stars
62
Forks
46
PR merge metrics
No merged PRs in 30d

Description

i would like to do some animations - and to start with the sequence i like some `fadeOn` animation.

sadly i did not find a simple way to do this..

i tried with
```python
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
# SPDX-License-Identifier: MIT
# based on
# https://learn.adafruit.com/circuitpython-led-animations/basic-animations#full-example-code-3063749

"""
just fadeOn to a solid color -
wait a little
and fadeOff again.
"""

import time
import board

# from adafruit_led_animation.animation.pulse import Pulse
from adafruit_led_animation.animation.colorcycle import ColorCycle
from adafruit_led_animation.color import (
AMBER,
BLACK,
)
from adafruit_led_animation.sequence import AnimateOnce

# Update to match the number of NeoPixels you have connected
pixel_num = 1

print("\n\n")
print("fade experiment")

if hasattr(board, "APA102_SCK"):
import adafruit_dotstar
pixels = adafruit_dotstar.DotStar(
board.APA102_SCK, board.APA102_MOSI, pixel_num, auto_write=False
)
else:
import neopixel
pixels = neopixel.NeoPixel(board.NEOPIXEL, pixel_num, auto_write=False)

pixels.brightness = 0.3

fadeOnCC = ColorCycle(pixels, speed=5, colors=[BLACK, AMBER])
fadeOffCC = ColorCycle(pixels, speed=5, colors=[AMBER, BLACK])

fadeOn = AnimateOnce(
fadeOnCC,
# auto_clear=False,
# auto_reset=True,
advance_interval=5,
)
fadeOff = AnimateOnce(
fadeOffCC,
# auto_clear=False,
# auto_reset=True,
advance_interval=5,
)

print("wait 5sec")
time.sleep(5)

print("start fadeOn:")
while fadeOn.animate():
pass
print("done.")

print("wait 5sec")
time.sleep(5)

print("start fadeOff:")
while fadeOff.animate():
pass
print("done.")

print("wait 10sec")
time.sleep(10)
print("done with this script. exiting.")
# while True:
# pass

```

i think i am missing some basics here..

i think a working example just for a `fadeIn` and `fadeOut` is a good idea for the documentation :-)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.