Thanks to visit codestin.com
Credit goes to github.com

Skip to content

what is the easiest way to do a fadeOn animation? #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
s-light opened this issue May 16, 2025 · 0 comments
Open

what is the easiest way to do a fadeOn animation? #128

s-light opened this issue May 16, 2025 · 0 comments

Comments

@s-light
Copy link

s-light commented May 16, 2025

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

# 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 :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant